From 7218160459dc3e2954c48cf3adf1bf736f44177c Mon Sep 17 00:00:00 2001 From: "Todd C. Miller" Date: Sat, 14 Jun 2003 22:12:54 +0000 Subject: 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. --- usr.sbin/user/user.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) (limited to 'usr.sbin/user') 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); -- cgit v1.2.3