Blame SOURCES/0098-ipa_s2n_get_acct_info_send-provide-correct-req_input.patch

bb7cd1
From 250777f65dc23917c436d3ecf0fe21abc65db65e Mon Sep 17 00:00:00 2001
bb7cd1
From: =?UTF-8?q?Pavel=20B=C5=99ezina?= <pbrezina@redhat.com>
bb7cd1
Date: Mon, 3 Apr 2017 12:09:44 +0200
bb7cd1
Subject: [PATCH 98/99] ipa_s2n_get_acct_info_send: provide correct req_input
bb7cd1
 name
bb7cd1
MIME-Version: 1.0
bb7cd1
Content-Type: text/plain; charset=UTF-8
bb7cd1
Content-Transfer-Encoding: 8bit
bb7cd1
bb7cd1
To avoid crash.
bb7cd1
bb7cd1
Resolves:
bb7cd1
https://pagure.io/SSSD/sssd/issue/3358
bb7cd1
bb7cd1
Reviewed-by: Sumit Bose <sbose@redhat.com>
bb7cd1
Reviewed-by: Lukáš Slebodník <lslebodn@redhat.com>
bb7cd1
(cherry picked from commit b07bcd8b99590bd404733fa7ff1add37c55126bc)
bb7cd1
---
bb7cd1
 src/providers/ipa/ipa_s2n_exop.c | 40 ++++++++++++++++++++++++++++++++++++----
bb7cd1
 1 file changed, 36 insertions(+), 4 deletions(-)
bb7cd1
bb7cd1
diff --git a/src/providers/ipa/ipa_s2n_exop.c b/src/providers/ipa/ipa_s2n_exop.c
bb7cd1
index 8a3391b4093f1547d84fe44a0f24b1d063d1e28c..2173db357700499a6140aa61841e443139981483 100644
bb7cd1
--- a/src/providers/ipa/ipa_s2n_exop.c
bb7cd1
+++ b/src/providers/ipa/ipa_s2n_exop.c
bb7cd1
@@ -1054,6 +1054,33 @@ static const char *ipa_s2n_reqtype2str(enum request_types request_type)
bb7cd1
     return "Unknown request type";
bb7cd1
 }
bb7cd1
 
bb7cd1
+static const char *ipa_s2n_reqinp2str(TALLOC_CTX *mem_ctx,
bb7cd1
+                                      struct req_input *req_input)
bb7cd1
+{
bb7cd1
+    const char *str = NULL;
bb7cd1
+
bb7cd1
+    switch (req_input->type) {
bb7cd1
+    case REQ_INP_NAME:
bb7cd1
+        str = talloc_strdup(mem_ctx, req_input->inp.name);
bb7cd1
+        break;
bb7cd1
+    case REQ_INP_SECID:
bb7cd1
+        str = talloc_strdup(mem_ctx, req_input->inp.secid);
bb7cd1
+        break;
bb7cd1
+    case REQ_INP_CERT:
bb7cd1
+        str = talloc_strdup(mem_ctx, req_input->inp.cert);
bb7cd1
+        break;
bb7cd1
+    case REQ_INP_ID:
bb7cd1
+        str = talloc_asprintf(mem_ctx, "%u", req_input->inp.id);
bb7cd1
+        break;
bb7cd1
+    }
bb7cd1
+
bb7cd1
+    if (str == NULL) {
bb7cd1
+        DEBUG(SSSDBG_CRIT_FAILURE, "Out of memory!\n");
bb7cd1
+    }
bb7cd1
+
bb7cd1
+    return str;
bb7cd1
+}
bb7cd1
+
bb7cd1
 struct ipa_s2n_get_list_state {
bb7cd1
     struct tevent_context *ev;
bb7cd1
     struct ipa_id_ctx *ipa_ctx;
bb7cd1
@@ -1410,6 +1437,7 @@ struct tevent_req *ipa_s2n_get_acct_info_send(TALLOC_CTX *mem_ctx,
bb7cd1
     struct tevent_req *req;
bb7cd1
     struct tevent_req *subreq;
bb7cd1
     struct berval *bv_req = NULL;
bb7cd1
+    const char *input;
bb7cd1
     int ret = EFAULT;
bb7cd1
     bool is_v1 = false;
bb7cd1
 
bb7cd1
@@ -1454,10 +1482,14 @@ struct tevent_req *ipa_s2n_get_acct_info_send(TALLOC_CTX *mem_ctx,
bb7cd1
         goto fail;
bb7cd1
     }
bb7cd1
 
bb7cd1
-    DEBUG(SSSDBG_TRACE_FUNC, "Sending request_type: [%s] for trust user [%s] "
bb7cd1
-                            "to IPA server\n",
bb7cd1
-                            ipa_s2n_reqtype2str(state->request_type),
bb7cd1
-                            req_input->inp.name);
bb7cd1
+    if (DEBUG_IS_SET(SSSDBG_TRACE_FUNC)) {
bb7cd1
+        input = ipa_s2n_reqinp2str(state, req_input);
bb7cd1
+        DEBUG(SSSDBG_TRACE_FUNC,
bb7cd1
+              "Sending request_type: [%s] for trust user [%s] to IPA server\n",
bb7cd1
+              ipa_s2n_reqtype2str(state->request_type),
bb7cd1
+              input);
bb7cd1
+        talloc_zfree(input);
bb7cd1
+    }
bb7cd1
 
bb7cd1
     subreq = ipa_s2n_exop_send(state, state->ev, state->sh, is_v1,
bb7cd1
                                state->exop_timeout, bv_req);
bb7cd1
-- 
bb7cd1
2.9.3
bb7cd1