wok-current annotate portmap/stuff/portmap-5beta-compilation_fixes-3.patch @ rev 2764

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