From e516fb9546daadd0d2ee59d8f7682a93f4ac9526 Mon Sep 17 00:00:00 2001 From: Moe Jette <jette1@llnl.gov> Date: Tue, 18 May 2004 21:58:31 +0000 Subject: [PATCH] Updates to make security tests usable with version 0.3. --- NEWS | 1 + src/common/slurm_auth.c | 7 +++++++ src/common/slurm_protocol_api.c | 14 ++++++++++++++ src/common/slurm_protocol_api.h | 9 ++++++++- testsuite/slurm_unit/slurmctld/security_2_2.c | 18 ++++++++++++------ testsuite/slurm_unit/slurmctld/security_2_4.c | 1 + 6 files changed, 43 insertions(+), 7 deletions(-) diff --git a/NEWS b/NEWS index 6dba86d4bca..2d3750d6ae2 100644 --- a/NEWS +++ b/NEWS @@ -10,6 +10,7 @@ documents those changes that are of interest to users and admins. RH EL3 under extremely heavy workload apparently due to memory fragmentation -- Fix scheduling logic for heterogeneous processor count. + -- Modify security_2_2 test to function with release 0.3 * Changes in SLURM 0.3.0 ======================== diff --git a/src/common/slurm_auth.c b/src/common/slurm_auth.c index 2c5ebbe61a9..ee14d5a55f4 100644 --- a/src/common/slurm_auth.c +++ b/src/common/slurm_auth.c @@ -285,6 +285,13 @@ slurm_auth_init( void ) goto done; auth_type = slurm_get_auth_type(); + if (strcmp(auth_type, "auth/dummy") == 0) { + info( "warning: %s plugin selected", auth_type); + retval = SLURM_ERROR; + xfree(auth_type); + goto done; + } + g_context = slurm_auth_context_create( auth_type ); if ( g_context == NULL ) { error( "cannot create a context for %s", auth_type ); diff --git a/src/common/slurm_protocol_api.c b/src/common/slurm_protocol_api.c index 9aebbf2ba3f..c6353b6ca2a 100644 --- a/src/common/slurm_protocol_api.c +++ b/src/common/slurm_protocol_api.c @@ -212,6 +212,20 @@ char *slurm_get_auth_type(void) return auth_type; } +/* slurm_set_auth_type + * set the authentication type in slurmctld_conf object + * used for security testing purposes + * RET 0 or error code + */ +extern int slurm_set_auth_type(char *auth_type) +{ + _lock_update_config(); + xfree(slurmctld_conf.authtype); + slurmctld_conf.authtype = xstrdup(auth_type); + slurm_mutex_unlock(&config_lock); + return 0; +} + /* slurm_get_jobcomp_type * returns the job completion logger type from slurmctld_conf object * RET char * - job completion type, MUST be xfreed by caller diff --git a/src/common/slurm_protocol_api.h b/src/common/slurm_protocol_api.h index 84139c27002..9be86e7ede4 100644 --- a/src/common/slurm_protocol_api.h +++ b/src/common/slurm_protocol_api.h @@ -110,7 +110,14 @@ char *slurm_get_plugin_dir(void); * returns the authentication type from slurmctld_conf object * RET char * - auth type, MUST be xfreed by caller */ -char *slurm_get_auth_type(void); +extern char *slurm_get_auth_type(void); + +/* slurm_set_auth_type + * set the authentication type in slurmctld_conf object + * used for security testing purposes + * RET 0 or error code + */ +extern int slurm_set_auth_type(char *auth_type); /* slurm_get_jobcomp_type * returns the job completion logger type from slurmctld_conf object diff --git a/testsuite/slurm_unit/slurmctld/security_2_2.c b/testsuite/slurm_unit/slurmctld/security_2_2.c index d5b9ce625c1..726a3ed09e6 100644 --- a/testsuite/slurm_unit/slurmctld/security_2_2.c +++ b/testsuite/slurm_unit/slurmctld/security_2_2.c @@ -7,6 +7,11 @@ #include <slurm/slurm.h> #include <slurm/slurm_errno.h> +/* This functions are not defined in slurm/slurm.h for external use. + * They are used internal security testing only. */ +extern char *slurm_get_auth_type(void); +extern int slurm_set_auth_type(char *auth_type); + typedef void * Buf; /* Attempt to run a job without a credential */ @@ -21,6 +26,11 @@ main (int argc, char *argv[]) job_mesg. user_id = getuid(); job_mesg. min_nodes = 1; + printf("Changing command's authtype from %s to ", + slurm_get_auth_type()); + slurm_set_auth_type("auth/dummy"); + printf("%s\n",slurm_get_auth_type()); + error_code = slurm_allocate_resources_and_run ( &job_mesg , &run_resp_msg ); if (error_code == SLURM_SUCCESS) { @@ -30,12 +40,8 @@ main (int argc, char *argv[]) printf ("SUCCESS!\n"); printf ("The allocate request was rejected as expected.\n"); printf ("Check SlurmctldLog for an error message.\n"); + printf ("Error returned from API: %s\n", + slurm_strerror(slurm_get_errno())); exit(0); } } - -/* This version supersedes that in libslurm, so a credential is not packed */ -int g_slurm_auth_pack(void * auth_cred, Buf buffer) -{ - return 0; -} diff --git a/testsuite/slurm_unit/slurmctld/security_2_4.c b/testsuite/slurm_unit/slurmctld/security_2_4.c index 8b92383e5be..92d889fbbb6 100644 --- a/testsuite/slurm_unit/slurmctld/security_2_4.c +++ b/testsuite/slurm_unit/slurmctld/security_2_4.c @@ -18,6 +18,7 @@ main (int argc, char *argv[]) slurm_init_job_desc_msg( &job_mesg ); job_mesg. user_id = getuid() + 1; job_mesg. min_nodes = 1; + job_mesg. task_dist = SLURM_DIST_CYCLIC; error_code = slurm_allocate_resources_and_run ( &job_mesg , &run_resp_msg ); -- GitLab