Blob Blame History Raw
From 6cb26b2d4ea21bc9f44f8448e2749b4624ff0581 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Pavel=20B=C5=99ezina?= <pbrezina@redhat.com>
Date: Thu, 20 Apr 2017 12:04:15 +0200
Subject: [PATCH] sssd: catch NoServiceError exception

SSSDConfig throws an NoServiceError exception if the service is not
yet present in the configuration file. We need to catch it and
create the service manually in such situation.
---
 authinfo.py | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/authinfo.py b/authinfo.py
index 7ef7453f6dea5e363a17efe199338a0646c20a51..510e6d5f140fd61322286c8eb630e88efeb5db11 100644
--- a/authinfo.py
+++ b/authinfo.py
@@ -3113,7 +3113,10 @@ class AuthInfo:
 		if not self.sssdConfig:
 			return True
 
-		pam = self.sssdConfig.get_service('pam')
+		try:
+			pam = self.sssdConfig.get_service('pam')
+		except SSSDConfig.NoServiceError:
+			pam = self.sssdConfig.new_service('pam')
 
 		if self.enableSmartcard and self.enableSSSDAuth and self.smartcardModule == "sssd" :
 			pam.set_option('pam_cert_auth', 'True')
-- 
2.9.3