Changeset View
Changeset View
Standalone View
Standalone View
usr.sbin/pw/tests/pw_useradd_test.sh
| # Import helper functions | # Import helper functions | ||||
| . $(atf_get_srcdir)/helper_functions.shin | . $(atf_get_srcdir)/helper_functions.shin | ||||
| # Test add user | # Test add user | ||||
| atf_test_case user_add | atf_test_case user_add | ||||
| user_add_body() { | user_add_body() { | ||||
| populate_etc_skel | populate_etc_skel | ||||
| ▲ Show 20 Lines • Show All 342 Lines • ▼ Show 20 Lines | user_add_skel_body() { | ||||
| echo "a" > ${HOME}/skel/.a | echo "a" > ${HOME}/skel/.a | ||||
| echo "b" > ${HOME}/skel/b | echo "b" > ${HOME}/skel/b | ||||
| mkdir ${HOME}/skel/c | mkdir ${HOME}/skel/c | ||||
| mkdir ${HOME}/skel/c/d | mkdir ${HOME}/skel/c/d | ||||
| mkdir ${HOME}/skel/dot.plop | mkdir ${HOME}/skel/dot.plop | ||||
| echo "c" > ${HOME}/skel/c/d/dot.c | echo "c" > ${HOME}/skel/c/d/dot.c | ||||
| mkdir ${HOME}/home | mkdir ${HOME}/home | ||||
| ln -sf /nonexistent ${HOME}/skel/c/foo | ln -sf /nonexistent ${HOME}/skel/c/foo | ||||
| atf_check -s exit:0 ${RPW} useradd foo -k /skel -m | atf_check -s exit:0 ${RPW} -M METALOG useradd foo -k /skel -m | ||||
| test -d ${HOME}/home/foo || atf_fail "Directory not created" | test -d ${HOME}/home/foo || atf_fail "Directory not created" | ||||
| test -f ${HOME}/home/foo/.a || atf_fail "File not created" | test -f ${HOME}/home/foo/.a || atf_fail "File not created" | ||||
| atf_check -o file:${HOME}/skel/.a -s exit:0 cat ${HOME}/home/foo/.a | atf_check -o file:${HOME}/skel/.a -s exit:0 cat ${HOME}/home/foo/.a | ||||
| atf_check -o file:${HOME}/skel/b -s exit:0 cat ${HOME}/home/foo/b | atf_check -o file:${HOME}/skel/b -s exit:0 cat ${HOME}/home/foo/b | ||||
| test -d ${HOME}/home/foo/c || atf_fail "Dotted directory in skel not copied" | test -d ${HOME}/home/foo/c || atf_fail "Directory in skel not copied" | ||||
| test -d ${HOME}/home/foo/.plop || atf_fail "Directory in skell not created" | test -d ${HOME}/home/foo/.plop || atf_fail "Dotted directory in skel not created" | ||||
| atf_check -o inline:"/nonexistent\n" -s ignore readlink -f ${HOME}/home/foo/c/foo | atf_check -o inline:"/nonexistent\n" -s ignore readlink -f ${HOME}/home/foo/c/foo | ||||
| atf_check -o file:${HOME}/skel/c/d/dot.c -s exit:0 cat ${HOME}/home/foo/c/d/.c | atf_check -o file:${HOME}/skel/c/d/dot.c -s exit:0 cat ${HOME}/home/foo/c/d/.c | ||||
| cat <<__EOF__ >METALOG.expected | |||||
| ./home/foo type=dir mode=0755 uid=1001 gid=1001 | |||||
| ./home/foo/.a type=file mode=0644 uid=1001 gid=1001 | |||||
| ./home/foo/.plop type=dir mode=0755 uid=1001 gid=1001 | |||||
| ./home/foo/b type=file mode=0644 uid=1001 gid=1001 | |||||
| ./home/foo/c type=dir mode=0755 uid=1001 gid=1001 | |||||
| ./home/foo/c/d type=dir mode=0755 uid=1001 gid=1001 | |||||
| ./home/foo/c/d/.c type=file mode=0644 uid=1001 gid=1001 | |||||
| ./home/foo/c/foo type=link mode=0755 uid=1001 gid=1001 link=/nonexistent | |||||
| __EOF__ | |||||
| atf_check -o save:METALOG.out sort METALOG | |||||
| atf_check diff METALOG.out METALOG.expected | |||||
| } | } | ||||
| atf_test_case user_add_uid0 | atf_test_case user_add_uid0 | ||||
| user_add_uid0_body() { | user_add_uid0_body() { | ||||
| populate_etc_skel | populate_etc_skel | ||||
| atf_check -e inline:"pw: WARNING: new account \`foo' has a uid of 0 (superuser access!)\n" \ | atf_check -e inline:"pw: WARNING: new account \`foo' has a uid of 0 (superuser access!)\n" \ | ||||
| -s exit:0 ${PW} useradd foo -u 0 -g 0 -d /root -s /bin/sh -c "Bourne-again Superuser" -o | -s exit:0 ${PW} useradd foo -u 0 -g 0 -d /root -s /bin/sh -c "Bourne-again Superuser" -o | ||||
| atf_check \ | atf_check \ | ||||
| ▲ Show 20 Lines • Show All 187 Lines • Show Last 20 Lines | |||||