URL: https://github.com/freeipa/freeipa/pull/829
Author: Tiboris
 Title: #829: client.py: Replace hardcoded 'admin' with options.principal
Action: synchronized

To pull the PR as Git branch:
git remote add ghfreeipa https://github.com/freeipa/freeipa
git fetch ghfreeipa pull/829/head:pr829
git checkout pr829
From 3af663c5edc411485369d4639dd37746997925f0 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Tibor=20Dudl=C3=A1k?= <tdud...@redhat.com>
Date: Tue, 30 May 2017 14:36:00 +0200
Subject: [PATCH] client.py: Replace hardcoded 'admin' with options.principal

Fixes: https://pagure.io/freeipa/issue/5406
---
 ipaclient/install/client.py | 15 ++++++++++++---
 1 file changed, 12 insertions(+), 3 deletions(-)

diff --git a/ipaclient/install/client.py b/ipaclient/install/client.py
index 1aa50372a4..d50039306a 100644
--- a/ipaclient/install/client.py
+++ b/ipaclient/install/client.py
@@ -2907,6 +2907,14 @@ def _install(options):
 
         # Check that nss is working properly
         if not options.on_master:
+            user = options.principal
+            if user is None:
+                user = "admin"
+                root_logger.info("Principal is not set when enrolling with OTP"
+                                 "; using principal '%s' for 'getent passwd'",
+                                 user)
+            else:
+                user = user.split("@")[0]
             n = 0
             found = False
             # Loop for up to 10 seconds to see if nss is working properly.
@@ -2915,7 +2923,8 @@ def _install(options):
             # Particulary, SSSD might take longer than 6-8 seconds.
             while n < 10 and not found:
                 try:
-                    ipautil.run(["getent", "passwd", "admin@%s" % cli_domain])
+                    ipautil.run(["getent", "passwd", "%s@%s"
+                                % (user, cli_domain)])
                     found = True
                 except Exception as e:
                     time.sleep(1)
@@ -2923,8 +2932,8 @@ def _install(options):
 
             if not found:
                 root_logger.error(
-                    "Unable to find 'admin' user with "
-                    "'getent passwd admin@%s'!" % cli_domain)
+                    "Unable to find '%s' user with 'getent passwd %s@%s'!"
+                    % (user, user, cli_domain))
                 if conf:
                     root_logger.info("Recognized configuration: %s", conf)
                 else:
_______________________________________________
FreeIPA-devel mailing list -- freeipa-devel@lists.fedorahosted.org
To unsubscribe send an email to freeipa-devel-le...@lists.fedorahosted.org

Reply via email to