diff options
Diffstat (limited to 'src/responder/ssh/sshsrv_cmd.c')
-rw-r--r-- | src/responder/ssh/sshsrv_cmd.c | 47 |
1 files changed, 28 insertions, 19 deletions
diff --git a/src/responder/ssh/sshsrv_cmd.c b/src/responder/ssh/sshsrv_cmd.c index ba3b694d9..1baba8b03 100644 --- a/src/responder/ssh/sshsrv_cmd.c +++ b/src/responder/ssh/sshsrv_cmd.c @@ -662,9 +662,8 @@ done: static errno_t ssh_cmd_parse_request(struct ssh_cmd_ctx *cmd_ctx) { - struct cli_ctx *cctx = cmd_ctx->cctx; - struct ssh_ctx *ssh_ctx = talloc_get_type(cctx->rctx->pvt_ctx, - struct ssh_ctx); + struct cli_protocol *pctx; + struct ssh_ctx *ssh_ctx; errno_t ret; uint8_t *body; size_t body_len; @@ -677,7 +676,10 @@ ssh_cmd_parse_request(struct ssh_cmd_ctx *cmd_ctx) uint32_t domain_len; char *domain = NULL; - sss_packet_get_body(cctx->creq->in, &body, &body_len); + ssh_ctx = talloc_get_type(cmd_ctx->cctx->rctx->pvt_ctx, struct ssh_ctx); + pctx = talloc_get_type(cmd_ctx->cctx->protocol_ctx, struct cli_protocol); + + sss_packet_get_body(pctx->creq->in, &body, &body_len); SAFEALIGN_COPY_UINT32_CHECK(&flags, body+c, body_len, &c); if (flags & ~(uint32_t)SSS_SSH_REQ_MASK) { @@ -752,7 +754,8 @@ ssh_cmd_parse_request(struct ssh_cmd_ctx *cmd_ctx) DEBUG(SSSDBG_TRACE_FUNC, "Parsing name [%s][%s]\n", name, domain ? domain : "<ALL>"); - ret = sss_parse_name_for_domains(cmd_ctx, cctx->rctx->domains, + ret = sss_parse_name_for_domains(cmd_ctx, + cmd_ctx->cctx->rctx->domains, domain, name, &cmd_ctx->domname, &cmd_ctx->name); @@ -882,7 +885,7 @@ static errno_t decode_and_add_base64_data(struct ssh_cmd_ctx *cmd_ctx, const char *fqname, size_t *c) { - struct cli_ctx *cctx = cmd_ctx->cctx; + struct cli_protocol *pctx; uint8_t *key; size_t key_len; uint8_t *body; @@ -902,6 +905,8 @@ static errno_t decode_and_add_base64_data(struct ssh_cmd_ctx *cmd_ctx, return ENOMEM; } + pctx = talloc_get_type(cmd_ctx->cctx->protocol_ctx, struct cli_protocol); + for (d = 0; d < el->num_values; d++) { if (skip_base64_decode) { key = el->values[d].data; @@ -916,13 +921,13 @@ static errno_t decode_and_add_base64_data(struct ssh_cmd_ctx *cmd_ctx, } } - ret = sss_packet_grow(cctx->creq->out, + ret = sss_packet_grow(pctx->creq->out, 3*sizeof(uint32_t) + key_len + fqname_len); if (ret != EOK) { DEBUG(SSSDBG_OP_FAILURE, "sss_packet_grow failed.\n"); goto done; } - sss_packet_get_body(cctx->creq->out, &body, &body_len); + sss_packet_get_body(pctx->creq->out, &body, &body_len); SAFEALIGN_SET_UINT32(body+(*c), 0, c); SAFEALIGN_SET_UINT32(body+(*c), fqname_len, c); @@ -943,7 +948,6 @@ done: static errno_t ssh_cmd_build_reply(struct ssh_cmd_ctx *cmd_ctx) { - struct cli_ctx *cctx = cmd_ctx->cctx; errno_t ret; uint8_t *body; size_t body_len; @@ -957,13 +961,16 @@ ssh_cmd_build_reply(struct ssh_cmd_ctx *cmd_ctx) const char *name; char *fqname; uint32_t fqname_len; - struct ssh_ctx *ssh_ctx = talloc_get_type(cctx->rctx->pvt_ctx, - struct ssh_ctx); TALLOC_CTX *tmp_ctx; + struct ssh_ctx *ssh_ctx; + struct cli_protocol *pctx; - ret = sss_packet_new(cctx->creq, 0, - sss_packet_get_cmd(cctx->creq->in), - &cctx->creq->out); + ssh_ctx = talloc_get_type(cmd_ctx->cctx->rctx->pvt_ctx, struct ssh_ctx); + pctx = talloc_get_type(cmd_ctx->cctx->protocol_ctx, struct cli_protocol); + + ret = sss_packet_new(pctx->creq, 0, + sss_packet_get_cmd(pctx->creq->in), + &pctx->creq->out); if (ret != EOK) { return ret; } @@ -1007,11 +1014,11 @@ ssh_cmd_build_reply(struct ssh_cmd_ctx *cmd_ctx) } } - ret = sss_packet_grow(cctx->creq->out, 2*sizeof(uint32_t)); + ret = sss_packet_grow(pctx->creq->out, 2*sizeof(uint32_t)); if (ret != EOK) { goto done; } - sss_packet_get_body(cctx->creq->out, &body, &body_len); + sss_packet_get_body(pctx->creq->out, &body, &body_len); SAFEALIGN_SET_UINT32(body+c, count, &c); SAFEALIGN_SET_UINT32(body+c, 0, &c); @@ -1096,17 +1103,19 @@ ssh_cmd_send_error(struct ssh_cmd_ctx *cmd_ctx, static errno_t ssh_cmd_send_reply(struct ssh_cmd_ctx *cmd_ctx) { - struct cli_ctx *cctx = cmd_ctx->cctx; + struct cli_protocol *pctx; errno_t ret; + pctx = talloc_get_type(cmd_ctx->cctx->protocol_ctx, struct cli_protocol); + /* create response packet */ ret = ssh_cmd_build_reply(cmd_ctx); if (ret != EOK) { return ret; } - sss_packet_set_error(cctx->creq->out, EOK); - sss_cmd_done(cctx, cmd_ctx); + sss_packet_set_error(pctx->creq->out, EOK); + sss_cmd_done(cmd_ctx->cctx, cmd_ctx); return EOK; } |