From owner-svn-src-head@FreeBSD.ORG Tue Oct 28 16:27:30 2014 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 6B088942; Tue, 28 Oct 2014 16:27:30 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::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 3D91E271; Tue, 28 Oct 2014 16:27:30 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.9/8.14.9) with ESMTP id s9SGRUk2041921; Tue, 28 Oct 2014 16:27:30 GMT (envelope-from bapt@FreeBSD.org) Received: (from bapt@localhost) by svn.freebsd.org (8.14.9/8.14.9/Submit) id s9SGRT7S041916; Tue, 28 Oct 2014 16:27:29 GMT (envelope-from bapt@FreeBSD.org) Message-Id: <201410281627.s9SGRT7S041916@svn.freebsd.org> X-Authentication-Warning: svn.freebsd.org: bapt set sender to bapt@FreeBSD.org using -f From: Baptiste Daroussin Date: Tue, 28 Oct 2014 16:27:29 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r273791 - in head: lib/libutil usr.sbin/pw/tests X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 28 Oct 2014 16:27:30 -0000 Author: bapt Date: Tue Oct 28 16:27:29 2014 New Revision: 273791 URL: https://svnweb.freebsd.org/changeset/base/273791 Log: Fix renaming a group via the gr_copy function Add a regression test to pw(8) because the bug was discovered via using: pw groupmod PR: 187189 Reported by: mcdouga9@egr.msu.edu Tested by: mcdouga9@egr.msu.edu Patch by: Marc de la Gueronniere Modified: head/lib/libutil/gr_util.c head/usr.sbin/pw/tests/pw_modify.sh Modified: head/lib/libutil/gr_util.c ============================================================================== --- head/lib/libutil/gr_util.c Tue Oct 28 16:24:44 2014 (r273790) +++ head/lib/libutil/gr_util.c Tue Oct 28 16:27:29 2014 (r273791) @@ -170,14 +170,21 @@ gr_copy(int ffd, int tfd, const struct g size_t len; int eof, readlen; - sgr = gr; + if (old_gr == NULL && gr == NULL) + return(-1); + + sgr = old_gr; + /* deleting a group */ if (gr == NULL) { line = NULL; - if (old_gr == NULL) + } else { + if ((line = gr_make(gr)) == NULL) return (-1); - sgr = old_gr; - } else if ((line = gr_make(gr)) == NULL) - return (-1); + } + + /* adding a group */ + if (sgr == NULL) + sgr = gr; eof = 0; len = 0; Modified: head/usr.sbin/pw/tests/pw_modify.sh ============================================================================== --- head/usr.sbin/pw/tests/pw_modify.sh Tue Oct 28 16:24:44 2014 (r273790) +++ head/usr.sbin/pw/tests/pw_modify.sh Tue Oct 28 16:27:29 2014 (r273791) @@ -58,9 +58,23 @@ usermod_bug_185666_body() { atf_check -o inline:"testgroup2:*:1003:testuser\n" -x pw -V ${HOME} groupshow testgroup2 } +atf_test_case do_not_duplicate_group_on_gid_change +do_not_duplicate_group_on_gid_change_head() { + atf_set "descr" "Do not duplicate group on gid change" +} + +do_not_duplicate_group_on_gid_change_body() { + populate_etc_skel + atf_check -s exit:0 -x pw -V ${HOME} groupadd testgroup + atf_check -s exit:0 -x pw -V ${HOME} groupmod testgroup -g 12345 + # use grep to see if the entry has not be duplicated + atf_check -o inline:"testgroup:*:12345:\n" -s exit:0 -x grep "^testgroup" ${HOME}/group +} + atf_init_test_cases() { atf_add_test_case groupmod_user atf_add_test_case groupmod_invalid_user atf_add_test_case groupmod_bug_193704 atf_add_test_case usermod_bug_185666 + atf_add_test_case do_not_duplicate_group_on_gid_change }