From e79d23932ef9d52cf4eb32ddec2d0a9b3af9a9eb Mon Sep 17 00:00:00 2001 From: Jan Zeleny Date: Fri, 20 May 2011 03:48:05 -0400 Subject: sysdb refactoring: memory context deleted This patch deletes memory context parameter in those places in sysdb where it is not necessary. The code using modified functions has been updated. Tests updated as well. --- src/providers/ldap/ldap_auth.c | 3 +-- src/providers/ldap/ldap_id.c | 12 +++++------- src/providers/ldap/ldap_id_cleanup.c | 4 ++-- src/providers/ldap/sdap_access.c | 3 +-- src/providers/ldap/sdap_async_accounts.c | 18 ++++++------------ 5 files changed, 15 insertions(+), 25 deletions(-) (limited to 'src/providers/ldap') diff --git a/src/providers/ldap/ldap_auth.c b/src/providers/ldap/ldap_auth.c index efc9f5278..ad4549e7c 100644 --- a/src/providers/ldap/ldap_auth.c +++ b/src/providers/ldap/ldap_auth.c @@ -1098,8 +1098,7 @@ static void sdap_pam_auth_done(struct tevent_req *req) } talloc_set_destructor((TALLOC_CTX *)password, password_destructor); - ret = sysdb_cache_password(state, - state->breq->be_ctx->sysdb, + ret = sysdb_cache_password(state->breq->be_ctx->sysdb, state->username, password); /* password caching failures are not fatal errors */ diff --git a/src/providers/ldap/ldap_id.c b/src/providers/ldap/ldap_id.c index 9525224bf..2d8aefff8 100644 --- a/src/providers/ldap/ldap_id.c +++ b/src/providers/ldap/ldap_id.c @@ -227,7 +227,7 @@ static void users_get_done(struct tevent_req *subreq) tevent_req_error(req, ret); return; case BE_FILTER_NAME: - ret = sysdb_delete_user(state, state->sysdb, state->name, 0); + ret = sysdb_delete_user(state->sysdb, state->name, 0); if (ret != EOK && ret != ENOENT) { tevent_req_error(req, ret); return; @@ -241,7 +241,7 @@ static void users_get_done(struct tevent_req *subreq) return; } - ret = sysdb_delete_user(state, state->sysdb, NULL, uid); + ret = sysdb_delete_user(state->sysdb, NULL, uid); if (ret != EOK && ret != ENOENT) { tevent_req_error(req, ret); return; @@ -470,7 +470,7 @@ static void groups_get_done(struct tevent_req *subreq) tevent_req_error(req, ret); return; case BE_FILTER_NAME: - ret = sysdb_delete_group(state, state->sysdb, state->name, 0); + ret = sysdb_delete_group(state->sysdb, state->name, 0); if (ret != EOK && ret != ENOENT) { tevent_req_error(req, ret); return; @@ -484,7 +484,7 @@ static void groups_get_done(struct tevent_req *subreq) return; } - ret = sysdb_delete_group(state, state->sysdb, NULL, gid); + ret = sysdb_delete_group(state->sysdb, NULL, gid); if (ret != EOK && ret != ENOENT) { tevent_req_error(req, ret); return; @@ -652,9 +652,7 @@ static void groups_by_user_done(struct tevent_req *subreq) } if (ret == ENOENT) { - ret = sysdb_delete_user(state, - state->ctx->be->sysdb, - state->name, 0); + ret = sysdb_delete_user(state->ctx->be->sysdb, state->name, 0); if (ret != EOK && ret != ENOENT) { tevent_req_error(req, ret); return; diff --git a/src/providers/ldap/ldap_id_cleanup.c b/src/providers/ldap/ldap_id_cleanup.c index fc6592712..9c50ee485 100644 --- a/src/providers/ldap/ldap_id_cleanup.c +++ b/src/providers/ldap/ldap_id_cleanup.c @@ -336,7 +336,7 @@ static int cleanup_users(TALLOC_CTX *memctx, struct sdap_id_ctx *ctx) /* If not logged in or cannot check the table, delete him */ DEBUG(9, ("About to delete user %s\n", name)); - ret = sysdb_delete_user(tmpctx, sysdb, name, 0); + ret = sysdb_delete_user(sysdb, name, 0); if (ret) { goto done; } @@ -465,7 +465,7 @@ static int cleanup_groups(TALLOC_CTX *memctx, } DEBUG(8, ("About to delete group %s\n", name)); - ret = sysdb_delete_group(tmpctx, sysdb, name, 0); + ret = sysdb_delete_group(sysdb, name, 0); if (ret) { DEBUG(2, ("Group delete returned %d (%s)\n", ret, strerror(ret))); diff --git a/src/providers/ldap/sdap_access.c b/src/providers/ldap/sdap_access.c index 0ac0f639b..9f10a1464 100644 --- a/src/providers/ldap/sdap_access.c +++ b/src/providers/ldap/sdap_access.c @@ -1058,8 +1058,7 @@ static void sdap_access_filter_get_access_done(struct tevent_req *subreq) goto done; } - ret = sysdb_set_user_attr(attrs, - state->be_ctx->sysdb, + ret = sysdb_set_user_attr(state->be_ctx->sysdb, state->username, attrs, SYSDB_MOD_REP); if (ret != EOK) { diff --git a/src/providers/ldap/sdap_async_accounts.c b/src/providers/ldap/sdap_async_accounts.c index a6907a34d..476532459 100644 --- a/src/providers/ldap/sdap_async_accounts.c +++ b/src/providers/ldap/sdap_async_accounts.c @@ -298,8 +298,7 @@ static int sdap_save_user(TALLOC_CTX *memctx, DEBUG(6, ("Storing info for user %s\n", name)); - ret = sysdb_store_user(user_attrs, ctx, - name, pwd, uid, gid, gecos, homedir, shell, + ret = sysdb_store_user(ctx, name, pwd, uid, gid, gecos, homedir, shell, user_attrs, missing, cache_timeout); if (ret) goto fail; @@ -664,8 +663,7 @@ done: /* FIXME: support storing additional attributes */ static errno_t -sdap_store_group_with_gid(TALLOC_CTX *mem_ctx, - struct sysdb_ctx *ctx, +sdap_store_group_with_gid(struct sysdb_ctx *ctx, const char *name, gid_t gid, struct sysdb_attrs *group_attrs, @@ -684,9 +682,7 @@ sdap_store_group_with_gid(TALLOC_CTX *mem_ctx, } } - ret = sysdb_store_group(mem_ctx, ctx, - name, gid, group_attrs, - cache_timeout); + ret = sysdb_store_group(ctx, name, gid, group_attrs, cache_timeout); if (ret) { DEBUG(2, ("Could not store group %s\n", name)); return ret; @@ -856,8 +852,7 @@ static int sdap_save_group(TALLOC_CTX *memctx, DEBUG(6, ("Storing info for group %s\n", name)); - ret = sdap_store_group_with_gid(group_attrs, ctx, - name, gid, group_attrs, + ret = sdap_store_group_with_gid(ctx, name, gid, group_attrs, dp_opt_get_int(opts->basic, SDAP_ENTRY_CACHE_TIMEOUT), posix_group); @@ -928,7 +923,7 @@ static int sdap_save_grpmem(TALLOC_CTX *memctx, DEBUG(6, ("Storing members for group %s\n", name)); - ret = sysdb_store_group(memctx, ctx, name, 0, group_attrs, + ret = sysdb_store_group(ctx, name, 0, group_attrs, dp_opt_get_int(opts->basic, SDAP_ENTRY_CACHE_TIMEOUT)); if (ret) goto fail; @@ -2052,8 +2047,7 @@ static errno_t sdap_nested_group_populate_users(struct sysdb_ctx *sysdb, ret = sysdb_attrs_add_string(attrs, SYSDB_NAME, username); if (ret) goto done; - ret = sysdb_set_user_attr(tmp_ctx, sysdb, - sysdb_name, attrs, SYSDB_MOD_REP); + ret = sysdb_set_user_attr(sysdb, sysdb_name, attrs, SYSDB_MOD_REP); if (ret != EOK) goto done; } -- cgit