From cec36d4c66e6b5a005c792f4c6a37243b6828b3b Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Pavel=20B=C5=99ezina?= <pbrezina@redhat.com>
Date: Mon, 5 Sep 2011 10:51:32 +0200
Subject: [PATCH 2/2] sss_ldap_err2string() - ldap_err2string() to
 sss_ldap_err2string()

https://fedorahosted.org/sssd/ticket/986
---
 src/providers/ldap/sdap.c                  |   28 ++++++++++++------------
 src/providers/ldap/sdap_async.c            |   10 ++++----
 src/providers/ldap/sdap_async_connection.c |   32 ++++++++++++++--------------
 src/util/sss_ldap.c                        |    6 ++--
 4 files changed, 38 insertions(+), 38 deletions(-)

diff --git a/src/providers/ldap/sdap.c b/src/providers/ldap/sdap.c
index 61044bb..02504a4 100644
--- a/src/providers/ldap/sdap.c
+++ b/src/providers/ldap/sdap.c
@@ -106,7 +106,7 @@ int sdap_parse_entry(TALLOC_CTX *memctx,
     ret = ldap_set_option(sh->ldap, LDAP_OPT_RESULT_CODE, &lerrno);
     if (ret != LDAP_OPT_SUCCESS) {
         DEBUG(1, ("ldap_set_option failed [%s], ignored.\n",
-                  ldap_err2string(ret)));
+                  sss_ldap_err2string(ret)));
     }
 
     attrs = sysdb_new_attrs(memctx);
@@ -116,7 +116,7 @@ int sdap_parse_entry(TALLOC_CTX *memctx,
     if (!str) {
         ldap_get_option(sh->ldap, LDAP_OPT_RESULT_CODE, &lerrno);
         DEBUG(1, ("ldap_get_dn failed: %d(%s)\n",
-                  lerrno, ldap_err2string(lerrno)));
+                  lerrno, sss_ldap_err2string(lerrno)));
         ret = EIO;
         goto fail;
     }
@@ -164,7 +164,7 @@ int sdap_parse_entry(TALLOC_CTX *memctx,
     if (!str) {
         ldap_get_option(sh->ldap, LDAP_OPT_RESULT_CODE, &lerrno);
         DEBUG(1, ("Entry has no attributes [%d(%s)]!?\n",
-                  lerrno, ldap_err2string(lerrno)));
+                  lerrno, sss_ldap_err2string(lerrno)));
         if (map) {
             ret = EINVAL;
             goto fail;
@@ -203,7 +203,7 @@ int sdap_parse_entry(TALLOC_CTX *memctx,
                 ldap_get_option(sh->ldap, LDAP_OPT_RESULT_CODE, &lerrno);
                 if (lerrno != LDAP_SUCCESS) {
                     DEBUG(1, ("LDAP Library error: %d(%s)",
-                              lerrno, ldap_err2string(lerrno)));
+                              lerrno, sss_ldap_err2string(lerrno)));
                     ret = EIO;
                     goto fail;
                 }
@@ -235,7 +235,7 @@ int sdap_parse_entry(TALLOC_CTX *memctx,
     ldap_get_option(sh->ldap, LDAP_OPT_RESULT_CODE, &lerrno);
     if (lerrno) {
         DEBUG(1, ("LDAP Library error: %d(%s)",
-                  lerrno, ldap_err2string(lerrno)));
+                  lerrno, sss_ldap_err2string(lerrno)));
         ret = EIO;
         goto fail;
     }
@@ -449,14 +449,14 @@ int sdap_get_msg_dn(TALLOC_CTX *memctx, struct sdap_handle *sh,
     ret = ldap_set_option(sh->ldap, LDAP_OPT_RESULT_CODE, &lerrno);
     if (ret != LDAP_OPT_SUCCESS) {
         DEBUG(1, ("ldap_set_option failed [%s], ignored.\n",
-                  ldap_err2string(ret)));
+                  sss_ldap_err2string(ret)));
     }
 
     str = ldap_get_dn(sh->ldap, sm->msg);
     if (!str) {
         ldap_get_option(sh->ldap, LDAP_OPT_RESULT_CODE, &lerrno);
         DEBUG(1, ("ldap_get_dn failed: %d(%s)\n",
-                  lerrno, ldap_err2string(lerrno)));
+                  lerrno, sss_ldap_err2string(lerrno)));
         return EIO;
     }
 
@@ -498,7 +498,7 @@ errno_t setup_tls_config(struct dp_option *basic_opts)
         ret = ldap_set_option(NULL, LDAP_OPT_X_TLS_REQUIRE_CERT,
                               &ldap_opt_x_tls_require_cert);
         if (ret != LDAP_OPT_SUCCESS) {
-            DEBUG(1, ("ldap_set_option failed: %s\n", ldap_err2string(ret)));
+            DEBUG(1, ("ldap_set_option failed: %s\n", sss_ldap_err2string(ret)));
             return EIO;
         }
     }
@@ -507,7 +507,7 @@ errno_t setup_tls_config(struct dp_option *basic_opts)
     if (tls_opt) {
         ret = ldap_set_option(NULL, LDAP_OPT_X_TLS_CACERTFILE, tls_opt);
         if (ret != LDAP_OPT_SUCCESS) {
-            DEBUG(1, ("ldap_set_option failed: %s\n", ldap_err2string(ret)));
+            DEBUG(1, ("ldap_set_option failed: %s\n", sss_ldap_err2string(ret)));
             return EIO;
         }
     }
@@ -516,7 +516,7 @@ errno_t setup_tls_config(struct dp_option *basic_opts)
     if (tls_opt) {
         ret = ldap_set_option(NULL, LDAP_OPT_X_TLS_CACERTDIR, tls_opt);
         if (ret != LDAP_OPT_SUCCESS) {
-            DEBUG(1, ("ldap_set_option failed: %s\n", ldap_err2string(ret)));
+            DEBUG(1, ("ldap_set_option failed: %s\n", sss_ldap_err2string(ret)));
             return EIO;
         }
     }
@@ -525,7 +525,7 @@ errno_t setup_tls_config(struct dp_option *basic_opts)
     if (tls_opt) {
         ret = ldap_set_option(NULL, LDAP_OPT_X_TLS_CERTFILE, tls_opt);
         if (ret != LDAP_OPT_SUCCESS) {
-            DEBUG(1, ("ldap_set_option failed: %s\n", ldap_err2string(ret)));
+            DEBUG(1, ("ldap_set_option failed: %s\n", sss_ldap_err2string(ret)));
             return EIO;
         }
     }
@@ -534,7 +534,7 @@ errno_t setup_tls_config(struct dp_option *basic_opts)
     if (tls_opt) {
         ret = ldap_set_option(NULL, LDAP_OPT_X_TLS_KEYFILE, tls_opt);
         if (ret != LDAP_OPT_SUCCESS) {
-            DEBUG(1, ("ldap_set_option failed: %s\n", ldap_err2string(ret)));
+            DEBUG(1, ("ldap_set_option failed: %s\n", sss_ldap_err2string(ret)));
             return EIO;
         }
     }
@@ -543,7 +543,7 @@ errno_t setup_tls_config(struct dp_option *basic_opts)
     if (tls_opt) {
         ret = ldap_set_option(NULL, LDAP_OPT_X_TLS_CIPHER_SUITE, tls_opt);
         if (ret != LDAP_OPT_SUCCESS) {
-            DEBUG(1, ("ldap_set_option failed: %s\n", ldap_err2string(ret)));
+            DEBUG(1, ("ldap_set_option failed: %s\n", sss_ldap_err2string(ret)));
             return EIO;
         }
     }
@@ -910,7 +910,7 @@ int sdap_control_create(struct sdap_handle *sh, const char *oid, int iscritical,
         ret = sss_ldap_control_create(oid, iscritical, value, dupval, ctrlp);
         if (ret != LDAP_SUCCESS) {
             DEBUG(1, ("sss_ldap_control_create failed [%d][%s].\n",
-                      ret, ldap_err2string(ret)));
+                      ret, sss_ldap_err2string(ret)));
         }
     } else {
         DEBUG(3, ("Server does not support the requested control [%s].\n", oid));
diff --git a/src/providers/ldap/sdap_async.c b/src/providers/ldap/sdap_async.c
index 6f73310..c3fe2ac 100644
--- a/src/providers/ldap/sdap_async.c
+++ b/src/providers/ldap/sdap_async.c
@@ -637,7 +637,7 @@ static void sdap_exop_modify_passwd_done(struct sdap_op *op,
     }
 
     DEBUG(3, ("ldap_extended_operation result: %s(%d), %s\n",
-              ldap_err2string(state->result), state->result, errmsg));
+            sss_ldap_err2string(state->result), state->result, errmsg));
 
     if (state->result != LDAP_SUCCESS) {
         if (errmsg) {
@@ -1016,7 +1016,7 @@ static errno_t sdap_get_generic_ext_step(struct tevent_req *req)
     ldap_control_free(page_control);
     state->serverctrls[state->nserverctrls] = NULL;
     if (lret != LDAP_SUCCESS) {
-        DEBUG(3, ("ldap_search_ext failed: %s\n", ldap_err2string(lret)));
+        DEBUG(3, ("ldap_search_ext failed: %s\n", sss_ldap_err2string(lret)));
         if (lret == LDAP_SERVER_DOWN) {
             ret = ETIMEDOUT;
             optret = sss_ldap_get_diagnostic_msg(state, state->sh->ldap,
@@ -1027,7 +1027,7 @@ static errno_t sdap_get_generic_ext_step(struct tevent_req *req)
             }
             else {
                 sss_log(SSS_LOG_ERR, "LDAP connection error, %s",
-                                     ldap_err2string(lret));
+                                     sss_ldap_err2string(lret));
             }
         }
 
@@ -1103,11 +1103,11 @@ static void sdap_get_generic_ext_done(struct sdap_op *op,
         }
 
         DEBUG(6, ("Search result: %s(%d), %s\n",
-                  ldap_err2string(result), result, errmsg));
+                  sss_ldap_err2string(result), result, errmsg));
 
         if (result != LDAP_SUCCESS && result != LDAP_NO_SUCH_OBJECT) {
             DEBUG(2, ("Unexpected result from ldap: %s(%d), %s\n",
-                      ldap_err2string(result), result, errmsg));
+                      sss_ldap_err2string(result), result, errmsg));
         }
         ldap_memfree(errmsg);
 
diff --git a/src/providers/ldap/sdap_async_connection.c b/src/providers/ldap/sdap_async_connection.c
index 83e6670..c69b9bc 100644
--- a/src/providers/ldap/sdap_async_connection.c
+++ b/src/providers/ldap/sdap_async_connection.c
@@ -284,13 +284,13 @@ static void sdap_sys_connect_done(struct tevent_req *subreq)
                                              &errmsg);
         if (optret == LDAP_SUCCESS) {
             DEBUG(3, ("ldap_start_tls failed: [%s] [%s]\n",
-                      ldap_err2string(lret),
+                      sss_ldap_err2string(lret),
                       errmsg));
             sss_log(SSS_LOG_ERR, "Could not start TLS. %s", errmsg);
         }
         else {
             DEBUG(3, ("ldap_start_tls failed: [%s]\n",
-                      ldap_err2string(lret)));
+                      sss_ldap_err2string(lret)));
             sss_log(SSS_LOG_ERR, "Could not start TLS. "
                                  "Check for certificate issues.");
         }
@@ -351,7 +351,7 @@ static void sdap_connect_done(struct sdap_op *op,
     }
 
     DEBUG(3, ("START TLS result: %s(%d), %s\n",
-              ldap_err2string(state->result), state->result, errmsg));
+              sss_ldap_err2string(state->result), state->result, errmsg));
     ldap_memfree(errmsg);
 
     if (ldap_tls_inplace(state->sh->ldap)) {
@@ -368,13 +368,13 @@ static void sdap_connect_done(struct sdap_op *op,
                                              &tlserr);
         if (optret == LDAP_SUCCESS) {
             DEBUG(3, ("ldap_install_tls failed: [%s] [%s]\n",
-                      ldap_err2string(ret),
+                      sss_ldap_err2string(ret),
                       tlserr));
             sss_log(SSS_LOG_ERR, "Could not start TLS encryption. %s", tlserr);
         }
         else {
             DEBUG(3, ("ldap_install_tls failed: [%s]\n",
-                      ldap_err2string(ret)));
+                      sss_ldap_err2string(ret)));
             sss_log(SSS_LOG_ERR, "Could not start TLS encryption. "
                                  "Check for certificate issues.");
         }
@@ -472,7 +472,7 @@ static struct tevent_req *simple_bind_send(TALLOC_CTX *memctx,
             ret = LDAP_LOCAL_ERROR;
         } else {
             DEBUG(1, ("ldap_bind failed (%d)[%s]\n",
-                      ldap_err, ldap_err2string(ldap_err)));
+                      ldap_err, sss_ldap_err2string(ldap_err)));
             ret = ldap_err;
         }
         goto fail;
@@ -588,7 +588,7 @@ static void simple_bind_done(struct sdap_op *op,
     }
 
     DEBUG(3, ("Bind result: %s(%d), %s\n",
-              ldap_err2string(state->result), state->result, errmsg));
+              sss_ldap_err2string(state->result), state->result, errmsg));
 
     ret = LDAP_SUCCESS;
 done:
@@ -667,7 +667,7 @@ static struct tevent_req *sasl_bind_send(TALLOC_CTX *memctx,
     state->result = ret;
     if (ret != LDAP_SUCCESS) {
         DEBUG(1, ("ldap_sasl_bind failed (%d)[%s]\n",
-                  ret, ldap_err2string(ret)));
+                  ret, sss_ldap_err2string(ret)));
         goto fail;
     }
 
@@ -1561,10 +1561,10 @@ static int synchronous_tls_setup(LDAP *ldap)
         optret = sss_ldap_get_diagnostic_msg(tmp_ctx, ldap, &errmsg);
         if (optret == LDAP_SUCCESS) {
             DEBUG(3, ("ldap_start_tls failed: [%s] [%s]\n",
-                      ldap_err2string(lret), errmsg));
+                      sss_ldap_err2string(lret), errmsg));
             sss_log(SSS_LOG_ERR, "Could not start TLS. %s", errmsg);
         } else {
-            DEBUG(3, ("ldap_start_tls failed: [%s]\n", ldap_err2string(lret)));
+            DEBUG(3, ("ldap_start_tls failed: [%s]\n", sss_ldap_err2string(lret)));
             sss_log(SSS_LOG_ERR, "Could not start TLS. "
                                  "Check for certificate issues.");
         }
@@ -1583,12 +1583,12 @@ static int synchronous_tls_setup(LDAP *ldap)
                              0);
     if (lret != LDAP_SUCCESS) {
         DEBUG(2, ("ldap_parse_result failed (%d) [%d][%s]\n", msgid, lret,
-                  ldap_err2string(lret)));
+                  sss_ldap_err2string(lret)));
         goto done;
     }
 
     DEBUG(3, ("START TLS result: %s(%d), %s\n",
-              ldap_err2string(ldaperr), ldaperr, errmsg));
+              sss_ldap_err2string(ldaperr), ldaperr, errmsg));
     ldap_memfree(errmsg);
 
     if (ldap_tls_inplace(ldap)) {
@@ -1603,11 +1603,11 @@ static int synchronous_tls_setup(LDAP *ldap)
         optret = sss_ldap_get_diagnostic_msg(tmp_ctx, ldap, &errmsg);
         if (optret == LDAP_SUCCESS) {
             DEBUG(3, ("ldap_install_tls failed: [%s] [%s]\n",
-                      ldap_err2string(lret), errmsg));
+                      sss_ldap_err2string(lret), errmsg));
             sss_log(SSS_LOG_ERR, "Could not start TLS encryption. %s", errmsg);
         } else {
             DEBUG(3, ("ldap_install_tls failed: [%s]\n",
-                      ldap_err2string(lret)));
+                      sss_ldap_err2string(lret)));
             sss_log(SSS_LOG_ERR, "Could not start TLS encryption. "
                                  "Check for certificate issues.");
         }
@@ -1680,7 +1680,7 @@ static int sdap_rebind_proc(LDAP *ldap, LDAP_CONST char *url, ber_tag_t request,
                                request_controls, NULL, NULL);
         if (ret != LDAP_SUCCESS) {
             DEBUG(1, ("ldap_sasl_bind_s failed (%d)[%s]\n", ret,
-                      ldap_err2string(ret)));
+                      sss_ldap_err2string(ret)));
         }
     } else {
         sasl_bind_state = talloc_zero(tmp_ctx, struct sasl_bind_state);
@@ -1698,7 +1698,7 @@ static int sdap_rebind_proc(LDAP *ldap, LDAP_CONST char *url, ber_tag_t request,
                                            sasl_bind_state);
         if (ret != LDAP_SUCCESS) {
             DEBUG(1, ("ldap_sasl_interactive_bind_s failed (%d)[%s]\n", ret,
-                      ldap_err2string(ret)));
+                      sss_ldap_err2string(ret)));
         }
     }
 
diff --git a/src/util/sss_ldap.c b/src/util/sss_ldap.c
index e799e43..afff22f 100644
--- a/src/util/sss_ldap.c
+++ b/src/util/sss_ldap.c
@@ -387,7 +387,7 @@ fail:
     if (ret == LDAP_SUCCESS) {
         tevent_req_done(req);
     } else {
-        DEBUG(1, ("ldap_initialize failed [%s].\n", ldap_err2string(ret)));
+        DEBUG(1, ("ldap_initialize failed [%s].\n", sss_ldap_err2string(ret)));
         if (ret == LDAP_SERVER_DOWN) {
             tevent_req_error(req, ETIMEDOUT);
         } else {
@@ -436,7 +436,7 @@ static void sss_ldap_init_sys_connect_done(struct tevent_req *subreq)
 
     lret = ldap_init_fd(state->sd, LDAP_PROTO_TCP, state->uri, &state->ldap);
     if (lret != LDAP_SUCCESS) {
-        DEBUG(1, ("ldap_init_fd failed: %s\n", ldap_err2string(lret)));
+        DEBUG(1, ("ldap_init_fd failed: %s\n", sss_ldap_err2string(lret)));
         close(state->sd);
         if (lret == LDAP_SERVER_DOWN) {
             tevent_req_error(req, ETIMEDOUT);
@@ -453,7 +453,7 @@ static void sss_ldap_init_sys_connect_done(struct tevent_req *subreq)
                 DEBUG(5, ("TLS/SSL already in place.\n"));
             } else {
                 DEBUG(1, ("ldap_install_tls failed: %s\n",
-                          ldap_err2string(lret)));
+                          sss_ldap_err2string(lret)));
 
                 tevent_req_error(req, EIO);
                 return;
-- 
1.7.6
