From c4471239d0e2452b347163bb8757a22daf3a0d64 Mon Sep 17 00:00:00 2001
From: jwindley <jwindley@unknown>
Date: Wed, 12 Mar 2003 20:30:09 +0000
Subject: [PATCH] Add plugin version to pack/unpack

---
 src/plugins/auth/auth_authd.c | 5 ++++-
 src/plugins/auth/auth_munge.c | 7 ++++++-
 src/plugins/auth/auth_none.c  | 3 +++
 3 files changed, 13 insertions(+), 2 deletions(-)

diff --git a/src/plugins/auth/auth_authd.c b/src/plugins/auth/auth_authd.c
index 0193f1a8d12..def27f6a64a 100644
--- a/src/plugins/auth/auth_authd.c
+++ b/src/plugins/auth/auth_authd.c
@@ -288,11 +288,12 @@ slurm_auth_pack( slurm_auth_credential_t *cred, Buf buf )
 	if ( ( cred == NULL ) || ( buf == NULL ) ) return;
 
 	/*
-	 * Marshall the plugin type for runtime sanity check.
+	 * Marshall the plugin type and version for runtime sanity check.
 	 * Add the terminating zero so we get it for free at the
 	 * other end.
 	 */
 	packmem( (char *) plugin_type, strlen( plugin_type ) + 1, buf );
+	pack32( plugin_version, buf );
 	
 	pack32( cred->cred.uid, buf );
 	pack32( cred->cred.gid, buf );
@@ -306,6 +307,7 @@ int
 slurm_auth_unpack( slurm_auth_credential_t *cred, Buf buf )
 {
 	uint16_t sig_size; /* ignored */
+	uint32_t version;	
 	char *data;
 
 	if ( ( cred == NULL) || ( buf == NULL ) )
@@ -317,6 +319,7 @@ slurm_auth_unpack( slurm_auth_credential_t *cred, Buf buf )
 		error( "authd plugin: authentication mismatch, got %s", data );
 		return SLURM_ERROR;
 	}
+	unpack32( &version, buf );
 	
 	unpack32( &cred->cred.uid, buf );
 	unpack32( &cred->cred.gid, buf );
diff --git a/src/plugins/auth/auth_munge.c b/src/plugins/auth/auth_munge.c
index ab9e88a80a0..bc7ba70d935 100644
--- a/src/plugins/auth/auth_munge.c
+++ b/src/plugins/auth/auth_munge.c
@@ -264,6 +264,7 @@ slurm_auth_pack( slurm_auth_credential_t *cred, Buf buf )
 	 * type so that it can be sanity-checked at the receiving end.
 	 */
 	packstr( (char *) plugin_type, buf );
+	pack32( plugin_version, buf );
 	/*
 	 * Pack the data.
 	 */
@@ -278,8 +279,9 @@ int
 slurm_auth_unpack( slurm_auth_credential_t *cred, Buf buf )
 {
 	char    *type;
-	char    *m;
+	char    *m;	
 	uint16_t size;
+	uint32_t version;
 	
 	if ((cred == NULL) || (buf == NULL)) {
 		error("malformed slurm_auth_unpack call in auth/munge plugin");
@@ -298,6 +300,9 @@ slurm_auth_unpack( slurm_auth_credential_t *cred, Buf buf )
 		error( "plugin expected 'auth/munge' and got '%s'", type );
 		return SLURM_ERROR;
 	}
+	if ( unpack32( &version, buf ) != SLURM_SUCCESS ) {
+		return SLURM_ERROR;
+	}	
 
 	if (unpackmem_ptr(&m, &size, buf) < 0) {
 		error("error retrieving munge cred in auth/munge plugin");
diff --git a/src/plugins/auth/auth_none.c b/src/plugins/auth/auth_none.c
index a57c50a2e9e..c51c6be1637 100644
--- a/src/plugins/auth/auth_none.c
+++ b/src/plugins/auth/auth_none.c
@@ -237,6 +237,7 @@ slurm_auth_pack( slurm_auth_credential_t *cred, Buf buf )
 	 * type so that it can be sanity-checked at the receiving end.
 	 */
 	packmem( (char *) plugin_type, strlen( plugin_type ) + 1, buf );
+	pack32( plugin_version, buf );
 	/*
 	 * Pack the data values.
 	 */
@@ -253,6 +254,7 @@ slurm_auth_unpack( slurm_auth_credential_t *cred, Buf buf )
 {
 	char *tmpstr;
 	int32_t tmpint;
+	uint32_t version;
 	uint16_t size;
 	
 	if ( ( cred == NULL ) || ( buf == NULL ) ) {
@@ -272,6 +274,7 @@ slurm_auth_unpack( slurm_auth_credential_t *cred, Buf buf )
 		error( "plugin expected 'auth/none' and got '%s'", tmpstr );
 		return SLURM_ERROR;
 	}
+	if ( unpack32( &version, buf ) != SLURM_SUCCESS ) return SLURM_ERROR;
 
 	/*
 	 * We do it the hard way because we don't know anything about the
-- 
GitLab