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 e51354ecdf39398f7809245669383930a4bc4e11 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, 11 insertions(+), 4 deletions(-)

diff --git a/ipaclient/install/client.py b/ipaclient/install/client.py
index 1aa50372a4..3af8168291 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@" + cli_domain
+                root_logger.info("Principal is not set when enrolling with OTP"
+                                 "; using principal '%s' for 'getent passwd'",
+                                 user)
+            else if '@' not in user:
+                user = user + '@' + cli_domain
             n = 0
             found = False
             # Loop for up to 10 seconds to see if nss is working properly.
@@ -2915,16 +2923,15 @@ 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" % user])
                     found = True
                 except Exception as e:
                     time.sleep(1)
                     n = n + 1
 
             if not found:
-                root_logger.error(
-                    "Unable to find 'admin' user with "
-                    "'getent passwd admin@%s'!" % cli_domain)
+                root_logger.error("Unable to find '%s' user with 'getent "
+                                  "passwd %s'!" % (user.split("@")[0], user))
                 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