summaryrefslogtreecommitdiffstats
path: root/usr.sbin/pw
diff options
context:
space:
mode:
authordavidn <davidn@FreeBSD.org>2000-07-20 04:37:00 +0000
committerdavidn <davidn@FreeBSD.org>2000-07-20 04:37:00 +0000
commit94db016d552528f16c2e7d8979a43221369067f4 (patch)
treeec24c6f9335b5ac2e98115277405b429327c43ca /usr.sbin/pw
parent64eb7674fbf5b44c6bcf718dec020a05af327db3 (diff)
downloadFreeBSD-src-94db016d552528f16c2e7d8979a43221369067f4.zip
FreeBSD-src-94db016d552528f16c2e7d8979a43221369067f4.tar.gz
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 'usr.sbin/pw')
-rw-r--r--usr.sbin/pw/pw_user.c13
1 files changed, 8 insertions, 5 deletions
diff --git a/usr.sbin/pw/pw_user.c b/usr.sbin/pw/pw_user.c
index 925c86c..c9119a2 100644
--- a/usr.sbin/pw/pw_user.c
+++ b/usr.sbin/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);
OpenPOWER on IntegriCloud