This commit is contained in:
ad 2000-08-03 08:22:33 +00:00
parent 9b50348e47
commit 308c65aabe
4 changed files with 95 additions and 59 deletions

View File

@ -0,0 +1,39 @@
/* $NetBSD: extern.h,v 1.1 2000/08/03 08:22:33 ad Exp $ */
/*
* Copyright (c) 1994 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. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by Mats O Jansson
* 4. 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.
*/
/* yppasswdd_mkpw.c */
void make_passwd(yppasswd *, struct svc_req *, SVCXPRT *);
/* rpc.yppasswdd.c */
extern int noshell, nogecos, nopw, domake;
extern char make_arg[_POSIX2_LINE_MAX];

View File

@ -1,4 +1,4 @@
/* $NetBSD: rpc.yppasswdd.c,v 1.3 1999/06/06 02:44:52 thorpej Exp $ */
/* $NetBSD: rpc.yppasswdd.c,v 1.4 2000/08/03 08:22:33 ad Exp $ */
/*
* Copyright (c) 1994 Mats O Jansson <moj@stacken.kth.se>
@ -31,8 +31,14 @@
* SUCH DAMAGE.
*/
#include <sys/cdefs.h>
#ifndef lint
__RCSID("$NetBSD: rpc.yppasswdd.c,v 1.4 2000/08/03 08:22:33 ad Exp $");
#endif /* not lint */
#include <sys/types.h>
#include <sys/wait.h>
#include <err.h>
#include <limits.h>
#include <stdio.h>
@ -46,21 +52,19 @@
#include <rpc/pmap_clnt.h>
#include <rpcsvc/yppasswd.h>
#include "extern.h"
extern char *__progname; /* from crt0.s */
int noshell, nogecos, nopw, domake;
char make_arg[_POSIX2_LINE_MAX] = "make";
extern void make_passwd __P((yppasswd *, struct svc_req *, SVCXPRT *));
int main __P((int, char *[]));
void yppasswddprog_1 __P((struct svc_req *, SVCXPRT *));
void usage __P((void));
int main(int, char *[]);
void yppasswddprog_1(struct svc_req *, SVCXPRT *);
void usage(void);
int
main(argc, argv)
int argc;
char *argv[];
main(int argc, char *argv[])
{
SVCXPRT *transp;
int i;
@ -86,35 +90,36 @@ main(argc, argv)
}
if (daemon(0, 0))
err(1, "can't detach");
err(EXIT_FAILURE, "can't detach");
pidfile(NULL);
(void) pmap_unset(YPPASSWDPROG, YPPASSWDVERS);
transp = svcudp_create(RPC_ANYSOCK);
if (transp == NULL)
errx(1, "cannot create UDP service");
errx(EXIT_FAILURE, "cannot create UDP service");
if (!svc_register(transp, YPPASSWDPROG, YPPASSWDVERS, yppasswddprog_1,
IPPROTO_UDP))
errx(1, "unable to register YPPASSWDPROG/YPPASSWDVERS/UDP");
errx(EXIT_FAILURE,
"unable to register YPPASSWDPROG/YPPASSWDVERS/UDP");
transp = svctcp_create(RPC_ANYSOCK, 0, 0);
if (transp == NULL)
errx(1, "cannot create TCP service");
errx(EXIT_FAILURE, "cannot create TCP service");
if (!svc_register(transp, YPPASSWDPROG, YPPASSWDVERS, yppasswddprog_1,
IPPROTO_TCP))
errx(1, "unable to register YPPASSWDPROG/YPPASSWDVERS/TCP");
errx(EXIT_FAILURE,
"unable to register YPPASSWDPROG/YPPASSWDVERS/TCP");
svc_run();
errx(1, "svc_run returned");
errx(EXIT_FAILURE, "svc_run returned");
/* NOTREACHED */
}
void
yppasswddprog_1(rqstp, transp)
struct svc_req *rqstp;
SVCXPRT *transp;
yppasswddprog_1(struct svc_req *rqstp, SVCXPRT *transp)
{
union {
yppasswd yppasswdproc_update_1_arg;
@ -140,7 +145,7 @@ yppasswddprog_1(rqstp, transp)
}
make_passwd((yppasswd *)&argument, rqstp, transp);
if (!svc_freeargs(transp, xdr_yppasswd, (caddr_t) &argument))
errx(1, "unable to free arguments");
errx(EXIT_FAILURE, "unable to free arguments");
return;
}
@ -148,10 +153,10 @@ yppasswddprog_1(rqstp, transp)
}
void
usage()
usage(void)
{
fprintf(stderr, "usage: %s [-noshell] [-nogecos] [-nopw] "
"[-m arg1 arg2 ...]\n", __progname);
exit(1);
exit(EXIT_FAILURE);
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: yppasswdd_mkpw.c,v 1.6 2000/07/07 15:11:47 itojun Exp $ */
/* $NetBSD: yppasswdd_mkpw.c,v 1.7 2000/08/03 08:22:34 ad Exp $ */
/*
* Copyright (c) 1996 Jason R. Thorpe <thorpej@NetBSD.ORG>
@ -34,11 +34,17 @@
* SUCH DAMAGE.
*/
#include <sys/cdefs.h>
#ifndef lint
__RCSID("$NetBSD: yppasswdd_mkpw.c,v 1.7 2000/08/03 08:22:34 ad Exp $");
#endif /* not lint */
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/time.h>
#include <sys/resource.h>
#include <sys/wait.h>
#include <err.h>
#include <fcntl.h>
#include <stdio.h>
@ -48,26 +54,18 @@
#include <string.h>
#include <unistd.h>
#include <util.h>
#include <limits.h>
#include <rpc/rpc.h>
#include <rpc/xdr.h>
#include <rpcsvc/yppasswd.h>
extern int noshell;
extern int nogecos;
extern int nopw;
extern int make;
extern char make_arg[];
void make_passwd __P((yppasswd *, struct svc_req *, SVCXPRT *));
#include "extern.h"
int handling_request; /* simple mutex */
void
make_passwd(argp, rqstp, transp)
yppasswd *argp;
struct svc_req *rqstp;
SVCXPRT *transp;
make_passwd(yppasswd *argp, struct svc_req *rqstp, SVCXPRT *transp)
{
struct passwd *pw;
int pfd, tfd;
@ -141,7 +139,7 @@ make_passwd(argp, rqstp, transp)
/* Update the YP maps. */
if (chdir("/var/yp"))
err(1, "/var/yp");
err(EXIT_FAILURE, "/var/yp");
(void) umask(022);
(void) system(make_arg);

View File

@ -1,4 +1,4 @@
/* $NetBSD: yppasswdd_xdr.c,v 1.1.1.1 1996/08/09 10:19:49 thorpej Exp $ */
/* $NetBSD: yppasswdd_xdr.c,v 1.2 2000/08/03 08:22:34 ad Exp $ */
/*
* Copyright (c) 1994 Mats O Jansson <moj@stacken.kth.se>
@ -31,50 +31,44 @@
* SUCH DAMAGE.
*/
#include <sys/cdefs.h>
#ifndef lint
__RCSID("$NetBSD: yppasswdd_xdr.c,v 1.2 2000/08/03 08:22:34 ad Exp $");
#endif /* not lint */
#include <rpc/rpc.h>
#include <rpcsvc/yppasswd.h>
bool_t
xdr_x_passwd(xdrs, objp)
XDR *xdrs;
x_passwd *objp;
xdr_x_passwd(XDR *xdrs, x_passwd *objp)
{
if (!xdr_string(xdrs, &objp->pw_name, ~0)) {
if (!xdr_string(xdrs, &objp->pw_name, ~0))
return (FALSE);
}
if (!xdr_string(xdrs, &objp->pw_passwd, ~0)) {
if (!xdr_string(xdrs, &objp->pw_passwd, ~0))
return (FALSE);
}
if (!xdr_int(xdrs, &objp->pw_uid)) {
if (!xdr_int(xdrs, &objp->pw_uid))
return (FALSE);
}
if (!xdr_int(xdrs, &objp->pw_gid)) {
if (!xdr_int(xdrs, &objp->pw_gid))
return (FALSE);
}
if (!xdr_string(xdrs, &objp->pw_gecos, ~0)) {
if (!xdr_string(xdrs, &objp->pw_gecos, ~0))
return (FALSE);
}
if (!xdr_string(xdrs, &objp->pw_dir, ~0)) {
if (!xdr_string(xdrs, &objp->pw_dir, ~0))
return (FALSE);
}
if (!xdr_string(xdrs, &objp->pw_shell, ~0)) {
if (!xdr_string(xdrs, &objp->pw_shell, ~0))
return (FALSE);
}
return (TRUE);
}
bool_t
xdr_yppasswd(xdrs, objp)
XDR *xdrs;
yppasswd *objp;
xdr_yppasswd(XDR *xdrs, yppasswd *objp)
{
if (!xdr_string(xdrs, &objp->oldpass, ~0)) {
if (!xdr_string(xdrs, &objp->oldpass, ~0))
return (FALSE);
}
if (!xdr_x_passwd(xdrs, &objp->newpw)) {
if (!xdr_x_passwd(xdrs, &objp->newpw))
return (FALSE);
}
return (TRUE);
}