summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/providers/ldap/ldap_common.c20
-rw-r--r--src/providers/ldap/ldap_common.h1
-rw-r--r--src/providers/ldap/sdap_async_groups.c2
-rw-r--r--src/providers/ldap/sdap_async_initgroups.c2
-rw-r--r--src/providers/ldap/sdap_async_netgroups.c16
-rw-r--r--src/providers/ldap/sdap_async_private.h2
-rw-r--r--src/providers/ldap/sdap_async_services.c9
-rw-r--r--src/providers/ldap/sdap_async_users.c13
8 files changed, 21 insertions, 44 deletions
diff --git a/src/providers/ldap/ldap_common.c b/src/providers/ldap/ldap_common.c
index 3b6a1b2ba..ee2b56b6f 100644
--- a/src/providers/ldap/ldap_common.c
+++ b/src/providers/ldap/ldap_common.c
@@ -1511,7 +1511,6 @@ errno_t get_sysdb_attr_name(TALLOC_CTX *mem_ctx,
errno_t list_missing_attrs(TALLOC_CTX *mem_ctx,
struct sdap_attr_map *map,
size_t map_size,
- const char **expected_attrs,
struct sysdb_attrs *recvd_attrs,
char ***missing_attrs)
{
@@ -1519,10 +1518,11 @@ errno_t list_missing_attrs(TALLOC_CTX *mem_ctx,
size_t attr_count = 0;
size_t i, j, k;
char **missing = NULL;
+ const char **expected_attrs;
char *sysdb_name;
TALLOC_CTX *tmp_ctx;
- if (!expected_attrs || !recvd_attrs || !missing_attrs) {
+ if (!recvd_attrs || !missing_attrs) {
return EINVAL;
}
@@ -1531,6 +1531,11 @@ errno_t list_missing_attrs(TALLOC_CTX *mem_ctx,
return ENOMEM;
}
+ ret = build_attrs_from_map(tmp_ctx, map, map_size, &expected_attrs);
+ if (ret != EOK) {
+ goto done;
+ }
+
/* Count the expected attrs */
while(expected_attrs[attr_count]) attr_count++;
@@ -1591,11 +1596,14 @@ errno_t list_missing_attrs(TALLOC_CTX *mem_ctx,
}
}
- /* Terminate the list */
- missing[k] = NULL;
-
+ if (k == 0) {
+ *missing = NULL;
+ } else {
+ /* Terminate the list */
+ missing[k] = NULL;
+ *missing_attrs = talloc_steal(mem_ctx, missing);
+ }
ret = EOK;
- *missing_attrs = talloc_steal(mem_ctx, missing);
done:
talloc_free(tmp_ctx);
diff --git a/src/providers/ldap/ldap_common.h b/src/providers/ldap/ldap_common.h
index 7c472cf44..58054afe6 100644
--- a/src/providers/ldap/ldap_common.h
+++ b/src/providers/ldap/ldap_common.h
@@ -186,7 +186,6 @@ errno_t get_sysdb_attr_name(TALLOC_CTX *mem_ctx,
errno_t list_missing_attrs(TALLOC_CTX *mem_ctx,
struct sdap_attr_map *map,
size_t map_size,
- const char **expected_attrs,
struct sysdb_attrs *recvd_attrs,
char ***missing_attrs);
diff --git a/src/providers/ldap/sdap_async_groups.c b/src/providers/ldap/sdap_async_groups.c
index d58ed468c..aad2990c5 100644
--- a/src/providers/ldap/sdap_async_groups.c
+++ b/src/providers/ldap/sdap_async_groups.c
@@ -1123,7 +1123,7 @@ next:
}
if (state->check_count == 0) {
- ret = sdap_save_users(state, state->sysdb, state->attrs,
+ ret = sdap_save_users(state, state->sysdb,
state->dom, state->opts,
state->new_members, state->count, NULL);
if (ret) {
diff --git a/src/providers/ldap/sdap_async_initgroups.c b/src/providers/ldap/sdap_async_initgroups.c
index 2f8e1ef62..1e2e6178d 100644
--- a/src/providers/ldap/sdap_async_initgroups.c
+++ b/src/providers/ldap/sdap_async_initgroups.c
@@ -2548,7 +2548,7 @@ static void sdap_get_initgr_user(struct tevent_req *subreq)
ret = sdap_save_user(state, state->sysdb,
state->opts, state->dom,
- state->orig_user, state->user_attrs,
+ state->orig_user,
true, NULL, 0);
if (ret) {
sysdb_transaction_cancel(state->sysdb);
diff --git a/src/providers/ldap/sdap_async_netgroups.c b/src/providers/ldap/sdap_async_netgroups.c
index a5f30623d..2262db51c 100644
--- a/src/providers/ldap/sdap_async_netgroups.c
+++ b/src/providers/ldap/sdap_async_netgroups.c
@@ -49,7 +49,6 @@ static errno_t sdap_save_netgroup(TALLOC_CTX *memctx,
const char *name = NULL;
int ret;
char *timestamp = NULL;
- const char **ldap_attrs = NULL;
char **missing = NULL;
ret = sysdb_attrs_get_el(attrs,
@@ -129,29 +128,16 @@ static errno_t sdap_save_netgroup(TALLOC_CTX *memctx,
goto fail;
}
- ret = build_attrs_from_map(attrs, opts->netgroup_map, SDAP_OPTS_NETGROUP,
- &ldap_attrs);
- if (ret != EOK) {
- DEBUG(SSSDBG_CRIT_FAILURE, ("Failed to retrieve attributes from map\n"));
- goto fail;
- }
-
/* Make sure that any attributes we requested from LDAP that we
* did not receive are also removed from the sysdb
*/
ret = list_missing_attrs(attrs, opts->netgroup_map, SDAP_OPTS_NETGROUP,
- ldap_attrs, attrs, &missing);
+ attrs, &missing);
if (ret != EOK) {
DEBUG(SSSDBG_CRIT_FAILURE, ("Failed to list missing attributes\n"));
goto fail;
}
- /* Remove missing attributes */
- if (missing && !missing[0]) {
- /* Nothing to remove */
- talloc_zfree(missing);
- }
-
ret = sysdb_add_netgroup(ctx, name, NULL, netgroup_attrs, missing,
dom->netgroup_timeout, now);
if (ret) goto fail;
diff --git a/src/providers/ldap/sdap_async_private.h b/src/providers/ldap/sdap_async_private.h
index 4192a225e..f6ed68005 100644
--- a/src/providers/ldap/sdap_async_private.h
+++ b/src/providers/ldap/sdap_async_private.h
@@ -94,14 +94,12 @@ int sdap_save_user(TALLOC_CTX *memctx,
struct sdap_options *opts,
struct sss_domain_info *dom,
struct sysdb_attrs *attrs,
- const char **ldap_attrs,
bool is_initgr,
char **_usn_value,
time_t now);
int sdap_save_users(TALLOC_CTX *memctx,
struct sysdb_ctx *sysdb,
- const char **attrs,
struct sss_domain_info *dom,
struct sdap_options *opts,
struct sysdb_attrs **users,
diff --git a/src/providers/ldap/sdap_async_services.c b/src/providers/ldap/sdap_async_services.c
index 783861c70..ae96d8882 100644
--- a/src/providers/ldap/sdap_async_services.c
+++ b/src/providers/ldap/sdap_async_services.c
@@ -53,7 +53,6 @@ sdap_get_services_process(struct tevent_req *subreq);
static errno_t
sdap_save_services(TALLOC_CTX *memctx,
struct sysdb_ctx *sysdb,
- const char **attrs,
struct sss_domain_info *dom,
struct sdap_options *opts,
struct sysdb_attrs **services,
@@ -65,7 +64,6 @@ sdap_save_service(TALLOC_CTX *mem_ctx,
struct sdap_options *opts,
struct sss_domain_info *dom,
struct sysdb_attrs *attrs,
- const char **ldap_attrs,
char **_usn_value,
time_t now);
@@ -231,7 +229,6 @@ sdap_get_services_process(struct tevent_req *subreq)
}
ret = sdap_save_services(state, state->sysdb,
- state->attrs,
state->dom, state->opts,
state->services, state->count,
&state->higher_usn);
@@ -251,7 +248,6 @@ sdap_get_services_process(struct tevent_req *subreq)
static errno_t
sdap_save_services(TALLOC_CTX *mem_ctx,
struct sysdb_ctx *sysdb,
- const char **attrs,
struct sss_domain_info *dom,
struct sdap_options *opts,
struct sysdb_attrs **services,
@@ -286,7 +282,7 @@ sdap_save_services(TALLOC_CTX *mem_ctx,
usn_value = NULL;
ret = sdap_save_service(tmp_ctx, sysdb, opts, dom,
- services[i], attrs,
+ services[i],
&usn_value, now);
/* Do not fail completely on errors.
@@ -344,7 +340,6 @@ sdap_save_service(TALLOC_CTX *mem_ctx,
struct sdap_options *opts,
struct sss_domain_info *dom,
struct sysdb_attrs *attrs,
- const char **ldap_attrs,
char **_usn_value,
time_t now)
{
@@ -451,7 +446,7 @@ sdap_save_service(TALLOC_CTX *mem_ctx,
* that have been removed from LDAP
*/
ret = list_missing_attrs(svc_attrs, opts->service_map, SDAP_OPTS_SERVICES,
- ldap_attrs, attrs, &missing);
+ attrs, &missing);
if (ret != EOK) {
DEBUG(SSSDBG_MINOR_FAILURE,
("Failed to identify removed attributes: [%s]\n",
diff --git a/src/providers/ldap/sdap_async_users.c b/src/providers/ldap/sdap_async_users.c
index 57540749c..200670404 100644
--- a/src/providers/ldap/sdap_async_users.c
+++ b/src/providers/ldap/sdap_async_users.c
@@ -34,7 +34,6 @@ int sdap_save_user(TALLOC_CTX *memctx,
struct sdap_options *opts,
struct sss_domain_info *dom,
struct sysdb_attrs *attrs,
- const char **ldap_attrs,
bool is_initgr,
char **_usn_value,
time_t now)
@@ -256,17 +255,11 @@ int sdap_save_user(TALLOC_CTX *memctx,
* did not receive are also removed from the sysdb
*/
ret = list_missing_attrs(user_attrs, opts->user_map, SDAP_OPTS_USER,
- ldap_attrs, attrs, &missing);
+ attrs, &missing);
if (ret != EOK) {
goto fail;
}
- /* Remove missing attributes */
- if (missing && !missing[0]) {
- /* Nothing to remove */
- talloc_zfree(missing);
- }
-
DEBUG(6, ("Storing info for user %s\n", name));
ret = sysdb_store_user(ctx, name, pwd, uid, gid, gecos, homedir, shell,
@@ -293,7 +286,6 @@ fail:
int sdap_save_users(TALLOC_CTX *memctx,
struct sysdb_ctx *sysdb,
- const char **attrs,
struct sss_domain_info *dom,
struct sdap_options *opts,
struct sysdb_attrs **users,
@@ -327,7 +319,7 @@ int sdap_save_users(TALLOC_CTX *memctx,
usn_value = NULL;
ret = sdap_save_user(tmpctx, sysdb, opts, dom,
- users[i], attrs, false,
+ users[i], false,
&usn_value, now);
/* Do not fail completely on errors.
@@ -558,7 +550,6 @@ static void sdap_get_users_process(struct tevent_req *subreq)
}
ret = sdap_save_users(state, state->sysdb,
- state->attrs,
state->dom, state->opts,
state->users, state->count,
&state->higher_usn);