diff options
author | Pavel Březina <pbrezina@redhat.com> | 2012-10-30 12:01:51 +0100 |
---|---|---|
committer | Jakub Hrozek <jhrozek@redhat.com> | 2012-11-14 17:33:48 +0100 |
commit | 7e315b08152b1340511d4f6211d524482107e481 (patch) | |
tree | bd36cebca0edbbfce3d059918b3a29af95b24d65 /src/responder/sudo/sudosrv_cmd.c | |
parent | 2055d5df8129256b08f66745a280b4cf1f76eba0 (diff) | |
download | sssd-7e315b08152b1340511d4f6211d524482107e481.tar.gz sssd-7e315b08152b1340511d4f6211d524482107e481.tar.xz sssd-7e315b08152b1340511d4f6211d524482107e481.zip |
sudo: support users from subdomains
https://fedorahosted.org/sssd/ticket/1616
Diffstat (limited to 'src/responder/sudo/sudosrv_cmd.c')
-rw-r--r-- | src/responder/sudo/sudosrv_cmd.c | 41 |
1 files changed, 33 insertions, 8 deletions
diff --git a/src/responder/sudo/sudosrv_cmd.c b/src/responder/sudo/sudosrv_cmd.c index 13eb4991f..d0c578157 100644 --- a/src/responder/sudo/sudosrv_cmd.c +++ b/src/responder/sudo/sudosrv_cmd.c @@ -155,10 +155,12 @@ errno_t sudosrv_cmd_done(struct sudo_cmd_ctx *cmd_ctx, int ret) return EOK; } +static void sudosrv_cmd_parse_query_done(struct tevent_req *req); + static int sudosrv_cmd(enum sss_sudo_type type, struct cli_ctx *cli_ctx) { + struct tevent_req *req = NULL; struct sudo_cmd_ctx *cmd_ctx = NULL; - struct sudo_dom_ctx *dom_ctx = NULL; uint8_t *query_body = NULL; size_t query_len = 0; errno_t ret; @@ -198,11 +200,35 @@ static int sudosrv_cmd(enum sss_sudo_type type, struct cli_ctx *cli_ctx) goto done; } - ret = sudosrv_parse_query(cmd_ctx, cli_ctx->rctx, - query_body, query_len, - &cmd_ctx->uid, &cmd_ctx->username, &cmd_ctx->domain); + req = sudosrv_parse_query_send(cmd_ctx, cli_ctx->rctx, + query_body, query_len); + if (req == NULL) { + ret = ENOMEM; + goto done; + } + + tevent_req_set_callback(req, sudosrv_cmd_parse_query_done, cmd_ctx); + + ret = EAGAIN; + +done: + return sudosrv_cmd_done(cmd_ctx, ret); +} + +static void sudosrv_cmd_parse_query_done(struct tevent_req *req) +{ + struct sudo_cmd_ctx *cmd_ctx = NULL; + struct sudo_dom_ctx *dom_ctx = NULL; + errno_t ret; + + cmd_ctx = tevent_req_callback_data(req, struct sudo_cmd_ctx); + + ret = sudosrv_parse_query_recv(cmd_ctx, req, &cmd_ctx->uid, + &cmd_ctx->username, &cmd_ctx->domain); + talloc_zfree(req); if (ret != EOK) { - DEBUG(SSSDBG_CRIT_FAILURE, ("Invalid query: %s\n", strerror(ret))); + DEBUG(SSSDBG_CRIT_FAILURE, ("Invalid query [%d]: %s\n", + ret, strerror(ret))); goto done; } @@ -230,15 +256,14 @@ static int sudosrv_cmd(enum sss_sudo_type type, struct cli_ctx *cli_ctx) } dom_ctx->cmd_ctx = cmd_ctx; dom_ctx->domain = cmd_ctx->domain != NULL ? cmd_ctx->domain - : cli_ctx->rctx->domains; + : cmd_ctx->cli_ctx->rctx->domains; ret = sudosrv_get_sudorules(dom_ctx); done: - return sudosrv_cmd_done(cmd_ctx, ret); + sudosrv_cmd_done(cmd_ctx, ret); } - static int sudosrv_cmd_get_sudorules(struct cli_ctx *cli_ctx) { return sudosrv_cmd(SSS_SUDO_USER, cli_ctx); |