a99c7c
From 7c5540bb47799b4db95673d22f61995ad5c56440 Mon Sep 17 00:00:00 2001
a99c7c
From: Rob Crittenden <rcritten@redhat.com>
a99c7c
Date: Mon, 31 Jan 2022 17:31:50 -0500
a99c7c
Subject: [PATCH] Remove ipa-join errors from behind the debug option
a99c7c
a99c7c
This brings it inline with the previous XML-RPC output which
a99c7c
only hid the request and response from the output and not
a99c7c
any errors returned.
a99c7c
a99c7c
https://pagure.io/freeipa/issue/9103
a99c7c
a99c7c
Signed-off-by: Rob Crittenden <rcritten@redhat.com>
a99c7c
Reviewed-By: Florence Blanc-Renaud <frenaud@redhat.com>
a99c7c
Reviewed-By: Peter Keresztes Schmidt <carbenium@outlook.com>
a99c7c
---
a99c7c
 client/ipa-join.c | 27 +++++++++------------------
a99c7c
 1 file changed, 9 insertions(+), 18 deletions(-)
a99c7c
a99c7c
diff --git a/client/ipa-join.c b/client/ipa-join.c
a99c7c
index d98739a9abfb01ecf619187483bfc6677957d498..5888a33bf221eb5d455b2adcfa0f33b38f0969ca 100644
a99c7c
--- a/client/ipa-join.c
a99c7c
+++ b/client/ipa-join.c
a99c7c
@@ -743,8 +743,7 @@ jsonrpc_request(const char *ipaserver, const json_t *json, curl_buffer *response
a99c7c
 
a99c7c
     json_str = json_dumps(json, 0);
a99c7c
     if (!json_str) {
a99c7c
-        if (debug)
a99c7c
-            fprintf(stderr, _("json_dumps() failed\n"));
a99c7c
+        fprintf(stderr, _("json_dumps() failed\n"));
a99c7c
 
a99c7c
         rval = 17;
a99c7c
         goto cleanup;
a99c7c
@@ -758,8 +757,7 @@ jsonrpc_request(const char *ipaserver, const json_t *json, curl_buffer *response
a99c7c
     CURLcode res = curl_easy_perform(curl);
a99c7c
     if (res != CURLE_OK)
a99c7c
     {
a99c7c
-        if (debug)
a99c7c
-            fprintf(stderr, _("JSON-RPC call failed: %s\n"), curl_easy_strerror(res));
a99c7c
+        fprintf(stderr, _("JSON-RPC call failed: %s\n"), curl_easy_strerror(res));
a99c7c
 
a99c7c
         rval = 17;
a99c7c
         goto cleanup;
a99c7c
@@ -769,8 +767,7 @@ jsonrpc_request(const char *ipaserver, const json_t *json, curl_buffer *response
a99c7c
     curl_easy_getinfo(curl, CURLINFO_RESPONSE_CODE, &resp_code);
a99c7c
 
a99c7c
     if (resp_code != 200) {
a99c7c
-        if (debug)
a99c7c
-            fprintf(stderr, _("JSON-RPC call failed with status code: %li\n"), resp_code);
a99c7c
+        fprintf(stderr, _("JSON-RPC call failed with status code: %li\n"), resp_code);
a99c7c
 
a99c7c
         if (!quiet && resp_code == 401)
a99c7c
             fprintf(stderr, _("JSON-RPC call was unauthorized. Check your credentials.\n"));
a99c7c
@@ -848,8 +845,7 @@ jsonrpc_parse_response(const char *payload, json_t** j_result_obj, bool quiet) {
a99c7c
 
a99c7c
     j_root = json_loads(payload, 0, &j_error);
a99c7c
     if (!j_root) {
a99c7c
-        if (debug)
a99c7c
-            fprintf(stderr, _("Parsing JSON-RPC response failed: %s\n"), j_error.text);
a99c7c
+        fprintf(stderr, _("Parsing JSON-RPC response failed: %s\n"), j_error.text);
a99c7c
 
a99c7c
         rval = 17;
a99c7c
         goto cleanup;
a99c7c
@@ -864,8 +860,7 @@ jsonrpc_parse_response(const char *payload, json_t** j_result_obj, bool quiet) {
a99c7c
 
a99c7c
     *j_result_obj = json_object_get(j_root, "result");
a99c7c
     if (!*j_result_obj) {
a99c7c
-        if (debug)
a99c7c
-            fprintf(stderr, _("Parsing JSON-RPC response failed: no 'result' value found.\n"));
a99c7c
+        fprintf(stderr, _("Parsing JSON-RPC response failed: no 'result' value found.\n"));
a99c7c
 
a99c7c
         rval = 17;
a99c7c
         goto cleanup;
a99c7c
@@ -897,8 +892,7 @@ jsonrpc_parse_join_response(const char *payload, join_info *join_i, bool quiet)
a99c7c
                        &tmp_hostdn,
a99c7c
                        "krbprincipalname", &tmp_princ,
a99c7c
                        "krblastpwdchange", &tmp_pwdch) != 0) {
a99c7c
-        if (debug)
a99c7c
-            fprintf(stderr, _("Extracting the data from the JSON-RPC response failed: %s\n"), j_error.text);
a99c7c
+        fprintf(stderr, _("Extracting the data from the JSON-RPC response failed: %s\n"), j_error.text);
a99c7c
 
a99c7c
         rval = 17;
a99c7c
         goto cleanup;
a99c7c
@@ -941,8 +935,7 @@ join_krb5_jsonrpc(const char *ipaserver, const char *hostname, char **hostdn, co
a99c7c
                              "nshardwareplatform", uinfo.machine);
a99c7c
 
a99c7c
     if (!json_req) {
a99c7c
-        if (debug)
a99c7c
-            fprintf(stderr, _("json_pack_ex() failed: %s\n"), j_error.text);
a99c7c
+        fprintf(stderr, _("json_pack_ex() failed: %s\n"), j_error.text);
a99c7c
 
a99c7c
         rval = 17;
a99c7c
         goto cleanup;
a99c7c
@@ -990,8 +983,7 @@ jsonrpc_parse_unenroll_response(const char *payload, bool* result, bool quiet) {
a99c7c
 
a99c7c
     if (json_unpack_ex(j_result_obj, &j_error, 0, "{s:b}",
a99c7c
                        "result", result) != 0) {
a99c7c
-        if (debug)
a99c7c
-            fprintf(stderr, _("Extracting the data from the JSON-RPC response failed: %s\n"), j_error.text);
a99c7c
+        fprintf(stderr, _("Extracting the data from the JSON-RPC response failed: %s\n"), j_error.text);
a99c7c
 
a99c7c
         rval = 20;
a99c7c
         goto cleanup;
a99c7c
@@ -1021,8 +1013,7 @@ jsonrpc_unenroll_host(const char *ipaserver, const char *host, bool quiet) {
a99c7c
                             host);
a99c7c
 
a99c7c
     if (!json_req) {
a99c7c
-        if (debug)
a99c7c
-            fprintf(stderr, _("json_pack_ex() failed: %s\n"), j_error.text);
a99c7c
+        fprintf(stderr, _("json_pack_ex() failed: %s\n"), j_error.text);
a99c7c
 
a99c7c
         rval = 17;
a99c7c
         goto cleanup;
a99c7c
-- 
a99c7c
2.34.1
a99c7c