diff options
author | Simo Sorce <ssorce@redhat.com> | 2009-11-07 12:59:17 -0500 |
---|---|---|
committer | Stephen Gallagher <sgallagh@redhat.com> | 2009-11-09 13:50:30 -0500 |
commit | 47d61ca8db78e5976400dbe08f426c0985e6e801 (patch) | |
tree | ec74b9a683113660420ee0aca8f10122ea8eb475 /server | |
parent | 35d0b225578e179b8c21f1eee59fcf075eb1f692 (diff) | |
download | sssd-47d61ca8db78e5976400dbe08f426c0985e6e801.tar.gz sssd-47d61ca8db78e5976400dbe08f426c0985e6e801.tar.bz2 sssd-47d61ca8db78e5976400dbe08f426c0985e6e801.zip |
Fix tevent_req error checking.
When possible using a macro that correctly deals with tstate
Diffstat (limited to 'server')
-rw-r--r-- | server/db/sysdb.c | 24 | ||||
-rw-r--r-- | server/db/sysdb_ops.c | 74 | ||||
-rw-r--r-- | server/providers/fail_over.c | 5 | ||||
-rw-r--r-- | server/providers/ipa/ipa_access.c | 21 | ||||
-rw-r--r-- | server/providers/krb5/krb5_auth.c | 43 | ||||
-rw-r--r-- | server/providers/ldap/ldap_auth.c | 18 | ||||
-rw-r--r-- | server/providers/ldap/ldap_id.c | 6 | ||||
-rw-r--r-- | server/providers/ldap/ldap_id_enum.c | 8 | ||||
-rw-r--r-- | server/providers/ldap/sdap_async.c | 20 | ||||
-rw-r--r-- | server/providers/ldap/sdap_async_accounts.c | 71 | ||||
-rw-r--r-- | server/providers/ldap/sdap_async_connection.c | 39 | ||||
-rw-r--r-- | server/providers/proxy.c | 24 | ||||
-rw-r--r-- | server/resolv/async_resolv.c | 16 | ||||
-rw-r--r-- | server/responder/pam/pamsrv_cmd.c | 7 | ||||
-rw-r--r-- | server/tools/sss_sync_ops.c | 7 | ||||
-rw-r--r-- | server/util/util.h | 12 |
16 files changed, 111 insertions, 284 deletions
diff --git a/server/db/sysdb.c b/server/db/sysdb.c index 971add09..e4131f11 100644 --- a/server/db/sysdb.c +++ b/server/db/sysdb.c @@ -375,12 +375,8 @@ static int sysdb_get_handle_recv(struct tevent_req *req, TALLOC_CTX *memctx, { struct sysdb_get_handle_state *state = tevent_req_data(req, struct sysdb_get_handle_state); - enum tevent_req_state tstate; - uint64_t err; - if (tevent_req_is_error(req, &tstate, &err)) { - return err; - } + TEVENT_REQ_RETURN_ON_ERROR(req); *handle = talloc_steal(memctx, state->handle); if (!*handle) return ENOMEM; @@ -454,12 +450,8 @@ int sysdb_transaction_recv(struct tevent_req *req, TALLOC_CTX *memctx, { struct sysdb_transaction_state *state = tevent_req_data(req, struct sysdb_transaction_state); - enum tevent_req_state tstate; - uint64_t err; - if (tevent_req_is_error(req, &tstate, &err)) { - return err; - } + TEVENT_REQ_RETURN_ON_ERROR(req); *handle = talloc_steal(memctx, state->handle); if (!*handle) return ENOMEM; @@ -503,16 +495,12 @@ int sysdb_transaction_commit_recv(struct tevent_req *req) { struct sysdb_transaction_state *state = tevent_req_data(req, struct sysdb_transaction_state); - enum tevent_req_state tstate; - uint64_t err; /* finally free handle * this will also trigger the next transaction in the queue if any */ talloc_zfree(state->handle); - if (tevent_req_is_error(req, &tstate, &err)) { - return err; - } + TEVENT_REQ_RETURN_ON_ERROR(req); return EOK; } @@ -595,12 +583,8 @@ int sysdb_operation_recv(struct tevent_req *req, TALLOC_CTX *memctx, { struct sysdb_operation_state *state = tevent_req_data(req, struct sysdb_operation_state); - enum tevent_req_state tstate; - uint64_t err; - if (tevent_req_is_error(req, &tstate, &err)) { - return err; - } + TEVENT_REQ_RETURN_ON_ERROR(req); *handle = talloc_steal(memctx, state->handle); if (!*handle) return ENOMEM; diff --git a/server/db/sysdb_ops.c b/server/db/sysdb_ops.c index 76413670..83082a0f 100644 --- a/server/db/sysdb_ops.c +++ b/server/db/sysdb_ops.c @@ -186,9 +186,14 @@ static int sldb_request_recv(struct tevent_req *req, } if (tevent_req_is_error(req, &tstate, &err)) { - if (err != 0) return err; - if (tstate == TEVENT_REQ_IN_PROGRESS) return EOK; - return EIO; + switch (tstate) { + case TEVENT_REQ_USER_ERROR: + return err; + case TEVENT_REQ_IN_PROGRESS: + return EOK; + default: + return EIO; + } } return EOK; @@ -238,12 +243,7 @@ done: static int sysdb_op_default_recv(struct tevent_req *req) { - enum tevent_req_state tstate; - uint64_t err; - - if (tevent_req_is_error(req, &tstate, &err)) { - return err; - } + TEVENT_REQ_RETURN_ON_ERROR(req); return EOK; } @@ -573,12 +573,8 @@ int sysdb_search_entry_recv(struct tevent_req *req, { struct sysdb_op_state *state = tevent_req_data(req, struct sysdb_op_state); - enum tevent_req_state tstate; - uint64_t err; - if (tevent_req_is_error(req, &tstate, &err)) { - return err; - } + TEVENT_REQ_RETURN_ON_ERROR(req); *msgs_count = state->msgs_count; *msgs = talloc_move(mem_ctx, &state->msgs); @@ -783,12 +779,8 @@ int sysdb_search_user_recv(struct tevent_req *req, { struct sysdb_search_user_state *state = tevent_req_data(req, struct sysdb_search_user_state); - enum tevent_req_state tstate; - uint64_t err; - if (tevent_req_is_error(req, &tstate, &err)) { - return err; - } + TEVENT_REQ_RETURN_ON_ERROR(req); if (state->msgs_count > 1) { DEBUG(1, ("More than one result found.\n")); @@ -1083,12 +1075,8 @@ int sysdb_search_group_recv(struct tevent_req *req, { struct sysdb_search_group_state *state = tevent_req_data(req, struct sysdb_search_group_state); - enum tevent_req_state tstate; - uint64_t err; - if (tevent_req_is_error(req, &tstate, &err)) { - return err; - } + TEVENT_REQ_RETURN_ON_ERROR(req); if (state->msgs_count > 1) { DEBUG(1, ("More than one result found.\n")); @@ -1750,12 +1738,8 @@ int sysdb_get_new_id_recv(struct tevent_req *req, uint32_t *id) { struct sysdb_get_new_id_state *state = tevent_req_data(req, struct sysdb_get_new_id_state); - enum tevent_req_state tstate; - uint64_t err; - if (tevent_req_is_error(req, &tstate, &err)) { - return err; - } + TEVENT_REQ_RETURN_ON_ERROR(req); *id = state->new_id; @@ -3590,12 +3574,8 @@ int sysdb_check_handle_recv(struct tevent_req *req, TALLOC_CTX *memctx, { struct sysdb_check_handle_state *state = tevent_req_data(req, struct sysdb_check_handle_state); - enum tevent_req_state tstate; - uint64_t err; - if (tevent_req_is_error(req, &tstate, &err)) { - return err; - } + TEVENT_REQ_RETURN_ON_ERROR(req); *handle = talloc_move(memctx, &state->handle); @@ -3735,12 +3715,8 @@ int sysdb_search_custom_recv(struct tevent_req *req, { struct sysdb_search_custom_state *state = tevent_req_data(req, struct sysdb_search_custom_state); - enum tevent_req_state tstate; - uint64_t err; - if (tevent_req_is_error(req, &tstate, &err)) { - return err; - } + TEVENT_REQ_RETURN_ON_ERROR(req); if (state->msgs_count > 1) { DEBUG(1, ("More than one result found.\n")); @@ -3940,12 +3916,7 @@ static void sysdb_store_custom_done(struct tevent_req *subreq) int sysdb_store_custom_recv(struct tevent_req *req) { - enum tevent_req_state tstate; - uint64_t err; - - if (tevent_req_is_error(req, &tstate, &err)) { - return err; - } + TEVENT_REQ_RETURN_ON_ERROR(req); return EOK; } @@ -4036,12 +4007,7 @@ static void sysdb_delete_custom_done(struct tevent_req *subreq) int sysdb_delete_custom_recv(struct tevent_req *req) { - enum tevent_req_state tstate; - uint64_t err; - - if (tevent_req_is_error(req, &tstate, &err)) { - return err; - } + TEVENT_REQ_RETURN_ON_ERROR(req); return EOK; } @@ -4247,13 +4213,9 @@ int sysdb_asq_search_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx, { struct sysdb_asq_search_state *state = tevent_req_data(req, struct sysdb_asq_search_state); - enum tevent_req_state tstate; - uint64_t err; int i; - if (tevent_req_is_error(req, &tstate, &err)) { - return err; - } + TEVENT_REQ_RETURN_ON_ERROR(req); *msgs_count = state->msgs_count; for (i = 0; i < state->msgs_count; i++) { diff --git a/server/providers/fail_over.c b/server/providers/fail_over.c index 796fc900..fa599e35 100644 --- a/server/providers/fail_over.c +++ b/server/providers/fail_over.c @@ -487,13 +487,10 @@ int fo_resolve_service_recv(struct tevent_req *req, struct fo_server **server) { struct resolve_service_state *state; - enum tevent_req_state tstate; - uint64_t err = EIO; state = tevent_req_data(req, struct resolve_service_state); - if (tevent_req_is_error(req, &tstate, &err)) - return err; + TEVENT_REQ_RETURN_ON_ERROR(req); if (server) *server = state->server; diff --git a/server/providers/ipa/ipa_access.c b/server/providers/ipa/ipa_access.c index 0adad546..19b707cd 100644 --- a/server/providers/ipa/ipa_access.c +++ b/server/providers/ipa/ipa_access.c @@ -274,14 +274,9 @@ static int hbac_get_user_info_recv(struct tevent_req *req, TALLOC_CTX *memctx, { struct hbac_get_user_info_state *state = tevent_req_data(req, struct hbac_get_user_info_state); - enum tevent_req_state tstate; - uint64_t err; int i; - if (tevent_req_is_error(req, &tstate, &err)) { - if (err) return err; - return EIO; - } + TEVENT_REQ_RETURN_ON_ERROR(req); *user_dn = talloc_steal(memctx, state->user_orig_dn); *groups_count = state->groups_count; @@ -716,13 +711,8 @@ static int hbac_get_host_info_recv(struct tevent_req *req, TALLOC_CTX *memctx, { struct hbac_get_host_info_state *state = tevent_req_data(req, struct hbac_get_host_info_state); - enum tevent_req_state tstate; - uint64_t err; - if (tevent_req_is_error(req, &tstate, &err)) { - if (err) return err; - return EIO; - } + TEVENT_REQ_RETURN_ON_ERROR(req); *hhi = talloc_steal(memctx, state->hbac_host_info); return EOK; @@ -1118,14 +1108,9 @@ static int hbac_get_rules_recv(struct tevent_req *req, TALLOC_CTX *memctx, { struct hbac_get_rules_state *state = tevent_req_data(req, struct hbac_get_rules_state); - enum tevent_req_state tstate; - uint64_t err; int i; - if (tevent_req_is_error(req, &tstate, &err)) { - if (err) return err; - return EIO; - } + TEVENT_REQ_RETURN_ON_ERROR(req); *hbac_rule_count = state->hbac_reply_count; *hbac_rule_list = talloc_steal(memctx, state->hbac_reply_list); diff --git a/server/providers/krb5/krb5_auth.c b/server/providers/krb5/krb5_auth.c index 1d699a87..cc5bc20d 100644 --- a/server/providers/krb5/krb5_auth.c +++ b/server/providers/krb5/krb5_auth.c @@ -573,19 +573,18 @@ static void read_pipe_done(struct tevent_context *ev, } -static ssize_t read_pipe_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx, - uint8_t **buf, uint64_t *error) +static int read_pipe_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx, + uint8_t **buf, ssize_t *len) { struct read_pipe_state *state = tevent_req_data(req, struct read_pipe_state); - enum tevent_req_state tstate; - if (tevent_req_is_error(req, &tstate, error)) { - return -1; - } + TEVENT_REQ_RETURN_ON_ERROR(req); *buf = talloc_move(mem_ctx, &state->buf); - return state->len; + *len = state->len; + + return EOK; } struct handle_child_state { @@ -647,15 +646,15 @@ static void handle_child_done(struct tevent_req *subreq) struct tevent_req); struct handle_child_state *state = tevent_req_data(req, struct handle_child_state); - uint64_t error; + int ret; - state->len = read_pipe_recv(subreq, state, &state->buf, &error); + ret = read_pipe_recv(subreq, state, &state->buf, &state->len); talloc_zfree(subreq); talloc_zfree(state->kr->timeout_handler); close(state->kr->read_from_child_fd); state->kr->read_from_child_fd = -1; - if (state->len == -1) { - tevent_req_error(req, error); + if (ret != EOK) { + tevent_req_error(req, ret); return; } @@ -663,20 +662,19 @@ static void handle_child_done(struct tevent_req *subreq) return; } -static ssize_t handle_child_recv(struct tevent_req *req, - TALLOC_CTX *mem_ctx, - uint8_t **buf, uint64_t *error) +static int handle_child_recv(struct tevent_req *req, + TALLOC_CTX *mem_ctx, + uint8_t **buf, ssize_t *len) { struct handle_child_state *state = tevent_req_data(req, struct handle_child_state); - enum tevent_req_state tstate; - if (tevent_req_is_error(req, &tstate, error)) { - return -1; - } + TEVENT_REQ_RETURN_ON_ERROR(req); *buf = talloc_move(mem_ctx, &state->buf); - return state->len; + *len = state->len; + + return EOK; } static void get_user_upn_done(void *pvt, int err, struct ldb_result *res); @@ -827,7 +825,6 @@ static void krb5_pam_handler_done(struct tevent_req *req) int ret; uint8_t *buf; ssize_t len; - uint64_t error; int p; int32_t *msg_status; int32_t *msg_type; @@ -841,10 +838,10 @@ static void krb5_pam_handler_done(struct tevent_req *req) pd->pam_status = PAM_SYSTEM_ERR; talloc_free(kr); - len = handle_child_recv(req, pd, &buf, &error); + ret = handle_child_recv(req, pd, &buf, &len); talloc_zfree(req); - if (len == -1) { - DEBUG(1, ("child failed\n")); + if (ret != EOK) { + DEBUG(1, ("child failed (%d [%s])\n", ret, strerror(ret))); goto done; } diff --git a/server/providers/ldap/ldap_auth.c b/server/providers/ldap/ldap_auth.c index 275c8945..a9f03a76 100644 --- a/server/providers/ldap/ldap_auth.c +++ b/server/providers/ldap/ldap_auth.c @@ -386,12 +386,8 @@ static int get_user_dn_recv(struct tevent_req *req, { struct get_user_dn_state *state = tevent_req_data(req, struct get_user_dn_state); - enum tevent_req_state tstate; - uint64_t err; - if (tevent_req_is_error(req, &tstate, &err)) { - return err; - } + TEVENT_REQ_RETURN_ON_ERROR(req); *dn = talloc_steal(memctx, state->dn); if (!*dn) return ENOMEM; @@ -535,9 +531,15 @@ int auth_recv(struct tevent_req *req, uint64_t err; if (tevent_req_is_error(req, &tstate, &err)) { - if (err == ETIMEDOUT) *result = SDAP_UNAVAIL; - else *result = SDAP_ERROR; - return EOK; + switch (tstate) { + case TEVENT_REQ_USER_ERROR: + if (err == ETIMEDOUT) *result = SDAP_UNAVAIL; + else *result = SDAP_ERROR; + return err; + default: + *result = SDAP_ERROR; + return EIO; + } } if (sh != NULL) { diff --git a/server/providers/ldap/ldap_id.c b/server/providers/ldap/ldap_id.c index 307f1e70..3268d734 100644 --- a/server/providers/ldap/ldap_id.c +++ b/server/providers/ldap/ldap_id.c @@ -176,7 +176,7 @@ static void users_get_done(struct tevent_req *req) struct be_req *breq = tevent_req_callback_data(req, struct be_req); struct sdap_id_ctx *ctx; enum tevent_req_state tstate; - uint64_t err; + uint64_t err = EIO; int dp_err = DP_ERR_OK; const char *error = NULL; int ret = EOK; @@ -347,7 +347,7 @@ static void groups_get_done(struct tevent_req *req) struct be_req *breq = tevent_req_callback_data(req, struct be_req); struct sdap_id_ctx *ctx; enum tevent_req_state tstate; - uint64_t err; + uint64_t err = EIO; int dp_err = DP_ERR_OK; const char *error = NULL; int ret = EOK; @@ -493,7 +493,7 @@ static void groups_by_user_done(struct tevent_req *req) struct be_req *breq = tevent_req_callback_data(req, struct be_req); struct sdap_id_ctx *ctx; enum tevent_req_state tstate; - uint64_t err; + uint64_t err = EIO; int dp_err = DP_ERR_OK; const char *error = NULL; int ret = EOK; diff --git a/server/providers/ldap/ldap_id_enum.c b/server/providers/ldap/ldap_id_enum.c index 39b24243..b7035efe 100644 --- a/server/providers/ldap/ldap_id_enum.c +++ b/server/providers/ldap/ldap_id_enum.c @@ -179,6 +179,9 @@ static void ldap_id_enum_users_done(struct tevent_req *subreq) uint64_t err = 0; if (tevent_req_is_error(subreq, &tstate, &err)) { + if (tstate != TEVENT_REQ_USER_ERROR) { + err = EIO; + } goto fail; } talloc_zfree(subreq); @@ -210,9 +213,12 @@ static void ldap_id_enum_groups_done(struct tevent_req *subreq) struct global_enum_state *state = tevent_req_data(req, struct global_enum_state); enum tevent_req_state tstate; - uint64_t err; + uint64_t err = 0; if (tevent_req_is_error(subreq, &tstate, &err)) { + if (tstate != TEVENT_REQ_USER_ERROR) { + err = EIO; + } goto fail; } talloc_zfree(subreq); diff --git a/server/providers/ldap/sdap_async.c b/server/providers/ldap/sdap_async.c index e02f3787..9e35c643 100644 --- a/server/providers/ldap/sdap_async.c +++ b/server/providers/ldap/sdap_async.c @@ -601,14 +601,10 @@ int sdap_exop_modify_passwd_recv(struct tevent_req *req, { struct sdap_exop_modify_passwd_state *state = tevent_req_data(req, struct sdap_exop_modify_passwd_state); - enum tevent_req_state tstate; - uint64_t err; *result = SDAP_ERROR; - if (tevent_req_is_error(req, &tstate, &err)) { - return err; - } + TEVENT_REQ_RETURN_ON_ERROR(req); if (state->result == LDAP_SUCCESS) { *result = SDAP_SUCCESS; @@ -702,13 +698,8 @@ int sdap_get_rootdse_recv(struct tevent_req *req, { struct sdap_get_rootdse_state *state = tevent_req_data(req, struct sdap_get_rootdse_state); - enum tevent_req_state tstate; - uint64_t err; - if (tevent_req_is_error(req, &tstate, &err)) { - if (err) return err; - return EIO; - } + TEVENT_REQ_RETURN_ON_ERROR(req); *rootdse = talloc_steal(memctx, state->rootdse); @@ -912,13 +903,8 @@ int sdap_get_generic_recv(struct tevent_req *req, { struct sdap_get_generic_state *state = tevent_req_data(req, struct sdap_get_generic_state); - enum tevent_req_state tstate; - uint64_t err; - if (tevent_req_is_error(req, &tstate, &err)) { - if (err) return err; - return EIO; - } + TEVENT_REQ_RETURN_ON_ERROR(req); *reply_count = state->reply_count; *reply = talloc_steal(mem_ctx, state->reply); diff --git a/server/providers/ldap/sdap_async_accounts.c b/server/providers/ldap/sdap_async_accounts.c index b38f6d62..bf6f852c 100644 --- a/server/providers/ldap/sdap_async_accounts.c +++ b/server/providers/ldap/sdap_async_accounts.c @@ -299,13 +299,8 @@ static int sdap_save_user_recv(struct tevent_req *req, { struct sdap_save_user_state *state = tevent_req_data(req, struct sdap_save_user_state); - enum tevent_req_state tstate; - uint64_t err; - if (tevent_req_is_error(req, &tstate, &err)) { - if (!err) return EIO; - return err; - } + TEVENT_REQ_RETURN_ON_ERROR(req); if (timestamp) { *timestamp = talloc_steal(mem_ctx, state->timestamp); @@ -460,13 +455,8 @@ static int sdap_save_users_recv(struct tevent_req *req, { struct sdap_save_users_state *state = tevent_req_data(req, struct sdap_save_users_state); - enum tevent_req_state tstate; - uint64_t err; - if (tevent_req_is_error(req, &tstate, &err)) { - if (err) return err; - return EIO; - } + TEVENT_REQ_RETURN_ON_ERROR(req); if (timestamp) { *timestamp = talloc_steal(mem_ctx, state->higher_timestamp); @@ -595,13 +585,8 @@ int sdap_get_users_recv(struct tevent_req *req, { struct sdap_get_users_state *state = tevent_req_data(req, struct sdap_get_users_state); - enum tevent_req_state tstate; - uint64_t err; - if (tevent_req_is_error(req, &tstate, &err)) { - if (err) return err; - return EIO; - } + TEVENT_REQ_RETURN_ON_ERROR(req); if (timestamp) { *timestamp = talloc_steal(mem_ctx, state->higher_timestamp); @@ -1020,13 +1005,8 @@ static int sdap_save_group_recv(struct tevent_req *req, { struct sdap_save_group_state *state = tevent_req_data(req, struct sdap_save_group_state); - enum tevent_req_state tstate; - uint64_t err; - if (tevent_req_is_error(req, &tstate, &err)) { - if (!err) return EIO; - return err; - } + TEVENT_REQ_RETURN_ON_ERROR(req); if ( timestamp ) { *timestamp = talloc_steal(mem_ctx, state->timestamp); @@ -1146,13 +1126,8 @@ static void sdap_save_grpmem_done(struct tevent_req *subreq) static int sdap_save_grpmem_recv(struct tevent_req *req) { - enum tevent_req_state tstate; - uint64_t err; + TEVENT_REQ_RETURN_ON_ERROR(req); - if (tevent_req_is_error(req, &tstate, &err)) { - if (!err) return EIO; - return err; - } return EOK; } @@ -1385,13 +1360,8 @@ static int sdap_save_groups_recv(struct tevent_req *req, { struct sdap_save_groups_state *state = tevent_req_data(req, struct sdap_save_groups_state); - enum tevent_req_state tstate; - uint64_t err; - if (tevent_req_is_error(req, &tstate, &err)) { - if (err) return err; - return EIO; - } + TEVENT_REQ_RETURN_ON_ERROR(req); if (timestamp) { *timestamp = talloc_steal(mem_ctx, state->higher_timestamp); @@ -1520,13 +1490,8 @@ int sdap_get_groups_recv(struct tevent_req *req, { struct sdap_get_groups_state *state = tevent_req_data(req, struct sdap_get_groups_state); - enum tevent_req_state tstate; - uint64_t err; - if (tevent_req_is_error(req, &tstate, &err)) { - if (err) return err; - return EIO; - } + TEVENT_REQ_RETURN_ON_ERROR(req); if (timestamp) { *timestamp = talloc_steal(mem_ctx, state->higher_timestamp); @@ -1647,13 +1612,8 @@ static void sdap_initgr_rfc2307_done(struct tevent_req *subreq) static int sdap_initgr_rfc2307_recv(struct tevent_req *req) { - enum tevent_req_state tstate; - uint64_t err; + TEVENT_REQ_RETURN_ON_ERROR(req); - if (tevent_req_is_error(req, &tstate, &err)) { - if (err) return err; - return EIO; - } return EOK; } @@ -1846,13 +1806,8 @@ static void sdap_initgr_nested_done(struct tevent_req *subreq) static int sdap_initgr_nested_recv(struct tevent_req *req) { - enum tevent_req_state tstate; - uint64_t err; + TEVENT_REQ_RETURN_ON_ERROR(req); - if (tevent_req_is_error(req, &tstate, &err)) { - if (err) return err; - return EIO; - } return EOK; } @@ -2147,13 +2102,7 @@ static void sdap_get_initgr_done(struct tevent_req *subreq) int sdap_get_initgr_recv(struct tevent_req *req) { - enum tevent_req_state tstate; - uint64_t err; - - if (tevent_req_is_error(req, &tstate, &err)) { - if (err) return err; - return EIO; - } + TEVENT_REQ_RETURN_ON_ERROR(req); return EOK; } diff --git a/server/providers/ldap/sdap_async_connection.c b/server/providers/ldap/sdap_async_connection.c index 5adb7c38..9f53ad6f 100644 --- a/server/providers/ldap/sdap_async_connection.c +++ b/server/providers/ldap/sdap_async_connection.c @@ -205,7 +205,7 @@ int sdap_connect_recv(struct tevent_req *req, struct sdap_connect_state *state = tevent_req_data(req, struct sdap_connect_state); enum tevent_req_state tstate; - uint64_t err; + uint64_t err = EIO; if (tevent_req_is_error(req, &tstate, &err)) { /* if tstate shows in progress, it is because @@ -401,14 +401,9 @@ static int simple_bind_recv(struct tevent_req *req, int *ldaperr) { struct simple_bind_state *state = tevent_req_data(req, struct simple_bind_state); - enum tevent_req_state tstate; - uint64_t err; - if (tevent_req_is_error(req, &tstate, &err)) { - *ldaperr = LDAP_OTHER; - if (err) return err; - return EIO; - } + *ldaperr = LDAP_OTHER; + TEVENT_REQ_RETURN_ON_ERROR(req); *ldaperr = state->result; return EOK; @@ -537,13 +532,12 @@ static int sasl_bind_recv(struct tevent_req *req, int *ldaperr) struct sasl_bind_state *state = tevent_req_data(req, struct sasl_bind_state); enum tevent_req_state tstate; - uint64_t err; + uint64_t err = EIO; if (tevent_req_is_error(req, &tstate, &err)) { if (tstate != TEVENT_REQ_IN_PROGRESS) { *ldaperr = LDAP_OTHER; - if (err) return err; - return EIO; + return err; } } @@ -755,13 +749,12 @@ int sdap_kinit_recv(struct tevent_req *req, enum sdap_result *result) struct sdap_kinit_state *state = tevent_req_data(req, struct sdap_kinit_state); enum tevent_req_state tstate; - uint64_t err; + uint64_t err = EIO; if (tevent_req_is_error(req, &tstate, &err)) { if (tstate != TEVENT_REQ_IN_PROGRESS) { *result = SDAP_ERROR; - if (err) return err; - return EIO; + return err; } } @@ -852,13 +845,10 @@ int sdap_auth_recv(struct tevent_req *req, enum sdap_result *result) { struct sdap_auth_state *state = tevent_req_data(req, struct sdap_auth_state); - enum tevent_req_state tstate; - uint64_t err; - if (tevent_req_is_error(req, &tstate, &err)) { - *result = SDAP_ERROR; - return err; - } + *result = SDAP_ERROR; + TEVENT_REQ_RETURN_ON_ERROR(req); + switch (state->result) { case LDAP_SUCCESS: *result = SDAP_AUTH_SUCCESS; @@ -870,7 +860,7 @@ int sdap_auth_recv(struct tevent_req *req, enum sdap_result *result) *result = SDAP_AUTH_PW_EXPIRED; break; default: - *result = SDAP_ERROR; + break; } return EOK; @@ -1128,13 +1118,8 @@ int sdap_cli_connect_recv(struct tevent_req *req, { struct sdap_cli_connect_state *state = tevent_req_data(req, struct sdap_cli_connect_state); - enum tevent_req_state tstate; - uint64_t err; - if (tevent_req_is_error(req, &tstate, &err)) { - if (err) return err; - return EIO; - } + TEVENT_REQ_RETURN_ON_ERROR(req); if (gsh) { *gsh = talloc_steal(memctx, state->sh); diff --git a/server/providers/proxy.c b/server/providers/proxy.c index bce6a75a..628f9d49 100644 --- a/server/providers/proxy.c +++ b/server/providers/proxy.c @@ -300,13 +300,7 @@ static void proxy_default_done(struct tevent_req *subreq) static int proxy_default_recv(struct tevent_req *req) { - enum tevent_req_state tstate; - uint64_t err = 0; - - if (tevent_req_is_error(req, &tstate, &err)) { - if (err != 0) return err; - return EIO; - } + TEVENT_REQ_RETURN_ON_ERROR(req); return EOK; } @@ -1808,13 +1802,7 @@ static void get_groups_by_gid_process(struct tevent_req *subreq) static int get_groups_by_gid_recv(struct tevent_req *req) { - enum tevent_req_state tstate; - uint64_t err = 0; - - if (tevent_req_is_error(req, &tstate, &err)) { - if (err != 0) return err; - return EIO; - } + TEVENT_REQ_RETURN_ON_ERROR(req); return EOK; } @@ -1977,13 +1965,7 @@ static void get_group_from_gid_send_del_done(struct tevent_req *subreq) static int get_group_from_gid_recv(struct tevent_req *req) { - enum tevent_req_state tstate; - uint64_t err = 0; - - if (tevent_req_is_error(req, &tstate, &err)) { - if (err != 0) return err; - return EIO; - } + TEVENT_REQ_RETURN_ON_ERROR(req); return EOK; } diff --git a/server/resolv/async_resolv.c b/server/resolv/async_resolv.c index f6ed2028..c05461d6 100644 --- a/server/resolv/async_resolv.c +++ b/server/resolv/async_resolv.c @@ -400,8 +400,6 @@ resolv_gethostbyname_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx, struct hostent **hostent) { struct gethostbyname_state *state = tevent_req_data(req, struct gethostbyname_state); - enum tevent_req_state tstate; - uint64_t err = EIO; /* Fill in even in case of error as status contains the * c-ares return code */ @@ -415,9 +413,7 @@ resolv_gethostbyname_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx, *hostent = talloc_steal(mem_ctx, state->hostent); } - if (tevent_req_is_error(req, &tstate, &err)) { - return err; - } + TEVENT_REQ_RETURN_ON_ERROR(req); return EOK; } @@ -587,8 +583,6 @@ resolv_getsrv_recv(TALLOC_CTX *mem_ctx, struct tevent_req *req, int *status, int *num_replies) { struct getsrv_state *state = tevent_req_data(req, struct getsrv_state); - enum tevent_req_state tstate; - uint64_t err; if (status) *status = state->status; @@ -599,8 +593,7 @@ resolv_getsrv_recv(TALLOC_CTX *mem_ctx, struct tevent_req *req, int *status, if (num_replies) *num_replies = state->num_replies; - if (tevent_req_is_error(req, &tstate, &err)) - return -1; + TEVENT_REQ_RETURN_ON_ERROR(req); return EOK; } @@ -769,8 +762,6 @@ resolv_gettxt_recv(TALLOC_CTX *mem_ctx, struct tevent_req *req, int *status, int *num_replies) { struct gettxt_state *state = tevent_req_data(req, struct gettxt_state); - enum tevent_req_state tstate; - uint64_t err; if (status) *status = state->status; @@ -781,8 +772,7 @@ resolv_gettxt_recv(TALLOC_CTX *mem_ctx, struct tevent_req *req, int *status, if (num_replies) *num_replies = state->num_replies; - if (tevent_req_is_error(req, &tstate, &err)) - return -1; + TEVENT_REQ_RETURN_ON_ERROR(req); return EOK; } diff --git a/server/responder/pam/pamsrv_cmd.c b/server/responder/pam/pamsrv_cmd.c index 699ec91a..815a0f96 100644 --- a/server/responder/pam/pamsrv_cmd.c +++ b/server/responder/pam/pamsrv_cmd.c @@ -388,12 +388,7 @@ static void set_last_login_done(struct tevent_req *subreq) static int set_last_login_recv(struct tevent_req *req) { - enum tevent_req_state tstate; - uint64_t err = 0; - - if (tevent_req_is_error(req, &tstate, &err)) { - return err; - } + TEVENT_REQ_RETURN_ON_ERROR(req); return EOK; } diff --git a/server/tools/sss_sync_ops.c b/server/tools/sss_sync_ops.c index 3359e5be..25b8ac7a 100644 --- a/server/tools/sss_sync_ops.c +++ b/server/tools/sss_sync_ops.c @@ -61,12 +61,7 @@ struct sync_op_res { */ static int sync_ops_recv(struct tevent_req *req) { - enum tevent_req_state tstate; - uint64_t err; - - if (tevent_req_is_error(req, &tstate, &err)) { - return err; - } + TEVENT_REQ_RETURN_ON_ERROR(req); return EOK; } diff --git a/server/util/util.h b/server/util/util.h index f13217e6..661bcebb 100644 --- a/server/util/util.h +++ b/server/util/util.h @@ -140,6 +140,18 @@ errno_t set_debug_file_from_fd(const int fd); } while(0) #endif +#define TEVENT_REQ_RETURN_ON_ERROR(req) do { \ + enum tevent_req_state TRROEstate; \ + uint64_t TRROEerr; \ + \ + if (tevent_req_is_error(req, &TRROEstate, &TRROEerr)) { \ + if (TRROEstate == TEVENT_REQ_USER_ERROR) { \ + return TRROEerr; \ + } \ + return EIO; \ + } \ +} while (0) + #include "util/dlinklist.h" /* From debug.c */ |