diff options
Diffstat (limited to 'usr.sbin/rpc.lockd')
-rw-r--r-- | usr.sbin/rpc.lockd/handles.c | 5 | ||||
-rw-r--r-- | usr.sbin/rpc.lockd/lockd.c | 60 | ||||
-rw-r--r-- | usr.sbin/rpc.lockd/procs.c | 10 | ||||
-rw-r--r-- | usr.sbin/rpc.lockd/rpc.lockd.8 | 21 | ||||
-rw-r--r-- | usr.sbin/rpc.lockd/test.c | 14 |
5 files changed, 58 insertions, 52 deletions
diff --git a/usr.sbin/rpc.lockd/handles.c b/usr.sbin/rpc.lockd/handles.c index 047f6d2..8be7a29 100644 --- a/usr.sbin/rpc.lockd/handles.c +++ b/usr.sbin/rpc.lockd/handles.c @@ -31,7 +31,10 @@ * */ - +#ifndef lint +static const char rcsid[] = + "$Id$"; +#endif /* not lint */ #include "nlm_prot.h" diff --git a/usr.sbin/rpc.lockd/lockd.c b/usr.sbin/rpc.lockd/lockd.c index 092628a..44a5e21 100644 --- a/usr.sbin/rpc.lockd/lockd.c +++ b/usr.sbin/rpc.lockd/lockd.c @@ -31,19 +31,29 @@ * */ +#ifndef lint +static const char rcsid[] = + "$Id$"; +#endif /* not lint */ /* main() function for NFS lock daemon. Most of the code in this */ /* file was generated by running rpcgen /usr/include/rpcsvc/nlm_prot.x */ /* The actual program logic is in the file procs.c */ +#include <err.h> +#include <stdlib.h> +#include <string.h> +#include <rpc/rpc.h> +#include <rpc/pmap_clnt.h> #include "lockd.h" void nlm_prog_1 __P((struct svc_req *, SVCXPRT *)); void nlm_prog_3 __P((struct svc_req *, SVCXPRT *)); +static void usage __P((void)); int debug_level = 0; /* Zero means no debugging syslog() calls */ - +int main(int argc, char **argv) { SVCXPRT *transp; @@ -51,10 +61,7 @@ main(int argc, char **argv) if (argc > 1) { if (strncmp(argv[1], "-d", 2)) - { - fprintf(stderr, "Usage: rpc.lockd [-d [<debuglevel>]]\n"); - exit(1); - } + usage(); if (argc > 2) debug_level = atoi(argv[2]); else debug_level = atoi(argv[1] + 2); /* Ensure at least some debug if -d with no specified level */ @@ -66,44 +73,24 @@ main(int argc, char **argv) transp = svcudp_create(RPC_ANYSOCK); if (transp == NULL) - { - (void)fprintf(stderr, "cannot create udp service.\n"); - exit(1); - } + errx(1, "cannot create udp service"); if (!svc_register(transp, NLM_PROG, NLM_VERS, nlm_prog_1, IPPROTO_UDP)) - { - (void)fprintf(stderr, "unable to register (NLM_PROG, NLM_VERS, udp).\n"); - exit(1); - } + errx(1, "unable to register (NLM_PROG, NLM_VERS, udp)"); if (!svc_register(transp, NLM_PROG, NLM_VERSX, nlm_prog_3, IPPROTO_UDP)) - { - (void)fprintf(stderr, "unable to register (NLM_PROG, NLM_VERSX, udp).\n"); - exit(1); - } + errx(1, "unable to register (NLM_PROG, NLM_VERSX, udp)"); transp = svctcp_create(RPC_ANYSOCK, 0, 0); if (transp == NULL) - { - (void)fprintf(stderr, "cannot create tcp service.\n"); - exit(1); - } + errx(1, "cannot create tcp service"); if (!svc_register(transp, NLM_PROG, NLM_VERS, nlm_prog_1, IPPROTO_TCP)) - { - (void)fprintf(stderr, "unable to register (NLM_PROG, NLM_VERS, tcp).\n"); - exit(1); - } + errx(1, "unable to register (NLM_PROG, NLM_VERS, tcp)"); if (!svc_register(transp, NLM_PROG, NLM_VERSX, nlm_prog_3, IPPROTO_TCP)) - { - (void)fprintf(stderr, "unable to register (NLM_PROG, NLM_VERSX, tcp).\n"); - exit(1); - } + errx(1, "unable to register (NLM_PROG, NLM_VERSX, tcp)"); /* Note that it is NOT sensible to run this program from inetd - the */ /* protocol assumes that it will run immediately at boot time. */ - if (daemon(0,0)) { - perror("cannot fork"); - exit(1); - } + if (daemon(0,0)) + err(1, "fork"); openlog("rpc.lockd", 0, LOG_DAEMON); if (debug_level) syslog(LOG_INFO, "Starting, debug level %d", debug_level); else syslog(LOG_INFO, "Starting"); @@ -111,3 +98,10 @@ main(int argc, char **argv) svc_run(); /* Should never return */ exit(1); } + +static void +usage() +{ + fprintf(stderr, "usage: rpc.lockd [-d [debuglevel]]\n"); + exit(1); +} diff --git a/usr.sbin/rpc.lockd/procs.c b/usr.sbin/rpc.lockd/procs.c index 54e5f81..84ead97 100644 --- a/usr.sbin/rpc.lockd/procs.c +++ b/usr.sbin/rpc.lockd/procs.c @@ -31,8 +31,12 @@ * */ +#ifndef lint +static const char rcsid[] = + "$Id$"; +#endif /* not lint */ - +#include <string.h> #include "lockd.h" #include <sys/param.h> /* for MAXHOSTNAMELEN */ @@ -205,7 +209,7 @@ static void transmit_result(int opcode, nlm_res *result, struct svc_req *req) struct timeval timeo; addr = svc_getcaller(req->rq_xprt); - if (cli = get_client(addr)) + if ((cli = get_client(addr))) { timeo.tv_sec = 0; /* No timeout - not expecting response */ timeo.tv_usec = 0; @@ -284,7 +288,7 @@ void *nlm_test_msg_1_svc(nlm_testargs *arg, struct svc_req *rqstp) /* nlm_test has different result type to the other operations, so */ /* can't use transmit_result() in this case */ addr = svc_getcaller(rqstp->rq_xprt); - if (cli = get_client(addr)) + if ((cli = get_client(addr))) { timeo.tv_sec = 0; /* No timeout - not expecting response */ timeo.tv_usec = 0; diff --git a/usr.sbin/rpc.lockd/rpc.lockd.8 b/usr.sbin/rpc.lockd/rpc.lockd.8 index e08a160..4fe66b6 100644 --- a/usr.sbin/rpc.lockd/rpc.lockd.8 +++ b/usr.sbin/rpc.lockd/rpc.lockd.8 @@ -42,17 +42,14 @@ .Nm rpc.lockd .Op Fl d Op Ar debug_level .Sh DESCRIPTION -.Nm rpc.lockd +.Nm Rpc.lockd is a daemon which provides file- and record-locking services in an NFS environment. .Pp -Options and operands available for -.Nm rpc.lockd : -.Bl -tag -width Ds +The following option is available: +.Bl -tag -width indent .It Fl d -The -.Fl d -option causes debugging information to be written to syslog, recording +Cause debugging information to be written to syslog, recording all RPC transactions to the daemon. These messages are logged with level LOG_DEBUG and facility LOG_DAEMON. If debug_level is not specified, level 1 is assumed, giving one log line per protocol operation. Higher @@ -64,7 +61,7 @@ Error conditions are logged to syslog, irrespective of the debug level, using log level LOG_ERR and facility LOG_DAEMON. .Pp The -.Nm rpc.lockd +.Nm daemon must NOT be invoked by .Xr inetd 8 because the protocol assumes that the daemon will run from system start time. @@ -82,8 +79,12 @@ RPC protocol specification for the network lock manager protocol. .Xr rpc.statd 8 .Sh BUGS The current implementation provides only the server side of the protocol -(ie. clients running other OS types can establish locks on a FreeBSD fileserver, -but there is currently no means for a FreeBSD client to establish locks). +(ie. clients running other OS types can establish locks on a +.Bx Free +fileserver, +but there is currently no means for a +.Bx Free +client to establish locks). .Pp Versions 1, 2 and 3 of the protocol are supported. However, only versions 2 (Unix systems) and 3 (PC-NFS clients) seem to be in common use - the version diff --git a/usr.sbin/rpc.lockd/test.c b/usr.sbin/rpc.lockd/test.c index 2f1eb5a..01142a4 100644 --- a/usr.sbin/rpc.lockd/test.c +++ b/usr.sbin/rpc.lockd/test.c @@ -1,11 +1,15 @@ -#include <rpc/rpc.h> -#include <rpcsvc/nlm_prot.h> #ifndef lint -/*static char sccsid[] = "from: @(#)nlm_prot.x 1.8 87/09/21 Copyr 1987 Sun Micro";*/ -/*static char sccsid[] = "from: * @(#)nlm_prot.x 2.1 88/08/01 4.0 RPCSRC";*/ -static char rcsid[] = "nlm_prot.x,v 1.1 1994/08/04 19:01:48 wollman Exp"; +#if 0 +static char sccsid[] = "from: @(#)nlm_prot.x 1.8 87/09/21 Copyr 1987 Sun Micro"; +static char sccsid[] = "from: * @(#)nlm_prot.x 2.1 88/08/01 4.0 RPCSRC"; +#endif +static const char rcsid[] = + "$Id$"; #endif /* not lint */ +#include <rpc/rpc.h> +#include <rpcsvc/nlm_prot.h> + /* Default timeout can be changed using clnt_control() */ static struct timeval TIMEOUT = { 0, 0 }; |