From d49c32634e4a21e2706cc51f6a34dc94a5186522 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Petr=20=C4=8Cech?= <pcech@redhat.com>
Date: Wed, 21 Sep 2016 15:13:34 +0200
Subject: [PATCH 7/7] WIP: Debuging of attr member in ldap answer

Explanation

Resolves:
https://fedorahosted.org/sssd/ticket/3186
---
 configure.ac                                  |  2 +-
 src/providers/ldap/sdap.c                     | 24 ++++++++++++++++++------
 src/providers/ldap/sdap_async.c               |  4 ++--
 src/providers/ldap/sdap_async_groups.c        |  6 ++++++
 src/providers/ldap/sdap_async_nested_groups.c |  6 +++---
 5 files changed, 30 insertions(+), 12 deletions(-)

diff --git a/configure.ac b/configure.ac
index 8760a8561979664a02bc3c2b2b2994a73825f2c3..8dd1ebbfe2f91699874671a5d82365d7a8e2a53a 100644
--- a/configure.ac
+++ b/configure.ac
@@ -11,7 +11,7 @@ m4_ifdef([AC_USE_SYSTEM_EXTENSIONS],
     [AC_USE_SYSTEM_EXTENSIONS],
     [AC_GNU_SOURCE])
 
-CFLAGS="$CFLAGS -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE"
+CFLAGS="$CFLAGS -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -O0"
 
 
 AM_INIT_AUTOMAKE([-Wall -Wno-portability foreign subdir-objects tar-pax
diff --git a/src/providers/ldap/sdap.c b/src/providers/ldap/sdap.c
index dc7d5e0caf223c3ee3c43054aa44e796f1b37766..49879cf4897d4a5ad2e0aba3f023d66b1946d828 100644
--- a/src/providers/ldap/sdap.c
+++ b/src/providers/ldap/sdap.c
@@ -477,7 +477,19 @@ int sdap_parse_entry(TALLOC_CTX *memctx,
             goto done;
         }
     }
+
+
+    DEBUG(SSSDBG_MINOR_FAILURE, ">>> ----- filter map:\n");
+    for (int ijk = 0; ijk < attrs_num; ijk++) {
+        DEBUG(SSSDBG_MINOR_FAILURE, ">>>   [%s]\n", map[ijk].name);
+    }
+
+
+    DEBUG(SSSDBG_MINOR_FAILURE, ">>> ----- attributes in ldap answer:\n");
     while (str) {
+
+        DEBUG(SSSDBG_CRIT_FAILURE, ">>>   [%s]\n", str);
+
         base64 = false;
 
         ret = sdap_parse_range(tmp_ctx, str, &base_attr, &range_offset,
@@ -497,7 +509,7 @@ int sdap_parse_entry(TALLOC_CTX *memctx,
             break;
         default:
             DEBUG(SSSDBG_CRIT_FAILURE,
-                  "Could not determine if attribute [%s] was ranged\n", str);
+                  ">>> Could not determine if attribute [%s] was ranged\n", str);
             goto done;
         }
 
@@ -535,19 +547,19 @@ int sdap_parse_entry(TALLOC_CTX *memctx,
             if (!vals) {
                 ldap_get_option(sh->ldap, LDAP_OPT_RESULT_CODE, &lerrno);
                 if (lerrno != LDAP_SUCCESS) {
-                    DEBUG(SSSDBG_CRIT_FAILURE, "LDAP Library error: %d(%s)\n",
+                    DEBUG(SSSDBG_CRIT_FAILURE, ">>> LDAP Library error: %d(%s)\n",
                           lerrno, sss_ldap_err2string(lerrno));
                     ret = EIO;
                     goto done;
                 }
 
                 DEBUG(SSSDBG_TRACE_LIBS,
-                      "Attribute [%s] has no values, skipping.\n", str);
+                      ">>> Attribute [%s] has no values, skipping.\n", str);
 
             } else {
                 if (!vals[0]) {
                     DEBUG(SSSDBG_CRIT_FAILURE,
-                          "Missing value after ldap_get_values() ??\n");
+                          ">>> Missing value after ldap_get_values() ??\n");
                     ldap_value_free_len(vals);
                     ret = EINVAL;
                     goto done;
@@ -555,7 +567,7 @@ int sdap_parse_entry(TALLOC_CTX *memctx,
                 for (i = 0; vals[i]; i++) {
                     if (vals[i]->bv_len == 0) {
                         DEBUG(SSSDBG_TRACE_LIBS,
-                              "Value of attribute [%s] is empty. "
+                              ">>> Value of attribute [%s] is empty. "
                                "Skipping this value.\n", str);
                         continue;
                     }
@@ -615,7 +627,7 @@ int sdap_parse_entry(TALLOC_CTX *memctx,
 
     ldap_get_option(sh->ldap, LDAP_OPT_RESULT_CODE, &lerrno);
     if (lerrno) {
-        DEBUG(SSSDBG_CRIT_FAILURE, "LDAP Library error: %d(%s)\n",
+        DEBUG(SSSDBG_CRIT_FAILURE, ">>> LDAP Library error: %d(%s)\n",
               lerrno, sss_ldap_err2string(lerrno));
         ret = EIO;
         goto done;
diff --git a/src/providers/ldap/sdap_async.c b/src/providers/ldap/sdap_async.c
index f374112935a7befa1d059df97f3119c14d8f5da5..7a4237e97c261baa9cec618b5cef3b348717f401 100644
--- a/src/providers/ldap/sdap_async.c
+++ b/src/providers/ldap/sdap_async.c
@@ -1329,7 +1329,7 @@ static errno_t sdap_get_generic_ext_step(struct tevent_req *req)
     talloc_zfree(state->op);
 
     DEBUG(SSSDBG_TRACE_FUNC,
-         "calling ldap_search_ext with [%s][%s].\n",
+         ">>> calling ldap_search_ext with [%s][%s].\n",
           state->filter ? state->filter : "no filter",
           state->search_base);
     if (DEBUG_IS_SET(SSSDBG_TRACE_LIBS)) {
@@ -1338,7 +1338,7 @@ static errno_t sdap_get_generic_ext_step(struct tevent_req *req)
         if (state->attrs) {
             for (i = 0; state->attrs[i]; i++) {
                 DEBUG(SSSDBG_TRACE_LIBS,
-                      "Requesting attrs: [%s]\n", state->attrs[i]);
+                      ">>> Requesting attrs: [%s]\n", state->attrs[i]);
             }
         }
     }
diff --git a/src/providers/ldap/sdap_async_groups.c b/src/providers/ldap/sdap_async_groups.c
index 08dfa01b1bc0cbde94928a2b577fd55667fbd48a..75fd814efe9694439013fe31823ac4b9d248da41 100644
--- a/src/providers/ldap/sdap_async_groups.c
+++ b/src/providers/ldap/sdap_async_groups.c
@@ -1995,6 +1995,12 @@ static void sdap_get_groups_process(struct tevent_req *subreq)
     DEBUG(SSSDBG_TRACE_FUNC,
           "Search for groups, returned %zu results.\n", count);
 
+    DEBUG(SSSDBG_TRACE_FUNC, ">>> Group contains:\n");
+    for (int j = 0; j < groups[0]->num; j++) {
+        DEBUG(SSSDBG_TRACE_FUNC, ">>>   %d: [%s]\n", j, groups[0]->a[j].name);
+    }
+
+
     if (state->lookup_type == SDAP_LOOKUP_WILDCARD || \
             state->lookup_type == SDAP_LOOKUP_ENUMERATE || \
         count == 0) {
diff --git a/src/providers/ldap/sdap_async_nested_groups.c b/src/providers/ldap/sdap_async_nested_groups.c
index 3e3329c0e8fba1915e2e065abb0cb3f21be36e6f..440d9d355dad6e4a1e599ed27045414c20e71036 100644
--- a/src/providers/ldap/sdap_async_nested_groups.c
+++ b/src/providers/ldap/sdap_async_nested_groups.c
@@ -1055,7 +1055,7 @@ sdap_nested_group_process_send(TALLOC_CTX *mem_ctx,
         goto immediately;
     }
 
-    DEBUG(SSSDBG_TRACE_INTERNAL, "About to process group [%s]\n", orig_dn);
+    DEBUG(SSSDBG_TRACE_INTERNAL, ">>> About to process group [%s]\n", orig_dn);
     PROBE(SDAP_NESTED_GROUP_PROCESS_SEND, state->group_dn);
 
     /* get member list, both direct and external */
@@ -1117,7 +1117,7 @@ sdap_nested_group_process_send(TALLOC_CTX *mem_ctx,
      */
 
     DEBUG(SSSDBG_TRACE_INTERNAL,
-          "Looking up %d/%d members of group [%s]\n",
+          ">>> Looking up %d/%d members of group [%s]\n",
           state->num_missing_total,
           state->members ? state->members->num_values : 0,
           orig_dn);
@@ -1132,7 +1132,7 @@ sdap_nested_group_process_send(TALLOC_CTX *mem_ctx,
                                               state->members, orig_dn,
                                               state->nesting_level);
     } else {
-        DEBUG(SSSDBG_TRACE_INTERNAL, "Members of group [%s] will be "
+        DEBUG(SSSDBG_TRACE_INTERNAL, ">>> Members of group [%s] will be "
                                       "processed individually\n", orig_dn);
         state->deref = false;
         subreq = sdap_nested_group_single_send(state, ev, group_ctx,
-- 
2.7.4

