diff options
author | Sumit Bose <sbose@redhat.com> | 2009-05-08 09:53:35 +0200 |
---|---|---|
committer | Simo Sorce <ssorce@redhat.com> | 2009-05-15 19:09:45 -0400 |
commit | ab691765dc8d727d01f061d846e7c765e89fb299 (patch) | |
tree | 086f4077b66eb3834eb6254db82eaa59fbd96dd0 /server/responder/common | |
parent | ca2fa90f8e7a9399c7c44781f1a032fe10f98cdc (diff) | |
download | sssd-ab691765dc8d727d01f061d846e7c765e89fb299.tar.gz sssd-ab691765dc8d727d01f061d846e7c765e89fb299.tar.bz2 sssd-ab691765dc8d727d01f061d846e7c765e89fb299.zip |
added more flexible handling of client protocol
- allow different protocol versions for PAM and NSS
- support more than one protocol version in the responder
Diffstat (limited to 'server/responder/common')
-rw-r--r-- | server/responder/common/responder.h | 8 | ||||
-rw-r--r-- | server/responder/common/responder_cmd.c | 34 |
2 files changed, 41 insertions, 1 deletions
diff --git a/server/responder/common/responder.h b/server/responder/common/responder.h index f5d5246f..946418c8 100644 --- a/server/responder/common/responder.h +++ b/server/responder/common/responder.h @@ -43,6 +43,12 @@ struct cli_request { struct sss_packet *out; }; +struct cli_protocol_version { + uint32_t version; + char *date; + char *description; +}; + struct sss_names_ctx { char *re_pattern; char *fq_fmt; @@ -83,6 +89,7 @@ struct cli_ctx { struct tevent_fd *cfde; struct sockaddr_un addr; struct cli_request *creq; + struct cli_protocol_version *cli_protocol_version; int priv; }; @@ -111,6 +118,7 @@ int sss_parse_name(TALLOC_CTX *memctx, 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); +struct cli_protocol_version *register_cli_protocol_version(void); /* responder_dp.c */ int sss_dp_init(struct resp_ctx *rctx, struct sbus_method dp_methods[]); diff --git a/server/responder/common/responder_cmd.c b/server/responder/common/responder_cmd.c index 33caa032..cab8b694 100644 --- a/server/responder/common/responder_cmd.c +++ b/server/responder/common/responder_cmd.c @@ -36,9 +36,39 @@ void sss_cmd_done(struct cli_ctx *cctx, void *freectx) int sss_cmd_get_version(struct cli_ctx *cctx) { + uint8_t *req_body; + size_t req_blen; uint8_t *body; size_t blen; int ret; + uint32_t client_version; + int i; + static struct cli_protocol_version *cli_protocol_version = NULL; + + cctx->cli_protocol_version = NULL; + + if (cli_protocol_version == NULL) { + cli_protocol_version = register_cli_protocol_version(); + } + + if (cli_protocol_version != NULL) { + cctx->cli_protocol_version = &cli_protocol_version[0]; + + sss_packet_get_body(cctx->creq->in, &req_body, &req_blen); + if (req_blen == sizeof(uint32_t)) { + client_version = (uint32_t ) *req_body; + DEBUG(4, ("Received client version [%d].\n", client_version)); + + i=0; + while(cli_protocol_version[i].version>0) { + if (cli_protocol_version[i].version == client_version) { + cctx->cli_protocol_version = &cli_protocol_version[i]; + break; + } + i++; + } + } + } /* create response packet */ ret = sss_packet_new(cctx->creq, sizeof(uint32_t), @@ -48,7 +78,9 @@ int sss_cmd_get_version(struct cli_ctx *cctx) return ret; } sss_packet_get_body(cctx->creq->out, &body, &blen); - ((uint32_t *)body)[0] = SSS_PROTOCOL_VERSION; + ((uint32_t *)body)[0] = cctx->cli_protocol_version!=NULL ? + cctx->cli_protocol_version->version : 0; + DEBUG(4, ("Offered version [%d].\n", ((uint32_t *)body)[0])); sss_cmd_done(cctx, NULL); return EOK; |