summaryrefslogtreecommitdiff
path: root/src/providers/ldap
diff options
context:
space:
mode:
Diffstat (limited to 'src/providers/ldap')
-rw-r--r--src/providers/ldap/ldap_common.c3
-rw-r--r--src/providers/ldap/ldap_id.c12
-rw-r--r--src/providers/ldap/ldap_id_enum.c8
-rw-r--r--src/providers/ldap/ldap_id_netgroup.c4
-rw-r--r--src/providers/ldap/ldap_id_services.c3
-rw-r--r--src/providers/ldap/sdap.c20
-rw-r--r--src/providers/ldap/sdap.h1
-rw-r--r--src/providers/ldap/sdap_async_autofs.c6
-rw-r--r--src/providers/ldap/sdap_async_groups.c10
-rw-r--r--src/providers/ldap/sdap_async_initgroups.c20
-rw-r--r--src/providers/ldap/sdap_async_services.c3
-rw-r--r--src/providers/ldap/sdap_sudo.c2
12 files changed, 58 insertions, 34 deletions
diff --git a/src/providers/ldap/ldap_common.c b/src/providers/ldap/ldap_common.c
index dd782815..22cd7d9a 100644
--- a/src/providers/ldap/ldap_common.c
+++ b/src/providers/ldap/ldap_common.c
@@ -1303,7 +1303,8 @@ errno_t list_missing_attrs(TALLOC_CTX *mem_ctx,
return ENOMEM;
}
- ret = build_attrs_from_map(tmp_ctx, map, map_size, &expected_attrs, &attr_count);
+ ret = build_attrs_from_map(tmp_ctx, map, map_size, NULL,
+ &expected_attrs, &attr_count);
if (ret != EOK) {
goto done;
}
diff --git a/src/providers/ldap/ldap_id.c b/src/providers/ldap/ldap_id.c
index bdd640a9..889fbddc 100644
--- a/src/providers/ldap/ldap_id.c
+++ b/src/providers/ldap/ldap_id.c
@@ -151,8 +151,8 @@ struct tevent_req *users_get_send(TALLOC_CTX *memctx,
}
/* TODO: handle attrs_type */
- ret = build_attrs_from_map(state, ctx->opts->user_map,
- SDAP_OPTS_USER, &state->attrs, NULL);
+ ret = build_attrs_from_map(state, ctx->opts->user_map, SDAP_OPTS_USER,
+ NULL, &state->attrs, NULL);
if (ret != EOK) goto fail;
ret = users_get_retry(req);
@@ -439,8 +439,8 @@ struct tevent_req *groups_get_send(TALLOC_CTX *memctx,
}
/* TODO: handle attrs_type */
- ret = build_attrs_from_map(state, ctx->opts->group_map,
- SDAP_OPTS_GROUP, &state->attrs, NULL);
+ ret = build_attrs_from_map(state, ctx->opts->group_map, SDAP_OPTS_GROUP,
+ NULL, &state->attrs, NULL);
if (ret != EOK) goto fail;
ret = groups_get_retry(req);
@@ -631,8 +631,8 @@ static struct tevent_req *groups_by_user_send(TALLOC_CTX *memctx,
state->name = name;
- ret = build_attrs_from_map(state, ctx->opts->group_map,
- SDAP_OPTS_GROUP, &state->attrs, NULL);
+ ret = build_attrs_from_map(state, ctx->opts->group_map, SDAP_OPTS_GROUP,
+ NULL, &state->attrs, NULL);
if (ret != EOK) goto fail;
ret = groups_by_user_retry(req);
diff --git a/src/providers/ldap/ldap_id_enum.c b/src/providers/ldap/ldap_id_enum.c
index 107ab23f..53fc99fb 100644
--- a/src/providers/ldap/ldap_id_enum.c
+++ b/src/providers/ldap/ldap_id_enum.c
@@ -557,8 +557,8 @@ static struct tevent_req *enum_users_send(TALLOC_CTX *memctx,
}
/* TODO: handle attrs_type */
- ret = build_attrs_from_map(state, ctx->opts->user_map,
- SDAP_OPTS_USER, &state->attrs, NULL);
+ ret = build_attrs_from_map(state, ctx->opts->user_map, SDAP_OPTS_USER,
+ NULL, &state->attrs, NULL);
if (ret != EOK) goto fail;
/* TODO: restrict the enumerations to using a single
@@ -716,8 +716,8 @@ static struct tevent_req *enum_groups_send(TALLOC_CTX *memctx,
}
/* TODO: handle attrs_type */
- ret = build_attrs_from_map(state, ctx->opts->group_map,
- SDAP_OPTS_GROUP, &state->attrs, NULL);
+ ret = build_attrs_from_map(state, ctx->opts->group_map, SDAP_OPTS_GROUP,
+ NULL, &state->attrs, NULL);
if (ret != EOK) goto fail;
/* TODO: restrict the enumerations to using a single
diff --git a/src/providers/ldap/ldap_id_netgroup.c b/src/providers/ldap/ldap_id_netgroup.c
index 7fe7543f..58a9a346 100644
--- a/src/providers/ldap/ldap_id_netgroup.c
+++ b/src/providers/ldap/ldap_id_netgroup.c
@@ -98,8 +98,8 @@ struct tevent_req *ldap_netgroup_get_send(TALLOC_CTX *memctx,
}
talloc_zfree(clean_name);
- ret = build_attrs_from_map(state, ctx->opts->netgroup_map,
- SDAP_OPTS_NETGROUP, &state->attrs, NULL);
+ ret = build_attrs_from_map(state, ctx->opts->netgroup_map, SDAP_OPTS_NETGROUP,
+ NULL, &state->attrs, NULL);
if (ret != EOK) goto fail;
ret = ldap_netgroup_get_retry(req);
diff --git a/src/providers/ldap/ldap_id_services.c b/src/providers/ldap/ldap_id_services.c
index 16d696af..b0291351 100644
--- a/src/providers/ldap/ldap_id_services.c
+++ b/src/providers/ldap/ldap_id_services.c
@@ -135,7 +135,8 @@ services_get_send(TALLOC_CTX *mem_ctx,
state->filter));
ret = build_attrs_from_map(state, id_ctx->opts->service_map,
- SDAP_OPTS_SERVICES, &state->attrs, NULL);
+ SDAP_OPTS_SERVICES, NULL,
+ &state->attrs, NULL);
if (ret != EOK) goto error;
ret = services_get_retry(req);
diff --git a/src/providers/ldap/sdap.c b/src/providers/ldap/sdap.c
index 01ba418a..cb02f4a5 100644
--- a/src/providers/ldap/sdap.c
+++ b/src/providers/ldap/sdap.c
@@ -1019,10 +1019,28 @@ void sdap_steal_server_opts(struct sdap_id_ctx *id_ctx,
id_ctx->srv_opts = talloc_move(id_ctx, srv_opts);
}
+static bool attr_is_filtered(const char *attr, const char **filter)
+{
+ int i;
+
+ if (filter) {
+ i = 0;
+ while (filter[i]) {
+ if (filter[i] == attr ||
+ strcasecmp(filter[i], attr) == 0) {
+ return true;
+ }
+ i++;
+ }
+ }
+
+ return false;
+}
int build_attrs_from_map(TALLOC_CTX *memctx,
struct sdap_attr_map *map,
size_t size,
+ const char **filter,
const char ***_attrs,
size_t *attr_count)
{
@@ -1045,7 +1063,7 @@ int build_attrs_from_map(TALLOC_CTX *memctx,
/* add the others */
for (i = j = 1; i < size; i++) {
- if (map[i].name) {
+ if (map[i].name && !attr_is_filtered(map[i].name, filter)) {
attrs[j] = map[i].name;
j++;
}
diff --git a/src/providers/ldap/sdap.h b/src/providers/ldap/sdap.h
index 61f899f3..90558221 100644
--- a/src/providers/ldap/sdap.h
+++ b/src/providers/ldap/sdap.h
@@ -454,6 +454,7 @@ bool sdap_check_sup_list(struct sup_list *l, const char *val);
int build_attrs_from_map(TALLOC_CTX *memctx,
struct sdap_attr_map *map,
size_t size,
+ const char **filter,
const char ***_attrs,
size_t *attr_count);
diff --git a/src/providers/ldap/sdap_async_autofs.c b/src/providers/ldap/sdap_async_autofs.c
index d8a2d0ee..9c8337d3 100644
--- a/src/providers/ldap/sdap_async_autofs.c
+++ b/src/providers/ldap/sdap_async_autofs.c
@@ -242,7 +242,8 @@ automntmaps_process_members_send(TALLOC_CTX *mem_ctx,
}
ret = build_attrs_from_map(state, opts->autofs_entry_map,
- SDAP_OPTS_AUTOFS_ENTRY, &state->attrs, NULL);
+ SDAP_OPTS_AUTOFS_ENTRY, NULL,
+ &state->attrs, NULL);
if (ret != EOK) {
DEBUG(SSSDBG_CRIT_FAILURE, ("Failed to build attributes from map\n"));
ret = ENOMEM;
@@ -674,7 +675,8 @@ sdap_autofs_setautomntent_send(TALLOC_CTX *memctx,
talloc_free(clean_mapname);
ret = build_attrs_from_map(state, state->opts->autofs_mobject_map,
- SDAP_OPTS_AUTOFS_MAP, &state->attrs, NULL);
+ SDAP_OPTS_AUTOFS_MAP, NULL,
+ &state->attrs, NULL);
if (ret != EOK) {
DEBUG(SSSDBG_CRIT_FAILURE, ("Failed to build attributes from map\n"));
ret = ENOMEM;
diff --git a/src/providers/ldap/sdap_async_groups.c b/src/providers/ldap/sdap_async_groups.c
index 637a2527..2a079228 100644
--- a/src/providers/ldap/sdap_async_groups.c
+++ b/src/providers/ldap/sdap_async_groups.c
@@ -728,7 +728,7 @@ struct tevent_req *sdap_process_group_send(TALLOC_CTX *memctx,
if (!req) return NULL;
ret = build_attrs_from_map(grp_state, opts->user_map, SDAP_OPTS_USER,
- &attrs, NULL);
+ NULL, &attrs, NULL);
if (ret) {
goto done;
}
@@ -2484,8 +2484,8 @@ sdap_nested_group_process_deref_call(struct tevent_req *req)
/* Pull down the whole group map, but only pull down username
* and originalDN for users. */
- ret = build_attrs_from_map(state, state->opts->group_map,
- SDAP_OPTS_GROUP, &sdap_attrs, &attr_count);
+ ret = build_attrs_from_map(state, state->opts->group_map, SDAP_OPTS_GROUP,
+ NULL, &sdap_attrs, &attr_count);
if (ret != EOK) goto fail;
sdap_attrs = talloc_realloc(NULL, sdap_attrs, const char *,
@@ -2687,8 +2687,8 @@ static errno_t sdap_nested_group_lookup_group(struct tevent_req *req)
return EOK;
}
- ret = build_attrs_from_map(state, state->opts->group_map,
- SDAP_OPTS_GROUP, &sdap_attrs, NULL);
+ ret = build_attrs_from_map(state, state->opts->group_map, SDAP_OPTS_GROUP,
+ NULL, &sdap_attrs, NULL);
if (ret != EOK) {
return ret;
}
diff --git a/src/providers/ldap/sdap_async_initgroups.c b/src/providers/ldap/sdap_async_initgroups.c
index 86117600..1911b1bb 100644
--- a/src/providers/ldap/sdap_async_initgroups.c
+++ b/src/providers/ldap/sdap_async_initgroups.c
@@ -353,8 +353,8 @@ struct tevent_req *sdap_initgr_rfc2307_send(TALLOC_CTX *memctx,
return NULL;
}
- ret = build_attrs_from_map(state, opts->group_map,
- SDAP_OPTS_GROUP, &state->attrs, NULL);
+ ret = build_attrs_from_map(state, opts->group_map, SDAP_OPTS_GROUP,
+ NULL, &state->attrs, NULL);
if (ret != EOK) {
talloc_free(req);
return NULL;
@@ -843,8 +843,8 @@ static errno_t sdap_initgr_nested_deref_search(struct tevent_req *req)
maps[0].num_attrs = SDAP_OPTS_GROUP;
maps[1].map = NULL;
- ret = build_attrs_from_map(state, state->opts->group_map,
- SDAP_OPTS_GROUP, &sdap_attrs, NULL);
+ ret = build_attrs_from_map(state, state->opts->group_map, SDAP_OPTS_GROUP,
+ NULL, &sdap_attrs, NULL);
if (ret != EOK) goto fail;
timeout = dp_opt_get_int(state->opts->basic, SDAP_SEARCH_TIMEOUT);
@@ -1495,8 +1495,8 @@ static struct tevent_req *sdap_initgr_rfc2307bis_send(
return NULL;
}
- ret = build_attrs_from_map(state, opts->group_map,
- SDAP_OPTS_GROUP, &state->attrs, NULL);
+ ret = build_attrs_from_map(state, opts->group_map, SDAP_OPTS_GROUP,
+ NULL, &state->attrs, NULL);
if (ret != EOK) goto done;
ret = sss_filter_sanitize(state, orig_dn, &clean_orig_dn);
@@ -2168,8 +2168,8 @@ static errno_t rfc2307bis_nested_groups_step(struct tevent_req *req)
goto done;
}
- ret = build_attrs_from_map(state, state->opts->group_map,
- SDAP_OPTS_GROUP, &state->attrs, NULL);
+ ret = build_attrs_from_map(state, state->opts->group_map, SDAP_OPTS_GROUP,
+ NULL, &state->attrs, NULL);
if (ret != EOK) {
goto done;
}
@@ -2504,8 +2504,8 @@ struct tevent_req *sdap_get_initgr_send(TALLOC_CTX *memctx,
return NULL;
}
- ret = build_attrs_from_map(state, state->opts->user_map,
- SDAP_OPTS_USER, &state->user_attrs, NULL);
+ ret = build_attrs_from_map(state, state->opts->user_map, SDAP_OPTS_USER,
+ NULL, &state->user_attrs, NULL);
if (ret) {
talloc_zfree(req);
return NULL;
diff --git a/src/providers/ldap/sdap_async_services.c b/src/providers/ldap/sdap_async_services.c
index 895ea7e7..a59db6c6 100644
--- a/src/providers/ldap/sdap_async_services.c
+++ b/src/providers/ldap/sdap_async_services.c
@@ -572,7 +572,8 @@ enum_services_send(TALLOC_CTX *memctx,
/* TODO: handle attrs_type */
ret = build_attrs_from_map(state, id_ctx->opts->service_map,
- SDAP_OPTS_SERVICES, &state->attrs, NULL);
+ SDAP_OPTS_SERVICES, NULL,
+ &state->attrs, NULL);
if (ret != EOK) goto fail;
subreq = sdap_get_services_send(state, state->ev,
diff --git a/src/providers/ldap/sdap_sudo.c b/src/providers/ldap/sdap_sudo.c
index 23fd062c..75d30430 100644
--- a/src/providers/ldap/sdap_sudo.c
+++ b/src/providers/ldap/sdap_sudo.c
@@ -456,7 +456,7 @@ struct tevent_req * sdap_sudo_load_sudoers_send(TALLOC_CTX *mem_ctx,
/* create attrs from map */
ret = build_attrs_from_map(state, opts->sudorule_map, SDAP_OPTS_SUDO,
- &state->attrs, NULL);
+ NULL, &state->attrs, NULL);
if (ret != EOK) {
goto fail;
}