summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJakub Hrozek <jhrozek@redhat.com>2013-02-12 13:58:46 +0100
committerJakub Hrozek <jhrozek@redhat.com>2013-03-08 22:19:26 +0100
commit1a5d83798af7bd88c9d20862c8830ebb5b755e2d (patch)
tree531716a7d11752a0cf6633d6f6de9daf62e8294b
parentda33a9d7742d45975bd97d33dd8ad04a843e7656 (diff)
downloadsssd-1a5d83798af7bd88c9d20862c8830ebb5b755e2d.tar.gz
sssd-1a5d83798af7bd88c9d20862c8830ebb5b755e2d.tar.bz2
sssd-1a5d83798af7bd88c9d20862c8830ebb5b755e2d.zip
Move sss_cmd_execute from client to responder code.
I think it logically belongs there and allows to better exercise the responder commands from unit tests.
-rw-r--r--src/responder/common/responder.h4
-rw-r--r--src/responder/common/responder_cmd.c8
-rw-r--r--src/responder/common/responder_common.c10
3 files changed, 15 insertions, 7 deletions
diff --git a/src/responder/common/responder.h b/src/responder/common/responder.h
index a265d61d..110bd38d 100644
--- a/src/responder/common/responder.h
+++ b/src/responder/common/responder.h
@@ -176,9 +176,11 @@ responder_get_domain(TALLOC_CTX *sd_mem_ctx, struct resp_ctx *rctx,
int sss_cmd_empty_packet(struct sss_packet *packet);
int sss_cmd_send_empty(struct cli_ctx *cctx, TALLOC_CTX *freectx);
int sss_cmd_send_error(struct cli_ctx *cctx, int err);
-int sss_cmd_execute(struct cli_ctx *cctx, struct sss_cmd_table *sss_cmds);
void sss_cmd_done(struct cli_ctx *cctx, void *freectx);
int sss_cmd_get_version(struct cli_ctx *cctx);
+int sss_cmd_execute(struct cli_ctx *cctx,
+ enum sss_cli_command cmd,
+ struct sss_cmd_table *sss_cmds);
struct cli_protocol_version *register_cli_protocol_version(void);
struct setent_req_list;
diff --git a/src/responder/common/responder_cmd.c b/src/responder/common/responder_cmd.c
index cb57cba1..3a3fca9b 100644
--- a/src/responder/common/responder_cmd.c
+++ b/src/responder/common/responder_cmd.c
@@ -141,13 +141,12 @@ int sss_cmd_get_version(struct cli_ctx *cctx)
return EOK;
}
-int sss_cmd_execute(struct cli_ctx *cctx, struct sss_cmd_table *sss_cmds)
+int sss_cmd_execute(struct cli_ctx *cctx,
+ enum sss_cli_command cmd,
+ struct sss_cmd_table *sss_cmds)
{
- enum sss_cli_command cmd;
int i;
- cmd = sss_packet_get_cmd(cctx->creq->in);
-
for (i = 0; sss_cmds[i].cmd != SSS_CLI_NULL; i++) {
if (cmd == sss_cmds[i].cmd) {
return sss_cmds[i].fn(cctx);
@@ -156,7 +155,6 @@ int sss_cmd_execute(struct cli_ctx *cctx, struct sss_cmd_table *sss_cmds)
return EINVAL;
}
-
struct setent_req_list {
struct setent_req_list *prev;
struct setent_req_list *next;
diff --git a/src/responder/common/responder_common.c b/src/responder/common/responder_common.c
index 824c649a..a4355ae6 100644
--- a/src/responder/common/responder_common.c
+++ b/src/responder/common/responder_common.c
@@ -262,6 +262,14 @@ static void client_send(struct cli_ctx *cctx)
return;
}
+static int client_cmd_execute(struct cli_ctx *cctx, struct sss_cmd_table *sss_cmds)
+{
+ enum sss_cli_command cmd;
+
+ cmd = sss_packet_get_cmd(cctx->creq->in);
+ return sss_cmd_execute(cctx, cmd, sss_cmds);
+}
+
static void client_recv(struct cli_ctx *cctx)
{
int ret;
@@ -291,7 +299,7 @@ static void client_recv(struct cli_ctx *cctx)
/* do not read anymore */
TEVENT_FD_NOT_READABLE(cctx->cfde);
/* execute command */
- ret = sss_cmd_execute(cctx, cctx->rctx->sss_cmds);
+ ret = client_cmd_execute(cctx, cctx->rctx->sss_cmds);
if (ret != EOK) {
DEBUG(0, ("Failed to execute request, aborting client!\n"));
talloc_free(cctx);