summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSumit Bose <sbose@redhat.com>2014-10-17 13:52:24 +0200
committerJakub Hrozek <jhrozek@redhat.com>2014-10-20 16:15:32 +0200
commit4777af0b8f9a3f418a54f0d4bf7eb72b896dabb5 (patch)
tree4420b85dde9058114427b02b05c7fabcb3aa84d6
parentc2788a00c49b14fc56690af93dc1ac60d6ee6c70 (diff)
downloadsssd-4777af0b8f9a3f418a54f0d4bf7eb72b896dabb5.tar.gz
sssd-4777af0b8f9a3f418a54f0d4bf7eb72b896dabb5.tar.xz
sssd-4777af0b8f9a3f418a54f0d4bf7eb72b896dabb5.zip
sysdb: add sysdb_enumpw/grent_with_views()
Reviewed-by: Pavel Březina <pbrezina@redhat.com>
-rw-r--r--src/db/sysdb.h8
-rw-r--r--src/db/sysdb_search.c88
2 files changed, 96 insertions, 0 deletions
diff --git a/src/db/sysdb.h b/src/db/sysdb.h
index f7e507c91..fa5b714e6 100644
--- a/src/db/sysdb.h
+++ b/src/db/sysdb.h
@@ -543,6 +543,10 @@ int sysdb_enumpwent(TALLOC_CTX *mem_ctx,
struct sss_domain_info *domain,
struct ldb_result **res);
+int sysdb_enumpwent_with_views(TALLOC_CTX *mem_ctx,
+ struct sss_domain_info *domain,
+ struct ldb_result **res);
+
int sysdb_getgrnam(TALLOC_CTX *mem_ctx,
struct sss_domain_info *domain,
const char *name,
@@ -557,6 +561,10 @@ int sysdb_enumgrent(TALLOC_CTX *mem_ctx,
struct sss_domain_info *domain,
struct ldb_result **res);
+int sysdb_enumgrent_with_views(TALLOC_CTX *mem_ctx,
+ struct sss_domain_info *domain,
+ struct ldb_result **res);
+
struct sysdb_netgroup_ctx {
enum {SYSDB_NETGROUP_TRIPLE_VAL, SYSDB_NETGROUP_GROUP_VAL} type;
union {
diff --git a/src/db/sysdb_search.c b/src/db/sysdb_search.c
index f4cecfc47..ca52f1185 100644
--- a/src/db/sysdb_search.c
+++ b/src/db/sysdb_search.c
@@ -291,6 +291,46 @@ done:
return ret;
}
+int sysdb_enumpwent_with_views(TALLOC_CTX *mem_ctx,
+ struct sss_domain_info *domain,
+ struct ldb_result **_res)
+{
+ TALLOC_CTX *tmp_ctx;
+ struct ldb_result *res;
+ size_t c;
+ int ret;
+
+ tmp_ctx = talloc_new(NULL);
+ if (tmp_ctx == NULL) {
+ DEBUG(SSSDBG_OP_FAILURE, "talloc_new failed.\n");
+ return ENOMEM;
+ }
+
+ ret = sysdb_enumpwent(tmp_ctx, domain, &res);
+ if (ret != EOK) {
+ DEBUG(SSSDBG_OP_FAILURE, "sysdb_enumpwent failed.\n");
+ goto done;
+ }
+
+ if (DOM_HAS_VIEWS(domain)) {
+ for (c = 0; c < res->count; c++) {
+ ret = sysdb_add_overrides_to_object(domain, res->msgs[c], NULL);
+ /* enumeration assumes that the cache is up-to-date, hence we do not
+ * need to handle ENOENT separately. */
+ if (ret != EOK) {
+ DEBUG(SSSDBG_OP_FAILURE, "sysdb_add_overrides_to_object failed.\n");
+ goto done;
+ }
+ }
+ }
+
+ *_res = talloc_steal(mem_ctx, res);
+
+done:
+ talloc_zfree(tmp_ctx);
+ return ret;
+}
+
/* groups */
static int mpg_convert(struct ldb_message *msg)
@@ -671,6 +711,54 @@ done:
return ret;
}
+int sysdb_enumgrent_with_views(TALLOC_CTX *mem_ctx,
+ struct sss_domain_info *domain,
+ struct ldb_result **_res)
+{
+ TALLOC_CTX *tmp_ctx;
+ struct ldb_result *res;
+ size_t c;
+ int ret;
+
+ tmp_ctx = talloc_new(NULL);
+ if (tmp_ctx == NULL) {
+ DEBUG(SSSDBG_OP_FAILURE, "talloc_new failed.\n");
+ return ENOMEM;
+ }
+
+ ret = sysdb_enumgrent(tmp_ctx, domain,&res);
+ if (ret != EOK) {
+ DEBUG(SSSDBG_OP_FAILURE, "sysdb_enumgrent failed.\n");
+ goto done;
+ }
+
+ if (DOM_HAS_VIEWS(domain)) {
+ for (c = 0; c < res->count; c++) {
+ ret = sysdb_add_overrides_to_object(domain, res->msgs[c], NULL);
+ /* enumeration assumes that the cache is up-to-date, hence we do not
+ * need to handle ENOENT separately. */
+ if (ret != EOK) {
+ DEBUG(SSSDBG_OP_FAILURE, "sysdb_add_overrides_to_object failed.\n");
+ goto done;
+ }
+
+ ret = sysdb_add_group_member_overrides(domain, res->msgs[c]);
+ if (ret != EOK) {
+ DEBUG(SSSDBG_OP_FAILURE,
+ "sysdb_add_group_member_overrides failed.\n");
+ goto done;
+ }
+ }
+ }
+
+
+ *_res = talloc_steal(mem_ctx, res);
+
+done:
+ talloc_zfree(tmp_ctx);
+ return ret;
+}
+
int sysdb_initgroups(TALLOC_CTX *mem_ctx,
struct sss_domain_info *domain,
const char *name,