diff options
author | charnier <charnier@FreeBSD.org> | 1997-10-09 07:17:36 +0000 |
---|---|---|
committer | charnier <charnier@FreeBSD.org> | 1997-10-09 07:17:36 +0000 |
commit | 6d64125af79075a334fc10b542f72059b668de3d (patch) | |
tree | c36830ab847da954e41fd0345ee3f004a854c701 /usr.sbin/portmap | |
parent | 0b1a7c5e856a56645b58c8fbf485e1bf6bdf3a01 (diff) | |
download | FreeBSD-src-6d64125af79075a334fc10b542f72059b668de3d.zip FreeBSD-src-6d64125af79075a334fc10b542f72059b668de3d.tar.gz |
Use err(3). Add usage().
Correct the .Nd string: in real life, portmap is translating rpc prog numbers
to darpa ports, not the opposite.
Diffstat (limited to 'usr.sbin/portmap')
-rw-r--r-- | usr.sbin/portmap/from_local.c | 7 | ||||
-rw-r--r-- | usr.sbin/portmap/pmap_check.c | 33 | ||||
-rw-r--r-- | usr.sbin/portmap/pmap_dump/pmap_dump.c | 5 | ||||
-rw-r--r-- | usr.sbin/portmap/pmap_set/pmap_set.c | 13 | ||||
-rw-r--r-- | usr.sbin/portmap/portmap.8 | 25 | ||||
-rw-r--r-- | usr.sbin/portmap/portmap.c | 45 |
6 files changed, 86 insertions, 42 deletions
diff --git a/usr.sbin/portmap/from_local.c b/usr.sbin/portmap/from_local.c index 6554de4..a1bfa72 100644 --- a/usr.sbin/portmap/from_local.c +++ b/usr.sbin/portmap/from_local.c @@ -36,8 +36,12 @@ */ #ifndef lint +#if 0 static char sccsid[] = "@(#) from_local.c 1.2 93/11/16 21:50:02"; #endif +static const char rcsid[] = + "$Id$"; +#endif #ifdef TEST #undef perror @@ -50,6 +54,7 @@ static char sccsid[] = "@(#) from_local.c 1.2 93/11/16 21:50:02"; #include <netdb.h> #include <syslog.h> +#include <unistd.h> #include <net/if.h> #include <netinet/in.h> @@ -67,6 +72,7 @@ static struct in_addr addrs[MAX_LOCAL]; /* find_local - find all IP addresses for this host */ +int find_local() { struct ifconf ifc; @@ -119,6 +125,7 @@ find_local() /* from_local - determine whether request comes from the local system */ +int from_local(addr) struct sockaddr_in *addr; { diff --git a/usr.sbin/portmap/pmap_check.c b/usr.sbin/portmap/pmap_check.c index eb0653b..c5aef7c 100644 --- a/usr.sbin/portmap/pmap_check.c +++ b/usr.sbin/portmap/pmap_check.c @@ -32,8 +32,19 @@ */ #ifndef lint +#if 0 static char sccsid[] = "@(#) pmap_check.c 1.6 93/11/21 20:58:59"; #endif +static const char rcsid[] = + "$Id$"; +#endif + +#include <stdio.h> +#include <unistd.h> +#include <sys/types.h> +#include <sys/socket.h> +#include <netinet/in.h> +#include <arpa/inet.h> #include <rpc/rpc.h> #include <rpc/pmap_prot.h> @@ -41,8 +52,6 @@ static char sccsid[] = "@(#) pmap_check.c 1.6 93/11/21 20:58:59"; #include <netdb.h> #include <sys/signal.h> -extern char *inet_ntoa(); - #include "pmap_check.h" /* Explicit #defines in case the include files are not available. */ @@ -100,6 +109,7 @@ void check_startup() /* check_default - additional checks for NULL, DUMP, GETPORT and unknown */ +int check_default(addr, proc, prog) struct sockaddr_in *addr; u_long proc; @@ -118,6 +128,7 @@ u_long prog; /* check_privileged_port - additional checks for privileged-port updates */ +int check_privileged_port(addr, proc, prog, port) struct sockaddr_in *addr; u_long proc; @@ -135,6 +146,7 @@ u_long port; /* check_setunset - additional checks for update requests */ +int check_setunset(addr, proc, prog, port) struct sockaddr_in *addr; u_long proc; @@ -157,6 +169,7 @@ u_long port; /* check_callit - additional checks for forwarded requests */ +int check_callit(addr, proc, prog, aproc) struct sockaddr_in *addr; u_long proc; @@ -209,13 +222,13 @@ char *text; }; struct proc_map *procp; static struct proc_map procmap[] = { - PMAPPROC_CALLIT, "callit", - PMAPPROC_DUMP, "dump", - PMAPPROC_GETPORT, "getport", - PMAPPROC_NULL, "null", - PMAPPROC_SET, "set", - PMAPPROC_UNSET, "unset", - 0, 0, + {PMAPPROC_CALLIT, "callit"}, + {PMAPPROC_DUMP, "dump"}, + {PMAPPROC_GETPORT, "getport"}, + {PMAPPROC_NULL, "null"}, + {PMAPPROC_SET, "set"}, + {PMAPPROC_UNSET, "unset"}, + {0, 0}, }; /* @@ -229,7 +242,7 @@ char *text; if (prognum == 0) { progname = ""; - } else if (rpc = getrpcbynumber((int) prognum)) { + } else if ((rpc = getrpcbynumber((int) prognum))) { progname = rpc->r_name; } else { sprintf(progname = progbuf, "%lu", prognum); diff --git a/usr.sbin/portmap/pmap_dump/pmap_dump.c b/usr.sbin/portmap/pmap_dump/pmap_dump.c index 9d57d65..409bf8b 100644 --- a/usr.sbin/portmap/pmap_dump/pmap_dump.c +++ b/usr.sbin/portmap/pmap_dump/pmap_dump.c @@ -6,8 +6,12 @@ */ #ifndef lint +#if 0 static char sccsid[] = "@(#) pmap_dump.c 1.1 92/06/11 22:53:15"; #endif +static const char rcsid[] = + "$Id$"; +#endif #include <stdio.h> #include <sys/types.h> @@ -23,6 +27,7 @@ static char sccsid[] = "@(#) pmap_dump.c 1.1 92/06/11 22:53:15"; static char *protoname(); +int main(argc, argv) int argc; char **argv; diff --git a/usr.sbin/portmap/pmap_set/pmap_set.c b/usr.sbin/portmap/pmap_set/pmap_set.c index 92e7994..3ba94fc 100644 --- a/usr.sbin/portmap/pmap_set/pmap_set.c +++ b/usr.sbin/portmap/pmap_set/pmap_set.c @@ -6,9 +6,14 @@ */ #ifndef lint +#if 0 static char sccsid[] = "@(#) pmap_set.c 1.1 92/06/11 22:53:16"; #endif +static const char rcsid[] = + "$Id$"; +#endif +#include <err.h> #include <stdio.h> #include <sys/types.h> #ifdef SYSV40 @@ -17,6 +22,9 @@ static char sccsid[] = "@(#) pmap_set.c 1.1 92/06/11 22:53:16"; #include <rpc/rpc.h> #include <rpc/pmap_clnt.h> +int parse_line __P((char *, u_long *, u_long *, int *, unsigned *)); + +int main(argc, argv) int argc; char **argv; @@ -32,17 +40,18 @@ char **argv; while (fgets(buf, sizeof(buf), stdin)) { if (parse_line(buf, &prog, &vers, &prot, &port) == 0) { - fprintf(stderr, "%s: malformed line: %s", argv[0], buf); + warnx("malformed line: %s", buf); return (1); } if (pmap_set(prog, vers, prot, (unsigned short) port) == 0) - fprintf(stderr, "not registered: %s", buf); + warnx("not registered: %s", buf); } return (0); } /* parse_line - convert line to numbers */ +int parse_line(buf, prog, vers, prot, port) char *buf; u_long *prog; diff --git a/usr.sbin/portmap/portmap.8 b/usr.sbin/portmap/portmap.8 index 6ee765c..5635356 100644 --- a/usr.sbin/portmap/portmap.8 +++ b/usr.sbin/portmap/portmap.8 @@ -38,10 +38,11 @@ .Sh NAME .Nm portmap .Nd -.Tn DARPA -port to .Tn RPC -program number mapper +program,version +to +.Tn DARPA +port mapper .Sh SYNOPSIS .Nm portmap .Op Fl d @@ -60,7 +61,7 @@ calls. When an .Tn RPC server is started, it will tell -.Nm portmap +.Nm what port number it is listening to, and what .Tn RPC program numbers it is prepared to serve. @@ -68,7 +69,7 @@ When a client wishes to make an .Tn RPC call to a given program number, it will first contact -.Nm portmap +.Nm on the server machine to determine the port number where .Tn RPC @@ -80,23 +81,23 @@ must be started before any servers are invoked. .Pp Normally -.Nm portmap +.Nm forks and dissociates itself from the terminal like any other daemon. .Nm Portmap then logs errors using .Xr syslog 3 . .Pp -Option available: -.Bl -tag -width Ds +The following options are available: +.Bl -tag -width indent .It Fl d -(debug) prevents -.Nm portmap +Prevent +.Nm from running as a daemon, and causes errors and debugging information to be printed to the standard error output. .It Fl v -(verbose) enable verbose logging access control checks. +Enable verbose logging access control checks. .El .Sh SEE ALSO .Xr inetd.conf 5 , @@ -104,7 +105,7 @@ to be printed to the standard error output. .Xr rpcinfo 8 .Sh BUGS If -.Nm portmap +.Nm crashes, all servers must be restarted. .Sh HISTORY The diff --git a/usr.sbin/portmap/portmap.c b/usr.sbin/portmap/portmap.c index c569841..56c1262 100644 --- a/usr.sbin/portmap/portmap.c +++ b/usr.sbin/portmap/portmap.c @@ -32,13 +32,17 @@ */ #ifndef lint -static char copyright[] = +static const char copyright[] = "@(#) Copyright (c) 1990, 1993\n\ The Regents of the University of California. All rights reserved.\n"; #endif /* not lint */ #ifndef lint +#if 0 static char sccsid[] = "@(#)portmap.c 8.1 (Berkeley) 6/6/93"; +#endif +static const char rcsid[] = + "$Id$"; #endif /* not lint */ /* @@ -80,14 +84,15 @@ static char sccsid[] = "@(#)portmap.c 1.32 87/08/06 Copyr 1984 Sun Micro"; * Mountain View, California 94043 */ -#include <rpc/rpc.h> -#include <rpc/pmap_prot.h> +#include <err.h> +#include <netdb.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <syslog.h> #include <unistd.h> -#include <netdb.h> +#include <rpc/rpc.h> +#include <rpc/pmap_prot.h> #include <sys/socket.h> #include <sys/ioctl.h> #include <sys/wait.h> @@ -99,10 +104,12 @@ static char sccsid[] = "@(#)portmap.c 1.32 87/08/06 Copyr 1984 Sun Micro"; void reg_service(); void reap(); static void callit(); +static void usage __P((void)); + struct pmaplist *pmaplist; int debugging = 0; -extern int errno; +int main(argc, argv) int argc; char **argv; @@ -125,17 +132,12 @@ main(argc, argv) break; default: - (void) fprintf(stderr, "usage: %s [-dv]\n", argv[0]); - (void) fprintf(stderr, "-d: debugging mode\n"); - (void) fprintf(stderr, "-v: verbose logging\n"); - exit(1); + usage(); } } - if (!debugging && daemon(0, 0)) { - (void) fprintf(stderr, "portmap: fork: %s", strerror(errno)); - exit(1); - } + if (!debugging && daemon(0, 0)) + err(1, "fork"); openlog("portmap", debugging ? LOG_PID | LOG_PERROR : LOG_PID, LOG_DAEMON); @@ -198,6 +200,13 @@ main(argc, argv) abort(); } +static void +usage() +{ + fprintf(stderr, "usage: portmap [-dv]\n"); + exit(1); +} + #ifndef lint /* need to override perror calls in rpc library */ void @@ -248,7 +257,7 @@ reg_service(rqstp, xprt) deny_severity = LOG_WARNING; if (debugging) - (void) fprintf(stderr, "server: about do a switch\n"); + (void) fprintf(stderr, "server: about to do a switch\n"); switch (rqstp->rq_proc) { case PMAPPROC_NULL: @@ -266,7 +275,7 @@ reg_service(rqstp, xprt) /* * Set a program,version to port mapping */ - if (!svc_getargs(xprt, xdr_pmap, ®)) + if (!svc_getargs(xprt, xdr_pmap, (caddr_t)®)) svcerr_decode(xprt); else { /* reject non-local requests, protect priv. ports */ @@ -320,7 +329,7 @@ reg_service(rqstp, xprt) /* * Remove a program,version to port mapping. */ - if (!svc_getargs(xprt, xdr_pmap, ®)) + if (!svc_getargs(xprt, xdr_pmap, (caddr_t)®)) svcerr_decode(xprt); else { ans = 0; @@ -366,7 +375,7 @@ reg_service(rqstp, xprt) /* * Lookup the mapping for a program,version and return its port */ - if (!svc_getargs(xprt, xdr_pmap, ®)) + if (!svc_getargs(xprt, xdr_pmap, (caddr_t)®)) svcerr_decode(xprt); else { /* remote host authorization check */ @@ -552,7 +561,7 @@ callit(rqstp, xprt) timeout.tv_sec = 5; timeout.tv_usec = 0; a.rmt_args.args = buf; - if (!svc_getargs(xprt, xdr_rmtcall_args, &a)) + if (!svc_getargs(xprt, xdr_rmtcall_args, (caddr_t)&a)) return; /* host and service access control */ if (!check_callit(svc_getcaller(xprt), |