From owner-svn-src-stable-10@freebsd.org Fri Sep 8 21:16:25 2017 Return-Path: Delivered-To: svn-src-stable-10@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 1459CE0B2DC; Fri, 8 Sep 2017 21:16:25 +0000 (UTC) (envelope-from emaste@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id D43936B212; Fri, 8 Sep 2017 21:16:24 +0000 (UTC) (envelope-from emaste@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v88LGNwC035048; Fri, 8 Sep 2017 21:16:23 GMT (envelope-from emaste@FreeBSD.org) Received: (from emaste@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v88LGNQ8035046; Fri, 8 Sep 2017 21:16:23 GMT (envelope-from emaste@FreeBSD.org) Message-Id: <201709082116.v88LGNQ8035046@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: emaste set sender to emaste@FreeBSD.org using -f From: Ed Maste Date: Fri, 8 Sep 2017 21:16:23 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r323333 - in stable/10/usr.sbin/pw: . tests X-SVN-Group: stable-10 X-SVN-Commit-Author: emaste X-SVN-Commit-Paths: in stable/10/usr.sbin/pw: . tests X-SVN-Commit-Revision: 323333 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-10@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for only the 10-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 08 Sep 2017 21:16:25 -0000 Author: emaste Date: Fri Sep 8 21:16:23 2017 New Revision: 323333 URL: https://svnweb.freebsd.org/changeset/base/323333 Log: MFC r322677: pw usermod: handle 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 Approved by: re (kib) Obtained from: ElectroBSD Relnotes: yes Modified: stable/10/usr.sbin/pw/pw_user.c stable/10/usr.sbin/pw/tests/pw_usermod_test.sh Directory Properties: stable/10/ (props changed) Modified: stable/10/usr.sbin/pw/pw_user.c ============================================================================== --- stable/10/usr.sbin/pw/pw_user.c Fri Sep 8 21:02:15 2017 (r323332) +++ stable/10/usr.sbin/pw/pw_user.c Fri Sep 8 21:16:23 2017 (r323333) @@ -1089,10 +1089,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/10/usr.sbin/pw/tests/pw_usermod_test.sh ============================================================================== --- stable/10/usr.sbin/pw/tests/pw_usermod_test.sh Fri Sep 8 21:02:15 2017 (r323332) +++ stable/10/usr.sbin/pw/tests/pw_usermod_test.sh Fri Sep 8 21:16:23 2017 (r323333) @@ -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