diff options
author | wollman <wollman@FreeBSD.org> | 1995-01-14 23:14:25 +0000 |
---|---|---|
committer | wollman <wollman@FreeBSD.org> | 1995-01-14 23:14:25 +0000 |
commit | dd6e6de5295ca534dd6b6d3a4796b611b1579e0a (patch) | |
tree | d78c2809d2d62b5e5c7c1b91193be0214cd795d0 /usr.bin/chpass/chpass.c | |
parent | 20054cbaa0f2df26f65ac5e230669382f151f599 (diff) | |
download | FreeBSD-src-dd6e6de5295ca534dd6b6d3a4796b611b1579e0a.zip FreeBSD-src-dd6e6de5295ca534dd6b6d3a4796b611b1579e0a.tar.gz |
Add a `-p' option, allowing the super-user to directly set a user's
encrypted password. Kerberized `login' might use this, if I get around
to implementing the complete Allspice System behavior.
Diffstat (limited to 'usr.bin/chpass/chpass.c')
-rw-r--r-- | usr.bin/chpass/chpass.c | 28 |
1 files changed, 22 insertions, 6 deletions
diff --git a/usr.bin/chpass/chpass.c b/usr.bin/chpass/chpass.c index 0852c53..f101101 100644 --- a/usr.bin/chpass/chpass.c +++ b/usr.bin/chpass/chpass.c @@ -38,7 +38,9 @@ static char copyright[] = #endif /* not lint */ #ifndef lint -static char sccsid[] = "@(#)chpass.c 8.4 (Berkeley) 4/2/94"; +static char sccsid[] = "From: @(#)chpass.c 8.4 (Berkeley) 4/2/94"; +static char rcsid[] = + "$Id$"; #endif /* not lint */ #include <sys/param.h> @@ -76,13 +78,13 @@ main(argc, argv) int argc; char **argv; { - enum { NEWSH, LOADENTRY, EDITENTRY } op; + enum { NEWSH, LOADENTRY, EDITENTRY, NEWPW } op; struct passwd *pw, lpw; int ch, pfd, tfd; char *arg; op = EDITENTRY; - while ((ch = getopt(argc, argv, "a:s:")) != EOF) + while ((ch = getopt(argc, argv, "a:p:s:")) != EOF) switch(ch) { case 'a': op = LOADENTRY; @@ -92,6 +94,10 @@ main(argc, argv) op = NEWSH; arg = optarg; break; + case 'p': + op = NEWPW; + arg = optarg; + break; case '?': default: usage(); @@ -101,7 +107,7 @@ main(argc, argv) uid = getuid(); - if (op == EDITENTRY || op == NEWSH) + if (op == EDITENTRY || op == NEWSH || op == NEWPW) switch(argc) { case 0: if (!(pw = getpwuid(uid))) @@ -133,6 +139,16 @@ main(argc, argv) exit(1); } + if (op == NEWPW) { + if (uid) + baduser(); + + if(strchr(arg, ':')) { + errx(1, "invalid format for password"); + } + pw->pw_passwd = arg; + } + /* * The temporary file/file descriptor usage is a little tricky here. * 1: We start off with two fd's, one for the master password @@ -179,7 +195,6 @@ main(argc, argv) void baduser() { - errx(1, "%s", strerror(EACCES)); } @@ -187,6 +202,7 @@ void usage() { - (void)fprintf(stderr, "usage: chpass [-a list] [-s shell] [user]\n"); + (void)fprintf(stderr, + "usage: chpass [-a list] [-p encpass] [-s shell] [user]\n"); exit(1); } |