Date: Fri, 21 Aug 2015 09:28:20 +0000 (UTC) From: Baptiste Daroussin <bapt@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r286986 - in head/usr.sbin/pw: . tests Message-ID: <201508210928.t7L9SKsH072522@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: bapt Date: Fri Aug 21 09:28:20 2015 New Revision: 286986 URL: https://svnweb.freebsd.org/changeset/base/286986 Log: Fix /home symlink creation Add regression test about it Modified: head/usr.sbin/pw/pw_user.c head/usr.sbin/pw/tests/pw_useradd.sh Modified: head/usr.sbin/pw/pw_user.c ============================================================================== --- head/usr.sbin/pw/pw_user.c Fri Aug 21 08:17:44 2015 (r286985) +++ head/usr.sbin/pw/pw_user.c Fri Aug 21 09:28:20 2015 (r286986) @@ -123,7 +123,7 @@ mkdir_home_parents(int dfd, const char * errx(EX_UNAVAILABLE, "out of memory"); if (mkdirat(dfd, tmp, _DEF_DIRMODE) != -1 || errno == EEXIST) { fchownat(dfd, tmp, 0, 0, 0); - symlinkat(tmp, dfd, dirs + 1); + symlinkat(tmp, dfd, dirs); } free(tmp); } Modified: head/usr.sbin/pw/tests/pw_useradd.sh ============================================================================== --- head/usr.sbin/pw/tests/pw_useradd.sh Fri Aug 21 08:17:44 2015 (r286985) +++ head/usr.sbin/pw/tests/pw_useradd.sh Fri Aug 21 09:28:20 2015 (r286986) @@ -246,6 +246,7 @@ user_add_R_body() { atf_check -s exit:0 ${RPW} useradd foo atf_check -s exit:0 ${RPW} useradd bar -m + test -d ${HOME}/home || atf_fail "Home parent directory not created" test -d ${HOME}/home/bar || atf_fail "Directory not created" atf_check -s exit:0 ${RPW} userdel bar test -d ${HOME}/home/bar || atf_fail "Directory removed" @@ -254,6 +255,17 @@ user_add_R_body() { [ ! -d ${HOME}/home/bar ] || atf_fail "Directory not removed" } +atf_test_case user_add_R_symlink +user_add_R_symlink_body() { + populate_root_etc_skel + + mkdir ${HOME}/usr + atf_check -s exit:0 ${RPW} useradd foo -m + test -d ${HOME}/usr/home || atf_fail "Home parent directory not created" + test -h ${HOME}/home || atf_fail "/home directory is not a symlink" + atf_check -s exit:0 -o inline:"usr/home\n" readlink ${HOME}/home +} + atf_test_case user_add_skel user_add_skel_body() { populate_root_etc_skel @@ -348,6 +360,7 @@ atf_init_test_cases() { atf_add_test_case user_add_invalid_group_entry atf_add_test_case user_add_password_from_h atf_add_test_case user_add_R + atf_add_test_case user_add_R_symlink atf_add_test_case user_add_skel atf_add_test_case user_add_uid0 atf_add_test_case user_add_uid_too_large
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201508210928.t7L9SKsH072522>