Skip to content

Commit ee0ba4d

Browse files
WOnder93stephensmalley
authored andcommitted
tmt: add some missing permissions to policy before running the tests
To enable test coverage for permissions that haven't been added to the distro SELinux policy yet, we may want to temporarily add these permissions to the policy. Since these new permissions will often only be present in new kernel code, let's do this only when testing the secnext kernel. The permissions added are the file loading permissions (extending module_load coverage) and the nlmsg permission (enabling the nlmsg test). Signed-off-by: Ondrej Mosnacek <omosnace@redhat.com> Acked-by: Stephen Smalley <stephen.smalley.work@gmail.com>
1 parent 1ee3b8b commit ee0ba4d

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

tmt/tests.fmf

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,29 @@
3737
--nogpgcheck --releasever rawhide \
3838
--repofrompath 'kernel-secnext,https://repo.paul-moore.com/rawhide/$basearch' \
3939
kernel-modules-*.secnext.* kernel-devel-*.secnext.*
40+
41+
# add classes/permissions currently not supported in Fedora
42+
semodule -c -E base
43+
sed -i \
44+
-e 's/\((class system (ipc_info syslog_read syslog_mod syslog_console module_request module_load \)\(halt reboot status start stop enable disable reload undefined ))\)/\1firmware_load kexec_image_load kexec_initramfs_load policy_load x509_certificate_load \2/' \
45+
-e 's/\((class netlink_[a-z0-9_]*_socket (\)\(nlmsg_read \)/\1nlmsg \2/' \
46+
base.cil
47+
echo "(policycap netlink_xperm)" >>base.cil
48+
# allow nlmsg to some system domains so that the system can boot
49+
for source in daemon initrc_domain systemprocess unconfined_domain_type sysadm_t; do
50+
echo "(allow $source self (netlink_route_socket (nlmsg)))" >>base.cil
51+
echo "(allow $source self (netlink_firewall_socket (nlmsg)))" >>base.cil
52+
echo "(allow $source self (netlink_tcpdiag_socket (nlmsg)))" >>base.cil
53+
echo "(allow $source self (netlink_xfrm_socket (nlmsg)))" >>base.cil
54+
echo "(allow $source self (netlink_audit_socket (nlmsg)))" >>base.cil
55+
echo "(allow $source self (netlink_ip6fw_socket (nlmsg)))" >>base.cil
56+
done
57+
semodule -X 456 -i base.cil
58+
rm -f base.cil
59+
sed -i.orig \
60+
-e 's/module_load /module_load firmware_load kexec_image_load kexec_initramfs_load policy_load x509_certificate_load /' \
61+
-e 's/nlmsg_read /nlmsg nlmsg_read /' \
62+
/usr/share/selinux/devel/include/support/all_perms.spt
4063
;;
4164
local)
4265
# for a non-rpm directly-installed kernel - assume all necessary files
@@ -100,6 +123,7 @@
100123
- jfsutils
101124
- dosfstools
102125
- rdma-core-devel
126+
- kexec-tools
103127
/main:
104128
summary: Run the testsuite
105129
duration: 20m
@@ -139,3 +163,7 @@
139163
semanage boolean --modify --off ssh_sysadm_login
140164
semanage login --modify -s unconfined_u root
141165
fi
166+
if [ "$STS_KERNEL" = secnext ]; then
167+
semodule -X 456 -r base
168+
env -C /usr/share/selinux/devel/include/support mv all_perms.spt.orig all_perms.spt
169+
fi

0 commit comments

Comments
 (0)