diff options
author | Stephen Gallagher <sgallagh@redhat.com> | 2010-04-12 09:17:41 -0400 |
---|---|---|
committer | Stephen Gallagher <sgallagh@redhat.com> | 2010-04-12 09:22:11 -0400 |
commit | cae9c9fbdebc3f6a4c390a20e75447217439dff7 (patch) | |
tree | c154ccd741e229430e630aa8980f6d4a32e5587d /src/db | |
parent | a21698161dcc506e469d7af58099e952062ff256 (diff) | |
download | sssd-cae9c9fbdebc3f6a4c390a20e75447217439dff7.tar.gz sssd-cae9c9fbdebc3f6a4c390a20e75447217439dff7.tar.xz sssd-cae9c9fbdebc3f6a4c390a20e75447217439dff7.zip |
sysdb: convert sysdb_delete_entry
Diffstat (limited to 'src/db')
-rw-r--r-- | src/db/sysdb.h | 9 | ||||
-rw-r--r-- | src/db/sysdb_ops.c | 74 |
2 files changed, 33 insertions, 50 deletions
diff --git a/src/db/sysdb.h b/src/db/sysdb.h index cf97ed62d..2fa1c7f98 100644 --- a/src/db/sysdb.h +++ b/src/db/sysdb.h @@ -331,12 +331,9 @@ int sysdb_get_user_attr(TALLOC_CTX *mem_ctx, * See sysdb_transaction_send()/_recv() */ /* Delete Entry */ -struct tevent_req *sysdb_delete_entry_send(TALLOC_CTX *mem_ctx, - struct tevent_context *ev, - struct sysdb_handle *handle, - struct ldb_dn *dn, - bool ignore_not_found); -int sysdb_delete_entry_recv(struct tevent_req *req); +int sysdb_delete_entry(struct sysdb_ctx *ctx, + struct ldb_dn *dn, + bool ignore_not_found); struct tevent_req *sysdb_delete_recursive_send(TALLOC_CTX *mem_ctx, diff --git a/src/db/sysdb_ops.c b/src/db/sysdb_ops.c index 618b81086..248ebfb6f 100644 --- a/src/db/sysdb_ops.c +++ b/src/db/sysdb_ops.c @@ -251,6 +251,29 @@ static int sysdb_op_default_recv(struct tevent_req *req) /* =Remove-Entry-From-Sysdb=============================================== */ +int sysdb_delete_entry(struct sysdb_ctx *ctx, + struct ldb_dn *dn, + bool ignore_not_found) +{ + int ret; + + ret = ldb_delete(ctx->ldb, dn); + switch (ret) { + case LDB_SUCCESS: + return EOK; + case LDB_ERR_NO_SUCH_OBJECT: + if (ignore_not_found) { + return EOK; + } + /* fall through */ + default: + DEBUG(1, ("LDB Error: %s(%d)\nError Message: [%s]\n", + ldb_strerror(ret), ret, ldb_errstring(ctx->ldb))); + return sysdb_error_to_errno(ret); + } +} + +static struct tevent_req *sysdb_delete_entry_send(TALLOC_CTX *mem_ctx, struct tevent_context *ev, struct sysdb_handle *handle, @@ -294,12 +317,12 @@ fail: return req; } +static int sysdb_delete_entry_recv(struct tevent_req *req) { return sysdb_op_default_recv(req); } - /* =Remove-Subentries-From-Sysdb=============================================== */ struct sysdb_delete_recursive_state { @@ -4218,7 +4241,6 @@ struct sysdb_delete_user_state { }; void sysdb_delete_user_check_handle(struct tevent_req *subreq); -static void sysdb_delete_user_found(struct tevent_req *subreq); static void sysdb_delete_user_done(struct tevent_req *subreq); struct tevent_req *sysdb_delete_user_send(TALLOC_CTX *mem_ctx, @@ -4282,10 +4304,10 @@ void sysdb_delete_user_check_handle(struct tevent_req *subreq) tevent_req_error(req, ENOMEM); return; } - tevent_req_set_callback(subreq, sysdb_delete_user_found, req); + tevent_req_set_callback(subreq, sysdb_delete_user_done, req); } -static void sysdb_delete_user_found(struct tevent_req *subreq) +static void sysdb_delete_user_done(struct tevent_req *subreq) { struct tevent_req *req = tevent_req_callback_data(subreq, struct tevent_req); @@ -4320,24 +4342,7 @@ static void sysdb_delete_user_found(struct tevent_req *subreq) } } - subreq = sysdb_delete_entry_send(state, state->ev, - state->handle, msg->dn, false); - if (!subreq) { - DEBUG(6, ("Error: Out of memory\n")); - tevent_req_error(req, ENOMEM); - return; - } - tevent_req_set_callback(subreq, sysdb_delete_user_done, req); -} - -static void sysdb_delete_user_done(struct tevent_req *subreq) -{ - struct tevent_req *req = tevent_req_callback_data(subreq, - struct tevent_req); - int ret; - - ret = sysdb_delete_entry_recv(subreq); - talloc_zfree(subreq); + ret = sysdb_delete_entry(state->handle->ctx, msg->dn, false); if (ret) { tevent_req_error(req, ret); return; @@ -4502,8 +4507,6 @@ struct sysdb_delete_group_state { }; void sysdb_delete_group_check_handle(struct tevent_req *subreq); -static void sysdb_delete_group_found(struct tevent_req *subreq); -static void sysdb_delete_group_done(struct tevent_req *subreq); struct tevent_req *sysdb_delete_group_send(TALLOC_CTX *mem_ctx, struct tevent_context *ev, @@ -4566,10 +4569,10 @@ void sysdb_delete_group_check_handle(struct tevent_req *subreq) tevent_req_error(req, ENOMEM); return; } - tevent_req_set_callback(subreq, sysdb_delete_group_found, req); + tevent_req_set_callback(subreq, sysdb_delete_group_done, req); } -static void sysdb_delete_group_found(struct tevent_req *subreq) +static void sysdb_delete_group_done(struct tevent_req *subreq) { struct tevent_req *req = tevent_req_callback_data(subreq, struct tevent_req); @@ -4604,24 +4607,7 @@ static void sysdb_delete_group_found(struct tevent_req *subreq) } } - subreq = sysdb_delete_entry_send(state, state->ev, - state->handle, msg->dn, false); - if (!subreq) { - DEBUG(6, ("Error: Out of memory\n")); - tevent_req_error(req, ENOMEM); - return; - } - tevent_req_set_callback(subreq, sysdb_delete_group_done, req); -} - -static void sysdb_delete_group_done(struct tevent_req *subreq) -{ - struct tevent_req *req = tevent_req_callback_data(subreq, - struct tevent_req); - int ret; - - ret = sysdb_delete_entry_recv(subreq); - talloc_zfree(subreq); + ret = sysdb_delete_entry(state->handle->ctx, msg->dn, false); if (ret) { tevent_req_error(req, ret); return; |