dpward / rpms / sssd

Forked from rpms/sssd 3 years ago
Clone

Blame SOURCES/0068-SDAP-Split-out-utility-function-sdap_get_object_doma.patch

9f2ebf
From 0e5d9f481daeeaecefeb68cdc03e45a11dfd7091 Mon Sep 17 00:00:00 2001
9f2ebf
From: Jakub Hrozek <jhrozek@redhat.com>
9f2ebf
Date: Tue, 7 Nov 2017 17:03:13 +0100
9f2ebf
Subject: [PATCH 68/83] SDAP: Split out utility function
9f2ebf
 sdap_get_object_domain() from sdap_object_in_domain()
9f2ebf
MIME-Version: 1.0
9f2ebf
Content-Type: text/plain; charset=UTF-8
9f2ebf
Content-Transfer-Encoding: 8bit
9f2ebf
9f2ebf
The DP request that returns a domain of an entry to responder will need
9f2ebf
this functionality in order to map the original DN of the entry found
9f2ebf
to a domain name.
9f2ebf
9f2ebf
Reviewed-by: Pavel Březina <pbrezina@redhat.com>
9f2ebf
Reviewed-by: Sumit Bose <sbose@redhat.com>
9f2ebf
(cherry picked from commit 37fdd9dc1ad5968067f8e3c43a51ed2ac9f3b104)
9f2ebf
---
9f2ebf
 src/providers/ldap/sdap.c | 26 ++++++++++++++++++++------
9f2ebf
 src/providers/ldap/sdap.h |  4 ++++
9f2ebf
 2 files changed, 24 insertions(+), 6 deletions(-)
9f2ebf
9f2ebf
diff --git a/src/providers/ldap/sdap.c b/src/providers/ldap/sdap.c
9f2ebf
index b6b1c91cb7507ebb95cd559634a77ed44dfb5fc0..59d24fed53cc35751b5c24679e247a42f82e1d0a 100644
9f2ebf
--- a/src/providers/ldap/sdap.c
9f2ebf
+++ b/src/providers/ldap/sdap.c
9f2ebf
@@ -1673,9 +1673,9 @@ char *sdap_make_oc_list(TALLOC_CTX *mem_ctx, struct sdap_attr_map *map)
9f2ebf
     }
9f2ebf
 }
9f2ebf
 
9f2ebf
-bool sdap_object_in_domain(struct sdap_options *opts,
9f2ebf
-                           struct sysdb_attrs *obj,
9f2ebf
-                           struct sss_domain_info *dom)
9f2ebf
+struct sss_domain_info *sdap_get_object_domain(struct sdap_options *opts,
9f2ebf
+                                               struct sysdb_attrs *obj,
9f2ebf
+                                               struct sss_domain_info *dom)
9f2ebf
 {
9f2ebf
     errno_t ret;
9f2ebf
     const char *original_dn = NULL;
9f2ebf
@@ -1685,7 +1685,7 @@ bool sdap_object_in_domain(struct sdap_options *opts,
9f2ebf
     if (ret) {
9f2ebf
         DEBUG(SSSDBG_FUNC_DATA,
9f2ebf
               "The group has no original DN, assuming our domain\n");
9f2ebf
-        return true;
9f2ebf
+        return dom;
9f2ebf
     }
9f2ebf
 
9f2ebf
     sdmatch = sdap_domain_get_by_dn(opts, original_dn);
9f2ebf
@@ -1693,10 +1693,24 @@ bool sdap_object_in_domain(struct sdap_options *opts,
9f2ebf
         DEBUG(SSSDBG_FUNC_DATA,
9f2ebf
               "The original DN of the group cannot "
9f2ebf
               "be related to any search base\n");
9f2ebf
-        return true;
9f2ebf
+        return dom;
9f2ebf
     }
9f2ebf
 
9f2ebf
-    return (sdmatch->dom == dom);
9f2ebf
+    return sdmatch->dom;
9f2ebf
+}
9f2ebf
+
9f2ebf
+bool sdap_object_in_domain(struct sdap_options *opts,
9f2ebf
+                           struct sysdb_attrs *obj,
9f2ebf
+                           struct sss_domain_info *dom)
9f2ebf
+{
9f2ebf
+    struct sss_domain_info *obj_dom;
9f2ebf
+
9f2ebf
+    obj_dom = sdap_get_object_domain(opts, obj, dom);
9f2ebf
+    if (obj_dom == NULL) {
9f2ebf
+        return false;
9f2ebf
+    }
9f2ebf
+
9f2ebf
+    return (obj_dom == dom);
9f2ebf
 }
9f2ebf
 
9f2ebf
 size_t sdap_steal_objects_in_dom(struct sdap_options *opts,
9f2ebf
diff --git a/src/providers/ldap/sdap.h b/src/providers/ldap/sdap.h
9f2ebf
index 2ba016ff52313198287ac5196e24517333882099..8b0f1f0ce0fef59554270f0f31cfd2d5f0aa57f5 100644
9f2ebf
--- a/src/providers/ldap/sdap.h
9f2ebf
+++ b/src/providers/ldap/sdap.h
9f2ebf
@@ -644,6 +644,10 @@ size_t sdap_steal_objects_in_dom(struct sdap_options *opts,
9f2ebf
                                  size_t count,
9f2ebf
                                  bool filter);
9f2ebf
 
9f2ebf
+struct sss_domain_info *sdap_get_object_domain(struct sdap_options *opts,
9f2ebf
+                                               struct sysdb_attrs *obj,
9f2ebf
+                                               struct sss_domain_info *dom);
9f2ebf
+
9f2ebf
 bool sdap_object_in_domain(struct sdap_options *opts,
9f2ebf
                            struct sysdb_attrs *obj,
9f2ebf
                            struct sss_domain_info *dom);
9f2ebf
-- 
9f2ebf
2.14.3
9f2ebf