#ifndef lint
static char sccsid[] = "From: @(#)chpass.c 8.4 (Berkeley) 4/2/94";
static char rcsid[] =
- "$Id: chpass.c,v 1.8 1996/05/25 01:05:17 wpaul Exp $";
+ "$Id: chpass.c,v 1.13 1997/02/22 19:54:25 peter Exp $";
#endif /* not lint */
#include <sys/param.h>
int argc;
char **argv;
{
- enum { NEWSH, LOADENTRY, EDITENTRY, NEWPW } op;
+ enum { NEWSH, LOADENTRY, EDITENTRY, NEWPW, NEWEXP } op;
struct passwd *pw, lpw;
- char *username;
+ char *username = NULL;
int ch, pfd, tfd;
char *arg;
#ifdef YP
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")) != -1)
#else
- while ((ch = getopt(argc, argv, "a:p:s:")) != EOF)
+ while ((ch = getopt(argc, argv, "a:p:s:e:")) != -1)
#endif
switch(ch) {
case 'a':
op = NEWPW;
arg = optarg;
break;
+ case 'e':
+ op = NEWEXP;
+ arg = optarg;
+ break;
#ifdef YP
case 'h':
#ifdef PARANOID
uid = getuid();
- if (op == EDITENTRY || op == NEWSH || op == NEWPW)
+ if (op == EDITENTRY || op == NEWSH || op == NEWPW || op == NEWEXP)
switch(argc) {
#ifdef YP
case 0:
default:
usage();
}
- username = pw->pw_name;
if (op == NEWSH) {
/* protect p_shell -- it thinks NULL is /bin/sh */
if (!arg[0])
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();
if (!pw_scan(arg, pw))
exit(1);
}
+ username = pw->pw_name;
if (op == NEWPW) {
if (uid)
(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);
}