dpward / rpms / sssd

Forked from rpms/sssd 3 years ago
Clone

Blame SOURCES/0056-sysdb-do-not-use-LDB_SCOPE_ONELEVEL.patch

ced1f5
From c36d5d56e62f879dbc1c58155097dfc26746a7f4 Mon Sep 17 00:00:00 2001
ced1f5
From: Sumit Bose <sbose@redhat.com>
ced1f5
Date: Tue, 14 Nov 2017 13:09:18 +0100
ced1f5
Subject: [PATCH 56/57] sysdb: do not use LDB_SCOPE_ONELEVEL
ced1f5
MIME-Version: 1.0
ced1f5
Content-Type: text/plain; charset=UTF-8
ced1f5
Content-Transfer-Encoding: 8bit
ced1f5
ced1f5
Currently the index for one-level searches is a huge blob which maps all
ced1f5
parents with all it children. Handling this blob is costly and since all
ced1f5
searches using LDB_SCOPE_ONELEVEL also have a filter with indexed
ced1f5
attributes a sub-tree search would be more efficient. But since libldb
ced1f5
currently first looks at the scope and hence use the one-level index
ced1f5
blob we have to explicitly use LDB_SCOPE_SUBTREE in the callers to use
ced1f5
the more efficient attribute based inxed.
ced1f5
ced1f5
Related to https://pagure.io/SSSD/sssd/issue/3503
ced1f5
ced1f5
Reviewed-by: Jakub Hrozek <jhrozek@redhat.com>
ced1f5
Reviewed-by: Fabiano FidĂȘncio <fidencio@redhat.com>
ced1f5
(cherry picked from commit 98195e591c4d97caa6125e8214879660b740973f)
ced1f5
---
ced1f5
 src/db/sysdb_autofs.c         | 2 +-
ced1f5
 src/db/sysdb_ranges.c         | 2 +-
ced1f5
 src/db/sysdb_subdomains.c     | 2 +-
ced1f5
 src/responder/ifp/ifp_users.c | 2 +-
ced1f5
 4 files changed, 4 insertions(+), 4 deletions(-)
ced1f5
ced1f5
diff --git a/src/db/sysdb_autofs.c b/src/db/sysdb_autofs.c
ced1f5
index b3e9b4ec83b66ec65a72ab7a3180106e2293d8a5..89803a778c370c899611ee5e15b7ae1a48e82cb9 100644
ced1f5
--- a/src/db/sysdb_autofs.c
ced1f5
+++ b/src/db/sysdb_autofs.c
ced1f5
@@ -384,7 +384,7 @@ sysdb_autofs_entries_by_map(TALLOC_CTX *mem_ctx,
ced1f5
         goto done;
ced1f5
     }
ced1f5
 
ced1f5
-    ret = sysdb_search_entry(tmp_ctx, domain->sysdb, mapdn, LDB_SCOPE_ONELEVEL,
ced1f5
+    ret = sysdb_search_entry(tmp_ctx, domain->sysdb, mapdn, LDB_SCOPE_SUBTREE,
ced1f5
                              filter, attrs, &count, &msgs);
ced1f5
     if (ret != EOK && ret != ENOENT) {
ced1f5
         DEBUG(SSSDBG_OP_FAILURE, "sysdb search failed: %d\n", ret);
ced1f5
diff --git a/src/db/sysdb_ranges.c b/src/db/sysdb_ranges.c
ced1f5
index 511e4785d9aa68b2a33b440e1c5ee62e5ccf7ce4..be3a0d37220f833d27417808ddfef0e74c0ba9b2 100644
ced1f5
--- a/src/db/sysdb_ranges.c
ced1f5
+++ b/src/db/sysdb_ranges.c
ced1f5
@@ -71,7 +71,7 @@ errno_t sysdb_get_ranges(TALLOC_CTX *mem_ctx, struct sysdb_ctx *sysdb,
ced1f5
         goto done;
ced1f5
     }
ced1f5
     ret = ldb_search(sysdb->ldb, tmp_ctx, &res,
ced1f5
-                     basedn, LDB_SCOPE_ONELEVEL,
ced1f5
+                     basedn, LDB_SCOPE_SUBTREE,
ced1f5
                      attrs, "objectclass=%s", SYSDB_ID_RANGE_CLASS);
ced1f5
     if (ret != LDB_SUCCESS) {
ced1f5
         ret = EIO;
ced1f5
diff --git a/src/db/sysdb_subdomains.c b/src/db/sysdb_subdomains.c
ced1f5
index 353561765904efe4bd698c38949a1b290ecf0b80..0dd05c24c963f12a28ef6f6b64dc40faa7fcc649 100644
ced1f5
--- a/src/db/sysdb_subdomains.c
ced1f5
+++ b/src/db/sysdb_subdomains.c
ced1f5
@@ -338,7 +338,7 @@ errno_t sysdb_update_subdomains(struct sss_domain_info *domain,
ced1f5
         goto done;
ced1f5
     }
ced1f5
     ret = ldb_search(domain->sysdb->ldb, tmp_ctx, &res,
ced1f5
-                     basedn, LDB_SCOPE_ONELEVEL,
ced1f5
+                     basedn, LDB_SCOPE_SUBTREE,
ced1f5
                      attrs, "objectclass=%s", SYSDB_SUBDOMAIN_CLASS);
ced1f5
     if (ret != LDB_SUCCESS) {
ced1f5
         ret = EIO;
ced1f5
diff --git a/src/responder/ifp/ifp_users.c b/src/responder/ifp/ifp_users.c
ced1f5
index cb342a245ef6545168a7a60c252505f50576fdf7..f66587b8cf81a555dd1cb7aff12e0c8347c250b1 100644
ced1f5
--- a/src/responder/ifp/ifp_users.c
ced1f5
+++ b/src/responder/ifp/ifp_users.c
ced1f5
@@ -1449,7 +1449,7 @@ void ifp_users_user_get_extra_attributes(struct sbus_request *sbus_req,
ced1f5
     }
ced1f5
 
ced1f5
     ret = sysdb_search_entry(sbus_req, domain->sysdb, basedn,
ced1f5
-                             LDB_SCOPE_ONELEVEL, filter,
ced1f5
+                             LDB_SCOPE_SUBTREE, filter,
ced1f5
                              extra, &count, &user);
ced1f5
     if (ret != EOK) {
ced1f5
         DEBUG(SSSDBG_CRIT_FAILURE, "Unable to lookup user [%d]: %s\n",
ced1f5
-- 
ced1f5
2.14.3
ced1f5