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
This commit is contained in:
parent
1561b87885
commit
6e6c53f063
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=273791
@ -170,14 +170,21 @@ gr_copy(int ffd, int tfd, const struct group *gr, struct group *old_gr)
|
||||
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;
|
||||
|
@ -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
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user