diff options
author | David Nugent <davidn@FreeBSD.org> | 2000-07-20 04:37:00 +0000 |
---|---|---|
committer | David Nugent <davidn@FreeBSD.org> | 2000-07-20 04:37:00 +0000 |
commit | b9b6670c5d1db26fec96eac9bc19dfac49aeca81 (patch) | |
tree | f0f60861fad050eb8060da085b0d4c95facd32b0 /pw | |
parent | 920b278577c3d0b2e84be2371da86184277e2a6c (diff) | |
download | pw-darwin-b9b6670c5d1db26fec96eac9bc19dfac49aeca81.tar.gz pw-darwin-b9b6670c5d1db26fec96eac9bc19dfac49aeca81.tar.zst pw-darwin-b9b6670c5d1db26fec96eac9bc19dfac49aeca81.zip |
Allow -g with an empty argument in the -D case. This allows -g "" to set
no default group (and thus fall back to user-based groups instead).
PR: bin/5717
Diffstat (limited to 'pw')
-rw-r--r-- | pw/pw_user.c | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/pw/pw_user.c b/pw/pw_user.c index 925c86c..c9119a2 100644 --- a/pw/pw_user.c +++ b/pw/pw_user.c @@ -219,12 +219,15 @@ pw_user(struct userconf * cnf, int mode, struct cargs * args) cnf->password_days = atoi(arg->val); if ((arg = getarg(args, 'g')) != NULL) { - p = arg->val; - if ((grp = GETGRNAM(p)) == NULL) { - if (!isdigit((unsigned char)*p) || (grp = GETGRGID((gid_t) atoi(p))) == NULL) - errx(EX_NOUSER, "group `%s' does not exist", p); + if (!*(p = arg->val)) /* Handle empty group list specially */ + cnf->default_group = ""; + else { + if ((grp = GETGRNAM(p)) == NULL) { + if (!isdigit((unsigned char)*p) || (grp = GETGRGID((gid_t) atoi(p))) == NULL) + errx(EX_NOUSER, "group `%s' does not exist", p); + } + cnf->default_group = newstr(grp->gr_name); } - cnf->default_group = newstr(grp->gr_name); } if ((arg = getarg(args, 'L')) != NULL) cnf->default_class = pw_checkname((u_char *)arg->val, 0); |