[Freeipa-devel] [PATCH] Make enabling the autofs service more robust

Jakub Hrozek jhrozek at redhat.com
Tue Nov 13 10:33:36 UTC 2012


On Mon, Nov 12, 2012 at 05:54:22PM +0100, Jan Cholasta wrote:
> On 9.11.2012 16:06, Jakub Hrozek wrote:
> >On Tue, Nov 06, 2012 at 08:57:06AM +0100, Jan Cholasta wrote:
> >>On 29.10.2012 17:21, Jakub Hrozek wrote:
> >>>An improvement based on Honza's suggestion.
> >>>
> >>
> >>You might want to remove the try block around
> >>"sssdconfig.activate_service('autofs')". If it throws NoServiceError
> >>at this point, there is something really broken in SSSDConfig, in
> >>which case it is better to display a traceback rather than a nice
> >>error message IMO.
> >>
> >
> >In retrospective, I agree. We can't try-except every line.
> >
> 
> Add an appropriate sys.exit() at the end of the except
> SSSDConfig.ServiceNotRecognizedError block and it's an ACK.
> 
> Honza

Done, thank you for the review.
-------------- next part --------------
>From 8fb1772843989969cdd839ac464915d741807fbf Mon Sep 17 00:00:00 2001
From: Jakub Hrozek <jhrozek at redhat.com>
Date: Mon, 29 Oct 2012 10:06:45 +0100
Subject: [PATCH] Make enabling the autofs service more robust

---
 ipa-client/ipa-install/ipa-client-automount | 17 +++++++++++------
 1 file changed, 11 insertions(+), 6 deletions(-)

diff --git a/ipa-client/ipa-install/ipa-client-automount b/ipa-client/ipa-install/ipa-client-automount
index 182f9f659dc3bfca198fc254f1a51047b3d9d31f..fd922b8a9e3fafbe1c740642752ff9258f1260bd 100755
--- a/ipa-client/ipa-install/ipa-client-automount
+++ b/ipa-client/ipa-install/ipa-client-automount
@@ -154,14 +154,19 @@ def configure_autofs_sssd(fstore, statestore, autodiscover, options):
     except Exception, e:
         sys.exit(e)
 
-    if 'autofs' not in sssdconfig.list_services():
+    try:
         sssdconfig.new_service('autofs')
+    except SSSDConfig.ServiceAlreadyExists:
+        pass
+    except SSSDConfig.ServiceNotRecognizedError:
+        root_logger.error("Unable to activate the Autofs service in SSSD config.")
+        root_logger.info(
+            "Please make sure you have SSSD built with autofs support installed.")
+        root_logger.info(
+            "Configure autofs support manually in /etc/sssd/sssd.conf.")
+        sys.exit("Cannot create the autofs service in sssd.conf")
 
-    try:
-        sssdconfig.activate_service('autofs')
-    except SSSDConfig.NoServiceError:
-        print "Unable to activate the autofs service in SSSD config."
-        root_logger.debug("Unable to activate the autofs service in SSSD config.")
+    sssdconfig.activate_service('autofs')
 
     domain = None
     for name in domains:
-- 
1.8.0



More information about the Freeipa-devel mailing list