diff options
author | Theo de Raadt <deraadt@cvs.openbsd.org> | 1995-11-01 17:40:38 +0000 |
---|---|---|
committer | Theo de Raadt <deraadt@cvs.openbsd.org> | 1995-11-01 17:40:38 +0000 |
commit | 66e65e13d60443077f12a35777f4fb1641bb3ad7 (patch) | |
tree | 5eeb280bfb775879c365650cff783a12d5353f59 /libexec/rpc.yppasswdd/rpc.yppasswdd.c | |
parent | 34ad72d2df218ebc618d3b321656804f58599720 (diff) |
+ from moj
Diffstat (limited to 'libexec/rpc.yppasswdd/rpc.yppasswdd.c')
-rw-r--r-- | libexec/rpc.yppasswdd/rpc.yppasswdd.c | 163 |
1 files changed, 67 insertions, 96 deletions
diff --git a/libexec/rpc.yppasswdd/rpc.yppasswdd.c b/libexec/rpc.yppasswdd/rpc.yppasswdd.c index 1dd0acba4c9..44176f7490e 100644 --- a/libexec/rpc.yppasswdd/rpc.yppasswdd.c +++ b/libexec/rpc.yppasswdd/rpc.yppasswdd.c @@ -28,92 +28,68 @@ */ #ifndef LINT -static char rcsid[] = "$Id: rpc.yppasswdd.c,v 1.1 1995/10/23 07:44:41 deraadt Exp $"; +static char rcsid[] = "$Id: rpc.yppasswdd.c,v 1.2 1995/11/01 17:40:34 deraadt Exp $"; #endif #include <stdio.h> #include <rpc/rpc.h> -#include <rpcsvc/yppasswd.h> #include <rpc/pmap_clnt.h> #include <signal.h> #include <sys/wait.h> #include <sys/types.h> #include <unistd.h> #include <string.h> -#include "yplog.h" + +#include "yppasswd.h" + static void yppasswddprog_1(); -void sig_child(); +void sig_child(); -int noshell = FALSE; -int nogecos = FALSE; -int nopw = FALSE; -int make = FALSE; -char make_arg[1024] = "make"; -char *progname = "yppasswdd"; -char *tempname; +int noshell, nogecos, nopw, domake; +char make_arg[1024] = "make"; +char *progname = "yppasswdd"; +char *tempname; + +void +usage() +{ + fprintf(stderr, "%s%s", + "usage: rpc.yppasswdd ", + "[-noshell] [-nogecos] [-nopw] [-m arg1 arg2 ... ]\n"); + exit(1); +} int -main(argc,argv) -int argc; -char *argv[]; +main(argc, argv) + int argc; + char *argv[]; { SVCXPRT *transp; - int i = 1; - int usage = FALSE; + int i = 1; while (i < argc) { - - if (argv[i][0] == '-') { - - if (strcmp("-noshell",argv[i]) == 0) { - noshell = TRUE; - i++; - continue; - } - - if (strcmp("-nogecos",argv[i]) == 0) { - nogecos = TRUE; - i++; - continue; - } - - if (strcmp("-nopw",argv[i]) == 0) { - nopw = TRUE; - i++; - continue; - } - - if (strcmp("-m",argv[i]) == 0) { - make = TRUE; - i++; - while (i < argc) { - strcat(make_arg," "); - strcat(make_arg,argv[i]); - i++; - } - continue; - } - - usage = TRUE; - i++; - - } else { - usage = TRUE; - i++; - } - - }; - - if (usage == TRUE) { - fprintf(stderr, - "%s%s", - "usage: rpc.yppasswdd ", - "[-noshell] [-nogecos] [-nopw] [-m arg1 arg2 ... ]\n"); - exit(1); + if (argv[i][0] == '-') { + if (strcmp("-noshell", argv[i]) == 0) { + noshell = 1; + } else if (strcmp("-nogecos", argv[i]) == 0) { + nogecos = 1; + } else if (strcmp("-nopw", argv[i]) == 0) { + nopw = 1; + } else if (strcmp("-m", argv[i]) == 0) { + domake = 1; + while (i < argc) { + strcat(make_arg, " "); + strcat(make_arg, argv[i]); + i++; + } + } else + usage(); + i++; + } else + usage(); } -#ifdef DAEMON - switch(fork()) { + switch (fork()) { case 0: break; case -1: @@ -122,44 +98,41 @@ char *argv[]; default: exit(0); } - setsid(); -#endif - - yplog_init(progname); + setsid(); chdir("/etc"); - - /* std* must exists */ + /* freopen("/dev/null", "r", stdin); freopen("/var/yp/stderr", "w", stderr); freopen("/var/yp/stdout", "w", stdout); -*/ - (void)pmap_unset(YPPASSWDPROG, YPPASSWDVERS); +*/ + (void) pmap_unset(YPPASSWDPROG, YPPASSWDVERS); - (void)signal(SIGCHLD, sig_child); + (void) signal(SIGCHLD, sig_child); transp = svcudp_create(RPC_ANYSOCK); if (transp == NULL) { - (void)fprintf(stderr, "cannot create udp service.\n"); + (void) fprintf(stderr, "cannot create udp service.\n"); exit(1); } - if (!svc_register(transp, YPPASSWDPROG, YPPASSWDVERS, yppasswddprog_1, IPPROTO_UDP)) { - (void)fprintf(stderr, "unable to register (YPPASSWDPROG, YPPASSWDVERS, udp).\n"); + if (!svc_register(transp, YPPASSWDPROG, YPPASSWDVERS, yppasswddprog_1, + IPPROTO_UDP)) { + fprintf(stderr, "unable to register YPPASSWDPROG, YPPASSWDVERS, udp\n"); exit(1); } - transp = svctcp_create(RPC_ANYSOCK, 0, 0); if (transp == NULL) { - (void)fprintf(stderr, "cannot create tcp service.\n"); + (void) fprintf(stderr, "cannot create tcp service.\n"); exit(1); } - if (!svc_register(transp, YPPASSWDPROG, YPPASSWDVERS, yppasswddprog_1, IPPROTO_TCP)) { - (void)fprintf(stderr, "unable to register (YPPASSWDPROG, YPPASSWDVERS, tcp).\n"); + if (!svc_register(transp, YPPASSWDPROG, YPPASSWDVERS, yppasswddprog_1, + IPPROTO_TCP)) { + fprintf(stderr, "unable to register YPPASSWDPROG, YPPASSWDVERS, tcp\n"); exit(1); } svc_run(); - (void)fprintf(stderr, "svc_run returned\n"); + (void) fprintf(stderr, "svc_run returned\n"); exit(1); } @@ -170,37 +143,35 @@ yppasswddprog_1(rqstp, transp) { union { yppasswd yppasswdproc_update_1_arg; - } argument; - char *result; - bool_t (*xdr_argument)(), (*xdr_result)(); - char *(*local)(); + } argument; + char *result; + bool_t(*xdr_argument) (), (*xdr_result) (); + char *(*local) (); switch (rqstp->rq_proc) { case NULLPROC: - (void)svc_sendreply(transp, xdr_void, (char *)NULL); + (void) svc_sendreply(transp, xdr_void, (char *) NULL); return; - case YPPASSWDPROC_UPDATE: xdr_argument = xdr_yppasswd; xdr_result = xdr_int; - local = (char *(*)()) yppasswdproc_update_1; + local = (char *(*) ()) yppasswdproc_update_1_svc; break; - default: svcerr_noproc(transp); return; } - bzero((char *)&argument, sizeof(argument)); - if (!svc_getargs(transp, xdr_argument, &argument)) { + bzero((char *) &argument, sizeof(argument)); + if (!svc_getargs(transp, xdr_argument, (caddr_t) & argument)) { svcerr_decode(transp); return; } - result = (*local)(&argument, rqstp, transp); - + result = (*local) (&argument, rqstp, transp); } void sig_child() { - while (wait3((int *)NULL, WNOHANG, (struct rusage *)NULL) > 0); + while (wait3((int *) NULL, WNOHANG, (struct rusage *) NULL) > 0) + ; } |