summaryrefslogtreecommitdiffstats
path: root/src/tools
diff options
context:
space:
mode:
authorStephen Gallagher <sgallagh@redhat.com>2010-04-12 09:17:41 -0400
committerStephen Gallagher <sgallagh@redhat.com>2010-04-12 09:22:11 -0400
commitcae9c9fbdebc3f6a4c390a20e75447217439dff7 (patch)
treec154ccd741e229430e630aa8980f6d4a32e5587d /src/tools
parenta21698161dcc506e469d7af58099e952062ff256 (diff)
downloadsssd-cae9c9fbdebc3f6a4c390a20e75447217439dff7.tar.gz
sssd-cae9c9fbdebc3f6a4c390a20e75447217439dff7.tar.xz
sssd-cae9c9fbdebc3f6a4c390a20e75447217439dff7.zip
sysdb: convert sysdb_delete_entry
Diffstat (limited to 'src/tools')
-rw-r--r--src/tools/sss_groupdel.c17
-rw-r--r--src/tools/sss_sync_ops.c227
-rw-r--r--src/tools/sss_sync_ops.h4
-rw-r--r--src/tools/sss_userdel.c7
4 files changed, 18 insertions, 237 deletions
diff --git a/src/tools/sss_groupdel.c b/src/tools/sss_groupdel.c
index e5b043e27..32335571d 100644
--- a/src/tools/sss_groupdel.c
+++ b/src/tools/sss_groupdel.c
@@ -110,24 +110,9 @@ int main(int argc, const char **argv)
goto fini;
}
- start_transaction(tctx);
- if (tctx->error != EOK) {
- goto done;
- }
-
/* groupdel */
- ret = groupdel(tctx, tctx->ev, tctx->sysdb, tctx->handle, tctx->octx);
- if (ret != EOK) {
- tctx->error = ret;
-
- /* cancel transaction */
- talloc_zfree(tctx->handle);
- goto done;
- }
-
- end_transaction(tctx);
+ ret = groupdel(tctx, tctx->sysdb, tctx->octx);
- ret = tctx->error;
done:
if (ret) {
DEBUG(1, ("sysdb operation failed (%d)[%s]\n", ret, strerror(ret)));
diff --git a/src/tools/sss_sync_ops.c b/src/tools/sss_sync_ops.c
index 498be2849..7feeedf29 100644
--- a/src/tools/sss_sync_ops.c
+++ b/src/tools/sss_sync_ops.c
@@ -397,80 +397,6 @@ static int user_add_recv(struct tevent_req *req)
}
/*
- * Remove a user
- */
-struct user_del_state {
- struct tevent_context *ev;
- struct sysdb_ctx *sysdb;
- struct sysdb_handle *handle;
-
- struct ops_ctx *data;
-};
-
-static void user_del_done(struct tevent_req *subreq);
-
-static struct tevent_req *user_del_send(TALLOC_CTX *mem_ctx,
- struct tevent_context *ev,
- struct sysdb_ctx *sysdb,
- struct sysdb_handle *handle,
- struct ops_ctx *data)
-{
- struct user_del_state *state = NULL;
- struct tevent_req *req;
- struct tevent_req *subreq;
- struct ldb_dn *user_dn;
-
- req = tevent_req_create(mem_ctx, &state, struct user_del_state);
- if (req == NULL) {
- talloc_zfree(req);
- return NULL;
- }
- state->ev = ev;
- state->sysdb = sysdb;
- state->handle = handle;
- state->data = data;
-
- user_dn = sysdb_user_dn(state->sysdb, state,
- state->data->domain->name, state->data->name);
- if (!user_dn) {
- DEBUG(1, ("Could not construct a user DN\n"));
- return NULL;
- }
-
- subreq = sysdb_delete_entry_send(state,
- state->ev, state->handle,
- user_dn, false);
- if (!subreq) {
- talloc_zfree(req);
- return NULL;
- }
-
- tevent_req_set_callback(subreq, user_del_done, req);
- return req;
-}
-
-static void user_del_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);
- if (ret) {
- tevent_req_error(req, ret);
- return;
- }
-
- return tevent_req_done(req);
-}
-
-static int user_del_recv(struct tevent_req *req)
-{
- return sync_ops_recv(req);
-}
-
-/*
* Modify a user
*/
struct user_mod_state {
@@ -827,81 +753,6 @@ static int group_add_recv(struct tevent_req *req)
}
/*
- * Delete a group
- */
-struct group_del_state {
- struct tevent_context *ev;
- struct sysdb_ctx *sysdb;
- struct sysdb_handle *handle;
- struct sysdb_attrs *attrs;
-
- struct ops_ctx *data;
-};
-
-static void group_del_done(struct tevent_req *subreq);
-
-static struct tevent_req *group_del_send(TALLOC_CTX *mem_ctx,
- struct tevent_context *ev,
- struct sysdb_ctx *sysdb,
- struct sysdb_handle *handle,
- struct ops_ctx *data)
-{
- struct group_del_state *state = NULL;
- struct tevent_req *req;
- struct tevent_req *subreq;
- struct ldb_dn *group_dn;
-
- req = tevent_req_create(mem_ctx, &state, struct group_del_state);
- if (req == NULL) {
- talloc_zfree(req);
- return NULL;
- }
- state->ev = ev;
- state->sysdb = sysdb;
- state->handle = handle;
- state->data = data;
-
- group_dn = sysdb_group_dn(state->sysdb, state,
- state->data->domain->name, state->data->name);
- if (group_dn == NULL) {
- DEBUG(1, ("Could not construct a group DN\n"));
- return NULL;
- }
-
- subreq = sysdb_delete_entry_send(state,
- state->ev, state->handle,
- group_dn, false);
- if (!subreq) {
- talloc_zfree(req);
- return NULL;
- }
-
- tevent_req_set_callback(subreq, group_del_done, req);
- return req;
-}
-
-static void group_del_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);
- if (ret) {
- tevent_req_error(req, ret);
- return;
- }
-
- return tevent_req_done(req);
-}
-
-static int group_del_recv(struct tevent_req *req)
-{
- return sync_ops_recv(req);
-}
-
-/*
* Modify a group
*/
struct group_mod_state {
@@ -1327,54 +1178,31 @@ static void useradd_done(struct tevent_req *req)
/*
* Public interface for deleting users
*/
-static void userdel_done(struct tevent_req *req);
-
int userdel(TALLOC_CTX *mem_ctx,
- struct tevent_context *ev,
struct sysdb_ctx *sysdb,
- struct sysdb_handle *handle,
struct ops_ctx *data)
{
+ struct ldb_dn *user_dn;
int ret;
- struct tevent_req *req;
- struct sync_op_res *res = NULL;
- res = talloc_zero(mem_ctx, struct sync_op_res);
- if (!res) {
+ user_dn = sysdb_user_dn(sysdb, mem_ctx,
+ data->domain->name, data->name);
+ if (!user_dn) {
+ DEBUG(1, ("Could not construct a user DN\n"));
return ENOMEM;
}
- req = user_del_send(res, ev, sysdb, handle, data);
- if (!req) {
- return ENOMEM;
+ ret = sysdb_delete_entry(sysdb, user_dn, false);
+ if (ret) {
+ DEBUG(2, ("Removing user failed: %s (%d)\n", strerror(ret), ret));
}
- tevent_req_set_callback(req, userdel_done, res);
-
- SYNC_LOOP(res, ret);
flush_nscd_cache(mem_ctx, NSCD_DB_PASSWD);
flush_nscd_cache(mem_ctx, NSCD_DB_GROUP);
- talloc_free(res);
return ret;
}
-static void userdel_done(struct tevent_req *req)
-{
- int ret;
- struct sync_op_res *res = tevent_req_callback_data(req,
- struct sync_op_res);
-
- ret = user_del_recv(req);
- talloc_free(req);
- if (ret) {
- DEBUG(2, ("Removing user failed: %s (%d)\n", strerror(ret), ret));
- }
-
- res->done = true;
- res->error = ret;
-}
-
/*
* Public interface for modifying users
*/
@@ -1479,53 +1307,30 @@ static void groupadd_done(struct tevent_req *req)
/*
* Public interface for deleting groups
*/
-static void groupdel_done(struct tevent_req *req);
-
int groupdel(TALLOC_CTX *mem_ctx,
- struct tevent_context *ev,
struct sysdb_ctx *sysdb,
- struct sysdb_handle *handle,
struct ops_ctx *data)
{
+ struct ldb_dn *group_dn;
int ret;
- struct tevent_req *req;
- struct sync_op_res *res = NULL;
- res = talloc_zero(mem_ctx, struct sync_op_res);
- if (!res) {
+ group_dn = sysdb_group_dn(sysdb, mem_ctx,
+ data->domain->name, data->name);
+ if (group_dn == NULL) {
+ DEBUG(1, ("Could not construct a group DN\n"));
return ENOMEM;
}
- req = group_del_send(res, ev, sysdb, handle, data);
- if (!req) {
- return ENOMEM;
+ ret = sysdb_delete_entry(sysdb, group_dn, false);
+ if (ret) {
+ DEBUG(2, ("Removing group failed: %s (%d)\n", strerror(ret), ret));
}
- tevent_req_set_callback(req, groupdel_done, res);
-
- SYNC_LOOP(res, ret);
flush_nscd_cache(mem_ctx, NSCD_DB_GROUP);
- talloc_free(res);
return ret;
}
-static void groupdel_done(struct tevent_req *req)
-{
- int ret;
- struct sync_op_res *res = tevent_req_callback_data(req,
- struct sync_op_res);
-
- ret = group_del_recv(req);
- talloc_free(req);
- if (ret) {
- DEBUG(2, ("Removing group failed: %s (%d)\n", strerror(ret), ret));
- }
-
- res->done = true;
- res->error = ret;
-}
-
/*
* Public interface for modifying groups
*/
diff --git a/src/tools/sss_sync_ops.h b/src/tools/sss_sync_ops.h
index 383319a8f..6629d9c92 100644
--- a/src/tools/sss_sync_ops.h
+++ b/src/tools/sss_sync_ops.h
@@ -78,9 +78,7 @@ int useradd(TALLOC_CTX *mem_ctx,
struct sysdb_handle *handle,
struct ops_ctx *data);
int userdel(TALLOC_CTX *mem_ctx,
- struct tevent_context *ev,
struct sysdb_ctx *sysdb,
- struct sysdb_handle *handle,
struct ops_ctx *data);
int usermod(TALLOC_CTX *mem_ctx,
struct tevent_context *ev,
@@ -94,9 +92,7 @@ int groupadd(TALLOC_CTX *mem_ctx,
struct sysdb_handle *handle,
struct ops_ctx *data);
int groupdel(TALLOC_CTX *mem_ctx,
- struct tevent_context *ev,
struct sysdb_ctx *sysdb,
- struct sysdb_handle *handle,
struct ops_ctx *data);
int groupmod(TALLOC_CTX *mem_ctx,
struct tevent_context *ev,
diff --git a/src/tools/sss_userdel.c b/src/tools/sss_userdel.c
index 464c22e74..890b4fec0 100644
--- a/src/tools/sss_userdel.c
+++ b/src/tools/sss_userdel.c
@@ -267,12 +267,8 @@ int main(int argc, const char **argv)
}
/* userdel */
- ret = userdel(tctx, tctx->ev, tctx->sysdb, tctx->handle, tctx->octx);
+ ret = userdel(tctx, tctx->sysdb, tctx->octx);
if (ret != EOK) {
- tctx->error = ret;
-
- /* cancel transaction */
- talloc_zfree(tctx->handle);
goto done;
}
@@ -331,7 +327,6 @@ int main(int argc, const char **argv)
}
}
- ret = tctx->error;
done:
if (ret) {
DEBUG(1, ("sysdb operation failed (%d)[%s]\n", ret, strerror(ret)));