diff options
author | Ed Maste <emaste@FreeBSD.org> | 2017-08-19 00:19:23 +0000 |
---|---|---|
committer | Ed Maste <emaste@FreeBSD.org> | 2017-08-19 00:19:23 +0000 |
commit | d79c5099603f0afa9e292d79f9595563cd623cf3 (patch) | |
tree | 7d42643c93fff34c94735547cb47e83ff24adf40 /pw | |
parent | da48ebc4de409fe039826d36b1da1f78ff5f84fc (diff) | |
download | pw-darwin-d79c5099603f0afa9e292d79f9595563cd623cf3.tar.gz pw-darwin-d79c5099603f0afa9e292d79f9595563cd623cf3.tar.zst pw-darwin-d79c5099603f0afa9e292d79f9595563cd623cf3.zip |
pw usermod: Properly deal with empty secondary group lists (-G '')
"pw usermod someuser -G ''" is supposed make sure that someuser
doesn't have any secondary group memberships.
Previouly it was a nop because split_groups() only intitialised
"groups" if at least one group was specified. As a result the
existing secondary group memberships were kept.
PR: 221417
Submitted by: Fabian Keil
Obtained from: ElectroBSD
MFC after: 1 week
Relnotes: yes
Diffstat (limited to 'pw')
-rw-r--r-- | pw/pw_user.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/pw/pw_user.c b/pw/pw_user.c index 76849ba..a71be12 100644 --- a/pw/pw_user.c +++ b/pw/pw_user.c @@ -1087,10 +1087,10 @@ split_groups(StringList **groups, char *groupsstr) char *p; char tok[] = ", \t"; + if (*groups == NULL) + *groups = sl_init(); for (p = strtok(groupsstr, tok); p != NULL; p = strtok(NULL, tok)) { grp = group_from_name_or_id(p); - if (*groups == NULL) - *groups = sl_init(); sl_add(*groups, newstr(grp->gr_name)); } } |