svn commit: r273791 - in head: lib/libutil usr.sbin/pw/tests
Baptiste Daroussin
bapt at FreeBSD.org
Tue Oct 28 16:27:30 UTC 2014
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 at egr.msu.edu
Tested by: mcdouga9 at 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
}
More information about the svn-src-head
mailing list