summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorPavel Březina <pbrezina@redhat.com>2014-10-02 16:13:34 +0200
committerJakub Hrozek <jhrozek@redhat.com>2014-10-20 16:21:22 +0200
commit727d46f4dace666c809310b3f685eef387023f65 (patch)
tree749790f3997ecbe39379fb995e4e890ca5263135 /src
parent396fb27b17d66261e2d15146a7c925be8d637226 (diff)
downloadsssd-727d46f4dace666c809310b3f685eef387023f65.tar.gz
sssd-727d46f4dace666c809310b3f685eef387023f65.tar.xz
sssd-727d46f4dace666c809310b3f685eef387023f65.zip
Add sysdb_search_[user|group]_override_attrs_by_name
Reviewed-by: Sumit Bose <sbose@redhat.com>
Diffstat (limited to 'src')
-rw-r--r--src/db/sysdb.h14
-rw-r--r--src/db/sysdb_views.c62
2 files changed, 51 insertions, 25 deletions
diff --git a/src/db/sysdb.h b/src/db/sysdb.h
index fa5b714e6..04733f2a8 100644
--- a/src/db/sysdb.h
+++ b/src/db/sysdb.h
@@ -447,6 +447,20 @@ errno_t sysdb_apply_default_override(struct sss_domain_info *domain,
struct sysdb_attrs *override_attrs,
struct ldb_dn *obj_dn);
+errno_t sysdb_search_user_override_attrs_by_name(TALLOC_CTX *mem_ctx,
+ struct sss_domain_info *domain,
+ const char *name,
+ const char **attrs,
+ struct ldb_result **override_obj,
+ struct ldb_result **orig_obj);
+
+errno_t sysdb_search_group_override_attrs_by_name(TALLOC_CTX *mem_ctx,
+ struct sss_domain_info *domain,
+ const char *name,
+ const char **attrs,
+ struct ldb_result **override_obj,
+ struct ldb_result **orig_obj);
+
errno_t sysdb_search_user_override_by_name(TALLOC_CTX *mem_ctx,
struct sss_domain_info *domain,
const char *name,
diff --git a/src/db/sysdb_views.c b/src/db/sysdb_views.c
index acb5d8138..926cd847c 100644
--- a/src/db/sysdb_views.c
+++ b/src/db/sysdb_views.c
@@ -661,14 +661,12 @@ enum override_object_type {
static errno_t sysdb_search_override_by_name(TALLOC_CTX *mem_ctx,
struct sss_domain_info *domain,
const char *name,
- enum override_object_type type,
+ const char *filter,
+ const char **attrs,
struct ldb_result **override_obj,
struct ldb_result **orig_obj)
{
TALLOC_CTX *tmp_ctx;
- static const char *user_attrs[] = SYSDB_PW_ATTRS;
- static const char *group_attrs[] = SYSDB_GRSRC_ATTRS;
- const char **attrs;
struct ldb_dn *base_dn;
struct ldb_result *override_res;
struct ldb_result *orig_res;
@@ -677,7 +675,6 @@ static errno_t sysdb_search_override_by_name(TALLOC_CTX *mem_ctx,
const char *src_name;
int ret;
const char *orig_obj_dn;
- const char *filter;
tmp_ctx = talloc_new(NULL);
if (!tmp_ctx) {
@@ -708,22 +705,6 @@ static errno_t sysdb_search_override_by_name(TALLOC_CTX *mem_ctx,
goto done;
}
- switch(type) {
- case OO_TYPE_USER:
- filter = SYSDB_USER_NAME_OVERRIDE_FILTER;
- attrs = user_attrs;
- break;
- case OO_TYPE_GROUP:
- filter = SYSDB_GROUP_NAME_OVERRIDE_FILTER;
- attrs = group_attrs;
- break;
- default:
- DEBUG(SSSDBG_CRIT_FAILURE, "Unexpected override object type [%d].\n",
- type);
- ret = EINVAL;
- goto done;
- }
-
ret = ldb_search(domain->sysdb->ldb, tmp_ctx, &override_res, base_dn,
LDB_SCOPE_SUBTREE, attrs, filter,
lc_sanitized_name,
@@ -784,14 +765,42 @@ done:
return ret;
}
+errno_t sysdb_search_user_override_attrs_by_name(TALLOC_CTX *mem_ctx,
+ struct sss_domain_info *domain,
+ const char *name,
+ const char **attrs,
+ struct ldb_result **override_obj,
+ struct ldb_result **orig_obj)
+{
+
+ return sysdb_search_override_by_name(mem_ctx, domain, name,
+ SYSDB_USER_NAME_OVERRIDE_FILTER,
+ attrs, override_obj, orig_obj);
+}
+
+errno_t sysdb_search_group_override_attrs_by_name(TALLOC_CTX *mem_ctx,
+ struct sss_domain_info *domain,
+ const char *name,
+ const char **attrs,
+ struct ldb_result **override_obj,
+ struct ldb_result **orig_obj)
+{
+ return sysdb_search_override_by_name(mem_ctx, domain, name,
+ SYSDB_GROUP_NAME_OVERRIDE_FILTER,
+ attrs, override_obj, orig_obj);
+}
+
errno_t sysdb_search_user_override_by_name(TALLOC_CTX *mem_ctx,
struct sss_domain_info *domain,
const char *name,
struct ldb_result **override_obj,
struct ldb_result **orig_obj)
{
- return sysdb_search_override_by_name(mem_ctx, domain, name, OO_TYPE_USER,
- override_obj, orig_obj);
+ const char *attrs[] = SYSDB_PW_ATTRS;
+
+ return sysdb_search_override_by_name(mem_ctx, domain, name,
+ SYSDB_USER_NAME_OVERRIDE_FILTER,
+ attrs, override_obj, orig_obj);
}
errno_t sysdb_search_group_override_by_name(TALLOC_CTX *mem_ctx,
@@ -800,8 +809,11 @@ errno_t sysdb_search_group_override_by_name(TALLOC_CTX *mem_ctx,
struct ldb_result **override_obj,
struct ldb_result **orig_obj)
{
- return sysdb_search_override_by_name(mem_ctx, domain, name, OO_TYPE_GROUP,
- override_obj, orig_obj);
+ const char *attrs[] = SYSDB_GRSRC_ATTRS;
+
+ return sysdb_search_override_by_name(mem_ctx, domain, name,
+ SYSDB_GROUP_NAME_OVERRIDE_FILTER,
+ attrs, override_obj, orig_obj);
}
static errno_t sysdb_search_override_by_id(TALLOC_CTX *mem_ctx,