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