diff options
author | Otto Moerbeek <otto@cvs.openbsd.org> | 2007-01-15 08:14:22 +0000 |
---|---|---|
committer | Otto Moerbeek <otto@cvs.openbsd.org> | 2007-01-15 08:14:22 +0000 |
commit | 7b97bb0346a400ffdf16127b2024dcb4e3c1476a (patch) | |
tree | 99fcf1f5529e7b397c4ac6cd56a1190ed95518ed /usr.bin/chpass/chpass.c | |
parent | ed506eeb056d2970a9c7986ef0154baaaed6d9dc (diff) |
Fix -a when given an entry with an already existing user. Also, give
error message if a user arg has been given with -a. Noted by Dan
Brosemer. ok millert@ jaredy@
Diffstat (limited to 'usr.bin/chpass/chpass.c')
-rw-r--r-- | usr.bin/chpass/chpass.c | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/usr.bin/chpass/chpass.c b/usr.bin/chpass/chpass.c index f4f32d5deb9..a418bbf4825 100644 --- a/usr.bin/chpass/chpass.c +++ b/usr.bin/chpass/chpass.c @@ -1,4 +1,4 @@ -/* $OpenBSD: chpass.c,v 1.32 2005/12/12 20:43:10 deraadt Exp $ */ +/* $OpenBSD: chpass.c,v 1.33 2007/01/15 08:14:21 otto Exp $ */ /* $NetBSD: chpass.c,v 1.8 1996/05/15 21:50:43 jtc Exp $ */ /*- @@ -40,7 +40,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.32 2005/12/12 20:43:10 deraadt Exp $"; +static char rcsid[] = "$OpenBSD: chpass.c,v 1.33 2007/01/15 08:14:21 otto Exp $"; #endif #endif /* not lint */ @@ -80,7 +80,7 @@ void usage(void); int main(int argc, char *argv[]) { - struct passwd *pw = NULL, *opw, lpw; + struct passwd *pw = NULL, *opw = NULL, lpw; int i, ch, pfd, tfd, dfd; char *arg = NULL; sigset_t fullset; @@ -156,13 +156,16 @@ main(int argc, char *argv[]) } if (op == LOADENTRY) { + if (argc != 0) + errx(1, "option -a does not accept user argument"); if (uid) baduser(); pw = &lpw; if (!pw_scan(arg, pw, NULL)) exit(1); + opw = getpwnam(pw->pw_name); } - if ((opw = pw_dup(pw)) == NULL) + if (opw == NULL && (opw = pw_dup(pw)) == NULL) err(1, NULL); /* Edit the user passwd information if requested. */ |