3 TEST_DESCRIPTION
="SELinux tests"
8 # selinux-policy-targeted
11 # Check if selinux-policy-devel is installed, and if it isn't bail out early instead of failing
12 test -f /usr
/share
/selinux
/devel
/include
/system
/systemd.
if ||
exit 0
14 .
$TEST_BASE_DIR/test-functions
16 KERNEL_APPEND
="$KERNEL_APPEND selinux=1 security=selinux"
20 mkdir
-p $TESTDIR/root
21 mount
${LOOPDEV}p1
$TESTDIR/root
23 # Create what will eventually be our root filesystem onto an overlay
26 eval $
(udevadm info
--export --query=env
--name=${LOOPDEV}p2
)
28 setup_basic_environment
30 # setup the testsuite service
31 cat <<EOF >$initdir/etc/systemd/system/testsuite.service
33 Description=Testsuite service
36 ExecStart=/test-selinux-checks.sh
40 cat <<EOF >$initdir/etc/systemd/system/hola.service
43 ExecStart=/bin/echo Start Hola
44 ExecReload=/bin/echo Reload Hola
45 ExecStop=/bin/echo Stop Hola
51 cat <<EOF >$initdir/etc/systemd/system/load-systemd-test-module.service
53 Description=Load systemd-test module
54 DefaultDependencies=no
55 Requires=local-fs.target
56 Conflicts=shutdown.target
58 Before=sysinit.target shutdown.target autorelabel.service
59 ConditionSecurity=selinux
60 ConditionPathExists=|/.load-systemd-test-module
63 ExecStart=/bin/sh -x -c 'echo 0 >/sys/fs/selinux/enforce && cd /systemd-test-module && make -f /usr/share/selinux/devel/Makefile load && rm /.load-systemd-test-module'
69 touch $initdir/.load-systemd-test-module
70 mkdir
-p $initdir/etc
/systemd
/system
/basic.target.wants
71 ln -fs load-systemd-test-module.service
$initdir/etc
/systemd
/system
/basic.target.wants
/load-systemd-test-module.service
73 local _modules_dir
=/var
/lib
/selinux
74 rm -rf $initdir/$_modules_dir
75 if ! cp -ar $_modules_dir $initdir/$_modules_dir; then
76 dfatal
"Failed to copy $_modules_dir"
80 local _policy_headers_dir
=/usr
/share
/selinux
/devel
81 rm -rf $initdir/$_policy_headers_dir
82 inst_dir
/usr
/share
/selinux
83 if ! cp -ar $_policy_headers_dir $initdir/$_policy_headers_dir; then
84 dfatal
"Failed to copy $_policy_headers_dir"
88 mkdir
$initdir/systemd-test-module
89 cp systemd_test.te
$initdir/systemd-test-module
90 cp systemd_test.
if $initdir/systemd-test-module
91 cp test-selinux-checks.sh
$initdir
92 dracut_install
-o sesearch
94 dracut_install checkmodule semodule semodule_package
m4 make /usr
/libexec
/selinux
/hll
/pp load_policy sefcontext_compile
97 # mask some services that we do not want to run in these tests
98 ln -s /dev
/null
$initdir/etc
/systemd
/system
/systemd-hwdb-update.service
99 ln -s /dev
/null
$initdir/etc
/systemd
/system
/systemd-journal-catalog-update.service
100 ln -s /dev
/null
$initdir/etc
/systemd
/system
/systemd-networkd.service
101 ln -s /dev
/null
$initdir/etc
/systemd
/system
/systemd-networkd.socket
102 ln -s /dev
/null
$initdir/etc
/systemd
/system
/systemd-resolved.service
104 ddebug
"umount $TESTDIR/root"