summaryrefslogtreecommitdiffstats
path: root/chpass/chpass.c
diff options
context:
space:
mode:
authorPeter Wemm <peter@FreeBSD.org>1996-08-12 14:45:26 +0000
committerPeter Wemm <peter@FreeBSD.org>1996-08-12 14:45:26 +0000
commit73ca041dfcdee40aae69e5de3412a1148126ec4e (patch)
tree7f390982242bddb86eda7b3f9ab11f97846f99d2 /chpass/chpass.c
parentdb3019bee11d27de92f652ab0a832ed72f97a4c6 (diff)
downloadpw-darwin-73ca041dfcdee40aae69e5de3412a1148126ec4e.tar.gz
pw-darwin-73ca041dfcdee40aae69e5de3412a1148126ec4e.tar.zst
pw-darwin-73ca041dfcdee40aae69e5de3412a1148126ec4e.zip
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 'chpass/chpass.c')
-rw-r--r--chpass/chpass.c25
1 files changed, 18 insertions, 7 deletions
diff --git a/chpass/chpass.c b/chpass/chpass.c
index 9a7b8a6..2c5e79d 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.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);
}