diff options
author | Bill Paul <wpaul@FreeBSD.org> | 1995-08-13 16:12:28 +0000 |
---|---|---|
committer | Bill Paul <wpaul@FreeBSD.org> | 1995-08-13 16:12:28 +0000 |
commit | f811b41cc996c70cfc5a1f29938e18cfacec1814 (patch) | |
tree | f1e4ce5b338fe0cb45c2e3f72efd88c0f8075a21 /chpass/chpass.c | |
parent | 0ad8070243d57c40e41817770e963eb7b713c958 (diff) | |
download | pw-darwin-f811b41cc996c70cfc5a1f29938e18cfacec1814.tar.gz pw-darwin-f811b41cc996c70cfc5a1f29938e18cfacec1814.tar.zst pw-darwin-f811b41cc996c70cfc5a1f29938e18cfacec1814.zip |
Take the ypchfn/ypchsh stuff that was removed from passwd
and graft it into chpass.
Chpass can now tell when it's being asked to operate on an NIS
user and it displayes the appropriate message in the editor
template ("Changing NIS information for foo"). After the changes
have been made, chpass will promte the user for his NIS password.
If the password is correct, the changes are committed to yppasswdd.
Hopefully, this should make NIS more transparent to the end user.
Note that even the superuser needs to know a user's password before
he can change any NIS information (such is the nature of yppasswdd).
Also, changes to the password field are not permitted -- that's what
yppasswd is for. (The superuser may specify a new password, but
again, he needs to know the user's original password before he can
change it.)
Diffstat (limited to 'chpass/chpass.c')
-rw-r--r-- | chpass/chpass.c | 32 |
1 files changed, 30 insertions, 2 deletions
diff --git a/chpass/chpass.c b/chpass/chpass.c index 086413d..bba8b3d 100644 --- a/chpass/chpass.c +++ b/chpass/chpass.c @@ -40,7 +40,7 @@ static char copyright[] = #ifndef lint static char sccsid[] = "From: @(#)chpass.c 8.4 (Berkeley) 4/2/94"; static char rcsid[] = - "$Id: chpass.c,v 1.2 1995/01/14 23:14:25 wollman Exp $"; + "$Id: chpass.c,v 1.3 1995/05/30 06:29:36 rgrimes Exp $"; #endif /* not lint */ #include <sys/param.h> @@ -62,6 +62,9 @@ static char rcsid[] = #include <pw_scan.h> #include <pw_util.h> #include "pw_copy.h" +#ifdef YP +#include "pw_yp.h" +#endif #include "chpass.h" #include "pathnames.h" @@ -122,7 +125,6 @@ main(argc, argv) default: usage(); } - if (op == NEWSH) { /* protect p_shell -- it thinks NULL is /bin/sh */ if (!arg[0]) @@ -149,6 +151,23 @@ main(argc, argv) pw->pw_passwd = arg; } +#ifdef YP + /* + * XXX The man page says the data returned by getpwent() + * and friends is stored in static buffers that may be + * overwritten after successive invokations. Unfortunately, + * we need to call getpwent() more than once with NIS + * enabled. + */ + pw->pw_name = strdup(pw->pw_name); + pw->pw_passwd = strdup(pw->pw_passwd); + pw->pw_class = strdup(pw->pw_class); + pw->pw_gecos = strdup(pw->pw_gecos); + pw->pw_shell = strdup(pw->pw_shell); + pw->pw_dir = strdup(pw->pw_dir); + _use_yp = use_yp(pw->pw_name); +#endif /* YP */ + /* * The temporary file/file descriptor usage is a little tricky here. * 1: We start off with two fd's, one for the master password @@ -185,10 +204,19 @@ main(argc, argv) tfd = pw_tmp(); } +#ifdef YP + if (_use_yp) { + yp_submit(pw); + (void)unlink(tempname); + } else { +#endif /* YP */ pw_copy(pfd, tfd, pw); if (!pw_mkdb()) pw_error((char *)NULL, 0, 1); +#ifdef YP + } +#endif /* YP */ exit(0); } |