diff options
author | Todd C. Miller <millert@cvs.openbsd.org> | 2003-06-14 22:12:54 +0000 |
---|---|---|
committer | Todd C. Miller <millert@cvs.openbsd.org> | 2003-06-14 22:12:54 +0000 |
commit | 7218160459dc3e2954c48cf3adf1bf736f44177c (patch) | |
tree | f56fca8f100ad20f8c27a437905d8844c0b8e03f | |
parent | 18fce112cec2ac84e749a1ce7db8e3401c011ea0 (diff) |
For moduser(), only do valid_class() check when F_CLASS is set in
up->u_flags. Fixes a coredump when changing/deleting an existing
user introduced by my recent commit here.
-rw-r--r-- | usr.sbin/user/user.c | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/usr.sbin/user/user.c b/usr.sbin/user/user.c index fa11af7b2c5..e05ff73f981 100644 --- a/usr.sbin/user/user.c +++ b/usr.sbin/user/user.c @@ -1,4 +1,4 @@ -/* $OpenBSD: user.c,v 1.51 2003/06/10 21:00:37 millert Exp $ */ +/* $OpenBSD: user.c,v 1.52 2003/06/14 22:12:53 millert Exp $ */ /* $NetBSD: user.c,v 1.69 2003/04/14 17:40:07 agc Exp $ */ /* @@ -1235,11 +1235,6 @@ moduser(char *login_name, char *newlogin, user_t *up) if (!valid_login(newlogin)) { errx(EXIT_FAILURE, "`%s' is not a valid login name", login_name); } -#ifdef EXTENSIONS - if (!valid_class(up->u_class)) { - errx(EXIT_FAILURE, "No such login class `%s'", up->u_class); - } -#endif if ((pwp = getpwnam(login_name)) == NULL) { errx(EXIT_FAILURE, "No such user `%s'", login_name); } @@ -1345,8 +1340,15 @@ moduser(char *login_name, char *newlogin, user_t *up) if (up->u_flags & F_SHELL) pwp->pw_shell = up->u_shell; #ifdef EXTENSIONS - if (up->u_flags & F_CLASS) + if (up->u_flags & F_CLASS) { + if (!valid_class(up->u_class)) { + (void) close(ptmpfd); + pw_abort(); + errx(EXIT_FAILURE, + "No such login class `%s'", up->u_class); + } pwp->pw_class = up->u_class; + } #endif } loginc = strlen(login_name); |