summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--libexec/rpc.yppasswdd/Makefile16
-rw-r--r--libexec/rpc.yppasswdd/rpc.yppasswdd.82
-rw-r--r--libexec/rpc.yppasswdd/rpc.yppasswdd.c163
-rw-r--r--libexec/rpc.yppasswdd/yppasswd.h87
-rw-r--r--libexec/rpc.yppasswdd/yppasswdd_mkpw.c74
-rw-r--r--libexec/rpc.yppasswdd/yppasswdd_proc.c49
-rw-r--r--libexec/rpc.yppasswdd/yppasswdd_xdr.c10
7 files changed, 196 insertions, 205 deletions
diff --git a/libexec/rpc.yppasswdd/Makefile b/libexec/rpc.yppasswdd/Makefile
index a67e37f5284..9539a81c20a 100644
--- a/libexec/rpc.yppasswdd/Makefile
+++ b/libexec/rpc.yppasswdd/Makefile
@@ -1,19 +1,19 @@
-.PATH: ${.CURDIR}/../../usr.sbin/vipw ${.CURDIR}/../../usr.bin/chpass \
- ${.CURDIR}/../../usr.sbin/ypserv
+# from: @(#)Makefile 5.8 (Berkeley) 7/28/90
+# $Id: Makefile,v 1.2 1995/11/01 17:40:33 deraadt Exp $
PROG= rpc.yppasswdd
SRCS= rpc.yppasswdd.c yppasswdd_xdr.c yppasswdd_proc.c yppasswdd_mkpw.c \
- pw_util.c pw_copy.c yplog.c
+ pw_util.c pw_copy.c
MAN= rpc.yppasswdd.8
BINOWN= root
BINMODE=4555
-
+BINDIR=/usr/sbin
MLINKS= rpc.yppasswdd.8 yppasswdd.8
-
+.PATH: ${.CURDIR}/../../usr.sbin/vipw ${.CURDIR}/../../usr.bin/chpass \
+ ${.CURDIR/../../ypserv
DPADD+= ${LIBCRYPT}
LDADD+= -lcrypt
-
-#CFLAGS+=-DDAEMON
-CFLAGS+=-I${.CURDIR}/../../usr.sbin/ypserv -DDEBUG
+CFLAGS+=-I${.CURDIR}/../../usr.sbin/ypserv -I${.CURDIR}/../../usr.sbin/vipw \
+ -I${.CURDIR}/../../usr.bin/chpass
.include <bsd.prog.mk>
diff --git a/libexec/rpc.yppasswdd/rpc.yppasswdd.8 b/libexec/rpc.yppasswdd/rpc.yppasswdd.8
index 0d83ecc5101..3c299eedd9e 100644
--- a/libexec/rpc.yppasswdd/rpc.yppasswdd.8
+++ b/libexec/rpc.yppasswdd/rpc.yppasswdd.8
@@ -25,7 +25,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" $Id: rpc.yppasswdd.8,v 1.1 1995/10/23 07:44:40 deraadt Exp $
+.\" $Id: rpc.yppasswdd.8,v 1.2 1995/11/01 17:40:34 deraadt Exp $
.\"
.Dd July 3, 1994
.Dt YPPASSWDD 8
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)
+ ;
}
diff --git a/libexec/rpc.yppasswdd/yppasswd.h b/libexec/rpc.yppasswdd/yppasswd.h
new file mode 100644
index 00000000000..28f1a01c215
--- /dev/null
+++ b/libexec/rpc.yppasswdd/yppasswd.h
@@ -0,0 +1,87 @@
+/*
+ * Copyright (c) 1995 Mats O Jansson <moj@stacken.kth.se>
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. The name of the author may not be used to endorse or promote
+ * products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * $Id: yppasswd.h,v 1.1 1995/11/01 17:40:35 deraadt Exp $
+ */
+
+#ifndef _YPPASSWD_H_RPCGEN
+#define _YPPASSWD_H_RPCGEN
+
+struct x_passwd {
+ char *pw_name;
+ char *pw_passwd;
+ int pw_uid;
+ int pw_gid;
+ char *pw_gecos;
+ char *pw_dir;
+ char *pw_shell;
+};
+typedef struct x_passwd x_passwd;
+#ifdef __cplusplus
+extern "C" bool_t xdr_x_passwd(XDR *, x_passwd*);
+#elif __STDC__
+extern bool_t xdr_x_passwd(XDR *, x_passwd*);
+#else /* Old Style C */
+bool_t xdr_x_passwd();
+#endif /* Old Style C */
+
+
+struct yppasswd {
+ char *oldpass;
+ x_passwd newpw;
+};
+typedef struct yppasswd yppasswd;
+#ifdef __cplusplus
+extern "C" bool_t xdr_yppasswd(XDR *, yppasswd*);
+#elif __STDC__
+extern bool_t xdr_yppasswd(XDR *, yppasswd*);
+#else /* Old Style C */
+bool_t xdr_yppasswd();
+#endif /* Old Style C */
+
+
+#define YPPASSWDPROG ((u_long)100009)
+#define YPPASSWDVERS ((u_long)1)
+
+#ifdef __cplusplus
+#define YPPASSWDPROC_UPDATE ((u_long)1)
+extern "C" int * yppasswdproc_update_1(yppasswd *, CLIENT *);
+extern "C" int * yppasswdproc_update_1_svc(yppasswd *, struct svc_req *, SVCXPRT *);
+
+#elif __STDC__
+#define YPPASSWDPROC_UPDATE ((u_long)1)
+extern int * yppasswdproc_update_1(yppasswd *, CLIENT *);
+extern int * yppasswdproc_update_1_svc(yppasswd *, struct svc_req *, SVCXPRT *);
+
+#else /* Old Style C */
+#define YPPASSWDPROC_UPDATE ((u_long)1)
+extern int * yppasswdproc_update_1();
+extern int * yppasswdproc_update_1_svc();
+#endif /* Old Style C */
+
+#endif /* !_YPPASSWD_H_RPCGEN */
diff --git a/libexec/rpc.yppasswdd/yppasswdd_mkpw.c b/libexec/rpc.yppasswdd/yppasswdd_mkpw.c
index 19f603d52e1..331d5db5842 100644
--- a/libexec/rpc.yppasswdd/yppasswdd_mkpw.c
+++ b/libexec/rpc.yppasswdd/yppasswdd_mkpw.c
@@ -28,7 +28,7 @@
*/
#ifndef LINT
-static char rcsid[] = "$Id: yppasswdd_mkpw.c,v 1.1 1995/10/23 07:44:42 deraadt Exp $";
+static char rcsid[] = "$Id: yppasswdd_mkpw.c,v 1.2 1995/11/01 17:40:35 deraadt Exp $";
#endif
#include <sys/types.h>
@@ -39,7 +39,9 @@ static char rcsid[] = "$Id: yppasswdd_mkpw.c,v 1.1 1995/10/23 07:44:42 deraadt E
#include <pwd.h>
#include <stdlib.h>
#include <unistd.h>
-#include "yplog.h"
+
+#include "pw_util.h"
+#include "pw_copy.h"
extern int noshell;
extern int nogecos;
@@ -52,25 +54,14 @@ make_passwd(argp)
yppasswd *argp;
{
struct passwd *pw;
- int pfd, tfd;
-
- yplog_line("enter make_passwd");
+ int pfd, tfd;
- if (!(pw = getpwnam(argp->newpw.pw_name))) {
- yplog_date("yppasswdd: unknown user");
- yplog_line(argp->newpw.pw_name);
- return(TRUE);
- }
-
- yplog_line("get user done");
+ pw = getpwnam(argp->newpw.pw_name);
+ if (!pw)
+ return (1);
- if (strcmp(crypt(argp->oldpass, pw->pw_passwd), pw->pw_passwd) != 0) {
- yplog_date("yppasswdd: incorrect password");
- yplog_line(argp->newpw.pw_name);
- return(TRUE);
- }
-
- yplog_line("password ok");
+ if (strcmp(crypt(argp->oldpass, pw->pw_passwd), pw->pw_passwd) != 0)
+ return (1);
pw_init();
pfd = pw_lock();
@@ -81,45 +72,26 @@ make_passwd(argp)
* classes are implemented, go and get the "offset" value for this
* class and reset the timer.
*/
- if (!(nopw)) {
- pw->pw_passwd = argp->newpw.pw_passwd;
- pw->pw_change = 0;
- }
-
- if (!(nogecos)) {
- pw->pw_gecos = argp->newpw.pw_gecos;
- }
-
- if (!(noshell)) {
- pw->pw_shell = argp->newpw.pw_shell;
+ if (!nopw) {
+ pw->pw_passwd = argp->newpw.pw_passwd;
+ pw->pw_change = 0;
}
-
- yplog_line("before pw_copy");
+ if (!nogecos)
+ pw->pw_gecos = argp->newpw.pw_gecos;
+ if (!noshell)
+ pw->pw_shell = argp->newpw.pw_shell;
pw_copy(pfd, tfd, pw);
-
- yplog_line("before pw_mkdb");
-
-/*
- if (!pw_mkdb())
- pw_error((char *)NULL, 0, 0);
-*/
pw_mkdb();
- yplog_line("before fork");
-
if (fork() == 0) {
- chdir("/var/yp");
- (void) umask(022);
- system(make_arg);
- exit(0);
+ chdir("/var/yp");
+ (void) umask(022);
+ system(make_arg);
+ exit(0);
}
-
- yplog_line("exit make_passwd");
-
- return(FALSE);
-
-};
+ return (0);
+}
/*
int
diff --git a/libexec/rpc.yppasswdd/yppasswdd_proc.c b/libexec/rpc.yppasswdd/yppasswdd_proc.c
index 73d8cbd4feb..77b08e5c3d5 100644
--- a/libexec/rpc.yppasswdd/yppasswdd_proc.c
+++ b/libexec/rpc.yppasswdd/yppasswdd_proc.c
@@ -28,66 +28,35 @@
*/
#ifndef LINT
-static char rcsid[] = "$Id: yppasswdd_proc.c,v 1.1 1995/10/23 07:44:43 deraadt Exp $";
+static char rcsid[] = "$Id: yppasswdd_proc.c,v 1.2 1995/11/01 17:40:36 deraadt Exp $";
#endif
+#include <sys/types.h>
#include <rpc/rpc.h>
-#include <rpcsvc/yppasswd.h>
#include <stdio.h>
#include <string.h>
-#include "yplog.h"
-extern int make_passwd();
+#include "yppasswd.h"
+
+int make_passwd __P((yppasswd *));
int *
-yppasswdproc_update_1(argp, rqstp, transp)
+yppasswdproc_update_1_svc(argp, rqstp, transp)
yppasswd *argp;
struct svc_req *rqstp;
SVCXPRT *transp;
{
static int res;
- char numstr[20];
bzero((char *)&res, sizeof(res));
-
- yplog_date("yppasswdd_update_1: this code isn't tested");
- yplog_call(transp);
-#ifdef DEBUG
- yplog_str (" oldpass: "); yplog_cat(argp->oldpass); yplog_cat("\n");
- yplog_line(" newpw:");
- yplog_str (" name: "); yplog_cat(argp->newpw.pw_name);
- yplog_cat ("\n");
- yplog_str (" passwd: "); yplog_cat(argp->newpw.pw_passwd);
- yplog_cat ("\n");
- yplog_str (" uid: ");
- sprintf(numstr,"%d\n",argp->newpw.pw_uid);
- yplog_cat (numstr);
- yplog_str (" gid: ");
- sprintf(numstr,"%d\n",argp->newpw.pw_gid);
- yplog_cat (numstr);
- yplog_str (" gecos: "); yplog_cat(argp->newpw.pw_gecos);
- yplog_cat ("\n");
- yplog_str (" dir: "); yplog_cat(argp->newpw.pw_dir);
- yplog_cat ("\n");
- yplog_str (" shell: "); yplog_cat(argp->newpw.pw_shell);
- yplog_cat ("\n");
-#endif
-
res = make_passwd(argp);
- yplog_line("after make_passwd");
-
- if (!svc_sendreply(transp, xdr_int, (char *) &res)) {
+ if (!svc_sendreply(transp, xdr_int, (char *)&res))
svcerr_systemerr(transp);
- }
-
- if (!svc_freeargs(transp, xdr_yppasswd, argp)) {
+
+ if (!svc_freeargs(transp, xdr_yppasswd, (caddr_t) argp)) {
(void)fprintf(stderr, "unable to free arguments\n");
exit(1);
}
-
- yplog_line("exit yppasswdproc_update_1");
-
return ((void *)&res);
}
-
diff --git a/libexec/rpc.yppasswdd/yppasswdd_xdr.c b/libexec/rpc.yppasswdd/yppasswdd_xdr.c
index aa1169d9f0b..d8f0745db3c 100644
--- a/libexec/rpc.yppasswdd/yppasswdd_xdr.c
+++ b/libexec/rpc.yppasswdd/yppasswdd_xdr.c
@@ -28,15 +28,12 @@
*/
#ifndef LINT
-static char rcsid[] = "$Id: yppasswdd_xdr.c,v 1.1 1995/10/23 07:44:44 deraadt Exp $";
+static char rcsid[] = "$Id: yppasswdd_xdr.c,v 1.2 1995/11/01 17:40:37 deraadt Exp $";
#endif
-
-
#include <rpc/rpc.h>
#include <rpcsvc/yppasswd.h>
-
bool_t
xdr_x_passwd(xdrs, objp)
XDR *xdrs;
@@ -66,9 +63,6 @@ xdr_x_passwd(xdrs, objp)
return (TRUE);
}
-
-
-
bool_t
xdr_yppasswd(xdrs, objp)
XDR *xdrs;
@@ -82,5 +76,3 @@ xdr_yppasswd(xdrs, objp)
}
return (TRUE);
}
-
-