|
|
b2d430 |
From a1e606d051c54dd603bf09adb2bd6d0d7db2663f Mon Sep 17 00:00:00 2001
|
|
|
b2d430 |
From: Sumit Bose <sbose@redhat.com>
|
|
|
b2d430 |
Date: Wed, 20 Jul 2016 18:42:27 +0200
|
|
|
b2d430 |
Subject: [PATCH 47/62] sysdb: add sysdb_get_user_members_recursively()
|
|
|
b2d430 |
|
|
|
b2d430 |
Reviewed-by: Jakub Hrozek <jhrozek@redhat.com>
|
|
|
b2d430 |
(cherry picked from commit 17bfd9f69251781140e4b2b55ffeb649d7a79e86)
|
|
|
b2d430 |
---
|
|
|
b2d430 |
src/db/sysdb.h | 5 +++++
|
|
|
b2d430 |
src/db/sysdb_ops.c | 61 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
|
|
b2d430 |
2 files changed, 66 insertions(+)
|
|
|
b2d430 |
|
|
|
b2d430 |
diff --git a/src/db/sysdb.h b/src/db/sysdb.h
|
|
|
b2d430 |
index 0cc550a4c389b4a1a2b78aff760f4b5cbf94e17f..405f89e2f1ac6fabc06e77c345de8693845f9d92 100644
|
|
|
b2d430 |
--- a/src/db/sysdb.h
|
|
|
b2d430 |
+++ b/src/db/sysdb.h
|
|
|
b2d430 |
@@ -1257,6 +1257,11 @@ errno_t sysdb_get_sids_of_members(TALLOC_CTX *mem_ctx,
|
|
|
b2d430 |
const char ***_dns,
|
|
|
b2d430 |
size_t *_n);
|
|
|
b2d430 |
|
|
|
b2d430 |
+errno_t sysdb_get_user_members_recursively(TALLOC_CTX *mem_ctx,
|
|
|
b2d430 |
+ struct sss_domain_info *dom,
|
|
|
b2d430 |
+ struct ldb_dn *group_dn,
|
|
|
b2d430 |
+ struct ldb_result **members);
|
|
|
b2d430 |
+
|
|
|
b2d430 |
errno_t sysdb_handle_original_uuid(const char *orig_name,
|
|
|
b2d430 |
struct sysdb_attrs *src_attrs,
|
|
|
b2d430 |
const char *src_name,
|
|
|
b2d430 |
diff --git a/src/db/sysdb_ops.c b/src/db/sysdb_ops.c
|
|
|
b2d430 |
index 19d6be03ede1bcec3bc7a4ed777e326460d80591..9a8a55ed8aa69e1638d0ab6f636e43baa3d0bfea 100644
|
|
|
b2d430 |
--- a/src/db/sysdb_ops.c
|
|
|
b2d430 |
+++ b/src/db/sysdb_ops.c
|
|
|
b2d430 |
@@ -4711,6 +4711,67 @@ done:
|
|
|
b2d430 |
return ret;
|
|
|
b2d430 |
}
|
|
|
b2d430 |
|
|
|
b2d430 |
+errno_t sysdb_get_user_members_recursively(TALLOC_CTX *mem_ctx,
|
|
|
b2d430 |
+ struct sss_domain_info *dom,
|
|
|
b2d430 |
+ struct ldb_dn *group_dn,
|
|
|
b2d430 |
+ struct ldb_result **members)
|
|
|
b2d430 |
+{
|
|
|
b2d430 |
+ TALLOC_CTX *tmp_ctx;
|
|
|
b2d430 |
+ int ret;
|
|
|
b2d430 |
+ size_t count;
|
|
|
b2d430 |
+ struct ldb_result *res;
|
|
|
b2d430 |
+ struct ldb_dn *base_dn;
|
|
|
b2d430 |
+ char *filter;
|
|
|
b2d430 |
+ const char *attrs[] = SYSDB_PW_ATTRS;
|
|
|
b2d430 |
+ struct ldb_message **msgs;
|
|
|
b2d430 |
+
|
|
|
b2d430 |
+ tmp_ctx = talloc_new(NULL);
|
|
|
b2d430 |
+ if (tmp_ctx == NULL) {
|
|
|
b2d430 |
+ return ENOMEM;
|
|
|
b2d430 |
+ }
|
|
|
b2d430 |
+
|
|
|
b2d430 |
+ base_dn = sysdb_base_dn(dom->sysdb, tmp_ctx);
|
|
|
b2d430 |
+ if (base_dn == NULL) {
|
|
|
b2d430 |
+ DEBUG(SSSDBG_OP_FAILURE, "sysdb_base_dn failed.\n");
|
|
|
b2d430 |
+ ret = ENOMEM;
|
|
|
b2d430 |
+ goto done;
|
|
|
b2d430 |
+ }
|
|
|
b2d430 |
+
|
|
|
b2d430 |
+ filter = talloc_asprintf(tmp_ctx, "(&("SYSDB_UC")("SYSDB_MEMBEROF"=%s))",
|
|
|
b2d430 |
+ ldb_dn_get_linearized(group_dn));
|
|
|
b2d430 |
+ if (filter == NULL) {
|
|
|
b2d430 |
+ DEBUG(SSSDBG_OP_FAILURE, "talloc_asprintf failed.\n");
|
|
|
b2d430 |
+ ret = ENOMEM;
|
|
|
b2d430 |
+ goto done;
|
|
|
b2d430 |
+ }
|
|
|
b2d430 |
+
|
|
|
b2d430 |
+ ret = sysdb_search_entry(tmp_ctx, dom->sysdb, base_dn, LDB_SCOPE_SUBTREE,
|
|
|
b2d430 |
+ filter, attrs, &count, &msgs);
|
|
|
b2d430 |
+
|
|
|
b2d430 |
+ res = talloc_zero(tmp_ctx, struct ldb_result);
|
|
|
b2d430 |
+ if (res == NULL) {
|
|
|
b2d430 |
+ DEBUG(SSSDBG_OP_FAILURE, "talloc_zero failed.\n");
|
|
|
b2d430 |
+ ret = ENOMEM;
|
|
|
b2d430 |
+ goto done;
|
|
|
b2d430 |
+ }
|
|
|
b2d430 |
+
|
|
|
b2d430 |
+ res->count = count;
|
|
|
b2d430 |
+ res->msgs = talloc_steal(res, msgs);
|
|
|
b2d430 |
+
|
|
|
b2d430 |
+ ret = EOK;
|
|
|
b2d430 |
+
|
|
|
b2d430 |
+done:
|
|
|
b2d430 |
+ if (ret == EOK) {
|
|
|
b2d430 |
+ *members = talloc_steal(mem_ctx, res);
|
|
|
b2d430 |
+ } else if (ret == ENOENT) {
|
|
|
b2d430 |
+ DEBUG(SSSDBG_TRACE_FUNC, "No such entry\n");
|
|
|
b2d430 |
+ } else {
|
|
|
b2d430 |
+ DEBUG(SSSDBG_OP_FAILURE, "Error: %d (%s)\n", ret, strerror(ret));
|
|
|
b2d430 |
+ }
|
|
|
b2d430 |
+ talloc_free(tmp_ctx);
|
|
|
b2d430 |
+ return ret;
|
|
|
b2d430 |
+}
|
|
|
b2d430 |
+
|
|
|
b2d430 |
errno_t sysdb_handle_original_uuid(const char *orig_name,
|
|
|
b2d430 |
struct sysdb_attrs *src_attrs,
|
|
|
b2d430 |
const char *src_name,
|
|
|
b2d430 |
--
|
|
|
b2d430 |
2.4.11
|
|
|
b2d430 |
|