Skip to content
Snippets Groups Projects
Commit 4c214c29 authored by Morris Jette's avatar Morris Jette
Browse files

Add mechanism for testing invalid Munge credential

parent 2c1adc99
No related branches found
No related tags found
No related merge requests found
...@@ -107,8 +107,8 @@ const uint32_t plugin_version = 10; ...@@ -107,8 +107,8 @@ const uint32_t plugin_version = 10;
const uint32_t min_plug_version = 10; /* minimum version accepted */ const uint32_t min_plug_version = 10; /* minimum version accepted */
static int plugin_errno = SLURM_SUCCESS; static int plugin_errno = SLURM_SUCCESS;
static int host_list_idx = -1; static int host_list_idx = -1;
static int bad_cred_test = -1;
enum { enum {
...@@ -154,12 +154,17 @@ static void _print_cred_info(munge_info_t *mi); ...@@ -154,12 +154,17 @@ static void _print_cred_info(munge_info_t *mi);
static void _print_cred(munge_ctx_t ctx); static void _print_cred(munge_ctx_t ctx);
static int _decode_cred(slurm_auth_credential_t *c, char *socket); static int _decode_cred(slurm_auth_credential_t *c, char *socket);
/* /*
* Munge plugin initialization * Munge plugin initialization
*/ */
int init ( void ) int init ( void )
{ {
char *fail_test_env = getenv("SLURM_MUNGE_AUTH_FAIL_TEST");
if (fail_test_env)
bad_cred_test = atoi(fail_test_env);
else
bad_cred_test = 0;
host_list_idx = arg_idx_by_name( slurm_auth_get_arg_desc(), host_list_idx = arg_idx_by_name( slurm_auth_get_arg_desc(),
ARG_HOST_LIST ); ARG_HOST_LIST );
if (host_list_idx == -1) if (host_list_idx == -1)
...@@ -240,6 +245,9 @@ slurm_auth_create( void *argv[], char *socket ) ...@@ -240,6 +245,9 @@ slurm_auth_create( void *argv[], char *socket )
xfree( cred ); xfree( cred );
cred = NULL; cred = NULL;
plugin_errno = e + MUNGE_ERRNO_OFFSET; plugin_errno = e + MUNGE_ERRNO_OFFSET;
} else if ((bad_cred_test > 0) && cred->m_str) {
int i = ((int) time(NULL)) % strlen(cred->m_str);
cred->m_str[i]++; /* random position in credential */
} }
xsignal(SIGALRM, ohandler); xsignal(SIGALRM, ohandler);
...@@ -542,7 +550,6 @@ _decode_cred(slurm_auth_credential_t *c, char *socket) ...@@ -542,7 +550,6 @@ _decode_cred(slurm_auth_credential_t *c, char *socket)
_print_cred(ctx); _print_cred(ctx);
if (e == EMUNGE_CRED_REWOUND) if (e == EMUNGE_CRED_REWOUND)
error("Check for out of sync clocks"); error("Check for out of sync clocks");
c->cr_errno = e + MUNGE_ERRNO_OFFSET; c->cr_errno = e + MUNGE_ERRNO_OFFSET;
#ifdef MULTIPLE_SLURMD #ifdef MULTIPLE_SLURMD
} else { } else {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment