diff options
-rw-r--r-- | usr.sbin/user/user.c | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/usr.sbin/user/user.c b/usr.sbin/user/user.c index 836b10b5937..09af2aad3fc 100644 --- a/usr.sbin/user/user.c +++ b/usr.sbin/user/user.c @@ -1,4 +1,4 @@ -/* $OpenBSD: user.c,v 1.16 2000/07/06 09:23:30 ho Exp $ */ +/* $OpenBSD: user.c,v 1.17 2000/07/15 08:31:54 ho Exp $ */ /* $NetBSD: user.c,v 1.17 2000/04/14 06:26:55 simonb Exp $ */ /* @@ -911,8 +911,10 @@ moduser(char *login, char *newlogin, user_t *up) if (up->u_uid == -1) { up->u_uid = pwp->pw_uid; } - /* if -g=uid was specified, check gid is unused */ - if (strcmp(up->u_primgrp, "=uid") == 0) { + if (up->u_primgrp == NULL) { + gid = pwp->pw_gid; + } else if (strcmp(up->u_primgrp, "=uid") == 0) { + /* if -g=uid was specified, check gid is unused */ if (getgrgid((gid_t)(up->u_uid)) != (struct group *) NULL) { (void) close(ptmpfd); (void) pw_abort(); @@ -938,6 +940,8 @@ moduser(char *login, char *newlogin, user_t *up) /* if home directory hasn't been given, use the old one */ if (!up->u_homeset) { (void) strlcpy(home, pwp->pw_dir, sizeof(home)); + } else { + (void) strlcpy(home, up->u_home, sizeof(home)); } expire = 0; if (up->u_expire != NULL) { @@ -1251,6 +1255,8 @@ usermod(int argc, char **argv) (void) memset(newuser, 0, sizeof(newuser)); read_defaults(&u); u.u_uid = -1; + free(u.u_primgrp); + u.u_primgrp = NULL; have_new_user = 0; while ((c = getopt(argc, argv, "G:c:d:e:f:g:l:mos:u:" MOD_OPT_EXTENSIONS)) != -1) { switch(c) { |