summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJakub Hrozek <jhrozek@redhat.com>2016-04-08 16:29:42 +0200
committerJakub Hrozek <jhrozek@redhat.com>2016-07-07 10:26:44 +0200
commit3931c6612fae5ad32ad81a59f77d77c2d896ebe1 (patch)
tree929e716427e6074743874e1003a9edd317f7dbcb
parent5475aa2616eda5ceaa1875610f9d9ce8c239b5cd (diff)
downloadsssd-3931c6612fae5ad32ad81a59f77d77c2d896ebe1.tar.gz
sssd-3931c6612fae5ad32ad81a59f77d77c2d896ebe1.tar.xz
sssd-3931c6612fae5ad32ad81a59f77d77c2d896ebe1.zip
SYSDB: Add a utility function to return a list of qualified names
Adds a utility function the LDAP provider can use. This is different from sss_create_internal_fqname_list in the sense that the LDAP provider passes in the attribute name that contains the name attribute value. Reviewed-by: Sumit Bose <sbose@redhat.com>
-rw-r--r--src/db/sysdb.c45
-rw-r--r--src/db/sysdb.h8
-rw-r--r--src/providers/ldap/sdap_async_groups.c2
-rw-r--r--src/providers/ldap/sdap_async_initgroups.c8
4 files changed, 49 insertions, 14 deletions
diff --git a/src/db/sysdb.c b/src/db/sysdb.c
index cb35d1c65..6f0b1b9e9 100644
--- a/src/db/sysdb.c
+++ b/src/db/sysdb.c
@@ -1442,12 +1442,13 @@ done:
return ret;
}
-errno_t sysdb_attrs_primary_name_list(struct sysdb_ctx *sysdb,
- TALLOC_CTX *mem_ctx,
- struct sysdb_attrs **attr_list,
- size_t attr_count,
- const char *ldap_attr,
- char ***name_list)
+static errno_t _sysdb_attrs_primary_name_list(struct sss_domain_info *domain,
+ TALLOC_CTX *mem_ctx,
+ struct sysdb_attrs **attr_list,
+ size_t attr_count,
+ const char *ldap_attr,
+ bool qualify_names,
+ char ***name_list)
{
errno_t ret;
size_t i, j;
@@ -1462,7 +1463,7 @@ errno_t sysdb_attrs_primary_name_list(struct sysdb_ctx *sysdb,
j = 0;
for (i = 0; i < attr_count; i++) {
- ret = sysdb_attrs_primary_name(sysdb,
+ ret = sysdb_attrs_primary_name(domain->sysdb,
attr_list[i],
ldap_attr,
&name);
@@ -1472,7 +1473,11 @@ errno_t sysdb_attrs_primary_name_list(struct sysdb_ctx *sysdb,
continue;
}
- list[j] = talloc_strdup(list, name);
+ if (qualify_names == false) {
+ list[j] = talloc_strdup(list, name);
+ } else {
+ list[j] = sss_create_internal_fqname(list, name, domain->name);
+ }
if (!list[j]) {
ret = ENOMEM;
goto done;
@@ -1495,6 +1500,30 @@ done:
return ret;
}
+errno_t sysdb_attrs_primary_name_list(struct sss_domain_info *domain,
+ TALLOC_CTX *mem_ctx,
+ struct sysdb_attrs **attr_list,
+ size_t attr_count,
+ const char *ldap_attr,
+ char ***name_list)
+{
+ return _sysdb_attrs_primary_name_list(domain, mem_ctx, attr_list,
+ attr_count, ldap_attr,
+ false, name_list);
+}
+
+errno_t sysdb_attrs_primary_fqdn_list(struct sss_domain_info *domain,
+ TALLOC_CTX *mem_ctx,
+ struct sysdb_attrs **attr_list,
+ size_t attr_count,
+ const char *ldap_attr,
+ char ***name_list)
+{
+ return _sysdb_attrs_primary_name_list(domain, mem_ctx, attr_list,
+ attr_count, ldap_attr,
+ true, name_list);
+}
+
errno_t sysdb_msg2attrs(TALLOC_CTX *mem_ctx, size_t count,
struct ldb_message **msgs,
struct sysdb_attrs ***attrs)
diff --git a/src/db/sysdb.h b/src/db/sysdb.h
index 2bc20ff97..cdd37d17c 100644
--- a/src/db/sysdb.h
+++ b/src/db/sysdb.h
@@ -384,7 +384,13 @@ errno_t sysdb_attrs_get_aliases(TALLOC_CTX *mem_ctx,
const char *primary,
bool lowercase,
const char ***_aliases);
-errno_t sysdb_attrs_primary_name_list(struct sysdb_ctx *sysdb,
+errno_t sysdb_attrs_primary_name_list(struct sss_domain_info *domain,
+ TALLOC_CTX *mem_ctx,
+ struct sysdb_attrs **attr_list,
+ size_t attr_count,
+ const char *ldap_attr,
+ char ***name_list);
+errno_t sysdb_attrs_primary_fqdn_list(struct sss_domain_info *domain,
TALLOC_CTX *mem_ctx,
struct sysdb_attrs **attr_list,
size_t attr_count,
diff --git a/src/providers/ldap/sdap_async_groups.c b/src/providers/ldap/sdap_async_groups.c
index 5edcd3af7..a4b917726 100644
--- a/src/providers/ldap/sdap_async_groups.c
+++ b/src/providers/ldap/sdap_async_groups.c
@@ -2020,7 +2020,7 @@ static void sdap_get_groups_process(struct tevent_req *subreq)
}
if (state->no_members) {
- ret = sysdb_attrs_primary_name_list(state->sysdb, state,
+ ret = sysdb_attrs_primary_name_list(state->dom, state,
state->groups, state->count,
state->opts->group_map[SDAP_AT_GROUP_NAME].name,
&groupnamelist);
diff --git a/src/providers/ldap/sdap_async_initgroups.c b/src/providers/ldap/sdap_async_initgroups.c
index 383b11637..8d9fcc459 100644
--- a/src/providers/ldap/sdap_async_initgroups.c
+++ b/src/providers/ldap/sdap_async_initgroups.c
@@ -286,7 +286,7 @@ int sdap_initgr_common_store(struct sysdb_ctx *sysdb,
ldap_grouplist = NULL;
} else {
ret = sysdb_attrs_primary_name_list(
- sysdb, tmp_ctx,
+ domain, tmp_ctx,
ldap_groups, ldap_groups_count,
opts->group_map[SDAP_AT_GROUP_NAME].name,
&ldap_grouplist);
@@ -1275,7 +1275,7 @@ sdap_initgr_store_user_memberships(struct sdap_initgr_nested_state *state)
if (nparents == 0) {
ldap_parent_name_list = NULL;
} else {
- ret = sysdb_attrs_primary_name_list(state->sysdb, tmp_ctx,
+ ret = sysdb_attrs_primary_name_list(state->dom, tmp_ctx,
ldap_parentlist,
nparents,
state->opts->group_map[SDAP_AT_GROUP_NAME].name,
@@ -1410,7 +1410,7 @@ sdap_initgr_nested_get_membership_diff(TALLOC_CTX *mem_ctx,
group_name, parents_count);
if (parents_count > 0) {
- ret = sysdb_attrs_primary_name_list(sysdb, tmp_ctx,
+ ret = sysdb_attrs_primary_name_list(dom, tmp_ctx,
ldap_parentlist,
parents_count,
opts->group_map[SDAP_AT_GROUP_NAME].name,
@@ -2076,7 +2076,7 @@ rfc2307bis_group_memberships_build(hash_entry_t *item, void *user_data)
}
if (group->parents_count > 0) {
- ret = sysdb_attrs_primary_name_list(mstate->sysdb, tmp_ctx,
+ ret = sysdb_attrs_primary_name_list(mstate->dom, tmp_ctx,
group->ldap_parents, group->parents_count,
mstate->opts->group_map[SDAP_AT_GROUP_NAME].name,
&ldap_parents_names_list);