From b00f9cde90a43a9aa9808f4c25b9cccee6ff8c08 Mon Sep 17 00:00:00 2001
From: Petr Cech <pcech@redhat.com>
Date: Tue, 23 Aug 2016 10:27:53 +0200
Subject: [PATCH 6/7] SYSDB: ldb_modify --> sss_ldb_modify in sysdb

Resolves:
https://fedorahosted.org/sssd/ticket/3060
---
 src/db/sysdb.c            |  2 +-
 src/db/sysdb_gpo.c        |  4 ++--
 src/db/sysdb_idmap.c      |  2 +-
 src/db/sysdb_ops.c        | 24 ++++++++++++------------
 src/db/sysdb_services.c   |  8 ++++----
 src/db/sysdb_subdomains.c |  5 +++--
 src/db/sysdb_sudo.c       |  2 +-
 src/db/sysdb_upgrade.c    | 26 +++++++++++++-------------
 src/db/sysdb_views.c      | 12 ++++++------
 9 files changed, 43 insertions(+), 42 deletions(-)

diff --git a/src/db/sysdb.c b/src/db/sysdb.c
index 0f490bc301a1a3c34769954dc90a1f901c4b0250..06530f30aaadcdfad25d3a4a16d67d13b3fc1044 100644
--- a/src/db/sysdb.c
+++ b/src/db/sysdb.c
@@ -1161,7 +1161,7 @@ errno_t sysdb_set_bool(struct sysdb_ctx *sysdb,
     }
 
     if (res->count) {
-        lret = ldb_modify(sysdb->ldb, msg);
+        lret = sss_ldb_modify(sysdb->ldb, msg);
     } else {
         lret = sss_ldb_add(sysdb->ldb, msg);
     }
diff --git a/src/db/sysdb_gpo.c b/src/db/sysdb_gpo.c
index 170d7b7489704a7e74dea27c3b9c0ce1c1870c1d..20fa1cebed2bf76c2ed649e705e295edcf81094c 100644
--- a/src/db/sysdb_gpo.c
+++ b/src/db/sysdb_gpo.c
@@ -206,7 +206,7 @@ sysdb_gpo_store_gpo(struct sss_domain_info *domain,
             goto done;
         }
 
-        lret = ldb_modify(domain->sysdb->ldb, update_msg);
+        lret = sss_ldb_modify(domain->sysdb->ldb, update_msg);
         if (lret != LDB_SUCCESS) {
             DEBUG(SSSDBG_MINOR_FAILURE,
                   "Failed to modify GPO: [%s](%d)[%s]\n",
@@ -499,7 +499,7 @@ sysdb_gpo_store_gpo_result_setting(struct sss_domain_info *domain,
             }
         }
 
-        lret = ldb_modify(domain->sysdb->ldb, update_msg);
+        lret = sss_ldb_modify(domain->sysdb->ldb, update_msg);
         if (lret != LDB_SUCCESS) {
             DEBUG(SSSDBG_MINOR_FAILURE,
                   "Failed to modify GPO Result: [%s](%d)[%s]\n",
diff --git a/src/db/sysdb_idmap.c b/src/db/sysdb_idmap.c
index f0186760e08470f07f73d4c3563a0097368bb8d6..6ef6efcb379d7a65c3df84b7ab8ff91d6007524f 100644
--- a/src/db/sysdb_idmap.c
+++ b/src/db/sysdb_idmap.c
@@ -245,7 +245,7 @@ sysdb_idmap_store_mapping(struct sss_domain_info *domain,
             }
         }
 
-        lret = ldb_modify(domain->sysdb->ldb, update_msg);
+        lret = sss_ldb_modify(domain->sysdb->ldb, update_msg);
         if (lret != LDB_SUCCESS) {
             DEBUG(SSSDBG_MINOR_FAILURE,
                   "Failed to update mapping: [%s](%d)[%s]\n",
diff --git a/src/db/sysdb_ops.c b/src/db/sysdb_ops.c
index 54dfc1a0c0e6587f9f8d66a43156f05b00127888..72edcbafc596e124d1e54fe5fb47fe60cb1c2631 100644
--- a/src/db/sysdb_ops.c
+++ b/src/db/sysdb_ops.c
@@ -1163,10 +1163,10 @@ static int sysdb_set_cache_entry_attr(struct ldb_context *ldb,
         goto done;
     }
 
-    lret = ldb_modify(ldb, msg);
+    lret = sss_ldb_modify(ldb, msg);
     if (lret != LDB_SUCCESS) {
         DEBUG(SSSDBG_MINOR_FAILURE,
-              "ldb_modify failed: [%s](%d)[%s]\n",
+              "sss_ldb_modify failed: [%s](%d)[%s]\n",
               ldb_strerror(lret), lret, ldb_errstring(ldb));
     }
 
@@ -1535,10 +1535,10 @@ int sysdb_get_new_id(struct sss_domain_info *domain,
         goto done;
     }
 
-    ret = ldb_modify(domain->sysdb->ldb, msg);
+    ret = sss_ldb_modify(domain->sysdb->ldb, msg);
     if (ret != LDB_SUCCESS) {
         DEBUG(SSSDBG_MINOR_FAILURE,
-              "ldb_modify failed: [%s](%d)[%s]\n",
+              "sss_ldb_modify failed: [%s](%d)[%s]\n",
               ldb_strerror(ret), ret, ldb_errstring(domain->sysdb->ldb));
     }
     ret = sysdb_error_to_errno(ret);
@@ -2302,10 +2302,10 @@ int sysdb_mod_group_member(struct sss_domain_info *domain,
         ERROR_OUT(ret, EINVAL, fail);
     }
 
-    ret = ldb_modify(domain->sysdb->ldb, msg);
+    ret = sss_ldb_modify(domain->sysdb->ldb, msg);
     if (ret != LDB_SUCCESS) {
         DEBUG(SSSDBG_MINOR_FAILURE,
-              "ldb_modify failed: [%s](%d)[%s]\n",
+              "sss_ldb_modify failed: [%s](%d)[%s]\n",
               ldb_strerror(ret), ret, ldb_errstring(domain->sysdb->ldb));
     }
     ret = sysdb_error_to_errno(ret);
@@ -3237,7 +3237,7 @@ int sysdb_store_custom(struct sss_domain_info *domain,
     if (add_object) {
         ret = sss_ldb_add(domain->sysdb->ldb, msg);
     } else {
-        ret = ldb_modify(domain->sysdb->ldb, msg);
+        ret = sss_ldb_modify(domain->sysdb->ldb, msg);
     }
     if (ret != LDB_SUCCESS) {
         DEBUG(SSSDBG_CRIT_FAILURE, "Failed to store custom entry: %s(%d)[%s]\n",
@@ -3586,10 +3586,10 @@ int sysdb_delete_user(struct sss_domain_info *domain,
             ret = sysdb_delete_string(msg, SYSDB_GHOST, name);
             if (ret) goto fail;
 
-            ret = ldb_modify(domain->sysdb->ldb, msg);
+            ret = sss_ldb_modify(domain->sysdb->ldb, msg);
             if (ret != LDB_SUCCESS) {
                 DEBUG(SSSDBG_MINOR_FAILURE,
-                      "ldb_modify failed: [%s](%d)[%s]\n",
+                      "sss_ldb_modify failed: [%s](%d)[%s]\n",
                       ldb_strerror(ret), ret,
                       ldb_errstring(domain->sysdb->ldb));
             }
@@ -4441,10 +4441,10 @@ errno_t sysdb_remove_attrs(struct sss_domain_info *domain,
          * attribute in the sysdb will cause other removals to
          * fail.
          */
-        lret = ldb_modify(domain->sysdb->ldb, msg);
+        lret = sss_ldb_modify(domain->sysdb->ldb, msg);
         if (lret != LDB_SUCCESS && lret != LDB_ERR_NO_SUCH_ATTRIBUTE) {
             DEBUG(SSSDBG_MINOR_FAILURE,
-                  "ldb_modify failed: [%s](%d)[%s]\n",
+                  "sss_ldb_modify failed: [%s](%d)[%s]\n",
                   ldb_strerror(lret), lret, ldb_errstring(domain->sysdb->ldb));
             ret = sysdb_error_to_errno(lret);
             goto done;
@@ -4887,7 +4887,7 @@ errno_t sysdb_mark_entry_as_expired_ldb_dn(struct sss_domain_info *dom,
         goto done;
     }
 
-    ret = ldb_modify(dom->sysdb->ldb, msg);
+    ret = sss_ldb_modify(dom->sysdb->ldb, msg);
     if (ret != LDB_SUCCESS) {
         ret = sysdb_error_to_errno(ret);
         goto done;
diff --git a/src/db/sysdb_services.c b/src/db/sysdb_services.c
index 751f1b12f88f7e38ed250793f867afe8f5f8df09..18df34085a86661b23d3168f50ad99e3e4386e4c 100644
--- a/src/db/sysdb_services.c
+++ b/src/db/sysdb_services.c
@@ -585,10 +585,10 @@ sysdb_svc_update(struct sysdb_ctx *sysdb,
         }
     }
 
-    lret = ldb_modify(sysdb->ldb, msg);
+    lret = sss_ldb_modify(sysdb->ldb, msg);
     if (lret != LDB_SUCCESS) {
         DEBUG(SSSDBG_MINOR_FAILURE,
-              "ldb_modify failed: [%s](%d)[%s]\n",
+              "sss_ldb_modify failed: [%s](%d)[%s]\n",
               ldb_strerror(lret), lret, ldb_errstring(sysdb->ldb));
     }
     ret = sysdb_error_to_errno(lret);
@@ -622,10 +622,10 @@ sysdb_svc_remove_alias(struct sysdb_ctx *sysdb,
     ret = sysdb_delete_string(msg, SYSDB_NAME_ALIAS, alias);
     if (ret != EOK) goto done;
 
-    lret = ldb_modify(sysdb->ldb, msg);
+    lret = sss_ldb_modify(sysdb->ldb, msg);
     if (lret != LDB_SUCCESS) {
         DEBUG(SSSDBG_MINOR_FAILURE,
-              "ldb_modify failed: [%s](%d)[%s]\n",
+              "sss_ldb_modify failed: [%s](%d)[%s]\n",
               ldb_strerror(lret), lret, ldb_errstring(sysdb->ldb));
     }
     ret = sysdb_error_to_errno(lret);
diff --git a/src/db/sysdb_subdomains.c b/src/db/sysdb_subdomains.c
index ff83f914f31d566e050c74a3ef5f5745f8c93add..66dd0546a560688e480e5ec1d2d5cfe50428fa8b 100644
--- a/src/db/sysdb_subdomains.c
+++ b/src/db/sysdb_subdomains.c
@@ -21,6 +21,7 @@
 */
 
 #include "util/util.h"
+#include "db/sysdb_ldb_wrapper.h"
 #include "db/sysdb_private.h"
 
 struct sss_domain_info *new_subdomain(TALLOC_CTX *mem_ctx,
@@ -797,7 +798,7 @@ errno_t sysdb_master_domain_add_info(struct sss_domain_info *domain,
         goto done;
     }
 
-    ret = ldb_modify(domain->sysdb->ldb, msg);
+    ret = sss_ldb_modify(domain->sysdb->ldb, msg);
     if (ret != LDB_SUCCESS) {
         DEBUG(SSSDBG_FATAL_FAILURE, "Failed to add subdomain attributes to "
                                      "[%s]: [%d][%s]!\n", domain->name, ret,
@@ -1098,7 +1099,7 @@ errno_t sysdb_subdomain_store(struct sysdb_ctx *sysdb,
         }
     }
 
-    ret = ldb_modify(sysdb->ldb, msg);
+    ret = sss_ldb_modify(sysdb->ldb, msg);
     if (ret != LDB_SUCCESS) {
         DEBUG(SSSDBG_FATAL_FAILURE, "Failed to add subdomain attributes to "
                                      "[%s]: [%d][%s]!\n", name, ret,
diff --git a/src/db/sysdb_sudo.c b/src/db/sysdb_sudo.c
index b080ddd71e6a3380a50f8b11efcc47fc28ea8677..f5cb91691242294de8d7168fc39637e68ef040b6 100644
--- a/src/db/sysdb_sudo.c
+++ b/src/db/sysdb_sudo.c
@@ -546,7 +546,7 @@ static errno_t sysdb_sudo_set_refresh_time(struct sss_domain_info *domain,
     }
 
     if (res->count) {
-        lret = ldb_modify(domain->sysdb->ldb, msg);
+        lret = sss_ldb_modify(domain->sysdb->ldb, msg);
     } else {
         lret = sss_ldb_add(domain->sysdb->ldb, msg);
     }
diff --git a/src/db/sysdb_upgrade.c b/src/db/sysdb_upgrade.c
index ee90b2cda7715f778b2e4de99dff7a29b085d861..5d3dcc1d1c8d441085aebbd86a0b5749c59e4f75 100644
--- a/src/db/sysdb_upgrade.c
+++ b/src/db/sysdb_upgrade.c
@@ -93,7 +93,7 @@ static errno_t update_version(struct upgrade_ctx *ctx)
         goto done;
     }
 
-    ret = ldb_modify(ctx->ldb, msg);
+    ret = sss_ldb_modify(ctx->ldb, msg);
     if (ret != LDB_SUCCESS) {
         ret = sysdb_error_to_errno(ret);
         goto done;
@@ -243,7 +243,7 @@ int sysdb_upgrade_01(struct ldb_context *ldb, const char **ver)
         }
 
         /* ok now we are ready to modify the entry */
-        ret = ldb_modify(ldb, msg);
+        ret = sss_ldb_modify(ldb, msg);
         if (ret != LDB_SUCCESS) {
             ret = sysdb_error_to_errno(ret);
             goto done;
@@ -571,7 +571,7 @@ int sysdb_check_upgrade_02(struct sss_domain_info *domains,
         goto done;
     }
 
-    ret = ldb_modify(ldb, msg);
+    ret = sss_ldb_modify(ldb, msg);
     if (ret != LDB_SUCCESS) {
         ret = sysdb_error_to_errno(ret);
         goto done;
@@ -643,7 +643,7 @@ int sysdb_upgrade_03(struct sysdb_ctx *sysdb, const char **ver)
         goto done;
     }
 
-    ret = ldb_modify(sysdb->ldb, msg);
+    ret = sss_ldb_modify(sysdb->ldb, msg);
     if (ret != LDB_SUCCESS) {
         ret = sysdb_error_to_errno(ret);
         goto done;
@@ -698,7 +698,7 @@ int sysdb_upgrade_04(struct sysdb_ctx *sysdb, const char **ver)
         goto done;
     }
 
-    ret = ldb_modify(sysdb->ldb, msg);
+    ret = sss_ldb_modify(sysdb->ldb, msg);
     if (ret != LDB_SUCCESS) {
         ret = sysdb_error_to_errno(ret);
         goto done;
@@ -784,7 +784,7 @@ int sysdb_upgrade_05(struct sysdb_ctx *sysdb, const char **ver)
         goto done;
     }
 
-    ret = ldb_modify(sysdb->ldb, msg);
+    ret = sss_ldb_modify(sysdb->ldb, msg);
     if (ret != LDB_SUCCESS) {
         ret = sysdb_error_to_errno(ret);
         goto done;
@@ -840,7 +840,7 @@ int sysdb_upgrade_06(struct sysdb_ctx *sysdb, const char **ver)
         goto done;
     }
 
-    ret = ldb_modify(sysdb->ldb, msg);
+    ret = sss_ldb_modify(sysdb->ldb, msg);
     if (ret != LDB_SUCCESS) {
         ret = sysdb_error_to_errno(ret);
         goto done;
@@ -896,7 +896,7 @@ int sysdb_upgrade_07(struct sysdb_ctx *sysdb, const char **ver)
         goto done;
     }
 
-    ret = ldb_modify(sysdb->ldb, msg);
+    ret = sss_ldb_modify(sysdb->ldb, msg);
     if (ret != LDB_SUCCESS) {
         ret = sysdb_error_to_errno(ret);
         goto done;
@@ -958,7 +958,7 @@ int sysdb_upgrade_08(struct sysdb_ctx *sysdb, const char **ver)
         goto done;
     }
 
-    ret = ldb_modify(sysdb->ldb, msg);
+    ret = sss_ldb_modify(sysdb->ldb, msg);
     if (ret != LDB_SUCCESS) {
         ret = sysdb_error_to_errno(ret);
         goto done;
@@ -1015,7 +1015,7 @@ int sysdb_upgrade_09(struct sysdb_ctx *sysdb, const char **ver)
         goto done;
     }
 
-    ret = ldb_modify(sysdb->ldb, msg);
+    ret = sss_ldb_modify(sysdb->ldb, msg);
     if (ret != LDB_SUCCESS) {
         ret = sysdb_error_to_errno(ret);
         goto done;
@@ -1328,7 +1328,7 @@ int sysdb_upgrade_12(struct sysdb_ctx *sysdb, const char **ver)
         goto done;
     }
 
-    ret = ldb_modify(sysdb->ldb, msg);
+    ret = sss_ldb_modify(sysdb->ldb, msg);
     if (ret != LDB_SUCCESS) {
         ret = sysdb_error_to_errno(ret);
         goto done;
@@ -1586,7 +1586,7 @@ int sysdb_upgrade_15(struct sysdb_ctx *sysdb, const char **ver)
         goto done;
     }
 
-    ret = ldb_modify(sysdb->ldb, msg);
+    ret = sss_ldb_modify(sysdb->ldb, msg);
     if (ret != LDB_SUCCESS) {
         ret = sysdb_error_to_errno(ret);
         goto done;
@@ -1637,7 +1637,7 @@ int sysdb_upgrade_16(struct sysdb_ctx *sysdb, const char **ver)
         goto done;
     }
 
-    ret = ldb_modify(sysdb->ldb, msg);
+    ret = sss_ldb_modify(sysdb->ldb, msg);
     if (ret != LDB_SUCCESS) {
         ret = sysdb_error_to_errno(ret);
         goto done;
diff --git a/src/db/sysdb_views.c b/src/db/sysdb_views.c
index 603241c625ac4ab209cf23c8340a25ee827d9680..08cf878ba76250efba9aadb424bf61ef3ec64101 100644
--- a/src/db/sysdb_views.c
+++ b/src/db/sysdb_views.c
@@ -162,7 +162,7 @@ errno_t sysdb_update_view_name(struct sysdb_ctx *sysdb,
     }
 
     if (view_container_exists) {
-        ret = ldb_modify(sysdb->ldb, msg);
+        ret = sss_ldb_modify(sysdb->ldb, msg);
     } else {
         ret = sss_ldb_add(sysdb->ldb, msg);
     }
@@ -284,10 +284,10 @@ errno_t sysdb_invalidate_overrides(struct sysdb_ctx *sysdb)
     for (c = 0; c < res->count; c++) {
         msg->dn = res->msgs[c]->dn;
 
-        ret = ldb_modify(sysdb->ldb, msg);
+        ret = sss_ldb_modify(sysdb->ldb, msg);
         if (ret != LDB_SUCCESS && ret != LDB_ERR_NO_SUCH_ATTRIBUTE) {
             DEBUG(SSSDBG_OP_FAILURE,
-                  "ldb_modify failed: [%s](%d)[%s]\n",
+                  "sss_ldb_modify failed: [%s](%d)[%s]\n",
                   ldb_strerror(ret), ret, ldb_errstring(sysdb->ldb));
             ret = sysdb_error_to_errno(ret);
             goto done;
@@ -307,10 +307,10 @@ errno_t sysdb_invalidate_overrides(struct sysdb_ctx *sysdb)
     for (c = 0; c < res->count; c++) {
         msg->dn = res->msgs[c]->dn;
 
-        ret = ldb_modify(sysdb->ldb, msg);
+        ret = sss_ldb_modify(sysdb->ldb, msg);
         if (ret != LDB_SUCCESS && ret != LDB_ERR_NO_SUCH_ATTRIBUTE) {
             DEBUG(SSSDBG_OP_FAILURE,
-                  "ldb_modify failed: [%s](%d)[%s]\n",
+                  "sss_ldb_modify failed: [%s](%d)[%s]\n",
                   ldb_strerror(ret), ret, ldb_errstring(sysdb->ldb));
             ret = sysdb_error_to_errno(ret);
             goto done;
@@ -605,7 +605,7 @@ errno_t sysdb_store_override(struct sss_domain_info *domain,
             goto done;
         }
 
-        ret = ldb_modify(domain->sysdb->ldb, msg);
+        ret = sss_ldb_modify(domain->sysdb->ldb, msg);
         if (ret != LDB_SUCCESS) {
             DEBUG(SSSDBG_CRIT_FAILURE,
                   "Failed to store override DN: %s(%d)[%s]\n",
-- 
2.7.4

