Modify passwd and chpass to use new AF_LOCAL RPC interface instead of
old kludged-up 'yppasswd_comm' support.
This commit is contained in:
parent
1f9224050e
commit
d4a27db19e
usr.bin
@ -20,10 +20,10 @@ COPTS+= -DYP -I. -I${.CURDIR}/../../libexec/ypxfr \
|
||||
#Some people need this, uncomment to activate
|
||||
#COPTS+= -DRESTRICT_FULLNAME_CHANGE
|
||||
|
||||
SRCS+= yppasswd_private_xdr.c yppasswd_comm.c yp_clnt.c \
|
||||
SRCS+= yppasswd_private_xdr.c yppasswd_private_clnt.c yp_clnt.c \
|
||||
yppasswd_clnt.c pw_yp.c ypxfr_misc.c
|
||||
CLEANFILES= yp_clnt.c yp.h yppasswd_clnt.c yppasswd.h \
|
||||
yppasswd_private_xdr.c yppasswd_private.h
|
||||
yppasswd_private_xdr.c yppasswd_private_clnt.c yppasswd_private.h
|
||||
|
||||
DPADD= ${LIBRPCSVC} ${LIBCRYPT}
|
||||
LDADD+= -lrpcsvc -lcrypt
|
||||
@ -51,6 +51,9 @@ yppasswd_private.h: ${RPCSRC_PRIV}
|
||||
yppasswd_private_xdr.c: ${RPCSRC_PRIV} yppasswd_private.h
|
||||
${RPCGEN} -c -o ${.TARGET} ${RPCSRC_PRIV}
|
||||
|
||||
yppasswd_private_clnt.c: ${RPCSRC_PRIV} yppasswd_private.h
|
||||
${RPCGEN} -l -o ${.TARGET} ${RPCSRC_PRIV}
|
||||
|
||||
beforeinstall:
|
||||
.for i in chpass chfn chsh ypchpass ypchfn ypchsh
|
||||
[ ! -e ${DESTDIR}${BINDIR}/$i ] || \
|
||||
|
@ -35,7 +35,7 @@
|
||||
* Center for Telecommunications Research
|
||||
* Columbia University, New York City
|
||||
*
|
||||
* $Id: pw_yp.c,v 1.9 1997/02/22 19:54:26 peter Exp $
|
||||
* $Id: pw_yp.c,v 1.2 1997/07/28 18:32:05 wpaul Exp $
|
||||
*/
|
||||
|
||||
#ifdef YP
|
||||
@ -65,7 +65,6 @@ struct dom_binding {};
|
||||
#include <pw_util.h>
|
||||
#include "pw_yp.h"
|
||||
#include "ypxfr_extern.h"
|
||||
#include "yppasswd_comm.h"
|
||||
#include "yppasswd_private.h"
|
||||
|
||||
#define PERM_SECURE (S_IRUSR|S_IWUSR)
|
||||
@ -339,6 +338,7 @@ char *get_yp_master(getserver)
|
||||
char *mastername;
|
||||
int rval, localport;
|
||||
struct stat st;
|
||||
char *sockname = YP_SOCKNAME;
|
||||
|
||||
/*
|
||||
* Sometimes we are called just to probe for rpc.yppasswdd and
|
||||
@ -421,6 +421,7 @@ void yp_submit(pw)
|
||||
char *master, *password;
|
||||
int *status = NULL;
|
||||
struct rpc_err err;
|
||||
char *sockname = YP_SOCKNAME;
|
||||
|
||||
_use_yp = 1;
|
||||
|
||||
@ -473,12 +474,13 @@ void yp_submit(pw)
|
||||
|
||||
if (suser_override) {
|
||||
/* Talk to server via AF_UNIX socket. */
|
||||
if (senddat(&master_yppasswd)) {
|
||||
warnx("failed to contact local rpc.yppasswdd");
|
||||
clnt = clnt_create(sockname, MASTER_YPPASSWDPROG,
|
||||
MASTER_YPPASSWDVERS, "unix");
|
||||
if (clnt == NULL) {
|
||||
warnx("failed to contact rpc.yppasswdd: %s",
|
||||
clnt_spcreateerror(master));
|
||||
pw_error(tempname, 0, 1);
|
||||
}
|
||||
/* Get return code. */
|
||||
status = getresp();
|
||||
} else {
|
||||
/* Create a handle to yppasswdd. */
|
||||
|
||||
@ -488,23 +490,24 @@ void yp_submit(pw)
|
||||
master, clnt_spcreateerror(master));
|
||||
pw_error(tempname, 0, 1);
|
||||
}
|
||||
}
|
||||
|
||||
clnt->cl_auth = authunix_create_default();
|
||||
clnt->cl_auth = authunix_create_default();
|
||||
|
||||
if (suser_override)
|
||||
status = yppasswdproc_update_master_1(&master_yppasswd, clnt);
|
||||
else
|
||||
status = yppasswdproc_update_1(&yppasswd, clnt);
|
||||
|
||||
clnt_geterr(clnt, &err);
|
||||
clnt_geterr(clnt, &err);
|
||||
|
||||
auth_destroy(clnt->cl_auth);
|
||||
clnt_destroy(clnt);
|
||||
}
|
||||
auth_destroy(clnt->cl_auth);
|
||||
clnt_destroy(clnt);
|
||||
|
||||
/* Call failed: signal the error. */
|
||||
|
||||
if ((!suser_override && err.re_status) != RPC_SUCCESS || status == NULL || *status) {
|
||||
warnx("NIS update failed: %s", (err.re_status != RPC_SUCCESS &&
|
||||
!suser_override) ? clnt_sperrno(err.re_status) :
|
||||
"rpc.yppasswdd returned error status");
|
||||
if (err.re_status != RPC_SUCCESS || status == NULL || *status) {
|
||||
warnx("NIS update failed: %s", clnt_sperrno(err.re_status));
|
||||
pw_error(NULL, 0, 1);
|
||||
}
|
||||
|
||||
|
@ -1,8 +1,8 @@
|
||||
# From: @(#)Makefile 8.3 (Berkeley) 4/2/94
|
||||
# $Id: Makefile,v 1.23 1997/02/22 19:56:34 peter Exp $
|
||||
# $Id: Makefile,v 1.2 1997/07/28 18:31:45 wpaul Exp $
|
||||
|
||||
PROG= passwd
|
||||
SRCS= local_passwd.c yppasswd_private_xdr.c yppasswd_comm.c yp_passwd.c \
|
||||
SRCS= local_passwd.c yppasswd_private_xdr.c yp_passwd.c \
|
||||
passwd.c pw_copy.c pw_util.c pw_yp.c
|
||||
|
||||
DPADD= ${LIBCRYPT} ${LIBRPCSVC} ${LIBUTIL}
|
||||
@ -18,10 +18,10 @@ CFLAGS+= -DLOGIN_CAP -DCRYPT -DYP -I. -I${.CURDIR} \
|
||||
-I${.CURDIR}/../../usr.sbin/rpc.yppasswdd \
|
||||
-Dyp_error=warnx -DLOGGING
|
||||
|
||||
SRCS+= ypxfr_misc.c yp_clnt.c yppasswd_clnt.c
|
||||
SRCS+= ypxfr_misc.c yp_clnt.c yppasswd_clnt.c yppasswd_private_clnt.c
|
||||
|
||||
CLEANFILES= yp.h yp_clnt.c yppasswd.h yppasswd_clnt.c \
|
||||
yppasswd_private.h yppasswd_private_xdr.c
|
||||
yppasswd_private.h yppasswd_private_xdr.c yppasswd_private_clnt.c
|
||||
|
||||
RPCGEN= rpcgen -C
|
||||
RPCSRC= ${DESTDIR}/usr/include/rpcsvc/yp.x
|
||||
@ -46,6 +46,9 @@ yppasswd_private.h: ${RPCSRC_PRIV}
|
||||
yppasswd_private_xdr.c: ${RPCSRC_PRIV} yppasswd_private.h
|
||||
${RPCGEN} -c -o ${.TARGET} ${RPCSRC_PRIV}
|
||||
|
||||
yppasswd_private_clnt.c: ${RPCSRC_PRIV} yppasswd_private.h
|
||||
${RPCGEN} -l -o ${.TARGET} ${RPCSRC_PRIV}
|
||||
|
||||
BINOWN= root
|
||||
BINMODE=4555
|
||||
MAN1=passwd.1
|
||||
|
@ -45,7 +45,7 @@
|
||||
#include <rpcsvc/ypclnt.h>
|
||||
#include <rpcsvc/yppasswd.h>
|
||||
#include <pw_yp.h>
|
||||
#include "yppasswd_comm.h"
|
||||
#include "yppasswd_private.h"
|
||||
|
||||
extern char *getnewpasswd __P(( struct passwd * , int ));
|
||||
|
||||
@ -61,6 +61,7 @@ yp_passwd(char *user)
|
||||
char *master;
|
||||
int *status = NULL;
|
||||
uid_t uid;
|
||||
char *sockname = YP_SOCKNAME;
|
||||
|
||||
_use_yp = 1;
|
||||
|
||||
@ -143,11 +144,12 @@ for other users");
|
||||
}
|
||||
|
||||
if (suser_override) {
|
||||
if (senddat(&master_yppasswd)) {
|
||||
warnx("failed to send request to rpc.yppasswdd");
|
||||
if ((clnt = clnt_create(sockname, MASTER_YPPASSWDPROG,
|
||||
MASTER_YPPASSWDVERS, "unix")) == NULL) {
|
||||
warnx("failed to contact rpc.yppasswdd on host %s: %s",
|
||||
master, clnt_spcreateerror(""));
|
||||
return(1);
|
||||
}
|
||||
status = getresp();
|
||||
} else {
|
||||
if ((clnt = clnt_create(master, YPPASSWDPROG,
|
||||
YPPASSWDVERS, "udp")) == NULL) {
|
||||
@ -155,32 +157,32 @@ for other users");
|
||||
master, clnt_spcreateerror(""));
|
||||
return(1);
|
||||
}
|
||||
}
|
||||
/*
|
||||
* The yppasswd.x file said `unix authentication required',
|
||||
* so I added it. This is the only reason it is in here.
|
||||
* My yppasswdd doesn't use it, but maybe some others out there
|
||||
* do. --okir
|
||||
*/
|
||||
clnt->cl_auth = authunix_create_default();
|
||||
clnt->cl_auth = authunix_create_default();
|
||||
|
||||
if (suser_override)
|
||||
status = yppasswdproc_update_master_1(&master_yppasswd, clnt);
|
||||
else
|
||||
status = yppasswdproc_update_1(&yppasswd, clnt);
|
||||
clnt_geterr(clnt, &err);
|
||||
|
||||
auth_destroy(clnt->cl_auth);
|
||||
clnt_destroy(clnt);
|
||||
}
|
||||
clnt_geterr(clnt, &err);
|
||||
|
||||
if ((!suser_override && err.re_status != RPC_SUCCESS) ||
|
||||
status == NULL || *status) {
|
||||
auth_destroy(clnt->cl_auth);
|
||||
clnt_destroy(clnt);
|
||||
|
||||
if (err.re_status != RPC_SUCCESS || status == NULL || *status) {
|
||||
errx(1, "Failed to change NIS password: %s",
|
||||
(err.re_status != RPC_SUCCESS && !suser_override) ?
|
||||
clnt_sperrno(err.re_status) :
|
||||
"rpc.yppasswdd returned error status");
|
||||
clnt_sperrno(err.re_status));
|
||||
}
|
||||
|
||||
printf("\nNIS password has%s been changed on %s.\n",
|
||||
((err.re_status != RPC_SUCCESS && !suser_override)
|
||||
|| status == NULL || *status) ?
|
||||
(err.re_status != RPC_SUCCESS || status == NULL || *status) ?
|
||||
" not" : "", master);
|
||||
|
||||
return ((err.re_status || status == NULL || *status));
|
||||
|
Loading…
x
Reference in New Issue
Block a user