From 46b0746fe9b043edb55649f7993cdc5b20b70c12 Mon Sep 17 00:00:00 2001 From: Alexander Bokovoy Date: Tue, 9 Feb 2021 13:41:13 +0200 Subject: [PATCH] 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 Reviewed-By: Florence Blanc-Renaud --- ipatests/test_ipaserver/test_install/test_installutils.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/ipatests/test_ipaserver/test_install/test_installutils.py b/ipatests/test_ipaserver/test_install/test_installutils.py index 029b20659..107adfe3c 100644 --- a/ipatests/test_ipaserver/test_install/test_installutils.py +++ b/ipatests/test_ipaserver/test_install/test_installutils.py @@ -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, )