summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Nugent <davidn@FreeBSD.org>2000-07-20 04:37:00 +0000
committerDavid Nugent <davidn@FreeBSD.org>2000-07-20 04:37:00 +0000
commitd58f0ff7d3bf5339610977878786ad46492a1a9c (patch)
treea75fe8c1561c2eafd110e9a16445f52f1e989d8b
parentaf81094e5ab0cacdc5af388813abcd30e397b72d (diff)
downloadpw-darwin-d58f0ff7d3bf5339610977878786ad46492a1a9c.tar.gz
pw-darwin-d58f0ff7d3bf5339610977878786ad46492a1a9c.tar.zst
pw-darwin-d58f0ff7d3bf5339610977878786ad46492a1a9c.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
-rw-r--r--pw/pw_user.c13
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);