summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/db/sysdb.h40
-rw-r--r--src/db/sysdb_ops.c480
-rw-r--r--src/providers/krb5/krb5_auth.c27
-rw-r--r--src/responder/pam/pam_LOCAL_domain.c28
-rw-r--r--src/responder/pam/pamsrv_cmd.c24
-rw-r--r--src/tests/sysdb-tests.c21
-rw-r--r--src/tools/sss_sync_ops.c113
7 files changed, 144 insertions, 589 deletions
diff --git a/src/db/sysdb.h b/src/db/sysdb.h
index aeea6224..dc311f10 100644
--- a/src/db/sysdb.h
+++ b/src/db/sysdb.h
@@ -382,33 +382,27 @@ int sysdb_search_group_by_gid(TALLOC_CTX *mem_ctx,
struct ldb_message **msg);
/* Replace entry attrs */
-struct tevent_req *sysdb_set_entry_attr_send(TALLOC_CTX *mem_ctx,
- struct tevent_context *ev,
- struct sysdb_handle *handle,
- struct ldb_dn *entry_dn,
- struct sysdb_attrs *attrs,
- int mod_op);
-int sysdb_set_entry_attr_recv(struct tevent_req *req);
+int sysdb_set_entry_attr(TALLOC_CTX *mem_ctx,
+ struct sysdb_ctx *ctx,
+ struct ldb_dn *entry_dn,
+ struct sysdb_attrs *attrs,
+ int mod_op);
/* Replace user attrs */
-struct tevent_req *sysdb_set_user_attr_send(TALLOC_CTX *mem_ctx,
- struct tevent_context *ev,
- struct sysdb_handle *handle,
- struct sss_domain_info *domain,
- const char *name,
- struct sysdb_attrs *attrs,
- int mod_op);
-int sysdb_set_user_attr_recv(struct tevent_req *req);
+int sysdb_set_user_attr(TALLOC_CTX *mem_ctx,
+ struct sysdb_ctx *ctx,
+ struct sss_domain_info *domain,
+ const char *name,
+ struct sysdb_attrs *attrs,
+ int mod_op);
/* Replace group attrs */
-struct tevent_req *sysdb_set_group_attr_send(TALLOC_CTX *mem_ctx,
- struct tevent_context *ev,
- struct sysdb_handle *handle,
- struct sss_domain_info *domain,
- const char *name,
- struct sysdb_attrs *attrs,
- int mod_op);
-int sysdb_set_group_attr_recv(struct tevent_req *req);
+int sysdb_set_group_attr(TALLOC_CTX *mem_ctx,
+ struct sysdb_ctx *ctx,
+ struct sss_domain_info *domain,
+ const char *name,
+ struct sysdb_attrs *attrs,
+ int mod_op);
/* Allocate a new id */
struct tevent_req *sysdb_get_new_id_send(TALLOC_CTX *mem_ctx,
diff --git a/src/db/sysdb_ops.c b/src/db/sysdb_ops.c
index 9bc24880..518d66fd 100644
--- a/src/db/sysdb_ops.c
+++ b/src/db/sysdb_ops.c
@@ -538,45 +538,30 @@ done:
/* =Replace-Attributes-On-Entry=========================================== */
-struct tevent_req *sysdb_set_entry_attr_send(TALLOC_CTX *mem_ctx,
- struct tevent_context *ev,
- struct sysdb_handle *handle,
- struct ldb_dn *entry_dn,
- struct sysdb_attrs *attrs,
- int mod_op)
+int sysdb_set_entry_attr(TALLOC_CTX *mem_ctx,
+ struct sysdb_ctx *ctx,
+ struct ldb_dn *entry_dn,
+ struct sysdb_attrs *attrs,
+ int mod_op)
{
- struct tevent_req *req, *subreq;
- struct sysdb_op_state *state;
- struct ldb_request *ldbreq;
struct ldb_message *msg;
int i, ret;
- req = tevent_req_create(mem_ctx, &state, struct sysdb_op_state);
- if (!req) return NULL;
-
- state->ev = ev;
- state->handle = handle;
- state->ignore_not_found = false;
- state->ldbreply = NULL;
-
- if (!entry_dn) {
- ERROR_OUT(ret, EINVAL, fail);
- }
-
- if (attrs->num == 0) {
- ERROR_OUT(ret, EINVAL, fail);
+ if (!entry_dn || attrs->num == 0) {
+ return EINVAL;
}
- msg = ldb_msg_new(state);
+ msg = ldb_msg_new(mem_ctx);
if (!msg) {
- ERROR_OUT(ret, ENOMEM, fail);
+ return ENOMEM;
}
msg->dn = entry_dn;
msg->elements = talloc_array(msg, struct ldb_message_element, attrs->num);
if (!msg->elements) {
- ERROR_OUT(ret, ENOMEM, fail);
+ ret = ENOMEM;
+ goto fail;
}
for (i = 0; i < attrs->num; i++) {
@@ -586,168 +571,55 @@ struct tevent_req *sysdb_set_entry_attr_send(TALLOC_CTX *mem_ctx,
msg->num_elements = attrs->num;
- ret = ldb_build_mod_req(&ldbreq, handle->ctx->ldb, state, msg,
- NULL, NULL, NULL, NULL);
- if (ret != LDB_SUCCESS) {
- DEBUG(1, ("Failed to build modify request: %s(%d)[%s]\n",
- ldb_strerror(ret), ret, ldb_errstring(handle->ctx->ldb)));
- ERROR_OUT(ret, sysdb_error_to_errno(ret), fail);
- }
-
- subreq = sldb_request_send(state, ev, handle->ctx->ldb, ldbreq);
- if (!subreq) {
- ERROR_OUT(ret, ENOMEM, fail);
- }
- tevent_req_set_callback(subreq, sysdb_op_default_done, req);
-
- return req;
+ ret = ldb_modify(ctx->ldb, msg);
+ ret = sysdb_error_to_errno(ret);
fail:
- DEBUG(6, ("Error: %d (%s)\n", ret, strerror(ret)));
- tevent_req_error(req, ret);
- tevent_req_post(req, ev);
- return req;
-}
-
-int sysdb_set_entry_attr_recv(struct tevent_req *req)
-{
- return sysdb_op_default_recv(req);
+ if (ret) {
+ DEBUG(6, ("Error: %d (%s)\n", ret, strerror(ret)));
+ }
+ talloc_zfree(msg);
+ return ret;
}
/* =Replace-Attributes-On-User============================================ */
-static void sysdb_set_user_attr_done(struct tevent_req *subreq);
-
-struct tevent_req *sysdb_set_user_attr_send(TALLOC_CTX *mem_ctx,
- struct tevent_context *ev,
- struct sysdb_handle *handle,
- struct sss_domain_info *domain,
- const char *name,
- struct sysdb_attrs *attrs,
- int mod_op)
+int sysdb_set_user_attr(TALLOC_CTX *mem_ctx,
+ struct sysdb_ctx *ctx,
+ struct sss_domain_info *domain,
+ const char *name,
+ struct sysdb_attrs *attrs,
+ int mod_op)
{
- struct tevent_req *req, *subreq;
- struct sysdb_op_state *state;
struct ldb_dn *dn;
- int ret;
-
- req = tevent_req_create(mem_ctx, &state, struct sysdb_op_state);
- if (!req) return NULL;
-
- state->ev = ev;
- state->handle = handle;
- state->ignore_not_found = false;
- state->ldbreply = NULL;
- dn = sysdb_user_dn(handle->ctx, state, domain->name, name);
+ dn = sysdb_user_dn(ctx, mem_ctx, domain->name, name);
if (!dn) {
- ERROR_OUT(ret, ENOMEM, fail);
- }
-
- subreq = sysdb_set_entry_attr_send(state, ev, handle, dn, attrs, mod_op);
- if (!subreq) {
- ERROR_OUT(ret, ENOMEM, fail);
- }
- tevent_req_set_callback(subreq, sysdb_set_user_attr_done, req);
-
- return req;
-
-fail:
- DEBUG(6, ("Error: %d (%s)\n", ret, strerror(ret)));
- tevent_req_error(req, ret);
- tevent_req_post(req, ev);
- return req;
-}
-
-static void sysdb_set_user_attr_done(struct tevent_req *subreq)
-{
- struct tevent_req *req = tevent_req_callback_data(subreq,
- struct tevent_req);
- int ret;
-
- ret = sysdb_set_entry_attr_recv(subreq);
- talloc_zfree(subreq);
- if (ret) {
- DEBUG(6, ("Error: %d (%s)\n", ret, strerror(ret)));
- tevent_req_error(req, ret);
- return;
+ return ENOMEM;
}
- tevent_req_done(req);
-}
-
-int sysdb_set_user_attr_recv(struct tevent_req *req)
-{
- return sysdb_op_default_recv(req);
+ return sysdb_set_entry_attr(mem_ctx, ctx, dn, attrs, mod_op);
}
/* =Replace-Attributes-On-Group=========================================== */
-static void sysdb_set_group_attr_done(struct tevent_req *subreq);
-
-struct tevent_req *sysdb_set_group_attr_send(TALLOC_CTX *mem_ctx,
- struct tevent_context *ev,
- struct sysdb_handle *handle,
- struct sss_domain_info *domain,
- const char *name,
- struct sysdb_attrs *attrs,
- int mod_op)
+int sysdb_set_group_attr(TALLOC_CTX *mem_ctx,
+ struct sysdb_ctx *ctx,
+ struct sss_domain_info *domain,
+ const char *name,
+ struct sysdb_attrs *attrs,
+ int mod_op)
{
- struct tevent_req *req, *subreq;
- struct sysdb_op_state *state;
struct ldb_dn *dn;
- int ret;
-
- req = tevent_req_create(mem_ctx, &state, struct sysdb_op_state);
- if (!req) return NULL;
-
- state->ev = ev;
- state->handle = handle;
- state->ignore_not_found = false;
- state->ldbreply = NULL;
- dn = sysdb_group_dn(handle->ctx, state, domain->name, name);
+ dn = sysdb_group_dn(ctx, mem_ctx, domain->name, name);
if (!dn) {
- ERROR_OUT(ret, ENOMEM, fail);
- }
-
- subreq = sysdb_set_entry_attr_send(state, ev, handle, dn, attrs, mod_op);
- if (!subreq) {
- ERROR_OUT(ret, ENOMEM, fail);
- }
- tevent_req_set_callback(subreq, sysdb_set_group_attr_done, req);
-
- return req;
-
-fail:
- DEBUG(6, ("Error: %d (%s)\n", ret, strerror(ret)));
- tevent_req_error(req, ret);
- tevent_req_post(req, ev);
- return req;
-}
-
-static void sysdb_set_group_attr_done(struct tevent_req *subreq)
-{
- struct tevent_req *req = tevent_req_callback_data(subreq,
- struct tevent_req);
- int ret;
-
- ret = sysdb_set_entry_attr_recv(subreq);
- talloc_zfree(subreq);
- if (ret) {
- DEBUG(6, ("Error: %d (%s)\n", ret, strerror(ret)));
- tevent_req_error(req, ret);
- return;
+ return ENOMEM;
}
- tevent_req_done(req);
-}
-
-int sysdb_set_group_attr_recv(struct tevent_req *req)
-{
- return sysdb_op_default_recv(req);
+ return sysdb_set_entry_attr(mem_ctx, ctx, dn, attrs, mod_op);
}
@@ -1233,9 +1105,7 @@ struct sysdb_add_user_state {
static void sysdb_add_user_basic_done(struct tevent_req *subreq);
static void sysdb_add_user_get_id_done(struct tevent_req *subreq);
-static void sysdb_add_user_set_id_done(struct tevent_req *subreq);
-static void sysdb_add_user_set_attrs(struct tevent_req *req);
-static void sysdb_add_user_set_attrs_done(struct tevent_req *subreq);
+static int sysdb_add_user_set_attrs(struct sysdb_add_user_state *state);
struct tevent_req *sysdb_add_user_send(TALLOC_CTX *mem_ctx,
struct tevent_context *ev,
@@ -1361,7 +1231,14 @@ static void sysdb_add_user_basic_done(struct tevent_req *subreq)
return;
}
- sysdb_add_user_set_attrs(req);
+ ret = sysdb_add_user_set_attrs(state);
+ if (ret) {
+ DEBUG(6, ("Error: %d (%s)\n", ret, strerror(ret)));
+ tevent_req_error(req, ret);
+ return;
+ }
+
+ tevent_req_done(req);
}
static void sysdb_add_user_get_id_done(struct tevent_req *subreq)
@@ -1403,102 +1280,54 @@ static void sysdb_add_user_get_id_done(struct tevent_req *subreq)
}
}
- subreq = sysdb_set_user_attr_send(state, state->ev, state->handle,
- state->domain, state->name,
- id_attrs, SYSDB_MOD_REP);
- if (!subreq) {
- DEBUG(6, ("Error: Out of memory\n"));
- tevent_req_error(req, ENOMEM);
- return;
+ ret = sysdb_set_user_attr(state, state->handle->ctx,
+ state->domain, state->name,
+ id_attrs, SYSDB_MOD_REP);
+ if (ret) {
+ tevent_req_error(req, ret);
+ } else {
+ tevent_req_done(req);
}
- tevent_req_set_callback(subreq, sysdb_add_user_set_id_done, req);
return;
}
- sysdb_add_user_set_attrs(req);
-}
-
-static void sysdb_add_user_set_id_done(struct tevent_req *subreq)
-{
- struct tevent_req *req = tevent_req_callback_data(subreq,
- struct tevent_req);
- struct sysdb_add_user_state *state = tevent_req_data(req,
- struct sysdb_add_user_state);
- int ret;
-
- ret = sysdb_set_user_attr_recv(subreq);
- talloc_zfree(subreq);
+ ret = sysdb_add_user_set_attrs(state);
if (ret) {
+ DEBUG(6, ("Error: %d (%s)\n", ret, strerror(ret)));
tevent_req_error(req, ret);
return;
}
- if (state->attrs) {
- }
-
tevent_req_done(req);
}
-static void sysdb_add_user_set_attrs(struct tevent_req *req)
+static int sysdb_add_user_set_attrs(struct sysdb_add_user_state *state)
{
- struct sysdb_add_user_state *state = tevent_req_data(req,
- struct sysdb_add_user_state);
- struct tevent_req *subreq;
time_t now = time(NULL);
int ret;
if (!state->attrs) {
state->attrs = sysdb_new_attrs(state);
if (!state->attrs) {
- DEBUG(6, ("Error: Out of memory\n"));
- tevent_req_error(req, ENOMEM);
- return;
+ return ENOMEM;
}
}
ret = sysdb_attrs_add_time_t(state->attrs, SYSDB_LAST_UPDATE, now);
if (ret) {
- DEBUG(6, ("Error: %d (%s)\n", ret, strerror(ret)));
- tevent_req_error(req, ret);
- return;
+ return ret;
}
ret = sysdb_attrs_add_time_t(state->attrs, SYSDB_CACHE_EXPIRE,
((state->cache_timeout) ?
(now + state->cache_timeout) : 0));
if (ret) {
- DEBUG(6, ("Error: %d (%s)\n", ret, strerror(ret)));
- tevent_req_error(req, ret);
- return;
- }
-
- subreq = sysdb_set_user_attr_send(state, state->ev,
- state->handle, state->domain,
- state->name, state->attrs,
- SYSDB_MOD_REP);
- if (!subreq) {
- DEBUG(6, ("Error: Out of memory\n"));
- tevent_req_error(req, ENOMEM);
- return;
- }
- tevent_req_set_callback(subreq, sysdb_add_user_set_attrs_done, req);
-}
-
-static void sysdb_add_user_set_attrs_done(struct tevent_req *subreq)
-{
- struct tevent_req *req = tevent_req_callback_data(subreq,
- struct tevent_req);
- int ret;
-
- ret = sysdb_set_user_attr_recv(subreq);
- talloc_zfree(subreq);
- if (ret) {
- DEBUG(6, ("Error: %d (%s)\n", ret, strerror(ret)));
- tevent_req_error(req, ret);
- return;
+ return ret;
}
- tevent_req_done(req);
+ return sysdb_set_user_attr(state, state->handle->ctx,
+ state->domain, state->name,
+ state->attrs, SYSDB_MOD_REP);
}
int sysdb_add_user_recv(struct tevent_req *req)
@@ -1601,7 +1430,6 @@ struct sysdb_add_group_state {
static void sysdb_add_group_basic_done(struct tevent_req *subreq);
static void sysdb_add_group_get_id_done(struct tevent_req *subreq);
static void sysdb_add_group_set_attrs(struct tevent_req *req);
-static void sysdb_add_group_set_attrs_done(struct tevent_req *subreq);
struct tevent_req *sysdb_add_group_send(TALLOC_CTX *mem_ctx,
struct tevent_context *ev,
@@ -1747,7 +1575,6 @@ static void sysdb_add_group_set_attrs(struct tevent_req *req)
{
struct sysdb_add_group_state *state = tevent_req_data(req,
struct sysdb_add_group_state);
- struct tevent_req *subreq;
time_t now = time(NULL);
int ret;
@@ -1776,26 +1603,9 @@ static void sysdb_add_group_set_attrs(struct tevent_req *req)
return;
}
- subreq = sysdb_set_group_attr_send(state, state->ev,
- state->handle, state->domain,
- state->name, state->attrs,
- SYSDB_MOD_REP);
- if (!subreq) {
- DEBUG(6, ("Error: Out of memory\n"));
- tevent_req_error(req, ENOMEM);
- return;
- }
- tevent_req_set_callback(subreq, sysdb_add_group_set_attrs_done, req);
-}
-
-static void sysdb_add_group_set_attrs_done(struct tevent_req *subreq)
-{
- struct tevent_req *req = tevent_req_callback_data(subreq,
- struct tevent_req);
- int ret;
-
- ret = sysdb_set_group_attr_recv(subreq);
- talloc_zfree(subreq);
+ ret = sysdb_set_group_attr(state, state->handle->ctx,
+ state->domain, state->name,
+ state->attrs, SYSDB_MOD_REP);
if (ret) {
DEBUG(6, ("Error: %d (%s)\n", ret, strerror(ret)));
tevent_req_error(req, ret);
@@ -1908,7 +1718,6 @@ struct sysdb_store_user_state {
};
static void sysdb_store_user_add_done(struct tevent_req *subreq);
-static void sysdb_store_user_attr_done(struct tevent_req *subreq);
struct tevent_req *sysdb_store_user_send(TALLOC_CTX *mem_ctx,
struct tevent_context *ev,
@@ -2022,16 +1831,15 @@ struct tevent_req *sysdb_store_user_send(TALLOC_CTX *mem_ctx,
(now + state->cache_timeout) : 0));
if (ret) goto fail;
- subreq = sysdb_set_user_attr_send(state, state->ev,
- state->handle, state->domain,
- state->name, state->attrs,
- SYSDB_MOD_REP);
- if (!subreq) {
- ret = ENOMEM;
+ ret = sysdb_set_user_attr(state, state->handle->ctx,
+ state->domain, state->name,
+ state->attrs, SYSDB_MOD_REP);
+ if (ret) {
goto fail;
}
- tevent_req_set_callback(subreq, sysdb_store_user_attr_done, req);
+ tevent_req_done(req);
+ tevent_req_post(req, ev);
return req;
fail:
@@ -2058,23 +1866,6 @@ static void sysdb_store_user_add_done(struct tevent_req *subreq)
tevent_req_done(req);
}
-static void sysdb_store_user_attr_done(struct tevent_req *subreq)
-{
- struct tevent_req *req = tevent_req_callback_data(subreq,
- struct tevent_req);
- int ret;
-
- ret = sysdb_set_user_attr_recv(subreq);
- talloc_zfree(subreq);
- if (ret) {
- DEBUG(6, ("Error: %d (%s)\n", ret, strerror(ret)));
- tevent_req_error(req, ret);
- return;
- }
-
- tevent_req_done(req);
-}
-
int sysdb_store_user_recv(struct tevent_req *req)
{
return sysdb_op_default_recv(req);
@@ -2098,7 +1889,6 @@ struct sysdb_store_group_state {
};
static void sysdb_store_group_add_done(struct tevent_req *subreq);
-static void sysdb_store_group_attr_done(struct tevent_req *subreq);
struct tevent_req *sysdb_store_group_send(TALLOC_CTX *mem_ctx,
struct tevent_context *ev,
@@ -2181,16 +1971,15 @@ struct tevent_req *sysdb_store_group_send(TALLOC_CTX *mem_ctx,
(now + state->cache_timeout) : 0));
if (ret) goto fail;
- subreq = sysdb_set_group_attr_send(state, state->ev,
- state->handle, state->domain,
- state->name, state->attrs,
- SYSDB_MOD_REP);
- if (!subreq) {
- ret = ENOMEM;
+ ret = sysdb_set_group_attr(state, state->handle->ctx,
+ state->domain, state->name,
+ state->attrs, SYSDB_MOD_REP);
+ if (ret) {
goto fail;
}
- tevent_req_set_callback(subreq, sysdb_store_group_attr_done, req);
+ tevent_req_done(req);
+ tevent_req_post(req, ev);
return req;
fail:
@@ -2217,23 +2006,6 @@ static void sysdb_store_group_add_done(struct tevent_req *subreq)
tevent_req_done(req);
}
-static void sysdb_store_group_attr_done(struct tevent_req *subreq)
-{
- struct tevent_req *req = tevent_req_callback_data(subreq,
- struct tevent_req);
- int ret;
-
- ret = sysdb_set_group_attr_recv(subreq);
- talloc_zfree(subreq);
- if (ret) {
- DEBUG(6, ("Error: %d (%s)\n", ret, strerror(ret)));
- tevent_req_error(req, ret);
- return;
- }
-
- tevent_req_done(req);
-}
-
int sysdb_store_group_recv(struct tevent_req *req)
{
return sysdb_op_default_recv(req);
@@ -2402,7 +2174,6 @@ struct sysdb_cache_pw_state {
};
static void sysdb_cache_password_trans(struct tevent_req *subreq);
-static void sysdb_cache_password_done(struct tevent_req *subreq);
struct tevent_req *sysdb_cache_password_send(TALLOC_CTX *mem_ctx,
struct tevent_context *ev,
@@ -2459,13 +2230,15 @@ struct tevent_req *sysdb_cache_password_send(TALLOC_CTX *mem_ctx,
state->handle = handle;
state->commit = false;
- subreq = sysdb_set_user_attr_send(state, state->ev, state->handle,
- state->domain, state->username,
- state->attrs, SYSDB_MOD_REP);
- if (!subreq) {
- ERROR_OUT(ret, ENOMEM, fail);
+ ret = sysdb_set_user_attr(state, state->handle->ctx,
+ state->domain, state->username,
+ state->attrs, SYSDB_MOD_REP);
+ if (ret) {
+ goto fail;
}
- tevent_req_set_callback(subreq, sysdb_cache_password_done, req);
+ tevent_req_done(req);
+ tevent_req_post(req, ev);
+
} else {
state->commit = true;
@@ -2502,46 +2275,22 @@ static void sysdb_cache_password_trans(struct tevent_req *subreq)
return;
}
- subreq = sysdb_set_user_attr_send(state, state->ev, state->handle,
- state->domain, state->username,
- state->attrs, SYSDB_MOD_REP);
- if (!subreq) {
- DEBUG(6, ("Error: Out of memory\n"));
- tevent_req_error(req, ENOMEM);
- return;
- }
- tevent_req_set_callback(subreq, sysdb_cache_password_done, req);
-}
-
-static void sysdb_cache_password_done(struct tevent_req *subreq)
-{
- struct tevent_req *req = tevent_req_callback_data(subreq,
- struct tevent_req);
- struct sysdb_cache_pw_state *state = tevent_req_data(req,
- struct sysdb_cache_pw_state);
- int ret;
-
- ret = sysdb_set_user_attr_recv(subreq);
- talloc_zfree(subreq);
+ ret = sysdb_set_user_attr(state, state->handle->ctx,
+ state->domain, state->username,
+ state->attrs, SYSDB_MOD_REP);
if (ret) {
- DEBUG(6, ("Error: %d (%s)\n", ret, strerror(ret)));
tevent_req_error(req, ret);
return;
}
- if (state->commit) {
- subreq = sysdb_transaction_commit_send(state, state->ev,
- state->handle);
- if (!subreq) {
- DEBUG(6, ("Error: Out of memory\n"));
- tevent_req_error(req, ENOMEM);
- return;
- }
- tevent_req_set_callback(subreq, sysdb_transaction_complete, req);
+ subreq = sysdb_transaction_commit_send(state, state->ev,
+ state->handle);
+ if (!subreq) {
+ DEBUG(6, ("Error: Out of memory\n"));
+ tevent_req_error(req, ENOMEM);
return;
}
-
- tevent_req_done(req);
+ tevent_req_set_callback(subreq, sysdb_transaction_complete, req);
}
int sysdb_cache_password_recv(struct tevent_req *req)
@@ -3817,7 +3566,6 @@ errno_t check_failed_login_attempts(TALLOC_CTX *mem_ctx, struct confdb_ctx *cdb,
}
static void sysdb_cache_auth_transaction_start_done(struct tevent_req *subreq);
-static void sysdb_cache_auth_attr_update_done(struct tevent_req *subreq);
static void sysdb_cache_auth_done(struct tevent_req *subreq);
struct tevent_req *sysdb_cache_auth_send(TALLOC_CTX *mem_ctx,
@@ -4046,42 +3794,16 @@ static void sysdb_cache_auth_transaction_start_done(struct tevent_req *subreq)
}
- subreq = sysdb_set_user_attr_send(state, state->ev, state->handle,
- state->domain, state->name,
- state->update_attrs,
- LDB_FLAG_MOD_REPLACE);
- if (subreq == NULL) {
- DEBUG(1, ("sysdb_set_user_attr_send failed.\n"));
- goto done;
- }
- tevent_req_set_callback(subreq, sysdb_cache_auth_attr_update_done,
- req);
- return;
-
-done:
- if (state->authentication_successful) {
- tevent_req_done(req);
- } else {
- tevent_req_error(req, EINVAL);
- }
- return;
-}
-
-static void sysdb_cache_auth_attr_update_done(struct tevent_req *subreq)
-{
- int ret;
- struct tevent_req *req = tevent_req_callback_data(subreq,
- struct tevent_req);
-
- struct sysdb_cache_auth_state *state = tevent_req_data(req,
- struct sysdb_cache_auth_state);
-
- ret = sysdb_set_user_attr_recv(subreq);
- talloc_zfree(subreq);
- if (ret != EOK) {
+ ret = sysdb_set_user_attr(state, state->handle->ctx,
+ state->domain, state->name,
+ state->update_attrs,
+ LDB_FLAG_MOD_REPLACE);
+ if (ret) {
DEBUG(1, ("sysdb_set_user_attr request failed [%d][%s].\n",
ret, strerror(ret)));
- goto done;
+ if (!state->authentication_successful) {
+ goto done;
+ }
}
subreq = sysdb_transaction_commit_send(state, state->ev, state->handle);
diff --git a/src/providers/krb5/krb5_auth.c b/src/providers/krb5/krb5_auth.c
index 880930a1..6b1f54d6 100644
--- a/src/providers/krb5/krb5_auth.c
+++ b/src/providers/krb5/krb5_auth.c
@@ -184,7 +184,6 @@ struct krb5_save_ccname_state {
};
static void krb5_save_ccname_trans(struct tevent_req *subreq);
-static void krb5_set_user_attr_done(struct tevent_req *subreq);
static struct tevent_req *krb5_save_ccname_send(TALLOC_CTX *mem_ctx,
struct tevent_context *ev,
@@ -251,27 +250,9 @@ static void krb5_save_ccname_trans(struct tevent_req *subreq)
return;
}
- subreq = sysdb_set_user_attr_send(state, state->ev, state->handle,
- state->domain, state->name,
- state->attrs, SYSDB_MOD_REP);
- if (subreq == NULL) {
- DEBUG(6, ("Error: Out of memory\n"));
- tevent_req_error(req, ENOMEM);
- return;
- }
- tevent_req_set_callback(subreq, krb5_set_user_attr_done, req);
-}
-
-static void krb5_set_user_attr_done(struct tevent_req *subreq)
-{
- struct tevent_req *req = tevent_req_callback_data(subreq,
- struct tevent_req);
- struct krb5_save_ccname_state *state = tevent_req_data(req,
- struct krb5_save_ccname_state);
- int ret;
-
- ret = sysdb_set_user_attr_recv(subreq);
- talloc_zfree(subreq);
+ ret = sysdb_set_user_attr(state, sysdb_handle_get_ctx(state->handle),
+ state->domain, state->name,
+ state->attrs, SYSDB_MOD_REP);
if (ret != EOK) {
DEBUG(6, ("Error: %d (%s)\n", ret, strerror(ret)));
tevent_req_error(req, ret);
@@ -1191,7 +1172,7 @@ static void krb5_save_ccname_done(struct tevent_req *req)
}
}
- ret = sysdb_set_user_attr_recv(req);
+ ret = krb5_save_ccname_recv(req);
talloc_zfree(req);
if (ret != EOK) {
DEBUG(1, ("Saving ccache name failed.\n"));
diff --git a/src/responder/pam/pam_LOCAL_domain.c b/src/responder/pam/pam_LOCAL_domain.c
index a598e77e..80f8a91c 100644
--- a/src/responder/pam/pam_LOCAL_domain.c
+++ b/src/responder/pam/pam_LOCAL_domain.c
@@ -86,12 +86,10 @@ static void set_user_attr_done(struct tevent_req *req)
prepare_reply(lreq);
}
-static void set_user_attr_req_done(struct tevent_req *subreq);
static void set_user_attr_req(struct tevent_req *req)
{
struct LOCAL_request *lreq = tevent_req_callback_data(req,
struct LOCAL_request);
- struct tevent_req *subreq;
int ret;
DEBUG(4, ("entering set_user_attr_req\n"));
@@ -102,28 +100,10 @@ static void set_user_attr_req(struct tevent_req *req)
return prepare_reply(lreq);
}
- subreq = sysdb_set_user_attr_send(lreq, lreq->ev, lreq->handle,
- lreq->preq->domain,
- lreq->preq->pd->user,
- lreq->mod_attrs, SYSDB_MOD_REP);
- if (!subreq) {
- /* cancel transaction */
- talloc_zfree(lreq->handle);
- lreq->error = ret;
- return prepare_reply(lreq);
- }
- tevent_req_set_callback(subreq, set_user_attr_req_done, lreq);
-}
-
-static void set_user_attr_req_done(struct tevent_req *subreq)
-{
- struct LOCAL_request *lreq = tevent_req_callback_data(subreq,
- struct LOCAL_request);
- struct tevent_req *req;
- int ret;
-
- ret = sysdb_set_user_attr_recv(subreq);
- talloc_zfree(subreq);
+ ret = sysdb_set_user_attr(lreq, sysdb_handle_get_ctx(lreq->handle),
+ lreq->preq->domain,
+ lreq->preq->pd->user,
+ lreq->mod_attrs, SYSDB_MOD_REP);
DEBUG(4, ("set_user_attr_callback, status [%d][%s]\n", ret, strerror(ret)));
diff --git a/src/responder/pam/pamsrv_cmd.c b/src/responder/pam/pamsrv_cmd.c
index 8d67da1b..168efb84 100644
--- a/src/responder/pam/pamsrv_cmd.c
+++ b/src/responder/pam/pamsrv_cmd.c
@@ -285,7 +285,6 @@ struct set_last_login_state {
};
static void set_last_login_trans_done(struct tevent_req *subreq);
-static void set_last_login_attrs_done(struct tevent_req *subreq);
static void set_last_login_done(struct tevent_req *subreq);
static struct tevent_req *set_last_login_send(TALLOC_CTX *memctx,
@@ -336,26 +335,9 @@ static void set_last_login_trans_done(struct tevent_req *subreq)
return;
}
- subreq = sysdb_set_user_attr_send(state, state->ev, state->handle,
- state->dom, state->username,
- state->attrs, SYSDB_MOD_REP);
- if (!subreq) {
- tevent_req_error(req, ENOMEM);
- return;
- }
- tevent_req_set_callback(subreq, set_last_login_attrs_done, req);
-}
-
-static void set_last_login_attrs_done(struct tevent_req *subreq)
-{
- struct tevent_req *req = tevent_req_callback_data(subreq,
- struct tevent_req);
- struct set_last_login_state *state = tevent_req_data(req,
- struct set_last_login_state);
- int ret;
-
- ret = sysdb_set_user_attr_recv(subreq);
- talloc_zfree(subreq);
+ ret = sysdb_set_user_attr(state, sysdb_handle_get_ctx(state->handle),
+ state->dom, state->username,
+ state->attrs, SYSDB_MOD_REP);
if (ret != EOK) {
DEBUG(4, ("set_user_attr_callback, status [%d][%s]\n",
ret, strerror(ret)));
diff --git a/src/tests/sysdb-tests.c b/src/tests/sysdb-tests.c
index 1a850c35..519d1c4b 100644
--- a/src/tests/sysdb-tests.c
+++ b/src/tests/sysdb-tests.c
@@ -686,11 +686,9 @@ static void test_enumpwent(void *pvt, int error, struct ldb_result *res)
data->error = EOK;
}
-static void test_set_user_attr_done(struct tevent_req *subreq);
static void test_set_user_attr(struct tevent_req *req)
{
struct test_data *data = tevent_req_callback_data(req, struct test_data);
- struct tevent_req *subreq;
int ret;
ret = sysdb_transaction_recv(req, data, &data->handle);
@@ -698,22 +696,9 @@ static void test_set_user_attr(struct tevent_req *req)
return test_return(data, ret);
}
- subreq = sysdb_set_user_attr_send(data, data->ev, data->handle,
- data->ctx->domain, data->username,
- data->attrs, SYSDB_MOD_REP);
- if (!subreq) return test_return(data, ENOMEM);
-
- tevent_req_set_callback(subreq, test_set_user_attr_done, data);
-}
-
-static void test_set_user_attr_done(struct tevent_req *subreq)
-{
- struct test_data *data = tevent_req_callback_data(subreq,
- struct test_data);
- int ret;
-
- ret = sysdb_set_user_attr_recv(subreq);
- talloc_zfree(subreq);
+ ret = sysdb_set_user_attr(data, data->handle->ctx,
+ data->ctx->domain, data->username,
+ data->attrs, SYSDB_MOD_REP);
return test_return(data, ret);
}
diff --git a/src/tools/sss_sync_ops.c b/src/tools/sss_sync_ops.c
index 7feeedf2..b68bd4a6 100644
--- a/src/tools/sss_sync_ops.c
+++ b/src/tools/sss_sync_ops.c
@@ -488,7 +488,6 @@ static int usermod_build_attrs(TALLOC_CTX *mem_ctx,
return EOK;
}
-static void user_mod_attr_done(struct tevent_req *attrreq);
static void user_mod_attr_wakeup(struct tevent_req *subreq);
static void user_mod_rm_group_done(struct tevent_req *groupreq);
static void user_mod_add_group_done(struct tevent_req *groupreq);
@@ -553,18 +552,17 @@ static void user_mod_attr_wakeup(struct tevent_req *subreq)
struct tevent_req);
struct user_mod_state *state = tevent_req_data(req,
struct user_mod_state);
- struct tevent_req *attrreq, *groupreq;
+ struct tevent_req *groupreq;
+ int ret;
if (state->attrs->num != 0) {
- attrreq = sysdb_set_user_attr_send(state, state->ev, state->handle,
- state->data->domain, state->data->name,
- state->attrs, SYSDB_MOD_REP);
- if (!attrreq) {
- tevent_req_error(req, ENOMEM);
+ ret = sysdb_set_user_attr(state, sysdb_handle_get_ctx(state->handle),
+ state->data->domain, state->data->name,
+ state->attrs, SYSDB_MOD_REP);
+ if (ret) {
+ tevent_req_error(req, ret);
return;
}
- tevent_req_set_callback(attrreq, user_mod_attr_done, req);
- return;
}
if (state->data->rmgroups != NULL) {
@@ -593,47 +591,6 @@ static void user_mod_attr_wakeup(struct tevent_req *subreq)
tevent_req_done(req);
}
-static void user_mod_attr_done(struct tevent_req *attrreq)
-{
- struct tevent_req *req = tevent_req_callback_data(attrreq,
- struct tevent_req);
- struct user_mod_state *state = tevent_req_data(req,
- struct user_mod_state);
- int ret;
- struct tevent_req *groupreq;
-
- ret = sysdb_set_user_attr_recv(attrreq);
- talloc_zfree(attrreq);
- if (ret != EOK) {
- tevent_req_error(req, ret);
- return;
- }
-
- if (state->data->rmgroups != NULL) {
- groupreq = remove_from_groups_send(state, state->ev, state->sysdb,
- state->handle, state->data, state->member_dn);
- if (!groupreq) {
- tevent_req_error(req, ENOMEM);
- return;
- }
- tevent_req_set_callback(groupreq, user_mod_rm_group_done, req);
- return;
- }
-
- if (state->data->addgroups != NULL) {
- groupreq = add_to_groups_send(state, state->ev, state->sysdb,
- state->handle, state->data, state->member_dn);
- if (!groupreq) {
- tevent_req_error(req, ENOMEM);
- return;
- }
- tevent_req_set_callback(groupreq, user_mod_add_group_done, req);
- return;
- }
-
- return tevent_req_done(req);
-}
-
static void user_mod_rm_group_done(struct tevent_req *groupreq)
{
struct tevent_req *req = tevent_req_callback_data(groupreq,
@@ -766,7 +723,6 @@ struct group_mod_state {
struct ops_ctx *data;
};
-static void group_mod_attr_done(struct tevent_req *);
static void group_mod_attr_wakeup(struct tevent_req *);
static void group_mod_add_group_done(struct tevent_req *groupreq);
static void group_mod_rm_group_done(struct tevent_req *groupreq);
@@ -817,7 +773,6 @@ static void group_mod_attr_wakeup(struct tevent_req *subreq)
struct group_mod_state *state = tevent_req_data(req,
struct group_mod_state);
struct sysdb_attrs *attrs;
- struct tevent_req *attrreq;
struct tevent_req *groupreq;
int ret;
@@ -833,16 +788,13 @@ static void group_mod_attr_wakeup(struct tevent_req *subreq)
return;
}
- attrreq = sysdb_set_group_attr_send(state, state->ev, state->handle,
- state->data->domain, state->data->name,
- attrs, SYSDB_MOD_REP);
- if (!attrreq) {
- tevent_req_error(req, ENOMEM);
+ ret = sysdb_set_group_attr(state, sysdb_handle_get_ctx(state->handle),
+ state->data->domain, state->data->name,
+ attrs, SYSDB_MOD_REP);
+ if (ret) {
+ tevent_req_error(req, ret);
return;
}
-
- tevent_req_set_callback(attrreq, group_mod_attr_done, req);
- return;
}
if (state->data->rmgroups != NULL) {
@@ -871,47 +823,6 @@ static void group_mod_attr_wakeup(struct tevent_req *subreq)
tevent_req_done(req);
}
-static void group_mod_attr_done(struct tevent_req *attrreq)
-{
- struct tevent_req *req = tevent_req_callback_data(attrreq,
- struct tevent_req);
- struct group_mod_state *state = tevent_req_data(req,
- struct group_mod_state);
- int ret;
- struct tevent_req *groupreq;
-
- ret = sysdb_set_group_attr_recv(attrreq);
- talloc_zfree(attrreq);
- if (ret != EOK) {
- tevent_req_error(req, ret);
- return;
- }
-
- if (state->data->rmgroups != NULL) {
- groupreq = remove_from_groups_send(state, state->ev, state->sysdb,
- state->handle, state->data, state->member_dn);
- if (!groupreq) {
- tevent_req_error(req, ENOMEM);
- return;
- }
- tevent_req_set_callback(groupreq, group_mod_rm_group_done, req);
- return;
- }
-
- if (state->data->addgroups != NULL) {
- groupreq = add_to_groups_send(state, state->ev, state->sysdb,
- state->handle, state->data, state->member_dn);
- if (!groupreq) {
- tevent_req_error(req, ENOMEM);
- return;
- }
- tevent_req_set_callback(groupreq, group_mod_add_group_done, req);
- return;
- }
-
- return tevent_req_done(req);
-}
-
static void group_mod_rm_group_done(struct tevent_req *groupreq)
{
struct tevent_req *req = tevent_req_callback_data(groupreq,