Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 26 Aug 2017 00:35:49 +0000 (UTC)
From:      Ed Maste <emaste@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org
Subject:   svn commit: r322919 - in stable/11/usr.sbin/pw: . tests
Message-ID:  <201708260035.v7Q0ZnST062262@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: emaste
Date: Sat Aug 26 00:35:49 2017
New Revision: 322919
URL: https://svnweb.freebsd.org/changeset/base/322919

Log:
  MFC r322677: pw usermod: Properly deal with empty secondary group lists (-G '')
  
  PR:		221417
  Relnotes:	Yes

Modified:
  stable/11/usr.sbin/pw/pw_user.c
  stable/11/usr.sbin/pw/tests/pw_usermod_test.sh
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/usr.sbin/pw/pw_user.c
==============================================================================
--- stable/11/usr.sbin/pw/pw_user.c	Sat Aug 26 00:30:59 2017	(r322918)
+++ stable/11/usr.sbin/pw/pw_user.c	Sat Aug 26 00:35:49 2017	(r322919)
@@ -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));
 	}
 }

Modified: stable/11/usr.sbin/pw/tests/pw_usermod_test.sh
==============================================================================
--- stable/11/usr.sbin/pw/tests/pw_usermod_test.sh	Sat Aug 26 00:30:59 2017	(r322918)
+++ stable/11/usr.sbin/pw/tests/pw_usermod_test.sh	Sat Aug 26 00:35:49 2017	(r322919)
@@ -128,6 +128,9 @@ user_mod_nogroups_body() {
 	atf_check -s exit:0 ${PW} usermod foo -G test3,test4
 	atf_check -s exit:0 -o inline:"test3\ntest4\n" \
 		awk -F\: '$4 == "foo" { print $1 }' ${HOME}/group
+	atf_check -s exit:0 ${PW} usermod foo -G ""
+	atf_check -s exit:0 -o empty \
+		awk -F\: '$4 == "foo" { print $1 }' ${HOME}/group
 }
 
 atf_test_case user_mod_rename



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201708260035.v7Q0ZnST062262>