diff --git a/bin/cp/tests/cp_test.sh b/bin/cp/tests/cp_test.sh --- a/bin/cp/tests/cp_test.sh +++ b/bin/cp/tests/cp_test.sh @@ -183,6 +183,7 @@ pflag_acls_body() { mkdir dir + ln -s dir lnk echo "hello" >dir/file if ! setfacl -m g:staff:D::allow dir || ! setfacl -m g:staff:d::allow dir/file ; then @@ -204,12 +205,21 @@ atf_check cp -rp dir dst4 atf_check -o match:"group:staff:-+D-+" getfacl dst4 atf_check -o match:"group:staff:-+d-+" getfacl dst4/file + # source is a link without -p + atf_check cp -r lnk dst5 + atf_check -o not-match:"group:staff:-+D-+" getfacl dst5 + atf_check -o not-match:"group:staff:-+d-+" getfacl dst5/file + # source is a link with -p + atf_check cp -rp lnk dst6 + atf_check -o match:"group:staff:-+D-+" getfacl dst6 + atf_check -o match:"group:staff:-+d-+" getfacl dst6/file } atf_test_case pflag_flags pflag_flags_body() { mkdir dir + ln -s dir lnk echo "hello" >dir/file if ! chflags nodump dir || ! chflags nodump dir/file ; then @@ -231,6 +241,14 @@ atf_check cp -rp dir dst4 atf_check -o match:"nodump" stat -f%Sf dst4 atf_check -o match:"nodump" stat -f%Sf dst4/file + # source is a link without -p + atf_check cp -r lnk dst5 + atf_check -o not-match:"nodump" stat -f%Sf dst5 + atf_check -o not-match:"nodump" stat -f%Sf dst5/file + # source is a link with -p + atf_check cp -rp lnk dst6 + atf_check -o match:"nodump" stat -f%Sf dst6 + atf_check -o match:"nodump" stat -f%Sf dst6/file } recursive_link_setup() diff --git a/bin/cp/utils.c b/bin/cp/utils.c --- a/bin/cp/utils.c +++ b/bin/cp/utils.c @@ -458,7 +458,7 @@ { int source_fd = -1, dest_fd = -1, ret; - if ((source_fd = open(source_dir, O_PATH)) < 0) { + if ((source_fd = open(source_dir, O_DIRECTORY | O_SEARCH)) < 0) { warn("%s: failed to copy ACLs", source_dir); return (-1); }