1# $FreeBSD$ 2 3# Import helper functions 4. $(atf_get_srcdir)/helper_functions.shin 5 6 7# Test that a user can be deleted when another user is part of this 8# user's default group and does not go into an infinate loop. 9# PR: 191427 10atf_test_case rmuser_seperate_group cleanup 11rmuser_seperate_group_head() { 12 atf_set "timeout" "30" 13} 14rmuser_seperate_group_body() { 15 populate_etc_skel 16 ${PW} useradd test || atf_fail "Creating test user" 17 ${PW} groupmod test -M 'test,root' || \ 18 atf_fail "Modifying the group" 19 ${PW} userdel test || atf_fail "Delete the test user" 20} 21 22 23atf_test_case user_do_not_try_to_delete_root_if_user_unknown 24user_do_not_try_to_delete_root_if_user_unknown_head() { 25 atf_set "descr" \ 26 "Make sure not to try to remove root if deleting an unknown user" 27} 28user_do_not_try_to_delete_root_if_user_unknown_body() { 29 populate_etc_skel 30 atf_check -e inline:"pw: Bad id 'plop': invalid\n" -s exit:64 -x \ 31 ${PW} userdel -u plop 32} 33 34atf_test_case delete_files 35delete_files_body() { 36 populate_root_etc_skel 37 38 mkdir -p ${HOME}/skel 39 touch ${HOME}/skel/a 40 mkdir -p ${HOME}/home 41 mkdir -p ${HOME}/var/mail 42 echo "foo wedontcare" > ${HOME}/etc/opiekeys 43 atf_check -s exit:0 ${RPW} useradd foo -k /skel -m 44 test -d ${HOME}/home || atf_fail "Fail to create home directory" 45 test -f ${HOME}/var/mail/foo || atf_fail "Mail file not created" 46 atf_check -s exit:0 ${RPW} userdel foo -r 47 atf_check -s exit:0 -o inline:"#oo wedontcare\n" cat ${HOME}/etc/opiekeys 48 if test -f ${HOME}/var/mail/foo; then 49 atf_fail "Mail file not removed" 50 fi 51} 52 53atf_test_case delete_numeric_name 54delete_numeric_name_body() { 55 populate_etc_skel 56 57 atf_check ${PW} useradd -n foo -u 4001 58 atf_check -e inline:"pw: no such user \`4001'\n" -s exit:67 \ 59 ${PW} userdel -n 4001 60} 61 62atf_test_case home_not_a_dir 63home_not_a_dir_body() { 64 populate_root_etc_skel 65 touch ${HOME}/foo 66 atf_check ${RPW} useradd foo -d /foo 67 atf_check ${RPW} userdel foo -r 68} 69 70atf_init_test_cases() { 71 atf_add_test_case rmuser_seperate_group 72 atf_add_test_case user_do_not_try_to_delete_root_if_user_unknown 73 atf_add_test_case delete_files 74 atf_add_test_case delete_numeric_name 75 atf_add_test_case home_not_a_dir 76} 77