diff options
author | Simo Sorce <ssorce@redhat.com> | 2010-03-11 23:03:47 -0500 |
---|---|---|
committer | Stephen Gallagher <sgallagh@redhat.com> | 2010-04-12 09:22:15 -0400 |
commit | d8d877a5fcde1defdd1a438df020e087339873a0 (patch) | |
tree | f385b1d75327ede87339b9d813a87920f9ca1231 /src/responder | |
parent | 40bb1ddf0a3f69922466b2b99bcdaf7746fc81ba (diff) | |
download | sssd-d8d877a5fcde1defdd1a438df020e087339873a0.tar.gz sssd-d8d877a5fcde1defdd1a438df020e087339873a0.tar.bz2 sssd-d8d877a5fcde1defdd1a438df020e087339873a0.zip |
Remove remaining use of sysdb_transaction_send
Diffstat (limited to 'src/responder')
-rw-r--r-- | src/responder/pam/pam_LOCAL_domain.c | 122 | ||||
-rw-r--r-- | src/responder/pam/pamsrv_cmd.c | 142 |
2 files changed, 32 insertions, 232 deletions
diff --git a/src/responder/pam/pam_LOCAL_domain.c b/src/responder/pam/pam_LOCAL_domain.c index 80f8a91c..09229c29 100644 --- a/src/responder/pam/pam_LOCAL_domain.c +++ b/src/responder/pam/pam_LOCAL_domain.c @@ -70,69 +70,8 @@ static void prepare_reply(struct LOCAL_request *lreq) lreq->preq->callback(lreq->preq); } -static void set_user_attr_done(struct tevent_req *req) -{ - struct LOCAL_request *lreq; - int ret; - - lreq = tevent_req_callback_data(req, struct LOCAL_request); - - ret = sysdb_transaction_commit_recv(req); - if (ret) { - DEBUG(2, ("set_user_attr failed.\n")); - lreq->error =ret; - } - - prepare_reply(lreq); -} - -static void set_user_attr_req(struct tevent_req *req) -{ - struct LOCAL_request *lreq = tevent_req_callback_data(req, - struct LOCAL_request); - int ret; - - DEBUG(4, ("entering set_user_attr_req\n")); - - ret = sysdb_transaction_recv(req, lreq, &lreq->handle); - if (ret) { - lreq->error = ret; - return prepare_reply(lreq); - } - - 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))); - - if (ret) { - lreq->error = ret; - goto fail; - } - - req = sysdb_transaction_commit_send(lreq, lreq->ev, lreq->handle); - if (!req) { - lreq->error = ENOMEM; - goto fail; - } - tevent_req_set_callback(req, set_user_attr_done, lreq); - - return; - -fail: - DEBUG(2, ("set_user_attr failed.\n")); - - /* cancel transaction */ - talloc_zfree(lreq->handle); - - prepare_reply(lreq); -} - static void do_successful_login(struct LOCAL_request *lreq) { - struct tevent_req *req; int ret; lreq->mod_attrs = sysdb_new_attrs(lreq); @@ -148,23 +87,19 @@ static void do_successful_login(struct LOCAL_request *lreq) NEQ_CHECK_OR_JUMP(ret, EOK, ("sysdb_attrs_add_long failed.\n"), lreq->error, ret, done); - req = sysdb_transaction_send(lreq, lreq->ev, lreq->dbctx); - if (!req) { - lreq->error = ENOMEM; - goto done; - } - tevent_req_set_callback(req, set_user_attr_req, lreq); - - return; + ret = sysdb_set_user_attr(lreq, lreq->dbctx, + lreq->preq->domain, + lreq->preq->pd->user, + lreq->mod_attrs, SYSDB_MOD_REP); + NEQ_CHECK_OR_JUMP(ret, EOK, ("sysdb_set_user_attr failed.\n"), + lreq->error, ret, done); done: - - prepare_reply(lreq); + return; } static void do_failed_login(struct LOCAL_request *lreq) { - struct tevent_req *req; int ret; int failedLoginAttempts; struct pam_data *pd; @@ -194,18 +129,15 @@ static void do_failed_login(struct LOCAL_request *lreq) NEQ_CHECK_OR_JUMP(ret, EOK, ("sysdb_attrs_add_long failed.\n"), lreq->error, ret, done); - req = sysdb_transaction_send(lreq, lreq->ev, lreq->dbctx); - if (!req) { - lreq->error = ENOMEM; - goto done; - } - tevent_req_set_callback(req, set_user_attr_req, lreq); - - return; + ret = sysdb_set_user_attr(lreq, lreq->dbctx, + lreq->preq->domain, + lreq->preq->pd->user, + lreq->mod_attrs, SYSDB_MOD_REP); + NEQ_CHECK_OR_JUMP(ret, EOK, ("sysdb_set_user_attr failed.\n"), + lreq->error, ret, done); done: - - prepare_reply(lreq); + return; } static void do_pam_acct_mgmt(struct LOCAL_request *lreq) @@ -222,13 +154,10 @@ static void do_pam_acct_mgmt(struct LOCAL_request *lreq) (strncasecmp(disabled, "no",2) != 0) ) { pd->pam_status = PAM_PERM_DENIED; } - - prepare_reply(lreq); } static void do_pam_chauthtok(struct LOCAL_request *lreq) { - struct tevent_req *req; int ret; char *newauthtok; char *salt; @@ -246,7 +175,7 @@ static void do_pam_chauthtok(struct LOCAL_request *lreq) if (strlen(newauthtok) == 0) { /* TODO: should we allow null passwords via a config option ? */ DEBUG(1, ("Empty passwords are not allowed!\n")); - ret = EINVAL; + lreq->error = EINVAL; goto done; } @@ -274,17 +203,15 @@ static void do_pam_chauthtok(struct LOCAL_request *lreq) NEQ_CHECK_OR_JUMP(ret, EOK, ("sysdb_attrs_add_long failed.\n"), lreq->error, ret, done); - req = sysdb_transaction_send(lreq, lreq->ev, lreq->dbctx); - if (!req) { - lreq->error = ENOMEM; - goto done; - } - tevent_req_set_callback(req, set_user_attr_req, lreq); + ret = sysdb_set_user_attr(lreq, lreq->dbctx, + lreq->preq->domain, + lreq->preq->pd->user, + lreq->mod_attrs, SYSDB_MOD_REP); + NEQ_CHECK_OR_JUMP(ret, EOK, ("sysdb_set_user_attr failed.\n"), + lreq->error, ret, done); - return; done: - - prepare_reply(lreq); + return; } static void local_handler_callback(void *pvt, int ldb_status, @@ -361,7 +288,7 @@ static void local_handler_callback(void *pvt, int ldb_status, if (strcmp(new_hash, password) != 0) { DEBUG(1, ("Passwords do not match.\n")); do_failed_login(lreq); - return; + goto done; } break; @@ -370,15 +297,12 @@ static void local_handler_callback(void *pvt, int ldb_status, switch (pd->cmd) { case SSS_PAM_AUTHENTICATE: do_successful_login(lreq); - return; break; case SSS_PAM_CHAUTHTOK: do_pam_chauthtok(lreq); - return; break; case SSS_PAM_ACCT_MGMT: do_pam_acct_mgmt(lreq); - return; break; case SSS_PAM_SETCRED: break; diff --git a/src/responder/pam/pamsrv_cmd.c b/src/responder/pam/pamsrv_cmd.c index 77f29ec8..eba78cce 100644 --- a/src/responder/pam/pamsrv_cmd.c +++ b/src/responder/pam/pamsrv_cmd.c @@ -271,119 +271,8 @@ static int pam_parse_in_data(struct sss_names_ctx *snctx, /*=Save-Last-Login-State===================================================*/ -struct set_last_login_state { - struct tevent_context *ev; - struct sysdb_ctx *dbctx; - - struct sss_domain_info *dom; - const char *username; - struct sysdb_attrs *attrs; - - struct sysdb_handle *handle; - - struct ldb_result *res; -}; - -static void set_last_login_trans_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, - struct tevent_context *ev, - struct sysdb_ctx *dbctx, - struct sss_domain_info *dom, - const char *username, - struct sysdb_attrs *attrs) -{ - struct tevent_req *req, *subreq; - struct set_last_login_state *state; - - req = tevent_req_create(memctx, &state, struct set_last_login_state); - if (!req) { - return NULL; - } - - state->ev = ev; - state->dbctx = dbctx; - state->dom = dom; - state->username = username; - state->attrs = attrs; - state->handle = NULL; - - subreq = sysdb_transaction_send(state, state->ev, state->dbctx); - if (!subreq) { - talloc_free(req); - return NULL; - } - tevent_req_set_callback(subreq, set_last_login_trans_done, req); - - return req; -} - -static void set_last_login_trans_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_transaction_recv(subreq, state, &state->handle); - talloc_zfree(subreq); - if (ret != EOK) { - DEBUG(1, ("Unable to acquire sysdb transaction lock\n")); - tevent_req_error(req, ret); - return; - } - - 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))); - tevent_req_error(req, ret); - return; - } - - subreq = sysdb_transaction_commit_send(state, state->ev, state->handle); - if (!subreq) { - tevent_req_error(req, ENOMEM); - return; - } - tevent_req_set_callback(subreq, set_last_login_done, req); -} - -static void set_last_login_done(struct tevent_req *subreq) -{ - struct tevent_req *req = tevent_req_callback_data(subreq, - struct tevent_req); - int ret; - - ret = sysdb_transaction_commit_recv(subreq); - if (ret != EOK) { - DEBUG(2, ("set_last_login failed.\n")); - tevent_req_error(req, ret); - return; - } - - tevent_req_done(req); -} - -static int set_last_login_recv(struct tevent_req *req) -{ - TEVENT_REQ_RETURN_ON_ERROR(req); - - return EOK; -} - -/*=========================================================================*/ - - -static void set_last_login_reply(struct tevent_req *req); - static errno_t set_last_login(struct pam_auth_req *preq) { - struct tevent_req *req; struct sysdb_ctx *dbctx; struct sysdb_attrs *attrs; errno_t ret; @@ -411,13 +300,17 @@ static errno_t set_last_login(struct pam_auth_req *preq) goto fail; } - req = set_last_login_send(preq, preq->cctx->ev, dbctx, - preq->domain, preq->pd->user, attrs); - if (!req) { - ret = ENOMEM; + ret = sysdb_set_user_attr(preq, dbctx, + preq->domain, preq->pd->user, + attrs, SYSDB_MOD_REP); + if (ret != EOK) { + DEBUG(2, ("set_last_login failed.\n")); + preq->pd->pam_status = PAM_SYSTEM_ERR; goto fail; + } else { + preq->pd->last_auth_saved = true; } - tevent_req_set_callback(req, set_last_login_reply, preq); + preq->callback(preq); return EOK; @@ -425,22 +318,6 @@ fail: return ret; } -static void set_last_login_reply(struct tevent_req *req) -{ - struct pam_auth_req *preq = tevent_req_callback_data(req, - struct pam_auth_req); - int ret; - - ret = set_last_login_recv(req); - if (ret != EOK) { - preq->pd->pam_status = PAM_SYSTEM_ERR; - } else { - preq->pd->last_auth_saved = true; - } - - preq->callback(preq); -} - static void pam_reply_delay(struct tevent_context *ev, struct tevent_timer *te, struct timeval tv, void *pvt) { @@ -566,7 +443,6 @@ static void pam_reply(struct pam_auth_req *preq) if (ret != EOK) { goto done; } - return; } |