test_installutils: run gpg-agent under a specific SELinux context

system_u:system_r:init_t:s0 cannot execute gpg=agent when SELinux is in
enforcing mode. Use SELinux context that allows this execution:
system_u:system_r:initrc_t:s0 and wrap the whole execution into a bash
run to make sure init_t -> initrc_t transition.

Fixes: https://pagure.io/freeipa/issue/8699
Signed-off-by: Alexander Bokovoy <abokovoy@redhat.com>
Reviewed-By: Florence Blanc-Renaud <flo@redhat.com>
This commit is contained in:
Alexander Bokovoy authored and Florence Blanc-Renaud committed 2021-02-11 12:45:33 +01:00
1 parent 55180f6e91
commit 7ca2797eac
1 file changed
+3 -1
@@ -57,10 +57,12 @@ def gpgkey(request, tempdir):
# daemonize agent (detach from the console and run in the background)
subprocess.run(
[paths.SYSTEMD_RUN, '--service-type=forking',
'--property', 'SELinuxContext=system_u:system_r:initrc_t:s0',
'--setenv=GNUPGHOME={}'.format(gnupghome),
'--setenv=LC_ALL=C.UTF-8',
'--setenv=LANGUAGE=C',
'--unit=gpg-agent', paths.GPG_AGENT, '--daemon', '--batch'],
'--unit=gpg-agent', '/bin/bash',
'-c', ' '.join([paths.GPG_AGENT, '--daemon', '--batch'])],
check=True,
env=env,
)