Hi,

another attempt to refine error/configuration reporting when configuring
means to access LDAP on a client. Previous one tried to use rpm to find
out package name but this approach is avoiding package names. Instead,
it tries to tell configuration file.

Ticker https://fedorahosted.org/freeipa/ticket/1369
-- 
/ Alexander Bokovoy
From 5497a7b2b39a6f7ffd48d35c37beeb80e9730f66 Mon Sep 17 00:00:00 2001
From: Alexander Bokovoy <aboko...@redhat.com>
Date: Fri, 29 Jul 2011 13:05:07 +0300
Subject: [PATCH] Make proper LDAP configuration reporting for
 ipa-client-install

Ticket https://fedorahosted.org/freeipa/ticket/1369
---
 ipa-client/ipa-install/ipa-client-install |   26 ++++++++++++++++----------
 1 files changed, 16 insertions(+), 10 deletions(-)

diff --git a/ipa-client/ipa-install/ipa-client-install 
b/ipa-client/ipa-install/ipa-client-install
index 
2e1a28ca087dee9eea04ccc55557a9e6e4f8ce89..75a1b3d1f8469433c404ef5f6b1989094a466f25
 100755
--- a/ipa-client/ipa-install/ipa-client-install
+++ b/ipa-client/ipa-install/ipa-client-install
@@ -336,6 +336,7 @@ def configure_ldap_conf(fstore, cli_basedn, cli_realm, 
cli_domain, cli_server, d
 
     opts.append({'name':'empty', 'type':'empty'})
 
+    ret = (0, 'LDAP', '')
     # Depending on the release and distribution this may exist in any
     # number of different file names, update what we find
     for filename in ['/etc/ldap.conf', '/etc/nss_ldap.conf', 
'/etc/libnss-ldap.conf', '/etc/pam_ldap.conf']:
@@ -343,11 +344,12 @@ def configure_ldap_conf(fstore, cli_basedn, cli_realm, 
cli_domain, cli_server, d
             try:
                 fstore.backup_file(filename)
                 ldapconf.newConf(filename, opts)
+                ret = (0, 'LDAP', filename)
             except Exception, e:
                 print "Creation of %s: %s" % (filename, str(e))
-                return 1
+                return (1, 'LDAP', filename)
 
-    return 0
+    return ret
 
 def configure_nslcd_conf(fstore, cli_basedn, cli_realm, cli_domain, 
cli_server, dnsok, options):
     nslcdconf = ipaclient.ipachangeconf.IPAChangeConf("IPA Installer")
@@ -379,7 +381,7 @@ def configure_nslcd_conf(fstore, cli_basedn, cli_realm, 
cli_domain, cli_server,
             nslcdconf.newConf('/etc/nslcd.conf', opts)
         except Exception, e:
             print "Creation of %s: %s" % ('/etc/nslcd.conf', str(e))
-            return 1
+            return (1, 'nslcd')
 
     if ipautil.service_is_installed('nslcd'):
         try:
@@ -395,7 +397,7 @@ def configure_nslcd_conf(fstore, cli_basedn, cli_realm, 
cli_domain, cli_server,
     else:
         logging.debug("NSLCD daemon is not installed, skip configuration")
 
-    return 0
+    return (0, 'NSLCD', '/etc/nslcd.conf')
 
 def hardcode_ldap_server(cli_server):
     """
@@ -945,7 +947,8 @@ def main():
 
     else:
         # this is optional service, just log
-        logging.info("NSCD daemon is not installed, skip configuration")
+        if not options.sssd:
+            logging.info("NSCD daemon is not installed, skip configuration")
 
     # Modify nsswitch/pam stack
     if options.sssd:
@@ -964,14 +967,17 @@ def main():
     run(["/usr/sbin/authconfig", "--enablekrb5", "--update", "--nostart"])
     print "Kerberos 5 enabled"
 
+    (retcode, conf, filename) = (0, 'SSSD', '/etc/sssd.conf')
     # Update non-SSSD LDAP configuration after authconfig calls as it would
     # change its configuration otherways
     if not options.sssd:
-        if configure_ldap_conf(fstore, cli_basedn, cli_realm, cli_domain, 
cli_server, dnsok, options):
+        (retcode, conf, filename) = configure_ldap_conf(fstore, cli_basedn, 
cli_realm, cli_domain, cli_server, dnsok, options)
+        if retcode:
             return 1
-        if configure_nslcd_conf(fstore, cli_basedn, cli_realm, cli_domain, 
cli_server, dnsok, options):
+        (retcode, conf, filename) = configure_nslcd_conf(fstore, cli_basedn, 
cli_realm, cli_domain, cli_server, dnsok, options)
+        if retcode:
             return 1
-        print "LDAP configured"
+        print "%s configured using configuration file %s" % (conf, filename)
 
     #Check that nss is working properly
     if not options.on_master:
@@ -989,8 +995,8 @@ def main():
                 n = n + 1
 
         if not found:
-            print "nss_ldap is not able to use DNS discovery!"
-            print "Changing configuration to use hardcoded server name: " 
+cli_server
+            print "Unable to use DNS discovery! Recognized configuration: %s" 
% (conf)
+            print "Changing configuration of /etc/ldap.conf to use hardcoded 
server name: " +cli_server
 
             try:
                 hardcode_ldap_server(cli_server)
-- 
1.7.6

_______________________________________________
Freeipa-devel mailing list
Freeipa-devel@redhat.com
https://www.redhat.com/mailman/listinfo/freeipa-devel

Reply via email to