diff options
Diffstat (limited to 'usr.bin/chpass')
-rw-r--r-- | usr.bin/chpass/chpass.c | 6 | ||||
-rw-r--r-- | usr.bin/chpass/chpass.h | 4 | ||||
-rw-r--r-- | usr.bin/chpass/edit.c | 11 | ||||
-rw-r--r-- | usr.bin/chpass/pw_yp.c | 9 | ||||
-rw-r--r-- | usr.bin/chpass/util.c | 78 |
5 files changed, 41 insertions, 67 deletions
diff --git a/usr.bin/chpass/chpass.c b/usr.bin/chpass/chpass.c index 099c805c3c3..8c77a86172c 100644 --- a/usr.bin/chpass/chpass.c +++ b/usr.bin/chpass/chpass.c @@ -1,4 +1,4 @@ -/* $OpenBSD: chpass.c,v 1.9 1997/06/17 20:49:55 kstailey Exp $ */ +/* $OpenBSD: chpass.c,v 1.10 1998/03/30 06:59:28 deraadt Exp $ */ /* $NetBSD: chpass.c,v 1.8 1996/05/15 21:50:43 jtc Exp $ */ /*- @@ -44,7 +44,7 @@ static char copyright[] = #if 0 static char sccsid[] = "@(#)chpass.c 8.4 (Berkeley) 4/2/94"; #else -static char rcsid[] = "$OpenBSD: chpass.c,v 1.9 1997/06/17 20:49:55 kstailey Exp $"; +static char rcsid[] = "$OpenBSD: chpass.c,v 1.10 1998/03/30 06:59:28 deraadt Exp $"; #endif #endif /* not lint */ @@ -75,6 +75,8 @@ uid_t uid; int use_yp; int force_yp = 0; extern struct passwd *ypgetpwnam(), *ypgetpwuid(); +int _yp_check __P((char **)); +int pw_yp __P((struct passwd *, uid_t)); #endif void baduser __P((void)); diff --git a/usr.bin/chpass/chpass.h b/usr.bin/chpass/chpass.h index 1183321034a..7a7027cdb8e 100644 --- a/usr.bin/chpass/chpass.h +++ b/usr.bin/chpass/chpass.h @@ -1,4 +1,4 @@ -/* $OpenBSD: chpass.h,v 1.3 1996/06/26 05:31:55 deraadt Exp $ */ +/* $OpenBSD: chpass.h,v 1.4 1998/03/30 06:59:29 deraadt Exp $ */ /* $NetBSD: chpass.h,v 1.4 1996/05/15 21:50:44 jtc Exp $ */ /* @@ -69,5 +69,5 @@ int p_login __P((char *, struct passwd *, ENTRY *)); int p_passwd __P((char *, struct passwd *, ENTRY *)); int p_shell __P((char *, struct passwd *, ENTRY *)); int p_uid __P((char *, struct passwd *, ENTRY *)); -char *ttoa __P((time_t)); +char *ttoa __P((char *, size_t, time_t)); int verify __P((char *, struct passwd *)); diff --git a/usr.bin/chpass/edit.c b/usr.bin/chpass/edit.c index cc658801dea..9f0d3736b96 100644 --- a/usr.bin/chpass/edit.c +++ b/usr.bin/chpass/edit.c @@ -1,4 +1,4 @@ -/* $OpenBSD: edit.c,v 1.12 1997/06/17 20:49:55 kstailey Exp $ */ +/* $OpenBSD: edit.c,v 1.13 1998/03/30 06:59:31 deraadt Exp $ */ /* $NetBSD: edit.c,v 1.6 1996/05/15 21:50:45 jtc Exp $ */ /*- @@ -38,7 +38,7 @@ #if 0 static char sccsid[] = "@(#)edit.c 8.3 (Berkeley) 4/2/94"; #else -static char rcsid[] = "$OpenBSD: edit.c,v 1.12 1997/06/17 20:49:55 kstailey Exp $"; +static char rcsid[] = "$OpenBSD: edit.c,v 1.13 1998/03/30 06:59:31 deraadt Exp $"; #endif #endif /* not lint */ @@ -94,7 +94,8 @@ display(tempname, fd, pw) struct passwd *pw; { FILE *fp; - char *bp, *p, *ttoa(); + char *bp, *p; + char chngstr[256]; if (!(fp = fdopen(fd, "w"))) pw_error(tempname, 1, 1); @@ -107,9 +108,9 @@ display(tempname, fd, pw) (void)fprintf(fp, "Uid [#]: %d\n", pw->pw_uid); (void)fprintf(fp, "Gid [# or name]: %d\n", pw->pw_gid); (void)fprintf(fp, "Change [month day year]: %s\n", - ttoa(pw->pw_change)); + ttoa(chngstr, sizeof(chngstr), pw->pw_change)); (void)fprintf(fp, "Expire [month day year]: %s\n", - ttoa(pw->pw_expire)); + ttoa(chngstr, sizeof(chngstr), pw->pw_expire)); (void)fprintf(fp, "Class: %s\n", pw->pw_class); (void)fprintf(fp, "Home directory: %s\n", pw->pw_dir); (void)fprintf(fp, "Shell: %s\n", diff --git a/usr.bin/chpass/pw_yp.c b/usr.bin/chpass/pw_yp.c index 38354b0956e..24f01b29d1e 100644 --- a/usr.bin/chpass/pw_yp.c +++ b/usr.bin/chpass/pw_yp.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pw_yp.c,v 1.7 1997/02/14 11:05:11 niklas Exp $ */ +/* $OpenBSD: pw_yp.c,v 1.8 1998/03/30 06:59:32 deraadt Exp $ */ /* $NetBSD: pw_yp.c,v 1.5 1995/03/26 04:55:33 glass Exp $ */ /* @@ -37,7 +37,7 @@ #if 0 static char sccsid[] = "@(#)pw_yp.c 1.0 2/2/93"; #else -static char rcsid[] = "$OpenBSD: pw_yp.c,v 1.7 1997/02/14 11:05:11 niklas Exp $"; +static char rcsid[] = "$OpenBSD: pw_yp.c,v 1.8 1998/03/30 06:59:32 deraadt Exp $"; #endif #endif /* not lint */ @@ -48,6 +48,7 @@ static char rcsid[] = "$OpenBSD: pw_yp.c,v 1.7 1997/02/14 11:05:11 niklas Exp $" #include <netdb.h> #include <time.h> #include <pwd.h> +#include <err.h> #include <errno.h> #include <stdlib.h> #include <rpc/rpc.h> @@ -61,12 +62,13 @@ extern char *progname; static char *domain; +int pw_yp(pw, uid) struct passwd *pw; uid_t uid; { char *master; - char *pp, *p; + char *p; char buf[10]; int r, rpcport, status, alen; struct yppasswd yppasswd; @@ -189,7 +191,6 @@ interpret(pwent, line) char *line; { register char *p = line; - register int c; pwent->pw_passwd = "*"; pwent->pw_uid = 0; diff --git a/usr.bin/chpass/util.c b/usr.bin/chpass/util.c index 419e266905c..3470c2c7be1 100644 --- a/usr.bin/chpass/util.c +++ b/usr.bin/chpass/util.c @@ -1,4 +1,4 @@ -/* $OpenBSD: util.c,v 1.3 1997/06/17 20:49:56 kstailey Exp $ */ +/* $OpenBSD: util.c,v 1.4 1998/03/30 06:59:34 deraadt Exp $ */ /* $NetBSD: util.c,v 1.4 1995/03/26 04:55:35 glass Exp $ */ /*- @@ -38,7 +38,7 @@ #if 0 static char sccsid[] = "@(#)util.c 8.4 (Berkeley) 4/2/94"; #else -static char rcsid[] = "$OpenBSD: util.c,v 1.3 1997/06/17 20:49:56 kstailey Exp $"; +static char rcsid[] = "$OpenBSD: util.c,v 1.4 1998/03/30 06:59:34 deraadt Exp $"; #endif #endif /* not lint */ @@ -56,28 +56,21 @@ static char rcsid[] = "$OpenBSD: util.c,v 1.3 1997/06/17 20:49:56 kstailey Exp $ #include "chpass.h" #include "pathnames.h" -static int dmsize[] = - { -1, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }; -static char *months[] = - { "January", "February", "March", "April", "May", "June", - "July", "August", "September", "October", "November", - "December", NULL }; - char * -ttoa(tval) +ttoa(buf, len, tval) + char *buf; + size_t len; time_t tval; { - struct tm *tp; - static char tbuf[50]; - if (tval) { - tp = localtime(&tval); - (void)sprintf(tbuf, "%s %d, %d", months[tp->tm_mon], - tp->tm_mday, tp->tm_year + TM_YEAR_BASE); + struct tm *tp = localtime(&tval); + + (void) strftime(buf, len, "%B %d, %Y", tp); + buf[len - 1] = '\0'; } - else - *tbuf = '\0'; - return (tbuf); + else if (len > 0) + *buf = '\0'; + return (buf); } int @@ -86,9 +79,9 @@ atot(p, store) time_t *store; { static struct tm *lt; - char *t, **mp; + struct tm tm; + char *t; time_t tval; - int day, month, year; if (!*p) { *store = 0; @@ -99,38 +92,15 @@ atot(p, store) (void)time(&tval); lt = localtime(&tval); } - if (!(t = strtok(p, " \t"))) - goto bad; - for (mp = months;; ++mp) { - if (!*mp) - goto bad; - if (!strncasecmp(*mp, t, 3)) { - month = mp - months + 1; - break; - } - } - if (!(t = strtok(NULL, " \t,")) || !isdigit(*t)) - goto bad; - day = atoi(t); - if (!(t = strtok(NULL, " \t,")) || !isdigit(*t)) - goto bad; - year = atoi(t); - if (day < 1 || day > 31 || month < 1 || month > 12 || !year) - goto bad; - if (year < 100) - year += TM_YEAR_BASE; - if (year <= EPOCH_YEAR) -bad: return (1); - tval = isleap(year) && month > 2; - for (--year; year >= EPOCH_YEAR; --year) - tval += isleap(year) ? - DAYSPERLYEAR : DAYSPERNYEAR; - while (--month) - tval += dmsize[month]; - tval += day; - tval = tval * HOURSPERDAY * MINSPERHOUR * SECSPERMIN; - tval -= lt->tm_gmtoff; - *store = tval; + (void) memset(&tm, 0, sizeof(tm)); + for (t = p; (t = strchr(t, ',')) != NULL; t++) + *t = ' '; + t = strptime(p, "%B %d %Y", &tm); + if (t == NULL || (*t != '\0' && *t != '\n')) + return 1; + *store = mktime(&tm); + if (*store == (time_t) -1) + return 1; return (0); } @@ -141,7 +111,7 @@ ok_shell(name) char *p, *sh; setusershell(); - while (sh = getusershell()) { + while ((sh = getusershell()) != NULL) { if (!strcmp(name, sh)) return (name); /* allow just shell name, but use "real" path */ |