summaryrefslogtreecommitdiff
path: root/usr.sbin/rpc.lockd/lockd.c
diff options
context:
space:
mode:
authorTheo de Raadt <deraadt@cvs.openbsd.org>1997-09-17 23:09:40 +0000
committerTheo de Raadt <deraadt@cvs.openbsd.org>1997-09-17 23:09:40 +0000
commitcd623858d6f607bf04845d0def21e84679e094ba (patch)
treefb297d5cf3c0f4ba2306499bd3b138b2c7209c73 /usr.sbin/rpc.lockd/lockd.c
parentb4d7fc23f6ebd761ebe5001df5744671bb03320f (diff)
make this readable, so that i can think about actually coding it..
Diffstat (limited to 'usr.sbin/rpc.lockd/lockd.c')
-rw-r--r--usr.sbin/rpc.lockd/lockd.c145
1 files changed, 74 insertions, 71 deletions
diff --git a/usr.sbin/rpc.lockd/lockd.c b/usr.sbin/rpc.lockd/lockd.c
index 7aa1b9d9b87..51aac43f0b6 100644
--- a/usr.sbin/rpc.lockd/lockd.c
+++ b/usr.sbin/rpc.lockd/lockd.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: lockd.c,v 1.3 1997/08/10 21:06:40 millert Exp $ */
+/* $OpenBSD: lockd.c,v 1.4 1997/09/17 23:09:36 deraadt Exp $ */
/*
* Copyright (c) 1995
@@ -33,89 +33,92 @@
*
*/
-
-/* 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 <sys/param.h>
+#include <sys/socket.h>
+#include <netinet/in.h>
+#include <rpc/rpc.h>
+#include <rpc/pmap_clnt.h>
+#include <rpcsvc/sm_inter.h>
+#include "nlm_prot.h"
+#include <arpa/inet.h>
+#include <stdio.h>
+#include <syslog.h>
+#include <stdlib.h>
+#include <string.h>
+#include <netdb.h>
#include "lockd.h"
extern void nlm_prog_1 __P((struct svc_req, register SVCXPRT));
extern void nlm_prog_3 __P((struct svc_req, register SVCXPRT));
-int debug_level = 0; /* Zero means no debugging syslog() calls */
+int debug_level = 0; /* Zero means no debugging syslog() calls */
-#if 1
-int _rpcsvcdirty;
-#endif
+int _rpcsvcdirty;
int
main(argc, argv)
- int argc;
- char **argv;
+ int argc;
+ char **argv;
{
- SVCXPRT *transp;
-
- if (argc > 1)
- {
- if (strncmp(argv[1], "-d", 2))
- {
- fprintf(stderr, "Usage: rpc.lockd [-d [<debuglevel>]]\n");
- exit(1);
- }
- 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 */
- if (!debug_level) debug_level = 1;
- }
-
- (void)pmap_unset(NLM_PROG, NLM_VERS);
- (void)pmap_unset(NLM_PROG, NLM_VERSX);
+ SVCXPRT *transp;
- transp = svcudp_create(RPC_ANYSOCK);
- if (transp == NULL)
- {
- (void)fprintf(stderr, "cannot create udp service.\n");
- exit(1);
- }
- if (!svc_register(transp, NLM_PROG, NLM_VERS, (void (*)())nlm_prog_1, IPPROTO_UDP))
- {
- (void)fprintf(stderr, "unable to register (NLM_PROG, NLM_VERS, udp).\n");
- exit(1);
- }
- if (!svc_register(transp, NLM_PROG, NLM_VERSX, (void (*)())nlm_prog_3, IPPROTO_UDP))
- {
- (void)fprintf(stderr, "unable to register (NLM_PROG, NLM_VERSX, udp).\n");
- exit(1);
- }
+ if (argc > 1) {
+ if (strncmp(argv[1], "-d", 2)) {
+ fprintf(stderr, "Usage: rpc.lockd [-d debuglevel]\n");
+ exit(1);
+ }
+ if (argc > 2)
+ debug_level = atoi(argv[2]);
+ else
+ debug_level = atoi(argv[1] + 2);
+ if (!debug_level)
+ debug_level = 1;
+ }
+ (void) pmap_unset(NLM_PROG, NLM_VERS);
+ (void) pmap_unset(NLM_PROG, NLM_VERSX);
- transp = svctcp_create(RPC_ANYSOCK, 0, 0);
- if (transp == NULL)
- {
- (void)fprintf(stderr, "cannot create tcp service.\n");
- exit(1);
- }
- if (!svc_register(transp, NLM_PROG, NLM_VERS, (void (*)())nlm_prog_1, IPPROTO_TCP))
- {
- (void)fprintf(stderr, "unable to register (NLM_PROG, NLM_VERS, tcp).\n");
- exit(1);
- }
- if (!svc_register(transp, NLM_PROG, NLM_VERSX, (void (*)())nlm_prog_3, IPPROTO_TCP))
- {
- (void)fprintf(stderr, "unable to register (NLM_PROG, NLM_VERSX, tcp).\n");
- exit(1);
- }
+ transp = svcudp_create(RPC_ANYSOCK);
+ if (transp == NULL) {
+ fprintf(stderr, "cannot create udp service.\n");
+ exit(1);
+ }
+ if (!svc_register(transp, NLM_PROG, NLM_VERS,
+ (void (*) ()) nlm_prog_1, IPPROTO_UDP)) {
+ fprintf(stderr, "unable to register (NLM_PROG, NLM_VERS, udp).\n");
+ exit(1);
+ }
+ if (!svc_register(transp, NLM_PROG, NLM_VERSX,
+ (void (*) ()) nlm_prog_3, IPPROTO_UDP)) {
+ fprintf(stderr, "unable to register (NLM_PROG, NLM_VERSX, udp).\n");
+ exit(1);
+ }
+ transp = svctcp_create(RPC_ANYSOCK, 0, 0);
+ if (transp == NULL) {
+ fprintf(stderr, "cannot create tcp service.\n");
+ exit(1);
+ }
+ if (!svc_register(transp, NLM_PROG, NLM_VERS,
+ (void (*) ()) nlm_prog_1, IPPROTO_TCP)) {
+ fprintf(stderr, "unable to register (NLM_PROG, NLM_VERS, tcp).\n");
+ exit(1);
+ }
+ if (!svc_register(transp, NLM_PROG, NLM_VERSX,
+ (void (*) ()) nlm_prog_3, IPPROTO_TCP)) {
+ fprintf(stderr, "unable to register (NLM_PROG, NLM_VERSX, tcp).\n");
+ exit(1);
+ }
- /* 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);
- }
- openlog("rpc.lockd", 0, LOG_DAEMON);
- if (debug_level) syslog(LOG_INFO, "Starting, debug level %d", debug_level);
- else syslog(LOG_INFO, "Starting");
+ if (daemon(0, 0)) {
+ perror("cannot fork");
+ exit(1);
+ }
+ openlog("rpc.lockd", 0, LOG_DAEMON);
+ if (debug_level)
+ syslog(LOG_INFO, "Starting, debug level %d", debug_level);
+ else
+ syslog(LOG_INFO, "Starting");
- svc_run(); /* Should never return */
- exit(1);
+ svc_run();
+ exit(1);
}