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 /sss_client | |
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 'sss_client')
-rw-r--r-- | sss_client/common.c | 22 | ||||
-rw-r--r-- | sss_client/sss_cli.h | 3 |
2 files changed, 20 insertions, 5 deletions
diff --git a/sss_client/common.c b/sss_client/common.c index d0fb0118..91b65cdc 100644 --- a/sss_client/common.c +++ b/sss_client/common.c @@ -295,15 +295,29 @@ static enum nss_status sss_nss_make_request_nochecks( * 0-3: 32bit unsigned version number */ -static int sss_nss_check_version(void) +static int sss_nss_check_version(const char *socket_name) { uint8_t *repbuf; size_t replen; enum nss_status nret; int errnop; int res = NSS_STATUS_UNAVAIL; + uint32_t expected_version; + struct sss_cli_req_data req; + + if (strcmp(socket_name, SSS_NSS_SOCKET_NAME) == 0) { + expected_version = SSS_NSS_PROTOCOL_VERSION; + } else if (strcmp(socket_name, SSS_PAM_SOCKET_NAME) == 0 || + strcmp(socket_name, SSS_PAM_PRIV_SOCKET_NAME) == 0) { + expected_version = SSS_PAM_PROTOCOL_VERSION; + } else { + return NSS_STATUS_UNAVAIL; + } + + req.len = sizeof(expected_version); + req.data = &expected_version; - nret = sss_nss_make_request_nochecks(SSS_GET_VERSION, NULL, + nret = sss_nss_make_request_nochecks(SSS_GET_VERSION, &req, &repbuf, &replen, &errnop); if (nret != NSS_STATUS_SUCCESS) { return nret; @@ -313,7 +327,7 @@ static int sss_nss_check_version(void) return res; } - if (((uint32_t *)repbuf)[0] == SSS_PROTOCOL_VERSION) { + if (((uint32_t *)repbuf)[0] == expected_version) { res = NSS_STATUS_SUCCESS; } @@ -555,7 +569,7 @@ static enum sss_status sss_cli_check_socket(int *errnop, const char *socket_name sss_cli_sd = mysd; - if (sss_nss_check_version()) { + if (sss_nss_check_version(socket_name) == NSS_STATUS_SUCCESS) { return SSS_STATUS_SUCCESS; } diff --git a/sss_client/sss_cli.h b/sss_client/sss_cli.h index 17749af8..ba412fd0 100644 --- a/sss_client/sss_cli.h +++ b/sss_client/sss_cli.h @@ -21,7 +21,8 @@ #define SSS_PAM_SOCKET_NAME "/var/lib/sss/pipes/pam" #define SSS_PAM_PRIV_SOCKET_NAME "/var/lib/sss/pipes/private/pam" -#define SSS_PROTOCOL_VERSION 1 +#define SSS_NSS_PROTOCOL_VERSION 1 +#define SSS_PAM_PROTOCOL_VERSION 1 enum sss_cli_command { /* null */ |