summaryrefslogtreecommitdiff
path: root/src/providers/ldap
diff options
context:
space:
mode:
authorJakub Hrozek <jhrozek@redhat.com>2013-08-20 16:12:13 +0200
committerJakub Hrozek <jhrozek@redhat.com>2013-08-28 18:06:57 +0200
commit4c63d8ae272923a734e3772f1cad49cbc1ee6e34 (patch)
tree05fddf6ff27f3d60a94fe8114567ce2d07777ef7 /src/providers/ldap
parenta4644da8f2bd25621ae159d753ffb66df9594dc8 (diff)
downloadsssd-4c63d8ae272923a734e3772f1cad49cbc1ee6e34.tar.gz
sssd-4c63d8ae272923a734e3772f1cad49cbc1ee6e34.tar.bz2
sssd-4c63d8ae272923a734e3772f1cad49cbc1ee6e34.zip
LDAP: Add enum_{users,groups}_recv to follow the tevent_req style
The enum code was quite old and predated the tevent_req style. In particular, the enum code was checking tevent state direcly and not using _recv functions or the helper macros we added later. As a consequence, it was not easy to read. This patch adds the standard _recv functions to read the status of the enum requests.
Diffstat (limited to 'src/providers/ldap')
-rw-r--r--src/providers/ldap/ldap_id_enum.c43
1 files changed, 19 insertions, 24 deletions
diff --git a/src/providers/ldap/ldap_id_enum.c b/src/providers/ldap/ldap_id_enum.c
index 06d6e877..4e8a80c4 100644
--- a/src/providers/ldap/ldap_id_enum.c
+++ b/src/providers/ldap/ldap_id_enum.c
@@ -192,6 +192,7 @@ static struct tevent_req *enum_users_send(TALLOC_CTX *memctx,
struct sdap_domain *sdom,
struct sdap_id_op *op,
bool purge);
+static errno_t enum_users_recv(struct tevent_req *req);
static void ldap_id_enum_users_done(struct tevent_req *subreq);
static struct tevent_req *enum_groups_send(TALLOC_CTX *memctx,
struct tevent_context *ev,
@@ -199,6 +200,7 @@ static struct tevent_req *enum_groups_send(TALLOC_CTX *memctx,
struct sdap_domain *sdom,
struct sdap_id_op *op,
bool purge);
+static errno_t enum_groups_recv(struct tevent_req *req);
static void ldap_id_enum_groups_done(struct tevent_req *subreq);
static void ldap_id_enum_services_done(struct tevent_req *subreq);
static void ldap_id_enum_cleanup_done(struct tevent_req *subreq);
@@ -296,22 +298,12 @@ static void ldap_id_enum_users_done(struct tevent_req *subreq)
struct tevent_req);
struct global_enum_state *state = tevent_req_data(req,
struct global_enum_state);
- enum tevent_req_state tstate;
uint64_t err = 0;
int ret, dp_error = DP_ERR_FATAL;
- if (tevent_req_is_error(subreq, &tstate, &err)) {
- if (tstate != TEVENT_REQ_USER_ERROR) {
- err = EIO;
- }
-
- if (err == ENOENT) {
- err = EOK;
- }
- }
+ err = enum_users_recv(subreq);
talloc_zfree(subreq);
-
- if (err != EOK) {
+ if (err != EOK && err != ENOENT) {
/* We call sdap_id_op_done only on error
* as the connection is reused by groups enumeration */
ret = sdap_id_op_done(state->op, (int)err, &dp_error);
@@ -351,22 +343,12 @@ static void ldap_id_enum_groups_done(struct tevent_req *subreq)
struct tevent_req);
struct global_enum_state *state = tevent_req_data(req,
struct global_enum_state);
- enum tevent_req_state tstate;
uint64_t err = 0;
int ret, dp_error = DP_ERR_FATAL;
- if (tevent_req_is_error(subreq, &tstate, &err)) {
- if (tstate != TEVENT_REQ_USER_ERROR) {
- err = EIO;
- }
-
- if (err == ENOENT) {
- err = EOK;
- }
- }
+ err = enum_groups_recv(subreq);
talloc_zfree(subreq);
-
- if (err != EOK) {
+ if (err != EOK && err != ENOENT) {
/* We call sdap_id_op_done only on error
* as the connection is reused by services enumeration */
ret = sdap_id_op_done(state->op, (int)err, &dp_error);
@@ -632,6 +614,13 @@ static void enum_users_op_done(struct tevent_req *subreq)
tevent_req_done(req);
}
+static errno_t enum_users_recv(struct tevent_req *req)
+{
+ TEVENT_REQ_RETURN_ON_ERROR(req);
+
+ return EOK;
+}
+
/* =Group-Enumeration===================================================== */
struct enum_groups_state {
@@ -794,3 +783,9 @@ static void enum_groups_op_done(struct tevent_req *subreq)
tevent_req_done(req);
}
+static errno_t enum_groups_recv(struct tevent_req *req)
+{
+ TEVENT_REQ_RETURN_ON_ERROR(req);
+
+ return EOK;
+}