b38368
From c702bb6ca3742cf7ea156e062840623f95a001b7 Mon Sep 17 00:00:00 2001
b38368
From: Martin Babinsky <mbabinsk@redhat.com>
b38368
Date: Thu, 22 Jun 2017 15:08:08 +0200
b38368
Subject: [PATCH] Use the compound statement formatting API for configuring
b38368
 PKINIT
b38368
b38368
Use `if_branch` and `else_branch` context managers instead of raw
b38368
`command` calls in the method that generates Bash snippet that
b38368
configures PKINIT on the master.
b38368
b38368
https://pagure.io/freeipa/issue/7036
b38368
b38368
Reviewed-By: Florence Blanc-Renaud <frenaud@redhat.com>
b38368
Reviewed-By: Alexander Bokovoy <abokovoy@redhat.com>
b38368
---
b38368
 ipaserver/advise/plugins/smart_card_auth.py | 16 +++++++---------
b38368
 1 file changed, 7 insertions(+), 9 deletions(-)
b38368
b38368
diff --git a/ipaserver/advise/plugins/smart_card_auth.py b/ipaserver/advise/plugins/smart_card_auth.py
b38368
index 138a44316473f6b504a44a1b68d01fa4d5a58308..2dc9ddb25ce41a8c85aab827a92a1143784d9457 100644
b38368
--- a/ipaserver/advise/plugins/smart_card_auth.py
b38368
+++ b/ipaserver/advise/plugins/smart_card_auth.py
b38368
@@ -214,15 +214,13 @@ class config_server_for_smart_card_auth(common_smart_card_auth_config):
b38368
 
b38368
     def check_and_enable_pkinit(self):
b38368
         self.log.comment('check whether PKINIT is configured on the master')
b38368
-        self.log.command(
b38368
-            "if ipa-pkinit-manage status | grep -q 'enabled'")
b38368
-        self.log.command('then')
b38368
-        self.log.command('  echo "PKINIT already enabled"')
b38368
-        self.log.command('else')
b38368
-        self.log.exit_on_failed_command(
b38368
-            'ipa-pkinit-manage enable',
b38368
-            ['Failed to issue PKINIT certificates to local KDC'])
b38368
-        self.log.command('fi')
b38368
+        with self.log.if_branch(
b38368
+                "ipa-pkinit-manage status | grep -q 'enabled'"):
b38368
+            self.log.command('echo "PKINIT already enabled"')
b38368
+        with self.log.else_branch():
b38368
+            self.log.exit_on_failed_command(
b38368
+                'ipa-pkinit-manage enable',
b38368
+                ['Failed to issue PKINIT certificates to local KDC'])
b38368
 
b38368
     def enable_ok_to_auth_as_delegate_on_http_principal(self):
b38368
         self.log.comment('Enable OK-AS-DELEGATE flag on the HTTP principal')
b38368
-- 
b38368
2.9.4
b38368