summaryrefslogtreecommitdiffstats
path: root/sss_client
diff options
context:
space:
mode:
authorSumit Bose <sbose@redhat.com>2009-05-08 09:53:35 +0200
committerSimo Sorce <ssorce@redhat.com>2009-05-15 19:09:45 -0400
commitab691765dc8d727d01f061d846e7c765e89fb299 (patch)
tree086f4077b66eb3834eb6254db82eaa59fbd96dd0 /sss_client
parentca2fa90f8e7a9399c7c44781f1a032fe10f98cdc (diff)
downloadsssd-ab691765dc8d727d01f061d846e7c765e89fb299.tar.gz
sssd-ab691765dc8d727d01f061d846e7c765e89fb299.tar.xz
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.c22
-rw-r--r--sss_client/sss_cli.h3
2 files changed, 20 insertions, 5 deletions
diff --git a/sss_client/common.c b/sss_client/common.c
index d0fb01183..91b65cdca 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 17749af88..ba412fd07 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 */