6d47df
From 64045c5dbaf24340dea5cf0bdb629c29f70a4a9d Mon Sep 17 00:00:00 2001
6d47df
From: Christian Heimes <cheimes@redhat.com>
6d47df
Date: Wed, 24 Oct 2018 16:08:16 +0200
6d47df
Subject: [PATCH] Replace hard-coded interpreter with sys.executable
6d47df
6d47df
Instead of hard-coding python3, the smart card advise script now uses
6d47df
the current executable path from sys.executable as interpreter.
6d47df
6d47df
Fixes: https://pagure.io/freeipa/issue/7741
6d47df
Signed-off-by: Christian Heimes <cheimes@redhat.com>
6d47df
Reviewed-By: Alexander Bokovoy <abokovoy@redhat.com>
6d47df
6d47df
diff --git a/ipaserver/advise/plugins/smart_card_auth.py b/ipaserver/advise/plugins/smart_card_auth.py
6d47df
index 2f2e7aec9..97e23303b 100644
6d47df
--- a/ipaserver/advise/plugins/smart_card_auth.py
6d47df
+++ b/ipaserver/advise/plugins/smart_card_auth.py
6d47df
@@ -4,6 +4,8 @@
6d47df
 
6d47df
 from __future__ import absolute_import
6d47df
 
6d47df
+import sys
6d47df
+
6d47df
 from ipalib.plugable import Registry
6d47df
 from ipaplatform import services
6d47df
 from ipaplatform.paths import paths
6d47df
@@ -186,9 +188,9 @@ class config_server_for_smart_card_auth(common_smart_card_auth_config):
6d47df
     def record_httpd_ocsp_status(self):
6d47df
         self.log.comment('store the OCSP upgrade state')
6d47df
         self.log.command(
6d47df
-            "python3 -c 'from ipaserver.install import sysupgrade; "
6d47df
+            "{} -c 'from ipaserver.install import sysupgrade; "
6d47df
             "sysupgrade.set_upgrade_state(\"httpd\", "
6d47df
-            "\"{}\", True)'".format(OCSP_ENABLED))
6d47df
+            "\"{}\", True)'".format(sys.executable, OCSP_ENABLED))
6d47df
 
6d47df
     def check_and_enable_pkinit(self):
6d47df
         self.log.comment('check whether PKINIT is configured on the master')
6d47df
@@ -310,10 +312,10 @@ class config_client_for_smart_card_auth(common_smart_card_auth_config):
6d47df
     def configure_pam_cert_auth(self):
6d47df
         self.log.comment('Set pam_cert_auth=True in /etc/sssd/sssd.conf')
6d47df
         self.log.command(
6d47df
-            "python3 -c 'from SSSDConfig import SSSDConfig; "
6d47df
+            "{} -c 'from SSSDConfig import SSSDConfig; "
6d47df
             "c = SSSDConfig(); c.import_config(); "
6d47df
             "c.set(\"pam\", \"pam_cert_auth\", \"True\"); "
6d47df
-            "c.write()'")
6d47df
+            "c.write()'".format(sys.executable))
6d47df
 
6d47df
     def restart_sssd(self):
6d47df
         self.log.command('systemctl restart sssd.service')