From: Pádraig Brady
Date: Sat, 10 Oct 2015 15:55:20 +0000 (+0100) Subject: tests: avoid false failure when restorecon is ineffective X-Git-Tag: v8.25~129 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=88eb88ee23ed05c08103225e41c180caeccb6918;p=thirdparty%2Fcoreutils.git tests: avoid false failure when restorecon is ineffective * tests/cp/cp-a-selinux.sh: Ensure we skip the portion of the test depending on restorecon to be effective. I.E. also skip when restorecon warns, as it doesn't exit with error status when matchpathcon fails to find a match for a file. This is the case in /tmp on Fedora for example, in which case the new destination that cp creates will have the default security context of the process, rather than the explicit context we set on the source file. Details at: http://bugzilla.redhat.com/1247641 --- diff --git a/tests/cp/cp-a-selinux.sh b/tests/cp/cp-a-selinux.sh index d000ee8f17..a889ad0a8a 100755 --- a/tests/cp/cp-a-selinux.sh +++ b/tests/cp/cp-a-selinux.sh @@ -73,7 +73,8 @@ old_type_d=$(get_selinux_type c_d) # and get the adjusted type for comparison cp -a c Z1 || fail=1 cp -a c_d Z1_d || fail=1 -if restorecon Z1 Z1_d 2>/dev/null; then +if restorecon Z1 Z1_d 2>restorecon.err \ + && compare /dev/null restorecon.err; then new_type_f=$(get_selinux_type Z1) new_type_d=$(get_selinux_type Z1_d)