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/providers | |
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/providers')
-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 |
10 files changed, 72 insertions, 183 deletions
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; } |