diff options
author | peter <peter@FreeBSD.org> | 1996-08-12 14:45:26 +0000 |
---|---|---|
committer | peter <peter@FreeBSD.org> | 1996-08-12 14:45:26 +0000 |
commit | 6b18c72cfcfbbcb9ef4ef47dba3d309c3ad51740 (patch) | |
tree | 1527176a279bb4dc9a6e348a851ec74ee4f7e79b /usr.bin/chpass/chpass.c | |
parent | 665b6e261ba076b16c6c02125a104c2297ae5a96 (diff) | |
download | FreeBSD-src-6b18c72cfcfbbcb9ef4ef47dba3d309c3ad51740.zip FreeBSD-src-6b18c72cfcfbbcb9ef4ef47dba3d309c3ad51740.tar.gz |
Add new option to chpass: -e "expire" ; change the account expire time
from a script as if it was done in the interactive editor.
When reassembling the gecos string, trim any excess trailing commas, they
look ugly in the passwd file. :-)
Have a simple Makefile tweak to prevent mortal users from changing their
fullname. As ISP's we have seem some real bizzare stuff here..
When decoding the change/expire string, allow the month number as a
synonym for the name of the month.. (ie: 1 as well as Jan or January)
Note that using numbers means there's a chance that you can get bitten
if you're not used to the American DD-MM-YY order.
Diffstat (limited to 'usr.bin/chpass/chpass.c')
-rw-r--r-- | usr.bin/chpass/chpass.c | 25 |
1 files changed, 18 insertions, 7 deletions
diff --git a/usr.bin/chpass/chpass.c b/usr.bin/chpass/chpass.c index 9a7b8a6..2c5e79d 100644 --- a/usr.bin/chpass/chpass.c +++ b/usr.bin/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.9 1996/07/01 19:38:07 guido Exp $"; + "$Id: chpass.c,v 1.10 1996/07/14 16:42:33 guido Exp $"; #endif /* not lint */ #include <sys/param.h> @@ -82,7 +82,7 @@ main(argc, argv) int argc; char **argv; { - enum { NEWSH, LOADENTRY, EDITENTRY, NEWPW } op; + enum { NEWSH, LOADENTRY, EDITENTRY, NEWPW, NEWEXP } op; struct passwd *pw, lpw; char *username = NULL; int ch, pfd, tfd; @@ -94,9 +94,9 @@ main(argc, argv) op = EDITENTRY; #ifdef YP - while ((ch = getopt(argc, argv, "a:p:s:d:h:oly")) != EOF) + while ((ch = getopt(argc, argv, "a:p:s:e:d:h:oly")) != EOF) #else - while ((ch = getopt(argc, argv, "a:p:s:")) != EOF) + while ((ch = getopt(argc, argv, "a:p:s:e:")) != EOF) #endif switch(ch) { case 'a': @@ -111,6 +111,10 @@ main(argc, argv) op = NEWPW; arg = optarg; break; + case 'e': + op = NEWEXP; + arg = optarg; + break; #ifdef YP case 'h': #ifdef PARANOID @@ -156,7 +160,7 @@ main(argc, argv) uid = getuid(); - if (op == EDITENTRY || op == NEWSH || op == NEWPW) + if (op == EDITENTRY || op == NEWSH || op == NEWPW || op == NEWEXP) switch(argc) { #ifdef YP case 0: @@ -189,6 +193,13 @@ main(argc, argv) pw_error((char *)NULL, 0, 1); } + if (op == NEWEXP) { + if (uid) /* only root can change expire */ + baduser(); + if (p_expire(arg, pw, (ENTRY *)NULL)) + pw_error((char *)NULL, 0, 1); + } + if (op == LOADENTRY) { if (uid) baduser(); @@ -272,9 +283,9 @@ usage() (void)fprintf(stderr, #ifdef YP - "usage: chpass [-l] [-y] [-d domain [-h host]] [-a list] [-p encpass] [-s shell] [user]\n"); + "usage: chpass [-l] [-y] [-d domain [-h host]] [-a list] [-p encpass] [-s shell] [-e mmm dd yy] [user]\n"); #else - "usage: chpass [-a list] [-p encpass] [-s shell] [user]\n"); + "usage: chpass [-a list] [-p encpass] [-s shell] [-e mmm dd yy] [user]\n"); #endif exit(1); } |