Misc CI fixes
Ondrej Mosnáček
reviewercover Misc CI fixes
This series works around/fixes four issues that are currently making the testsuite CI fail. The last patch additionally tweaks the Testing Farm settings to make the CI a bit faster.
Ondrej Mosnáček (5):
tmt: raise duration of the prepare-system test to 10 minutes nfs.sh: work around NFS hangs with nfs-utils 2.9+
tmt: rework sysadm_t testing
tmt: work around missing rule for sysadm_t
ci: disable guest setup in Testing Farm requests
.github/workflows/checks.yml | 2 ++ tmt/tests.fmf | 47 +++++++++++++++++++++++++++++------- tools/nfs.sh | 3 +++ 3 files changed, 43 insertions(+), 9 deletions(-)
Signature · 1 line
2.54.0
Ondrej Mosnáček
reviewerPATCH 1/5 tmt: raise duration of the prepare-system test to 10 minutes
There is some issue with cloud-init on Rawhide Amazon VMs that causes every boot to hang for 5 minutes. Work around it by raising the duration limit for the test that reboots the machine.
--- tmt/tests.fmf | 1 + 1 file changed, 1 insertion(+)
tmt/tests.fmf +1 -0
@@ -3,6 +3,7 @@ /prepare-system: summary: Prepare the system for testing order: 1 + duration: 10m require: policycoreutils-python-utils test: | set -ex
Signature · 1 line
2.54.0
Re: [PATCH testsuite 1/5] tmt: raise duration of the prepare-system test to 10 minutes
Quoted 6 lines · Ondrej Mosnáček
There is some issue with cloud-init on Rawhide Amazon VMs that causes every boot to hang for 5 minutes. Work around it by raising the duration limit for the test that reboots the machine.
Signed-off-by Ondrej Mosnáček <[email protected]>
Ondrej Mosnáček
reviewerPATCH 2/5 nfs.sh: work around NFS hangs with nfs-utils 2.9+
In reply to Ondrej MosnáčekThere is a bug [1] in nfs-utils 2.9+ that causes nfs-mountd.service to fail shortly after nfs-server.service is started, leading to a hang on any attempt to mount an NFS filesystem afterwards. Work around it by waiting a bit until nfs-mountd.service fails and then starting it again.
--- tools/nfs.sh | 3 +++ 1 file changed, 3 insertions(+)
tools/nfs.sh +3 -0
@@ -55,6 +55,9 @@ export NFS_TESTDIR=$TESTDIR export NFS_MOUNT=$MOUNT # systemctl start nfs-server +# Work around https://bugzilla.redhat.com/show_bug.cgi?id=2547879 +# Remove this line once the bug is fixed. +sleep 5; systemctl start nfs-mountd # Run the testsuite on a labeled NFS mount. exportfs -o rw,no_root_squash,security_label localhost:$MOUNT mkdir -p /mnt/selinux-testsuite
Signature · 1 line
2.54.0
Re: [PATCH testsuite 2/5] nfs.sh: work around NFS hangs with nfs-utils 2.9+
Quoted 7 lines · Ondrej Mosnáček
There is a bug [1] in nfs-utils 2.9+ that causes nfs-mountd.service to fail shortly after nfs-server.service is started, leading to a hang on any attempt to mount an NFS filesystem afterwards. Work around it by waiting a bit until nfs-mountd.service fails and then starting it again.
Signed-off-by Ondrej Mosnáček <[email protected]>
You didn't provide the [1] reference in the patch description only in the code but regardless:
Ondrej Mosnáček
reviewerPATCH 3/5 tmt: rework sysadm_t testing
In reply to Ondrej MosnáčekFor sysadm testing we currently rely on the fact that TMT will connect to the test machine via SSH and thus SELinux login configuration will be applied. However, TMT uses ssh -M and ssh -S to keep a single SSH session across test execution and while a new shell is still started for each remote command, the SELinux context for the login shell is not recomputed, so semanage login changes are not applied.
We currently work around this by forcing a reboot in the prepare-system phase, but after https://github.com/teemtee/tmt/pull/5069, we would now need to also do the reboot in unprepare phase as well, otherwise new SSH connections fail due to the ssh_sysadm_login boolean being already turned off and SSH still trying to transition into the sysadm context.
So let's stop relying on TMT "logging in" via SSH and instead do a local SSH login over loopback, avoiding the need for reboots and unwanted interactions between semanage login configuration and TMT's SSH connections.
--- tmt/tests.fmf | 43 ++++++++++++++++++++++++++++++++----------- 1 file changed, 32 insertions(+), 11 deletions(-)
tmt/tests.fmf +32 -11
@@ -4,21 +4,30 @@ summary: Prepare the system for testing order: 1 duration: 10m - require: policycoreutils-python-utils + require: + - policycoreutils-python-utils + - openssh-server + - openssh-clients test: | set -ex if [ "$TMT_REBOOT_COUNT" -eq 0 ]; then reboot=0 + # Enable root to log in via SSH as itself (so we can potentially test + # sysadm confined root) + systemctl start sshd + if ! [ -e ~/.ssh/id_rsa.pub ]; then + echo | ssh-keygen -t rsa -q -N '' + fi + if ! grep -qF "$(cat ~/.ssh/id_rsa.pub)" ~/.ssh/authorized_keys; then + echo "$(cat ~/.ssh/id_rsa.pub)" >>~/.ssh/authorized_keys + fi + case "$STS_ROOT_DOMAIN" in unconfined_t|'') ;; sysadm_t) - semanage boolean --modify --on ssh_sysadm_login - semanage login --modify -s sysadm_u root - - reboot=1 ;; *) echo "Invalid STS_ROOT_DOMAIN value!"
@@ -129,16 +138,32 @@ - rdma-core-devel - kexec-tools - liburing-devel + test: | + set -ex + + if [ "$STS_ROOT_DOMAIN" = sysadm_t ]; then + semanage boolean --modify --on ssh_sysadm_login + semanage login --modify -s sysadm_u root + trap ' + semanage boolean --modify --off ssh_sysadm_login + semanage login --modify -s unconfined_u root + ' EXIT + fi + + # Force a new login to pick up the `semanage login` changes + ssh localhost -o StrictHostKeyChecking=no env -C "$PWD/.." $TEST_COMMAND /main: summary: Run the testsuite duration: 20m - test: make -C .. test + environment: + TEST_COMMAND: make test /nfs: summary: Run the NFS tests tag: [nfs] duration: 25m require+: [nfs-utils] - test: env -C .. bash -x ./tools/nfs.sh + environment: + TEST_COMMAND: bash -x ./tools/nfs.sh /avc-check: summary: Check unwanted denials order: 4
@@ -164,10 +189,6 @@ set -ex make -C ../policy unload || true - if [ "$STS_ROOT_DOMAIN" = sysadm_t ]; then - semanage boolean --modify --off ssh_sysadm_login - semanage login --modify -s unconfined_u root - fi if [ "$STS_KERNEL" = secnext ]; then semodule -X 456 -r base env -C /usr/share/selinux/devel/include/support mv all_perms.spt.orig all_perms.spt
Signature · 1 line
2.54.0
Re: [PATCH testsuite 3/5] tmt: rework sysadm_t testing
Quoted 14 lines · Ondrej Mosnáček
For sysadm testing we currently rely on the fact that TMT will connect to the test machine via SSH and thus SELinux login configuration will be applied. However, TMT uses
ssh -Mandssh -Sto keep a single SSH session across test execution and while a new shell is still started for each remote command, the SELinux context for the login shell is not recomputed, sosemanage loginchanges are not applied.We currently work around this by forcing a reboot in the prepare-system phase, but after https://github.com/teemtee/tmt/pull/5069, we would now need to also do the reboot in unprepare phase as well, otherwise new SSH connections fail due to the
ssh_sysadm_loginboolean being already turned off and SSH still trying to transition into the sysadm context.
Quoted 6 lines
So let's stop relying on TMT "logging in" via SSH and instead do a local SSH login over loopback, avoiding the need for reboots and unwanted interactions between
semanage loginconfiguration and TMT's SSH connections.Signed-off-by Ondrej Mosnáček <[email protected]>
Ondrej Mosnáček
reviewerPATCH 4/5 tmt: work around missing rule for sysadm_t
In reply to Ondrej MosnáčekThe avc-check test currently catchesa denial triggered when the testsuite is ran under a confined root (sysadm_r). Add the rule into the system policy as a workaround until the rule is added to Fedora policy
(https://github.com/fedora-selinux/selinux-policy/pull/3465).
--- tmt/tests.fmf | 7 +++++++ 1 file changed, 7 insertions(+)
tmt/tests.fmf +7 -0
@@ -28,6 +28,10 @@ unconfined_t|'') ;; sysadm_t) + # Workaround for missing https://github.com/fedora-selinux/selinux-policy/pull/3465 + echo '(allow sysadm_t self (netlink_iscsi_socket (create)))' >/tmp/sysadm_workaround.cil + semodule -i /tmp/sysadm_workaround.cil + rm -f /tmp/sysadm_workaround.cil ;; *) echo "Invalid STS_ROOT_DOMAIN value!"
@@ -189,6 +193,9 @@ set -ex make -C ../policy unload || true + if [ "$STS_ROOT_DOMAIN" = sysadm_t ]; then + semodule -r sysadm_workaround + fi if [ "$STS_KERNEL" = secnext ]; then semodule -X 456 -r base env -C /usr/share/selinux/devel/include/support mv all_perms.spt.orig all_perms.spt
Signature · 1 line
2.54.0
Stephen Smalley
maintainerRe: [PATCH testsuite 4/5] tmt: work around missing rule for sysadm_t
Quoted 2 lines · Ondrej Mosnáček
The avc-check test currently catchesa denial triggered when the
typo: catchesa->catches
Quoted 1 line
testsuite is ran under a confined root (
sysadm_r). Add the rule into the
ran->run
Quoted 24 lines
system policy as a workaround until the rule is added to Fedora policy
(https://github.com/fedora-selinux/selinux-policy/pull/3465).Signed-off-by Ondrej Mosnáček <[email protected]>--- tmt/tests.fmf | 7 +++++++ 1 file changed, 7 insertions(+)tmt/tests.fmf +4
-0@@ -28,6 +28,10 @@ unconfined_t|'') ;; sysadm_t) + # Workaround for missing https://github.com/fedora-selinux/selinux-policy/pull/3465 + echo '(allow sysadm_t self (netlink_iscsi_socket (create)))' >/tmp/sysadm_workaround.cil + semodule -i /tmp/sysadm_workaround.cil + rm -f /tmp/sysadm_workaround.cil ;; *) echo "Invalid STS_ROOT_DOMAIN value!"
tmt/tests.fmf line 197
Quoted 5 lines
tmt/tests.fmf +2
-0@@ -189,6 +193,9 @@ set -ex make -C ../policy unload || true + if [ "$STS_ROOT_DOMAIN" = sysadm_t ]; then + semodule -r sysadm_workaround
Should add a || true to the end of this line in case prepare aborted before semodule -i completed;
else the semodule -r here will abort the unprepare.
Ondrej Mosnáček
reviewerPATCH 5/5 ci: disable guest setup in Testing Farm requests
In reply to Ondrej MosnáčekOur usage doesn't require it and disabling it saves around 5 minutes from the request duration.
--- .github/workflows/checks.yml | 2 ++ 1 file changed, 2 insertions(+)
.github/workflows/checks.yml +2 -0
@@ -28,3 +28,5 @@ jobs: compose: Fedora-${{ matrix.kernel == 'secnext' && 'Rawhide' || 'latest' }} variables: STS_ROOT_DOMAIN=${{ matrix.domain }}; STS_KERNEL=${{ matrix.kernel }} tmt_plan_filter: tag:ci + # no need for the "guest setup" - it just takes a lot of time for no benefit + environment_settings: '{ "pipeline": { "skip_guest_setup": true } }'
Signature · 1 line
2.54.0
Re: [PATCH testsuite 5/5] ci: disable guest setup in Testing Farm requests
Quoted 5 lines · Ondrej Mosnáček
Our usage doesn't require it and disabling it saves around 5 minutes from the request duration.
Signed-off-by Ondrej Mosnáček <[email protected]>
Ondrej Mosnáček
reviewerQuoted 12 lines · Ondrej Mosnáček
This series works around/fixes four issues that are currently making the testsuite CI fail. The last patch additionally tweaks the Testing Farm settings to make the CI a bit faster.
Ondrej Mosnáček (5):
tmt: raise duration of the prepare-system test to 10 minutesnfs.sh: work around NFS hangs with nfs-utils 2.9+
tmt: reworksysadm_ttesting
tmt: work around missing rule forsysadm_t
ci: disable guest setup in Testing Farm requests
Quoted 8 lines
.github/workflows/checks.yml | 2 ++ tmt/tests.fmf | 47 +++++++++++++++++++++++++++++------- tools/nfs.sh | 3 +++ 3 files changed, 43 insertions(+), 9 deletions(-)--
2.54.0
Applied with Stephen's review comments incorporated. Thanks for the review!