On 08/31/2016 09:36 AM, Lukas Slebodnik wrote:
On (31/08/16 08:28), Petr Cech wrote:
From b3ae463a7544bb9561126c5e05475d5b98928edc Mon Sep 17 00:00:00 2001
From: Petr Cech <pc...@example.com>
Date: Fri, 15 Jul 2016 14:54:35 +0200
Subject: [PATCH] LDAP: Improving debug message

There were debug messges refering to user by for loop variable.
We might obtain user name and refer to user by this.
---
src/providers/ldap/sdap_async_users.c | 21 +++++++++++++++++++--
1 file changed, 19 insertions(+), 2 deletions(-)

diff --git a/src/providers/ldap/sdap_async_users.c 
b/src/providers/ldap/sdap_async_users.c
index 
87d91d8247c37a4c6a1d83b7189399056528fc90..17d8680d82b25946e975034b852e24fcb731b535
 100644
--- a/src/providers/ldap/sdap_async_users.c
+++ b/src/providers/ldap/sdap_async_users.c
@@ -540,6 +540,7 @@ int sdap_save_users(TALLOC_CTX *memctx,
                    char **_usn_value)
{
    TALLOC_CTX *tmpctx;
+    const char *user_name = NULL;
    char *higher_usn = NULL;
    char *usn_value;
    int ret;
@@ -569,14 +570,30 @@ int sdap_save_users(TALLOC_CTX *memctx,
    for (i = 0; i < num_users; i++) {
        usn_value = NULL;

+        ret = sdap_get_user_primary_name(memctx, opts, users[i],
+                                         dom, &user_name);
+        if (ret != EOK) {
+            user_name = NULL;
+        }
+
        ret = sdap_save_user(tmpctx, opts, dom, users[i], &usn_value, now);

        /* Do not fail completely on errors.
         * Just report the failure to save and go on */
        if (ret) {
-            DEBUG(SSSDBG_OP_FAILURE, "Failed to store user %d. Ignoring.\n", 
i);
+            if (user_name != NULL) {
+               DEBUG(SSSDBG_OP_FAILURE, "Failed to store user %s. Ignoring.\n",
+                                        user_name);
+            } else {
+                DEBUG(SSSDBG_OP_FAILURE, "Failed to store user %d. 
Ignoring.\n",
+                                          i);
+            }
        } else {
-            DEBUG(SSSDBG_TRACE_ALL, "User %d processed!\n", i);
+            if (user_name != NULL) {
+                DEBUG(SSSDBG_TRACE_ALL, "User %s processed!\n", user_name);
+            } else {
+                DEBUG(SSSDBG_TRACE_ALL, "User %d processed!\n", i);
+            }
        }
I do not think that this patch improves anything.
Could you describe a use-case?

BTW W already log a message in sdap_save_user(<-singular)
e.g.
(Wed Aug 31 09:30:02 2016) [sssd[be[example.com]]] [sdap_get_primary_name] 
(0x0400): Processing object pcech
(Wed Aug 31 09:30:02 2016) [sssd[be[example.com]]] [sdap_save_user] (0x0400): 
Processing user pc...@example.com
(Wed Aug 31 09:30:02 2016) [sssd[be[example.com]]] [is_email_from_domain] 
(0x4000): Email [pc...@example.com] is from domain [example.com]
(Wed Aug 31 09:30:02 2016) [sssd[be[example.com]]] [sdap_save_user] (0x0400): 
Storing info for user pc...@example.com

And we log message there as soon as possible.
We cannot get a name earlier in the function.

LS

Hi Lukas, I acknowledge.

NACK

--
Petr^4 Čech
_______________________________________________
sssd-devel mailing list
sssd-devel@lists.fedorahosted.org
https://lists.fedorahosted.org/admin/lists/sssd-devel@lists.fedorahosted.org

Reply via email to