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

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