diff --git a/xCAT-test/autotest/testcase/selinux/cases0 b/xCAT-test/autotest/testcase/selinux/cases0 index 649f542986..8a7961d35e 100644 --- a/xCAT-test/autotest/testcase/selinux/cases0 +++ b/xCAT-test/autotest/testcase/selinux/cases0 @@ -20,6 +20,8 @@ label:mn_only,selinux cmd:getenforce check:rc==0 check:output=~^Enforcing$ +cmd:sh -c 'date "+%x %T" > /tmp/selinux_client_domain.start' +check:rc==0 cmd:ls -Z /opt/xcat/bin/xcatclient check:rc==0 check:output=~:xcat_client_exec_t: @@ -36,8 +38,16 @@ check:rc==0 check:output=~xcat_t cmd:sesearch -T -s unconfined_t -t bin_t -c process check:output!~xcat_t +cmd:sh -c 'seinfo -runconfined_r -x | grep -w xcat_t' +check:rc==0 cmd:lsxcatd -v check:rc==0 +check:output=~^Version +cmd:sh -c 'ausearch --input-logs -m SELINUX_ERR -ts "$(cat /tmp/selinux_client_domain.start)" 2>&1 | grep -F invalid_context | wc -l' +check:rc==0 +check:output=~^0$ +cmd:rm -f /tmp/selinux_client_domain.start +check:rc==0 end start:selinux_mn_labels diff --git a/xCAT-test/unit/xcat_selinux_package.t b/xCAT-test/unit/xcat_selinux_package.t index 478d426592..e59621d7bd 100644 --- a/xCAT-test/unit/xcat_selinux_package.t +++ b/xCAT-test/unit/xcat_selinux_package.t @@ -211,6 +211,14 @@ my @domtrans = $te =~ /^\s*domtrans_pattern\((\w+), xcat_client_exec_t, xcat_t\) is_deeply(\@domtrans, ['unconfined_t'], 'only the unconfined domain transitions into xcat_t'); +# The transition computes unconfined_u:unconfined_r:xcat_t. Without this +# statement that context is invalid, and the kernel refuses the exec with +# EACCES whether or not xcat_t is permissive. A permissive domain does not +# help: an invalid context is not a permission check, and the record is +# SELINUX_ERR, which no AVC query finds. +like($te, qr/^\s*role unconfined_r types xcat_t;$/m, + 'unconfined_r is authorized for xcat_t'); + # A confined user domain that entered a permissive xcat_t would leave its own # confinement, so the module gives it no transition. foreach my $domain (qw(user_t staff_t sysadm_t guest_t xguest_t)) {