]>
Commit | Line | Data |
---|---|---|
769a61c5 MT |
1 | Submitted By: Kevin P. Fleming <kpfleming at linuxfromscratch dot org> |
2 | Date: 2004-05-02 | |
3 | Initial Package Version: 5beta | |
4 | Origin: http://archives.linuxfromscratch.org/mail-archives/blfs-dev/2003-January/001960.html | |
5 | Description: The patch was created from the portmap modified package by Mark Heerdink. | |
6 | This patch provides the following improvements: | |
7 | * Link against dynamic tcp_wrappers. | |
8 | * Create an install target for portmap. | |
9 | * Compilation and security fixes. | |
10 | * Documentation fixes. | |
11 | ||
12 | Originally created by Tushar Teredesai, updated by kpfleming to ensure | |
13 | portmap will compile without tcp_wrappers installed. | |
14 | diff -Naur portmap_5beta/BLURB portmap_5beta.gimli/BLURB | |
15 | --- portmap_5beta/BLURB 1996-07-06 16:09:46.000000000 -0500 | |
16 | +++ portmap_5beta.gimli/BLURB 2002-01-07 09:13:58.000000000 -0600 | |
17 | @@ -1,3 +1,6 @@ | |
18 | + | |
19 | +############################################################################### | |
20 | + | |
21 | @(#) BLURB 1.5 96/07/06 23:09:45 | |
22 | ||
23 | This is the fifth replacement portmapper release. | |
24 | diff -Naur portmap_5beta/Makefile portmap_5beta.gimli/Makefile | |
25 | --- portmap_5beta/Makefile 1996-07-06 16:06:19.000000000 -0500 | |
26 | +++ portmap_5beta.gimli/Makefile 2002-07-15 16:00:07.000000000 -0500 | |
27 | @@ -8,7 +8,7 @@ | |
28 | # if you disagree. See `man 3 syslog' for examples. Some syslog versions | |
29 | # do not provide this flexibility. | |
30 | # | |
31 | -FACILITY=LOG_MAIL | |
32 | +FACILITY=LOG_DAEMON | |
33 | ||
34 | # To disable tcp-wrapper style access control, comment out the following | |
35 | # macro definitions. Access control can also be turned off by providing | |
36 | @@ -16,7 +16,8 @@ | |
37 | # daemon, is always treated as an authorized host. | |
38 | ||
39 | HOSTS_ACCESS= -DHOSTS_ACCESS | |
40 | -WRAP_LIB = $(WRAP_DIR)/libwrap.a | |
41 | +#WRAP_LIB = $(WRAP_DIR)/libwrap.a | |
42 | +WRAP_LIB = -lwrap | |
43 | ||
44 | # Comment out if your RPC library does not allocate privileged ports for | |
45 | # requests from processes with root privilege, or the new portmap will | |
46 | @@ -71,7 +72,7 @@ | |
47 | # With verbose logging on, HP-UX 9.x and AIX 4.1 leave zombies behind when | |
48 | # SIGCHLD is not ignored. Enable next macro for a fix. | |
49 | # | |
50 | -# ZOMBIES = -DIGNORE_SIGCHLD # AIX 4.x, HP-UX 9.x | |
51 | +ZOMBIES = -DIGNORE_SIGCHLD # AIX 4.x, HP-UX 9.x | |
52 | ||
53 | # Uncomment the following macro if your system does not have u_long. | |
54 | # | |
55 | @@ -81,7 +82,7 @@ | |
56 | # libwrap.a object library. WRAP_DIR should specify the directory with | |
57 | # that library. | |
58 | ||
59 | -WRAP_DIR= ../tcp_wrappers | |
60 | +WRAP_DIR= $(TCPD_DIR) | |
61 | ||
62 | # Auxiliary object files that may be missing from your C library. | |
63 | # | |
64 | @@ -99,22 +100,31 @@ | |
65 | ||
66 | # Comment out if your compiler talks ANSI and understands const | |
67 | # | |
68 | -CONST = -Dconst= | |
69 | +#CONST = -Dconst= | |
70 | ||
71 | ### End of configurable stuff. | |
72 | ############################## | |
73 | ||
74 | +GLIBC=$(shell grep -s -c __GLIBC__ /usr/include/features.h) | |
75 | + | |
76 | +ifeq ($(GLIBC),0) | |
77 | +LIBS += # -lbsd | |
78 | +else | |
79 | +LIBS += -lnsl | |
80 | +endif | |
81 | + | |
82 | + | |
83 | SHELL = /bin/sh | |
84 | ||
85 | -COPT = $(CONST) -Dperror=xperror $(HOSTS_ACCESS) $(CHECK_PORT) \ | |
86 | +COPT = $(CONST) $(HOSTS_ACCESS) $(CHECK_PORT) \ | |
87 | $(SYS) -DFACILITY=$(FACILITY) $(ULONG) $(ZOMBIES) $(SA_LEN) \ | |
88 | $(LOOPBACK) $(SETPGRP) | |
89 | -CFLAGS = $(COPT) -O $(NSARCHS) | |
90 | +CFLAGS = -Wall $(COPT) -O2 $(NSARCHS) | |
91 | OBJECTS = portmap.o pmap_check.o from_local.o $(AUX) | |
92 | ||
93 | all: portmap pmap_dump pmap_set | |
94 | ||
95 | -portmap: $(OBJECTS) $(WRAP_DIR)/libwrap.a | |
96 | +portmap: $(OBJECTS) # $(WRAP_DIR)/libwrap.a | |
97 | $(CC) $(CFLAGS) -o $@ $(OBJECTS) $(WRAP_LIB) $(LIBS) | |
98 | ||
99 | pmap_dump: pmap_dump.c | |
100 | @@ -129,6 +139,17 @@ | |
101 | get_myaddress: get_myaddress.c | |
102 | cc $(CFLAGS) -DTEST -o $@ get_myaddress.c $(LIBS) | |
103 | ||
104 | +install: all | |
105 | + install -o root -g root -m 0755 -s portmap ${BASEDIR}/sbin | |
106 | + install -o root -g root -m 0755 -s pmap_dump ${BASEDIR}/usr/sbin | |
107 | + install -o root -g root -m 0755 -s pmap_set ${BASEDIR}/usr/sbin | |
108 | + install -o root -g root -m 0644 portmap.8 ${BASEDIR}/usr/share/man/man8 | |
109 | + install -o root -g root -m 0644 pmap_dump.8 ${BASEDIR}/usr/share/man/man8 | |
110 | + install -o root -g root -m 0644 pmap_set.8 ${BASEDIR}/usr/share/man/man8 | |
111 | +# cat README BLURB >${BASEDIR}/usr/share/doc/portmap/portmapper.txt | |
112 | +# gzip -9f ${BASEDIR}/usr/share/doc/portmap/portmapper.txt | |
113 | + | |
114 | + | |
115 | lint: | |
116 | lint $(COPT) $(OBJECTS:%.o=%.c) | |
117 | ||
118 | diff -Naur portmap_5beta/daemon.c portmap_5beta.gimli/daemon.c | |
119 | --- portmap_5beta/daemon.c 1992-06-11 15:53:12.000000000 -0500 | |
120 | +++ portmap_5beta.gimli/daemon.c 2002-01-07 09:22:24.000000000 -0600 | |
121 | @@ -36,16 +36,13 @@ | |
122 | #endif /* LIBC_SCCS and not lint */ | |
123 | ||
124 | #include <fcntl.h> | |
125 | - | |
126 | -/* From unistd.h */ | |
127 | -#define STDIN_FILENO 0 | |
128 | -#define STDOUT_FILENO 1 | |
129 | -#define STDERR_FILENO 2 | |
130 | +#include <unistd.h> | |
131 | +#include <sys/types.h> | |
132 | ||
133 | /* From paths.h */ | |
134 | #define _PATH_DEVNULL "/dev/null" | |
135 | ||
136 | -daemon(nochdir, noclose) | |
137 | +int daemon(nochdir, noclose) | |
138 | int nochdir, noclose; | |
139 | { | |
140 | int cpid; | |
141 | diff -Naur portmap_5beta/from_local.c portmap_5beta.gimli/from_local.c | |
142 | --- portmap_5beta/from_local.c 1996-05-31 08:52:58.000000000 -0500 | |
143 | +++ portmap_5beta.gimli/from_local.c 2002-01-07 09:25:49.000000000 -0600 | |
144 | @@ -35,7 +35,7 @@ | |
145 | * Mountain View, California 94043 | |
146 | */ | |
147 | ||
148 | -#ifndef lint | |
149 | +#ifdef lint | |
150 | static char sccsid[] = "@(#) from_local.c 1.3 96/05/31 15:52:57"; | |
151 | #endif | |
152 | ||
153 | @@ -51,6 +51,9 @@ | |
154 | #include <net/if.h> | |
155 | #include <sys/ioctl.h> | |
156 | #include <syslog.h> | |
157 | +#include <stdlib.h> | |
158 | +#include <string.h> | |
159 | +#include <unistd.h> | |
160 | ||
161 | #ifndef TRUE | |
162 | #define TRUE 1 | |
163 | @@ -96,7 +99,7 @@ | |
164 | ||
165 | /* find_local - find all IP addresses for this host */ | |
166 | ||
167 | -find_local() | |
168 | +int find_local() | |
169 | { | |
170 | struct ifconf ifc; | |
171 | struct ifreq ifreq; | |
172 | @@ -154,7 +157,7 @@ | |
173 | ||
174 | /* from_local - determine whether request comes from the local system */ | |
175 | ||
176 | -from_local(addr) | |
177 | +int from_local(addr) | |
178 | struct sockaddr_in *addr; | |
179 | { | |
180 | int i; | |
181 | diff -Naur portmap_5beta/pmap_check.c portmap_5beta.gimli/pmap_check.c | |
182 | --- portmap_5beta/pmap_check.c 1996-07-07 03:49:10.000000000 -0500 | |
183 | +++ portmap_5beta.gimli/pmap_check.c 2002-01-07 09:37:58.000000000 -0600 | |
184 | @@ -32,7 +32,7 @@ | |
185 | * Computing Science, Eindhoven University of Technology, The Netherlands. | |
186 | */ | |
187 | ||
188 | -#ifndef lint | |
189 | +#ifdef lint | |
190 | static char sccsid[] = "@(#) pmap_check.c 1.8 96/07/07 10:49:10"; | |
191 | #endif | |
192 | ||
193 | @@ -45,6 +45,11 @@ | |
194 | #include <netinet/in.h> | |
195 | #include <rpc/rpcent.h> | |
196 | #endif | |
197 | +#include <sys/types.h> | |
198 | +#include <unistd.h> | |
199 | +#ifdef HOSTS_ACCESS | |
200 | +#include <tcpd.h> | |
201 | +#endif | |
202 | ||
203 | extern char *inet_ntoa(); | |
204 | ||
205 | @@ -110,7 +113,7 @@ | |
206 | ||
207 | /* check_default - additional checks for NULL, DUMP, GETPORT and unknown */ | |
208 | ||
209 | -check_default(addr, proc, prog) | |
210 | +int check_default(addr, proc, prog) | |
211 | struct sockaddr_in *addr; | |
212 | u_long proc; | |
213 | u_long prog; | |
214 | @@ -128,7 +131,7 @@ | |
215 | ||
216 | /* check_privileged_port - additional checks for privileged-port updates */ | |
217 | ||
218 | -check_privileged_port(addr, proc, prog, port) | |
219 | +int check_privileged_port(addr, proc, prog, port) | |
220 | struct sockaddr_in *addr; | |
221 | u_long proc; | |
222 | u_long prog; | |
223 | @@ -173,7 +176,7 @@ | |
224 | ||
225 | #else | |
226 | ||
227 | -check_setunset(addr, proc, prog, port) | |
228 | +int check_setunset(addr, proc, prog, port) | |
229 | struct sockaddr_in *addr; | |
230 | u_long proc; | |
231 | u_long prog; | |
232 | @@ -197,7 +200,7 @@ | |
233 | ||
234 | /* check_callit - additional checks for forwarded requests */ | |
235 | ||
236 | -check_callit(addr, proc, prog, aproc) | |
237 | +int check_callit(addr, proc, prog, aproc) | |
238 | struct sockaddr_in *addr; | |
239 | u_long proc; | |
240 | u_long prog; | |
241 | @@ -249,13 +252,13 @@ | |
242 | }; | |
243 | struct proc_map *procp; | |
244 | static struct proc_map procmap[] = { | |
245 | - PMAPPROC_CALLIT, "callit", | |
246 | - PMAPPROC_DUMP, "dump", | |
247 | - PMAPPROC_GETPORT, "getport", | |
248 | - PMAPPROC_NULL, "null", | |
249 | - PMAPPROC_SET, "set", | |
250 | - PMAPPROC_UNSET, "unset", | |
251 | - 0, 0, | |
252 | + { PMAPPROC_CALLIT, "callit" }, | |
253 | + { PMAPPROC_DUMP, "dump" }, | |
254 | + { PMAPPROC_GETPORT, "getport" }, | |
255 | + { PMAPPROC_NULL, "null" }, | |
256 | + { PMAPPROC_SET, "set" }, | |
257 | + { PMAPPROC_UNSET, "unset" }, | |
258 | + { 0, 0 } | |
259 | }; | |
260 | ||
261 | /* | |
262 | @@ -269,7 +272,7 @@ | |
263 | ||
264 | if (prognum == 0) { | |
265 | progname = ""; | |
266 | - } else if (rpc = getrpcbynumber((int) prognum)) { | |
267 | + } else if ((rpc = getrpcbynumber((int) prognum)) != NULL) { | |
268 | progname = rpc->r_name; | |
269 | } else { | |
270 | sprintf(progname = progbuf, "%lu", prognum); | |
271 | diff -Naur portmap_5beta/pmap_dump.8 portmap_5beta.gimli/pmap_dump.8 | |
272 | --- portmap_5beta/pmap_dump.8 1969-12-31 18:00:00.000000000 -0600 | |
273 | +++ portmap_5beta.gimli/pmap_dump.8 2002-01-07 09:13:58.000000000 -0600 | |
274 | @@ -0,0 +1,24 @@ | |
275 | +.TH PMAP_DUMP 8 "21th June 1997" Linux "Linux Programmer's Manual" | |
276 | +.SH NAME | |
277 | +pmap_dump \- print a list of all registered RPC programs | |
278 | +.SH SYNOPSIS | |
279 | +.B pmap_dump | |
280 | +.SH DESCRIPTION | |
281 | +The | |
282 | +.B pmap_dump | |
283 | +command can be used to restart a running portmapper or to print | |
284 | +a list of all registered RPC programs on the local host. If you | |
285 | +want to use the program to restart the portmapper you have to | |
286 | +redirect the output of | |
287 | +.B pmap_dump | |
288 | +to a file. After this you can restart the portmapper and restore | |
289 | +the list of the registered RPC programs by feeding the output | |
290 | +of | |
291 | +.B pmap_dump | |
292 | +to the | |
293 | +.B pmap_set | |
294 | +command. | |
295 | +.SH SEE ALSO | |
296 | +.BR pmap_set (8), | |
297 | +.BR rpc.portmap (8) | |
298 | + | |
299 | diff -Naur portmap_5beta/pmap_dump.c portmap_5beta.gimli/pmap_dump.c | |
300 | --- portmap_5beta/pmap_dump.c 1992-06-11 15:53:16.000000000 -0500 | |
301 | +++ portmap_5beta.gimli/pmap_dump.c 2002-01-07 09:20:19.000000000 -0600 | |
302 | @@ -5,7 +5,7 @@ | |
303 | * Computing Science, Eindhoven University of Technology, The Netherlands. | |
304 | */ | |
305 | ||
306 | -#ifndef lint | |
307 | +#ifdef lint | |
308 | static char sccsid[] = "@(#) pmap_dump.c 1.1 92/06/11 22:53:15"; | |
309 | #endif | |
310 | ||
311 | @@ -23,7 +23,20 @@ | |
312 | ||
313 | static char *protoname(); | |
314 | ||
315 | -main(argc, argv) | |
316 | +#ifndef INADDR_LOOPBACK | |
317 | +#define INADDR_LOOPBACK ntohl(inet_addr("127.0.0.1")) | |
318 | +#endif | |
319 | + | |
320 | +static void get_myloopaddress(addrp) | |
321 | +struct sockaddr_in *addrp; | |
322 | +{ | |
323 | + memset((char *) addrp, 0, sizeof(*addrp)); | |
324 | + addrp->sin_family = AF_INET; | |
325 | + addrp->sin_port = htons(PMAPPORT); | |
326 | + addrp->sin_addr.s_addr = htonl(INADDR_LOOPBACK); | |
327 | +} | |
328 | + | |
329 | +int main(argc, argv) | |
330 | int argc; | |
331 | char **argv; | |
332 | { | |
333 | @@ -31,7 +44,7 @@ | |
334 | register struct pmaplist *list; | |
335 | register struct rpcent *rpc; | |
336 | ||
337 | - get_myaddress(&addr); | |
338 | + get_myloopaddress(&addr); | |
339 | ||
340 | for (list = pmap_getmaps(&addr); list; list = list->pml_next) { | |
341 | rpc = getrpcbynumber((int) list->pml_map.pm_prog); | |
342 | diff -Naur portmap_5beta/pmap_set.8 portmap_5beta.gimli/pmap_set.8 | |
343 | --- portmap_5beta/pmap_set.8 1969-12-31 18:00:00.000000000 -0600 | |
344 | +++ portmap_5beta.gimli/pmap_set.8 2002-01-07 09:13:58.000000000 -0600 | |
345 | @@ -0,0 +1,24 @@ | |
346 | +.TH PMAP_SET 8 "21th June 1997" Linux "Linux Programmer's Manual" | |
347 | +.SH NAME | |
348 | +pmap_set \- set the list of registered RPC programs | |
349 | +.SH SYNOPSIS | |
350 | +.B pmap_set | |
351 | +.SH DESCRIPTION | |
352 | +The | |
353 | +.B pmap_set | |
354 | +command can be used to restart a running portmapper or to set | |
355 | +the list of registered RPC programs on the local host. If you | |
356 | +want to use the program to restart the portmapper you have to | |
357 | +redirect the output of | |
358 | +.B pmap_dump | |
359 | +to a file. After this you can restart the portmapper and restore | |
360 | +the list of the registered RPC programs by feeding the output | |
361 | +of | |
362 | +.B pmap_dump | |
363 | +to the | |
364 | +.B pmap_set | |
365 | +command. | |
366 | +.SH SEE ALSO | |
367 | +.BR pmap_dump (8), | |
368 | +.BR rpc.portmap (8) | |
369 | + | |
370 | diff -Naur portmap_5beta/pmap_set.c portmap_5beta.gimli/pmap_set.c | |
371 | --- portmap_5beta/pmap_set.c 1996-07-06 16:06:23.000000000 -0500 | |
372 | +++ portmap_5beta.gimli/pmap_set.c 2002-01-07 09:22:10.000000000 -0600 | |
373 | @@ -5,7 +5,7 @@ | |
374 | * Computing Science, Eindhoven University of Technology, The Netherlands. | |
375 | */ | |
376 | ||
377 | -#ifndef lint | |
378 | +#ifdef lint | |
379 | static char sccsid[] = "@(#) pmap_set.c 1.2 96/07/06 23:06:23"; | |
380 | #endif | |
381 | ||
382 | @@ -17,7 +17,9 @@ | |
383 | #include <rpc/rpc.h> | |
384 | #include <rpc/pmap_clnt.h> | |
385 | ||
386 | -main(argc, argv) | |
387 | +int parse_line(char *buf, u_long *prog, u_long *vers, int *prot, unsigned *port); | |
388 | + | |
389 | +int main(argc, argv) | |
390 | int argc; | |
391 | char **argv; | |
392 | { | |
393 | @@ -40,16 +42,16 @@ | |
394 | ||
395 | /* parse_line - convert line to numbers */ | |
396 | ||
397 | -parse_line(buf, prog, vers, prot, port) | |
398 | +int parse_line(buf, prog, vers, prot, port) | |
399 | char *buf; | |
400 | u_long *prog; | |
401 | u_long *vers; | |
402 | int *prot; | |
403 | unsigned *port; | |
404 | { | |
405 | - char proto_name[BUFSIZ]; | |
406 | + char proto_name[256]; | |
407 | ||
408 | - if (sscanf(buf, "%lu %lu %s %u", prog, vers, proto_name, port) != 4) { | |
409 | + if (sscanf(buf, "%lu %lu %255s %u", prog, vers, proto_name, port) != 4) { | |
410 | return (0); | |
411 | } | |
412 | if (strcmp(proto_name, "tcp") == 0) { | |
413 | diff -Naur portmap_5beta/portmap.8 portmap_5beta.gimli/portmap.8 | |
414 | --- portmap_5beta/portmap.8 1969-12-31 18:00:00.000000000 -0600 | |
415 | +++ portmap_5beta.gimli/portmap.8 2002-01-07 09:13:58.000000000 -0600 | |
416 | @@ -0,0 +1,146 @@ | |
417 | +.\" Copyright (c) 1987 Sun Microsystems | |
418 | +.\" Copyright (c) 1990, 1991 The Regents of the University of California. | |
419 | +.\" All rights reserved. | |
420 | +.\" | |
421 | +.\" Redistribution and use in source and binary forms, with or without | |
422 | +.\" modification, are permitted provided that the following conditions | |
423 | +.\" are met: | |
424 | +.\" 1. Redistributions of source code must retain the above copyright | |
425 | +.\" notice, this list of conditions and the following disclaimer. | |
426 | +.\" 2. Redistributions in binary form must reproduce the above copyright | |
427 | +.\" notice, this list of conditions and the following disclaimer in the | |
428 | +.\" documentation and/or other materials provided with the distribution. | |
429 | +.\" 3. All advertising materials mentioning features or use of this software | |
430 | +.\" must display the following acknowledgement: | |
431 | +.\" This product includes software developed by the University of | |
432 | +.\" California, Berkeley and its contributors. | |
433 | +.\" 4. Neither the name of the University nor the names of its contributors | |
434 | +.\" may be used to endorse or promote products derived from this software | |
435 | +.\" without specific prior written permission. | |
436 | +.\" | |
437 | +.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND | |
438 | +.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | |
439 | +.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | |
440 | +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE | |
441 | +.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | |
442 | +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | |
443 | +.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | |
444 | +.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | |
445 | +.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | |
446 | +.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |
447 | +.\" SUCH DAMAGE. | |
448 | +.\" | |
449 | +.\" from: @(#)portmap.8 5.3 (Berkeley) 3/16/91 | |
450 | +.\" $Id: portmap-5beta-compilation_fixes-3.patch,v 1.1 2004/06/08 04:53:09 jim Exp $ | |
451 | +.\" | |
452 | +.Dd March 16, 1991 | |
453 | +.Dt PORTMAP 8 | |
454 | +.Os BSD 4.3 | |
455 | +.Sh NAME | |
456 | +.Nm portmap | |
457 | +.Nd | |
458 | +.Tn DARPA | |
459 | +port to | |
460 | +.Tn RPC | |
461 | +program number mapper | |
462 | +.Sh SYNOPSIS | |
463 | +.Nm portmap | |
464 | +.Op Fl d | |
465 | +.Op Fl v | |
466 | +.Sh DESCRIPTION | |
467 | +.Nm Portmap | |
468 | +is a server that converts | |
469 | +.Tn RPC | |
470 | +program numbers into | |
471 | +.Tn DARPA | |
472 | +protocol port numbers. | |
473 | +It must be running in order to make | |
474 | +.Tn RPC | |
475 | +calls. | |
476 | +.Pp | |
477 | +When an | |
478 | +.Tn RPC | |
479 | +server is started, it will tell | |
480 | +.Nm portmap | |
481 | +what port number it is listening to, and what | |
482 | +.Tn RPC | |
483 | +program numbers it is prepared to serve. | |
484 | +When a client wishes to make an | |
485 | +.Tn RPC | |
486 | +call to a given program number, | |
487 | +it will first contact | |
488 | +.Nm portmap | |
489 | +on the server machine to determine | |
490 | +the port number where | |
491 | +.Tn RPC | |
492 | +packets should be sent. | |
493 | +.Pp | |
494 | +.Nm Portmap | |
495 | +must be started before any | |
496 | +.Tn RPC | |
497 | +servers are invoked. | |
498 | +.Pp | |
499 | +Normally | |
500 | +.Nm portmap | |
501 | +forks and dissociates itself from the terminal | |
502 | +like any other daemon. | |
503 | +.Nm Portmap | |
504 | +then logs errors using | |
505 | +.Xr syslog 3 . | |
506 | +.Pp | |
507 | +Option available: | |
508 | +.Bl -tag -width Ds | |
509 | +.It Fl d | |
510 | +(debug) prevents | |
511 | +.Nm portmap | |
512 | +from running as a daemon, | |
513 | +and causes errors and debugging information | |
514 | +to be printed to the standard error output. | |
515 | +.It Fl v | |
516 | +(verbose) run | |
517 | +.Nm portmap | |
518 | +in verbose mode. | |
519 | +.El | |
520 | + | |
521 | +This | |
522 | +.Nm portmap | |
523 | +version is protected by the | |
524 | +.Nm tcp_wrapper | |
525 | +library. You have to give the clients access to | |
526 | +.Nm portmap | |
527 | +if they should be allowed to use it. To allow connects from clients of | |
528 | +the .bar.com domain you could use the following line in /etc/hosts.allow: | |
529 | + | |
530 | +portmap: .bar.com | |
531 | + | |
532 | +You have to use the daemon name | |
533 | +.Nm portmap | |
534 | +for the daemon name (even if the binary has a different name). For the | |
535 | +client names you can only use the keyword ALL or IP addresses (NOT | |
536 | +host or domain names). | |
537 | + | |
538 | +For further information please have a look at the | |
539 | +.Xr tcpd 8 , | |
540 | +.Xr hosts_allow 5 | |
541 | +and | |
542 | +.Xr hosts_access 5 | |
543 | +manual pages. | |
544 | + | |
545 | +.Sh SEE ALSO | |
546 | +.Xr inetd.conf 5 , | |
547 | +.Xr rpcinfo 8 , | |
548 | +.Xr pmap_set 8 , | |
549 | +.Xr pmap_dump 8 , | |
550 | +.Xr inetd 8 | |
551 | +.Xr tcpd 8 | |
552 | +.Xr hosts_access 5 | |
553 | +.Xr hosts_options 5 | |
554 | +.Sh BUGS | |
555 | +If | |
556 | +.Nm portmap | |
557 | +crashes, all servers must be restarted. | |
558 | +.Sh HISTORY | |
559 | +The | |
560 | +.Nm | |
561 | +command appeared in | |
562 | +.Bx 4.3 | |
563 | diff -Naur portmap_5beta/portmap.c portmap_5beta.gimli/portmap.c | |
564 | --- portmap_5beta/portmap.c 1996-07-06 16:06:24.000000000 -0500 | |
565 | +++ portmap_5beta.gimli/portmap.c 2002-01-07 09:26:41.000000000 -0600 | |
566 | @@ -37,7 +37,7 @@ | |
567 | All rights reserved.\n"; | |
568 | #endif /* not lint */ | |
569 | ||
570 | -#ifndef lint | |
571 | +#ifdef lint | |
572 | static char sccsid[] = "@(#) portmap.c 1.6 96/07/06 23:06:23"; | |
573 | #endif /* not lint */ | |
574 | ||
575 | @@ -80,6 +80,9 @@ | |
576 | * Mountain View, California 94043 | |
577 | */ | |
578 | ||
579 | +#if defined(__GLIBC__) | |
580 | +#include <rpc/xdr.h> | |
581 | +#endif /* __GLIBC__ */ | |
582 | #include <rpc/rpc.h> | |
583 | #include <rpc/pmap_prot.h> | |
584 | #include <stdio.h> | |
585 | @@ -94,6 +97,8 @@ | |
586 | #ifdef SYSV40 | |
587 | #include <netinet/in.h> | |
588 | #endif | |
589 | +#include <sys/types.h> | |
590 | +#include <unistd.h> | |
591 | ||
592 | extern char *strerror(); | |
593 | #include <stdlib.h> | |
594 | @@ -148,7 +153,7 @@ | |
595 | #endif | |
596 | #endif | |
597 | ||
598 | -main(argc, argv) | |
599 | +int main(argc, argv) | |
600 | int argc; | |
601 | char **argv; | |
602 | { | |
603 | @@ -350,7 +355,7 @@ | |
604 | */ | |
605 | /* remote host authorization check */ | |
606 | check_default(svc_getcaller(xprt), rqstp->rq_proc, (u_long) 0); | |
607 | - if (!svc_sendreply(xprt, xdr_void, (caddr_t)0) && debugging) { | |
608 | + if (!svc_sendreply(xprt, (xdrproc_t) xdr_void, (caddr_t)0) && debugging) { | |
609 | abort(); | |
610 | } | |
611 | break; | |
612 | @@ -359,7 +364,7 @@ | |
613 | /* | |
614 | * Set a program,version to port mapping | |
615 | */ | |
616 | - if (!svc_getargs(xprt, xdr_pmap, ®)) | |
617 | + if (!svc_getargs(xprt, (xdrproc_t) xdr_pmap, (caddr_t) ®)) | |
618 | svcerr_decode(xprt); | |
619 | else { | |
620 | /* reject non-local requests, protect priv. ports */ | |
621 | @@ -401,7 +406,7 @@ | |
622 | ans = 1; | |
623 | } | |
624 | done: | |
625 | - if ((!svc_sendreply(xprt, xdr_int, (caddr_t)&ans)) && | |
626 | + if ((!svc_sendreply(xprt, (xdrproc_t) xdr_int, (caddr_t)&ans)) && | |
627 | debugging) { | |
628 | (void) fprintf(stderr, "svc_sendreply\n"); | |
629 | abort(); | |
630 | @@ -413,7 +418,7 @@ | |
631 | /* | |
632 | * Remove a program,version to port mapping. | |
633 | */ | |
634 | - if (!svc_getargs(xprt, xdr_pmap, ®)) | |
635 | + if (!svc_getargs(xprt, (xdrproc_t) xdr_pmap, (caddr_t) ®)) | |
636 | svcerr_decode(xprt); | |
637 | else { | |
638 | ans = 0; | |
639 | @@ -447,7 +452,7 @@ | |
640 | prevpml->pml_next = pml; | |
641 | free(t); | |
642 | } | |
643 | - if ((!svc_sendreply(xprt, xdr_int, (caddr_t)&ans)) && | |
644 | + if ((!svc_sendreply(xprt, (xdrproc_t) xdr_int, (caddr_t)&ans)) && | |
645 | debugging) { | |
646 | (void) fprintf(stderr, "svc_sendreply\n"); | |
647 | abort(); | |
648 | @@ -459,7 +464,7 @@ | |
649 | /* | |
650 | * Lookup the mapping for a program,version and return its port | |
651 | */ | |
652 | - if (!svc_getargs(xprt, xdr_pmap, ®)) | |
653 | + if (!svc_getargs(xprt, (xdrproc_t) xdr_pmap, (caddr_t) ®)) | |
654 | svcerr_decode(xprt); | |
655 | else { | |
656 | /* remote host authorization check */ | |
657 | @@ -474,7 +479,7 @@ | |
658 | port = fnd->pml_map.pm_port; | |
659 | else | |
660 | port = 0; | |
661 | - if ((!svc_sendreply(xprt, xdr_int, (caddr_t)&port)) && | |
662 | + if ((!svc_sendreply(xprt, (xdrproc_t) xdr_int, (caddr_t)&port)) && | |
663 | debugging) { | |
664 | (void) fprintf(stderr, "svc_sendreply\n"); | |
665 | abort(); | |
666 | @@ -486,7 +491,7 @@ | |
667 | /* | |
668 | * Return the current set of mapped program,version | |
669 | */ | |
670 | - if (!svc_getargs(xprt, xdr_void, NULL)) | |
671 | + if (!svc_getargs(xprt, (xdrproc_t) xdr_void, (caddr_t) NULL)) | |
672 | svcerr_decode(xprt); | |
673 | else { | |
674 | /* remote host authorization check */ | |
675 | @@ -497,7 +502,7 @@ | |
676 | } else { | |
677 | p = pmaplist; | |
678 | } | |
679 | - if ((!svc_sendreply(xprt, xdr_pmaplist, | |
680 | + if ((!svc_sendreply(xprt, (xdrproc_t) xdr_pmaplist, | |
681 | (caddr_t)&p)) && debugging) { | |
682 | (void) fprintf(stderr, "svc_sendreply\n"); | |
683 | abort(); | |
684 | @@ -645,7 +650,7 @@ | |
685 | timeout.tv_sec = 5; | |
686 | timeout.tv_usec = 0; | |
687 | a.rmt_args.args = buf; | |
688 | - if (!svc_getargs(xprt, xdr_rmtcall_args, &a)) | |
689 | + if (!svc_getargs(xprt, (xdrproc_t) xdr_rmtcall_args, (caddr_t) &a)) | |
690 | return; | |
691 | /* host and service access control */ | |
692 | if (!check_callit(svc_getcaller(xprt), | |
693 | @@ -674,9 +679,9 @@ | |
694 | au->aup_uid, au->aup_gid, au->aup_len, au->aup_gids); | |
695 | } | |
696 | a.rmt_port = (u_long)port; | |
697 | - if (clnt_call(client, a.rmt_proc, xdr_opaque_parms, &a, | |
698 | - xdr_len_opaque_parms, &a, timeout) == RPC_SUCCESS) { | |
699 | - svc_sendreply(xprt, xdr_rmtcall_result, (caddr_t)&a); | |
700 | + if (clnt_call(client, a.rmt_proc, (xdrproc_t) xdr_opaque_parms, (char*) &a, | |
701 | + (xdrproc_t) xdr_len_opaque_parms, (char*) &a, timeout) == RPC_SUCCESS) { | |
702 | + svc_sendreply(xprt, (xdrproc_t) xdr_rmtcall_result, (caddr_t)&a); | |
703 | } | |
704 | AUTH_DESTROY(client->cl_auth); | |
705 | clnt_destroy(client); |