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
2021-02-11 09:09:46 +01:00
committed by Florence Blanc-Renaud
parent bf06579895
commit 46b0746fe9
@@ -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,
)