diff --git a/src/common/slurm_auth.h b/src/common/slurm_auth.h index f4f5c0621b15d5a435af5a078570dc558615701f..eb7a8da7aab2ae32bd596060822667d32050b6b3 100644 --- a/src/common/slurm_auth.h +++ b/src/common/slurm_auth.h @@ -1,5 +1,5 @@ /*****************************************************************************\ - * slurm_authentication.h - implementation-independent authentication API. + * slurm_auth.h - implementation-independent authentication API. ***************************************************************************** * Copyright (C) 2002 The Regents of the University of California. * Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER). @@ -43,9 +43,9 @@ * Here are included the implementation details of the * authentication scheme. Among other things, that file must define * slurm_auth_credentials_t. That file is identified at compile - * time. + * time. (XXX: This can't work as described. Fix in the near future) */ -#include <src/common/slurm_auth_impl.h> +#include <src/common/slurm_auth_authd.h> /* diff --git a/src/common/slurm_auth_authd.c b/src/common/slurm_auth_authd.c index ece502c7024e223094d8ec65b87b2104d2b09e12..0697b05ec26a0bdab569354f92b25f1b88b00041 100644 --- a/src/common/slurm_auth_authd.c +++ b/src/common/slurm_auth_authd.c @@ -1,5 +1,5 @@ /*****************************************************************************\ - * slurm_auth_imple.h - authentication implementation for Brent Chun's authd + * slurm_auth_authd.h - authentication implementation for Brent Chun's authd ***************************************************************************** * Copyright (C) 2002 The Regents of the University of California. * Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER). @@ -25,7 +25,11 @@ \*****************************************************************************/ #if HAVE_CONFIG_H -#include <config.h> +# include <config.h> +#endif + +#if HAVE_AUTHD +# include <auth.h> #endif #include <stdio.h> @@ -33,9 +37,12 @@ #include <string.h> #include <pwd.h> #include <grp.h> -#include <openssl/rsa.h> -#include <openssl/pem.h> -#include <openssl/err.h> + +#if HAVE_SSL +# include <openssl/rsa.h> +# include <openssl/pem.h> +# include <openssl/err.h> +#endif /* * Because authd's authentication scheme relies on determining the @@ -47,19 +54,15 @@ #include <sys/socket.h> #include <sys/un.h> -#include <src/common/slurm_authentication.h> +#include <src/common/slurm_auth.h> #include <src/common/slurm_errno.h> #include <src/common/xmalloc.h> #include <src/common/pack.h> +#include <src/common/log.h> #define UNIX_PATH_MAX 108 /* Cribbed from /usr/include/linux/un.h */ static int slurm_sign_auth_credentials( slurm_auth_credentials_t *cred ); -#ifdef HAVE_AUTHD -static int open_authd_connection( void ); -static int read_bytes( int fd, void *buf, size_t len ); -static int write_bytes( int fd, void *buf, size_t len ); -#endif slurm_auth_credentials_t * slurm_auth_alloc_credentials( void ) @@ -85,7 +88,6 @@ slurm_auth_activate_credentials( slurm_auth_credentials_t *cred, * built on top of its author's convenience library, which we * don't want to require for SLURM users. */ - /* Initialize credentials with our user and group IDs. */ cred->creds.uid = getuid(); cred->creds.gid = getgid(); @@ -103,41 +105,7 @@ int slurm_auth_verify_credentials( slurm_auth_credentials_t *cred ) { #ifdef HAVE_AUTHD - FILE *f; - RSA *pub; - int rc; - time_t now; - - /* Open public key file. XXX - want to configify this. */ - if ( ( f = fopen( AUTH_PUB_KEY, "r" ) ) == NULL ) { - return SLURM_PROTOCOL_AUTHENTICATION_ERROR; - } - - /* Read key. */ - pub = PEM_read_RSA_PUBKEY( f, NULL, NULL, NULL ); - fclose( f ); - if ( pub == NULL ) return SLURM_PROTOCOL_AUTHENTICATION_ERROR; - - /* Verify signature. */ - ERR_load_crypto_strings(); - rc = RSA_verify( 0, - (unsigned char *) &cred->creds, - sizeof( credentials ), - cred->sig.data, - AUTH_RSA_SIGLEN, - pub ); - RSA_free( pub ); - - /* RSA verification failed. */ - if ( rc == 0 ) return SLURM_PROTOCOL_AUTHENTICATION_ERROR; - - /* See if credential has expired. */ - now = time( NULL ); - if ( ( now >= cred->creds.valid_from ) - && ( now <= cred->creds.valid_to ) ) - return SLURM_SUCCESS; - else - return SLURM_PROTOCOL_AUTHENTICATION_ERROR; + return auth_verify_signature(&cred->creds, &cred->sig); #else return SLURM_SUCCESS; #endif @@ -176,7 +144,7 @@ void slurm_auth_unpack_credentials( slurm_auth_credentials_t **cred_ptr, uint16_t dummy; char *data; slurm_auth_credentials_t *cred = xmalloc ( sizeof ( slurm_auth_credentials_t ) ) ; - + unpack32( &cred->creds.uid, buffer, length ); unpack32( &cred->creds.gid, buffer, length ); unpack32( (uint32_t *) &cred->creds.valid_from, buffer, length ); @@ -184,6 +152,7 @@ void slurm_auth_unpack_credentials( slurm_auth_credentials_t **cred_ptr, unpackmem_ptr( &data, &dummy, buffer, length ); memcpy( cred->sig.data, data, sizeof( signature ) ); *cred_ptr = cred ; + } @@ -191,30 +160,7 @@ static int slurm_sign_auth_credentials( slurm_auth_credentials_t *cred ) { #ifdef HAVE_AUTHD - int fd; - - /* Open connection to authd. */ - fd = open_authd_connection(); - if ( fd < 0 ) return SLURM_PROTOCOL_AUTHENTICATION_ERROR; - - /* Write credentials to socket. */ - if ( write_bytes( fd, - &cred->creds, - sizeof( credentials ) ) != SLURM_SUCCESS ) { - close( fd ); - return SLURM_PROTOCOL_AUTHENTICATION_ERROR; - } - - /* Read response. */ - if ( read_bytes( fd, - &cred->sig, - sizeof( signature ) ) != SLURM_SUCCESS ) { - close( fd ); - return SLURM_PROTOCOL_AUTHENTICATION_ERROR; - } - - close( fd ); - return SLURM_SUCCESS; + return auth_get_signature(&cred->creds, &cred->sig); #else return SLURM_SUCCESS; #endif @@ -253,77 +199,3 @@ slurm_auth_print_credentials( slurm_auth_credentials_t *cred ) printf( "\n-- END CLIENT CREDENTIALS\n" ); } #endif /*DEBUG*/ - -#ifdef HAVE_AUTHD -static int -open_authd_connection( void ) -{ - int sock; - char auth_sock_path[ UNIX_PATH_MAX ]; - struct sockaddr_un cl_addr; - struct sockaddr_un sv_addr; - - sprintf( auth_sock_path, AUTH_SOCK_PATH, getpid() ); - - sock = socket( AF_UNIX, SOCK_STREAM, 0 ); - if ( sock < 0 ) return SLURM_ERROR; - - cl_addr.sun_family = AF_UNIX; - memset( cl_addr.sun_path, 0, UNIX_PATH_MAX ); - strncpy( &cl_addr.sun_path[ 1 ], auth_sock_path, UNIX_PATH_MAX - 1 ); - if ( bind( sock, - (struct sockaddr *) &cl_addr, - sizeof( struct sockaddr_un ) ) < 0 ) { - close( sock ); - return SLURM_ERROR; - } - - sv_addr.sun_family = AF_UNIX; - memset( sv_addr.sun_path, 0, UNIX_PATH_MAX ); - strncpy( &sv_addr.sun_path[ 1 ], AUTHD_SOCK_PATH, UNIX_PATH_MAX - 1 ); - if ( connect( sock, - (struct sockaddr *) &sv_addr, - sizeof( struct sockaddr_un ) ) < 0 ) { - close( sock ); - return SLURM_ERROR; - } - - return sock; -} - -static int read_bytes( int fd, void *buf, size_t n_bytes ) -{ - size_t bytes_accumulated = 0; - ssize_t bytes_read; - - while ( bytes_accumulated < n_bytes ) { - bytes_read = read( fd, - (void *) ((unsigned long) buf + - (unsigned long) bytes_accumulated ), - n_bytes - bytes_accumulated ); - if ( bytes_read == 0 ) return 0; - if ( bytes_read < 0 ) return -1; - bytes_accumulated += bytes_read; - } - - return 0; -} - -static int write_bytes( int fd, void *buf, size_t n_bytes ) -{ - size_t bytes_disposed = 0; - ssize_t bytes_written; - - while ( bytes_disposed < n_bytes ) { - bytes_written = write( fd, - (void *) ((unsigned long) buf + - (unsigned long) bytes_disposed ), - n_bytes - bytes_disposed ); - if ( bytes_written < 0 ) return -1; - bytes_disposed += bytes_written; - } - - return 0; -} - -#endif diff --git a/src/common/slurm_auth_authd.h b/src/common/slurm_auth_authd.h index f82c40c625658b8036435a899e876d070ea76f4a..cc2b41f24baec9641d353a9d50dfb54acd6df23b 100644 --- a/src/common/slurm_auth_authd.h +++ b/src/common/slurm_auth_authd.h @@ -1,5 +1,5 @@ /*****************************************************************************\ - * slurm_auth_imple.h - authentication implementation for Brent Chun's authd + * slurm_auth_authd.h - authentication implementation for Brent Chun's authd ***************************************************************************** * Copyright (C) 2002 The Regents of the University of California. * Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER). @@ -27,7 +27,7 @@ #ifndef __SLURM_AUTH_IMPL_H__ #define __SLURM_AUTH_IMPL_H__ -#include <src/common/auth.h> +#include <auth.h> /* Each implementation must define this structure. */ typedef struct slurm_auth_credentials { diff --git a/src/common/slurm_protocol_api.c b/src/common/slurm_protocol_api.c index 5ad4c1156d57058cf103c5b3c5b0f6d4df3a0eb9..5d933be1e8eecfe865bdf0b8c158fd5003d48f7b 100644 --- a/src/common/slurm_protocol_api.c +++ b/src/common/slurm_protocol_api.c @@ -1,3 +1,7 @@ +#if HAVE_CONFIG_H +# include <config.h> +#endif + /* GLOBAL INCLUDES */ #include <stdlib.h> #include <string.h> @@ -11,7 +15,7 @@ #include <src/common/slurm_protocol_common.h> #include <src/common/slurm_protocol_pack.h> #include <src/common/slurm_protocol_util.h> -#include <src/common/slurm_authentication.h> +#include <src/common/slurm_auth.h> #include <src/common/xmalloc.h> #include <src/common/log.h> @@ -19,43 +23,43 @@ /* #DEFINES */ #define BUF_SIZE 1024 -#define CREDENTIAL_TTL_SEC 5 +#define CREDENTIAL_TTL_SEC 5 /* STATIC VARIABLES */ -static slurm_protocol_config_t proto_conf_default ; -static slurm_protocol_config_t * proto_conf = & proto_conf_default ; +static slurm_protocol_config_t proto_conf_default; +static slurm_protocol_config_t *proto_conf = &proto_conf_default; static slurm_ctl_conf_t slurmctld_conf; /************************/ /***** API init functions */ /************************/ -int slurm_set_api_config ( slurm_protocol_config_t * protocol_conf ) +int slurm_set_api_config(slurm_protocol_config_t * protocol_conf) { - proto_conf = protocol_conf ; - return SLURM_SUCCESS ; + proto_conf = protocol_conf; + return SLURM_SUCCESS; } -slurm_protocol_config_t * slurm_get_api_config ( ) +slurm_protocol_config_t *slurm_get_api_config() { - return proto_conf ; + return proto_conf; } -int slurm_api_set_default_config ( ) +int slurm_api_set_default_config() { - if ( (slurmctld_conf . control_machine == NULL) || - (slurmctld_conf . backup_controller == NULL) || - (slurmctld_conf . slurmctld_port == 0) ) - read_slurm_port_config ( ); + if ((slurmctld_conf.control_machine == NULL) || + (slurmctld_conf.backup_controller == NULL) || + (slurmctld_conf.slurmctld_port == 0)) + read_slurm_port_config(); - slurm_set_addr ( & proto_conf_default . primary_controller , - slurmctld_conf . slurmctld_port , - slurmctld_conf . control_machine ) ; - slurm_set_addr ( & proto_conf_default . secondary_controller , - slurmctld_conf . slurmctld_port , - slurmctld_conf . backup_controller ) ; - proto_conf = & proto_conf_default ; + slurm_set_addr(&proto_conf_default.primary_controller, + slurmctld_conf.slurmctld_port, + slurmctld_conf.control_machine); + slurm_set_addr(&proto_conf_default.secondary_controller, + slurmctld_conf.slurmctld_port, + slurmctld_conf.backup_controller); + proto_conf = &proto_conf_default; - return SLURM_SUCCESS ; + return SLURM_SUCCESS; } /* @@ -66,46 +70,49 @@ int slurm_api_set_default_config ( ) * if the lookup fails, translate SLURMCTLD_PORT/SLURMD_PORT into a number * These port numbers are over-ridden if set in the configuration file */ -int read_slurm_port_config ( ) +int read_slurm_port_config() { FILE *slurm_spec_file; /* pointer to input data file */ char in_line[BUF_SIZE]; /* input line */ - char * control_machine = NULL; - char * backup_controller = NULL; + char *control_machine = NULL; + char *backup_controller = NULL; int error_code, i, j, line_num = 0; int slurmctld_port = 0, slurmd_port = 0; struct servent *servent; - servent = getservbyname (SLURMCTLD_PORT, NULL); + servent = getservbyname(SLURMCTLD_PORT, NULL); if (servent) - slurmctld_conf.slurmctld_port = servent -> s_port; + slurmctld_conf.slurmctld_port = servent->s_port; else - slurmctld_conf.slurmctld_port = strtol (SLURMCTLD_PORT, (char **) NULL, 10); - endservent (); + slurmctld_conf.slurmctld_port = + strtol(SLURMCTLD_PORT, (char **) NULL, 10); + endservent(); - servent = getservbyname (SLURMD_PORT, NULL); + servent = getservbyname(SLURMD_PORT, NULL); if (servent) - slurmctld_conf.slurmd_port = servent -> s_port; + slurmctld_conf.slurmd_port = servent->s_port; else - slurmctld_conf.slurmd_port = strtol (SLURMD_PORT, (char **) NULL, 10); - endservent (); + slurmctld_conf.slurmd_port = + strtol(SLURMD_PORT, (char **) NULL, 10); + endservent(); - slurm_spec_file = fopen (SLURM_CONFIG_FILE, "r"); + slurm_spec_file = fopen(SLURM_CONFIG_FILE, "r"); if (slurm_spec_file == NULL) { - error ( "read_slurm_conf error %d opening file %s: %m", - errno, SLURM_CONFIG_FILE); - return SLURM_ERROR ; + error("read_slurm_conf error %d opening file %s: %m", + errno, SLURM_CONFIG_FILE); + return SLURM_ERROR; } - while (fgets (in_line, BUF_SIZE, slurm_spec_file) != NULL) { + while (fgets(in_line, BUF_SIZE, slurm_spec_file) != NULL) { line_num++; - if (strlen (in_line) >= (BUF_SIZE - 1)) { - error ("read_slurm_conf line %d, of input file %s too long\n", - line_num, SLURM_CONFIG_FILE); - fclose (slurm_spec_file); + if (strlen(in_line) >= (BUF_SIZE - 1)) { + error + ("read_slurm_conf line %d, of input file %s too long\n", + line_num, SLURM_CONFIG_FILE); + fclose(slurm_spec_file); return E2BIG; break; - } + } /* everything after a non-escaped "#" is a comment */ @@ -118,45 +125,52 @@ int read_slurm_port_config ( ) if ((i > 0) && (in_line[i - 1] == '\\')) { /* escaped "#" */ for (j = i; j < BUF_SIZE; j++) { in_line[j - 1] = in_line[j]; - } + } continue; - } + } in_line[i] = (char) NULL; break; - } + } /* parse what is left */ /* overall slurm configuration parameters */ error_code = slurm_parser(in_line, - "ControlMachine=", 's', &control_machine, - "BackupController=", 's', &backup_controller, - "SlurmctldPort=", 'd', &slurmctld_port, - "SlurmdPort=", 'd', &slurmd_port, - "END"); + "ControlMachine=", 's', + &control_machine, + "BackupController=", 's', + &backup_controller, + "SlurmctldPort=", 'd', + &slurmctld_port, "SlurmdPort=", + 'd', &slurmd_port, "END"); if (error_code) { - fclose (slurm_spec_file); + fclose(slurm_spec_file); return error_code; - } + } - if ( slurmctld_conf.control_machine == NULL ) + if (slurmctld_conf.control_machine == NULL) slurmctld_conf.control_machine = control_machine; - if ( slurmctld_conf.backup_controller == NULL ) - slurmctld_conf.backup_controller = backup_controller; + if (slurmctld_conf.backup_controller == NULL) + slurmctld_conf.backup_controller = + backup_controller; if (slurmctld_port) slurmctld_conf.slurmctld_port = slurmctld_port; if (slurmd_port) slurmctld_conf.slurmd_port = slurmd_port; - } - fclose (slurm_spec_file); + } + fclose(slurm_spec_file); return SLURM_SUCCESS; } -int slurm_set_default_controllers ( char * primary_controller_hostname , char * secondary_controller_hostname, uint16_t pri_port , uint16_t sec_port ) +int slurm_set_default_controllers(char *primary_controller_hostname, + char *secondary_controller_hostname, + uint16_t pri_port, uint16_t sec_port) { - slurm_set_addr ( & proto_conf_default . primary_controller , pri_port , primary_controller_hostname ) ; - slurm_set_addr ( & proto_conf_default . secondary_controller , sec_port , secondary_controller_hostname ) ; + slurm_set_addr(&proto_conf_default.primary_controller, pri_port, + primary_controller_hostname); + slurm_set_addr(&proto_conf_default.secondary_controller, sec_port, + secondary_controller_hostname); - return SLURM_SUCCESS ; + return SLURM_SUCCESS; } /************************/ @@ -168,11 +182,11 @@ int slurm_set_default_controllers ( char * primary_controller_hostname , char * * slurm_address - for now it is really just a sockaddr_in * slurm_fd - file descriptor of the connection created */ -slurm_fd slurm_init_msg_engine_port ( uint16_t port ) +slurm_fd slurm_init_msg_engine_port(uint16_t port) { - slurm_addr slurm_address ; - slurm_set_addr_any ( &slurm_address , port ) ; - return _slurm_init_msg_engine ( & slurm_address ) ; + slurm_addr slurm_address; + slurm_set_addr_any(&slurm_address, port); + return _slurm_init_msg_engine(&slurm_address); } /* In the socket implementation it creates a socket, binds to it, and listens for connections. @@ -180,27 +194,27 @@ slurm_fd slurm_init_msg_engine_port ( uint16_t port ) * slurm_address - for now it is really just a sockaddr_in * slurm_fd - file descriptor of the connection created */ -slurm_fd slurm_init_msg_engine ( slurm_addr * slurm_address ) +slurm_fd slurm_init_msg_engine(slurm_addr * slurm_address) { - return _slurm_init_msg_engine ( slurm_address ) ; + return _slurm_init_msg_engine(slurm_address); } /* just calls close on an established msg connection * open_fd - an open file descriptor * int - the return code */ -int slurm_shutdown_msg_engine ( slurm_fd open_fd ) +int slurm_shutdown_msg_engine(slurm_fd open_fd) { - return _slurm_close ( open_fd ) ; + return _slurm_close(open_fd); } /* just calls close on an established msg connection * open_fd - an open file descriptor * int - the return code */ -int slurm_shutdown_msg_conn ( slurm_fd open_fd ) +int slurm_shutdown_msg_conn(slurm_fd open_fd) { - return _slurm_close ( open_fd ) ; + return _slurm_close(open_fd); } /* In the bsd implementation it creates a SOCK_STREAM socket and calls connect on it @@ -209,28 +223,33 @@ int slurm_shutdown_msg_conn ( slurm_fd open_fd ) * slurm_address - for now it is really just a sockaddr_in * int - the return code */ -slurm_fd slurm_open_msg_conn ( slurm_addr * slurm_address ) +slurm_fd slurm_open_msg_conn(slurm_addr * slurm_address) { - return _slurm_open_msg_conn ( slurm_address ) ; + return _slurm_open_msg_conn(slurm_address); } /* calls connect to make a connection-less datagram connection to the the primary or secondary slurmctld message engine * slurm_address - for now it is really just a sockaddr_in * int - the return code */ -slurm_fd slurm_open_controller_conn ( ) -{ - slurm_fd connection_fd ; - slurm_api_set_default_config ( ) ; - /* try to send to primary first then secondary */ - if ( ( connection_fd = slurm_open_msg_conn ( & proto_conf -> primary_controller ) ) == SLURM_SOCKET_ERROR ) - { - debug ( "Open connection to primary controller failed: %m" ) ; - - if ( ( connection_fd = slurm_open_msg_conn ( & proto_conf -> secondary_controller ) ) == SLURM_SOCKET_ERROR ) - debug ( "Open connection to secondary controller failed: %m" ) ; +slurm_fd slurm_open_controller_conn() +{ + slurm_fd connection_fd; + slurm_api_set_default_config(); + /* try to send to primary first then secondary */ + if ((connection_fd = + slurm_open_msg_conn(&proto_conf->primary_controller)) == + SLURM_SOCKET_ERROR) { + debug("Open connection to primary controller failed: %m"); + + if ((connection_fd = + slurm_open_msg_conn(&proto_conf-> + secondary_controller)) == + SLURM_SOCKET_ERROR) + debug + ("Open connection to secondary controller failed: %m"); } - return connection_fd ; + return connection_fd; } /* In the bsd implmentation maps directly to a accept call @@ -239,9 +258,10 @@ slurm_fd slurm_open_controller_conn ( ) * slurm_address - for now it is really just a sockaddr_in * int - the return code */ -slurm_fd slurm_accept_msg_conn ( slurm_fd open_fd , slurm_addr * slurm_address ) +slurm_fd slurm_accept_msg_conn(slurm_fd open_fd, + slurm_addr * slurm_address) { - return _slurm_accept_msg_conn ( open_fd , slurm_address ) ; + return _slurm_accept_msg_conn(open_fd, slurm_address); } /* In the bsd implmentation maps directly to a close call, to close the socket that was accepted @@ -249,9 +269,9 @@ slurm_fd slurm_accept_msg_conn ( slurm_fd open_fd , slurm_addr * slurm_address ) * open_fd - file descriptor to accept connection on * int - the return code */ -int slurm_close_accepted_conn ( slurm_fd open_fd ) +int slurm_close_accepted_conn(slurm_fd open_fd) { - return _slurm_close_accepted_conn ( open_fd ) ; + return _slurm_close_accepted_conn(open_fd); } /***** recv msg functions */ @@ -261,60 +281,57 @@ int slurm_close_accepted_conn ( slurm_fd open_fd ) * msg - a slurm msg struct * int - size of msg received in bytes before being unpacked */ -int slurm_receive_msg ( slurm_fd open_fd , slurm_msg_t * msg ) -{ - char buftemp[SLURM_PROTOCOL_MAX_MESSAGE_BUFFER_SIZE] ; - char * buffer = buftemp ; - header_t header ; - int rc ; - slurm_auth_credentials_t * client_cred ; - unsigned int unpack_len ; - unsigned int receive_len = SLURM_PROTOCOL_MAX_MESSAGE_BUFFER_SIZE ; - - if ( ( rc = _slurm_msg_recvfrom ( open_fd , buffer , receive_len, SLURM_PROTOCOL_NO_SEND_RECV_FLAGS , & (msg)->address ) ) == SLURM_SOCKET_ERROR ) - { - debug ( "Error receiving msg socket: %m") ; - return rc ; +int slurm_receive_msg(slurm_fd open_fd, slurm_msg_t * msg) +{ + char buftemp[SLURM_PROTOCOL_MAX_MESSAGE_BUFFER_SIZE]; + char *buffer = buftemp; + header_t header; + int rc; + slurm_auth_credentials_t *client_cred; + unsigned int unpack_len; + unsigned int receive_len = SLURM_PROTOCOL_MAX_MESSAGE_BUFFER_SIZE; + + if ((rc = + _slurm_msg_recvfrom(open_fd, buffer, receive_len, + SLURM_PROTOCOL_NO_SEND_RECV_FLAGS, + &(msg)->address)) == SLURM_SOCKET_ERROR) { + debug("Error receiving msg socket: %m"); + return rc; } /* unpack header */ - unpack_len = rc ; - unpack_header ( &header , & buffer , & unpack_len ) ; - if ( (rc = check_header_version ( & header ) ) < 0 ) - { + unpack_len = rc; + unpack_header(&header, &buffer, &unpack_len); + if ((rc = check_header_version(&header)) < 0) { return rc; } - + /* unpack cred */ - if ( header . cred_length <= unpack_len ) - { - slurm_auth_unpack_credentials ( & client_cred , (void ** ) & buffer , & unpack_len ) ; - } - else - { - slurm_seterrno_ret ( ESLURM_PROTOCOL_INCOMPLETE_PACKET ) ; + if (header.cred_length <= unpack_len) { + slurm_auth_unpack_credentials(&client_cred, + (void **) &buffer, + &unpack_len); + } else { + slurm_seterrno_ret(ESLURM_PROTOCOL_INCOMPLETE_PACKET); } - + /* verify credentials */ - if ( (rc = slurm_auth_verify_credentials( client_cred ) ) < 0 ) { - return rc; - } - msg -> cred_type = header . cred_type ; - msg -> cred_size = header . cred_length ; - msg -> cred = client_cred ; + if ((rc = slurm_auth_verify_credentials(client_cred)) != SLURM_SUCCESS) + slurm_seterrno_ret(rc); + + msg->cred_type = header.cred_type; + msg->cred_size = header.cred_length; + msg->cred = client_cred; /* unpack msg body */ - msg -> msg_type = header . msg_type ; - if ( header . body_length <= unpack_len ) - { - unpack_msg ( msg , & buffer , & unpack_len ) ; - } - else - { - slurm_seterrno_ret ( ESLURM_PROTOCOL_INCOMPLETE_PACKET ) ; + msg->msg_type = header.msg_type; + if (header.body_length <= unpack_len) { + unpack_msg(msg, &buffer, &unpack_len); + } else { + slurm_seterrno_ret(ESLURM_PROTOCOL_INCOMPLETE_PACKET); } - return rc ; + return rc; } /***** send msg functions */ @@ -325,19 +342,21 @@ int slurm_receive_msg ( slurm_fd open_fd , slurm_msg_t * msg ) * msg - a slurm msg struct * int - size of msg sent in bytes */ -int slurm_send_controller_msg ( slurm_fd open_fd , slurm_msg_t * msg ) -{ - int rc ; - /* try to send to primary first then secondary */ - msg -> address = proto_conf -> primary_controller ; - if ( (rc = slurm_send_node_msg ( open_fd , msg ) ) == SLURM_SOCKET_ERROR ) - { - debug ( "Send message to primary controller failed: %m" ) ; - msg -> address = proto_conf -> secondary_controller ; - if ( (rc = slurm_send_node_msg ( open_fd , msg ) ) == SLURM_SOCKET_ERROR ) - debug ( "Send messge to secondary controller failed: %m" ) ; +int slurm_send_controller_msg(slurm_fd open_fd, slurm_msg_t * msg) +{ + int rc; + /* try to send to primary first then secondary */ + msg->address = proto_conf->primary_controller; + if ((rc = slurm_send_node_msg(open_fd, msg)) == SLURM_SOCKET_ERROR) { + debug("Send message to primary controller failed: %m"); + msg->address = proto_conf->secondary_controller; + if ((rc = + slurm_send_node_msg(open_fd, + msg)) == SLURM_SOCKET_ERROR) + debug + ("Send messge to secondary controller failed: %m"); } - return rc ; + return rc; } /* sends a message to an arbitrary node @@ -346,108 +365,132 @@ int slurm_send_controller_msg ( slurm_fd open_fd , slurm_msg_t * msg ) * msg - a slurm msg struct * int - size of msg sent in bytes */ -int slurm_send_node_msg ( slurm_fd open_fd , slurm_msg_t * msg ) -{ - char buf_temp[SLURM_PROTOCOL_MAX_MESSAGE_BUFFER_SIZE] ; - char * buffer = buf_temp ; - header_t header ; - slurm_auth_credentials_t client_cred ; - int rc ; - unsigned int pack_len ; +int slurm_send_node_msg(slurm_fd open_fd, slurm_msg_t * msg) +{ + char buf_temp[SLURM_PROTOCOL_MAX_MESSAGE_BUFFER_SIZE]; + char *buffer = buf_temp; + header_t header; + slurm_auth_credentials_t client_cred; + int rc; + unsigned int pack_len; unsigned int cred_len = 0; unsigned int msg_len = 0; unsigned int tmp_len = 0; /* initheader */ - init_header ( & header , msg->msg_type , SLURM_PROTOCOL_NO_FLAGS ) ; + init_header(&header, msg->msg_type, SLURM_PROTOCOL_NO_FLAGS); - if ( slurm_auth_activate_credentials( & client_cred , CREDENTIAL_TTL_SEC ) != SLURM_SUCCESS ) { + if (slurm_auth_activate_credentials(&client_cred, CREDENTIAL_TTL_SEC) + != SLURM_SUCCESS) { /* Should probably do something more meaningful. */ - error ( "init_header: failed to sign client credentials\n" ); + error("init_header: failed to sign client credentials\n"); } - + /* pack header */ - pack_len = SLURM_PROTOCOL_MAX_MESSAGE_BUFFER_SIZE ; - pack_header ( &header , & buffer , & pack_len ) ; + pack_len = SLURM_PROTOCOL_MAX_MESSAGE_BUFFER_SIZE; + pack_header(&header, &buffer, &pack_len); /* pack msg */ - tmp_len = pack_len ; - slurm_auth_pack_credentials ( & client_cred , (void ** ) & buffer , & pack_len ) ; - cred_len = tmp_len - pack_len ; - + tmp_len = pack_len; + slurm_auth_pack_credentials(&client_cred, (void **) &buffer, + &pack_len); + cred_len = tmp_len - pack_len; + /* pack msg */ - tmp_len = pack_len ; - pack_msg ( msg , & buffer , & pack_len ) ; - msg_len = tmp_len - pack_len ; + tmp_len = pack_len; + pack_msg(msg, &buffer, &pack_len); + msg_len = tmp_len - pack_len; /* update header with packed cred and msg lengths */ - update_header ( & header , cred_len , msg_len ) ; + update_header(&header, cred_len, msg_len); /* repack updated header */ - buffer = buf_temp ; - tmp_len = SLURM_PROTOCOL_MAX_MESSAGE_BUFFER_SIZE ; - pack_header ( &header , & buffer , & tmp_len ) ; - + buffer = buf_temp; + tmp_len = SLURM_PROTOCOL_MAX_MESSAGE_BUFFER_SIZE; + pack_header(&header, &buffer, &tmp_len); + /* send msg */ - if ( ( rc = _slurm_msg_sendto ( open_fd , buf_temp , SLURM_PROTOCOL_MAX_MESSAGE_BUFFER_SIZE - pack_len , SLURM_PROTOCOL_NO_SEND_RECV_FLAGS , &msg->address ) ) == SLURM_SOCKET_ERROR ) - debug ( "Error sending msg socket: %m" ) ; - return rc ; + if ((rc = + _slurm_msg_sendto(open_fd, buf_temp, + SLURM_PROTOCOL_MAX_MESSAGE_BUFFER_SIZE - + pack_len, SLURM_PROTOCOL_NO_SEND_RECV_FLAGS, + &msg->address)) == SLURM_SOCKET_ERROR) + debug("Error sending msg socket: %m"); + return rc; } /************************/ /***** stream functions */ /************************/ -slurm_fd slurm_listen_stream ( slurm_addr * slurm_address ) +slurm_fd slurm_listen_stream(slurm_addr * slurm_address) { - return _slurm_listen_stream ( slurm_address ) ; + return _slurm_listen_stream(slurm_address); } -slurm_fd slurm_accept_stream ( slurm_fd open_fd , slurm_addr * slurm_address ) +slurm_fd slurm_accept_stream(slurm_fd open_fd, slurm_addr * slurm_address) { - return _slurm_accept_stream ( open_fd , slurm_address ) ; + return _slurm_accept_stream(open_fd, slurm_address); } -slurm_fd slurm_open_stream ( slurm_addr * slurm_address ) +slurm_fd slurm_open_stream(slurm_addr * slurm_address) { - return _slurm_open_stream ( slurm_address ) ; + return _slurm_open_stream(slurm_address); } -size_t slurm_write_stream_timeout_tv ( slurm_fd open_fd , char * buffer , size_t size , struct timeval * timeout ) +size_t slurm_write_stream_timeout_tv(slurm_fd open_fd, char *buffer, + size_t size, struct timeval * timeout) { - return _slurm_send_timeout ( open_fd , buffer , size , SLURM_PROTOCOL_NO_SEND_RECV_FLAGS , timeout ) ; + return _slurm_send_timeout(open_fd, buffer, size, + SLURM_PROTOCOL_NO_SEND_RECV_FLAGS, + timeout); } -size_t slurm_read_stream_timeout_tv ( slurm_fd open_fd , char * buffer , size_t size , struct timeval * timeout ) +size_t slurm_read_stream_timeout_tv(slurm_fd open_fd, char *buffer, + size_t size, struct timeval * timeout) { - return _slurm_recv_timeout ( open_fd , buffer , size , SLURM_PROTOCOL_NO_SEND_RECV_FLAGS , timeout ) ; + return _slurm_recv_timeout(open_fd, buffer, size, + SLURM_PROTOCOL_NO_SEND_RECV_FLAGS, + timeout); } -size_t slurm_write_stream_timeout ( slurm_fd open_fd , char * buffer , size_t size , int timeout ) +size_t slurm_write_stream_timeout(slurm_fd open_fd, char *buffer, + size_t size, int timeout) { - struct timeval time_out ; - time_out . tv_sec = timeout ; - time_out . tv_usec = 0 ; - return _slurm_send_timeout ( open_fd , buffer , size , SLURM_PROTOCOL_NO_SEND_RECV_FLAGS , & time_out ) ; + struct timeval time_out; + time_out.tv_sec = timeout; + time_out.tv_usec = 0; + return _slurm_send_timeout(open_fd, buffer, size, + SLURM_PROTOCOL_NO_SEND_RECV_FLAGS, + &time_out); } -size_t slurm_read_stream_timeout ( slurm_fd open_fd , char * buffer , size_t size , int timeout ) +size_t slurm_read_stream_timeout(slurm_fd open_fd, char *buffer, + size_t size, int timeout) { - struct timeval time_out ; - time_out . tv_sec = timeout ; - time_out . tv_usec = 0 ; - return _slurm_recv_timeout ( open_fd , buffer , size , SLURM_PROTOCOL_NO_SEND_RECV_FLAGS , & time_out ) ; + struct timeval time_out; + time_out.tv_sec = timeout; + time_out.tv_usec = 0; + return _slurm_recv_timeout(open_fd, buffer, size, + SLURM_PROTOCOL_NO_SEND_RECV_FLAGS, + &time_out); } -size_t slurm_write_stream ( slurm_fd open_fd , char * buffer , size_t size ) +size_t slurm_write_stream(slurm_fd open_fd, char *buffer, size_t size) { - struct timeval SLURM_MESSGE_TIMEOUT_SEC = SLURM_MESSGE_TIMEOUT_SEC_STATIC ; - return _slurm_send_timeout ( open_fd , buffer , size , SLURM_PROTOCOL_NO_SEND_RECV_FLAGS , & SLURM_MESSGE_TIMEOUT_SEC ) ; + struct timeval SLURM_MESSGE_TIMEOUT_SEC = + SLURM_MESSGE_TIMEOUT_SEC_STATIC; + return _slurm_send_timeout(open_fd, buffer, size, + SLURM_PROTOCOL_NO_SEND_RECV_FLAGS, + &SLURM_MESSGE_TIMEOUT_SEC); } -size_t slurm_read_stream ( slurm_fd open_fd , char * buffer , size_t size ) +size_t slurm_read_stream(slurm_fd open_fd, char *buffer, size_t size) { - struct timeval SLURM_MESSGE_TIMEOUT_SEC = SLURM_MESSGE_TIMEOUT_SEC_STATIC ; - return _slurm_recv_timeout ( open_fd , buffer , size , SLURM_PROTOCOL_NO_SEND_RECV_FLAGS , & SLURM_MESSGE_TIMEOUT_SEC ) ; + struct timeval SLURM_MESSGE_TIMEOUT_SEC = + SLURM_MESSGE_TIMEOUT_SEC_STATIC; + return _slurm_recv_timeout(open_fd, buffer, size, + SLURM_PROTOCOL_NO_SEND_RECV_FLAGS, + &SLURM_MESSGE_TIMEOUT_SEC); } /* @@ -498,254 +541,278 @@ size_t slurm_read_stream ( slurm_fd open_fd , char * buffer , size_t size ) } */ -int slurm_get_stream_addr ( slurm_fd open_fd , slurm_addr * address ) +int slurm_get_stream_addr(slurm_fd open_fd, slurm_addr * address) { - return _slurm_get_stream_addr ( open_fd , address ) ; + return _slurm_get_stream_addr(open_fd, address); } -int slurm_close_stream ( slurm_fd open_fd ) +int slurm_close_stream(slurm_fd open_fd) { - return _slurm_close_stream ( open_fd ) ; + return _slurm_close_stream(open_fd); } -int slurm_select(int n, slurm_fd_set *readfds, slurm_fd_set *writefds, slurm_fd_set *exceptfds, struct timeval *timeout) +int slurm_select(int n, slurm_fd_set * readfds, slurm_fd_set * writefds, + slurm_fd_set * exceptfds, struct timeval *timeout) { return _slurm_select(n, readfds, writefds, exceptfds, timeout); } -void slurm_FD_CLR(slurm_fd fd, slurm_fd_set *set) +void slurm_FD_CLR(slurm_fd fd, slurm_fd_set * set) { return _slurm_FD_CLR(fd, set); } -int slurm_FD_ISSET(slurm_fd fd, slurm_fd_set *set) +int slurm_FD_ISSET(slurm_fd fd, slurm_fd_set * set) { return _slurm_FD_ISSET(fd, set); } -void slurm_FD_SET(slurm_fd fd, slurm_fd_set *set) +void slurm_FD_SET(slurm_fd fd, slurm_fd_set * set) { return _slurm_FD_SET(fd, set); } -void slurm_FD_ZERO(slurm_fd_set *set) +void slurm_FD_ZERO(slurm_fd_set * set) { return _slurm_FD_ZERO(set); } -int slurm_fcntl ( slurm_fd fd , int cmd , ... ) +int slurm_fcntl(slurm_fd fd, int cmd, ...) { - va_list va ; - int rc ; - - va_start ( va , cmd ); - rc = _slurm_vfcntl ( fd , cmd , va ) ; - va_end ( va ) ; + va_list va; + int rc; + + va_start(va, cmd); + rc = _slurm_vfcntl(fd, cmd, va); + va_end(va); - return rc ; + return rc; } - -int slurm_set_stream_non_blocking ( slurm_fd open_fd ) + +int slurm_set_stream_non_blocking(slurm_fd open_fd) { - return _slurm_set_stream_non_blocking ( open_fd ) ; + return _slurm_set_stream_non_blocking(open_fd); } -int slurm_set_stream_blocking ( slurm_fd open_fd ) +int slurm_set_stream_blocking(slurm_fd open_fd) { - return _slurm_set_stream_blocking ( open_fd ) ; + return _slurm_set_stream_blocking(open_fd); } /************************/ /***** slurm addr functions */ /************************/ /* sets/gets the fields of a slurm_addr */ -void slurm_set_addr_uint ( slurm_addr * slurm_address , uint16_t port , uint32_t ip_address ) +void slurm_set_addr_uint(slurm_addr * slurm_address, uint16_t port, + uint32_t ip_address) { - _slurm_set_addr_uint ( slurm_address , port , ip_address ) ; + _slurm_set_addr_uint(slurm_address, port, ip_address); } -void slurm_set_addr_any ( slurm_addr * slurm_address , uint16_t port ) +void slurm_set_addr_any(slurm_addr * slurm_address, uint16_t port) { - _slurm_set_addr_uint ( slurm_address , port , SLURM_INADDR_ANY ) ; + _slurm_set_addr_uint(slurm_address, port, SLURM_INADDR_ANY); } -void slurm_set_addr ( slurm_addr * slurm_address , uint16_t port , char * host ) +void slurm_set_addr(slurm_addr * slurm_address, uint16_t port, char *host) { - _slurm_set_addr ( slurm_address , port , host ) ; + _slurm_set_addr(slurm_address, port, host); } -void slurm_set_addr_char ( slurm_addr * slurm_address , uint16_t port , char * host ) +void slurm_set_addr_char(slurm_addr * slurm_address, uint16_t port, + char *host) { - _slurm_set_addr_char ( slurm_address , port , host ) ; + _slurm_set_addr_char(slurm_address, port, host); } -void slurm_get_addr ( slurm_addr * slurm_address , uint16_t * port , char * host , unsigned int buf_len ) +void slurm_get_addr(slurm_addr * slurm_address, uint16_t * port, + char *host, unsigned int buf_len) { - _slurm_get_addr ( slurm_address , port , host , buf_len ) ; + _slurm_get_addr(slurm_address, port, host, buf_len); } -void slurm_pack_slurm_addr ( slurm_addr * slurm_address , void ** buffer , int * length ) +void slurm_pack_slurm_addr(slurm_addr * slurm_address, void **buffer, + int *length) { - _slurm_pack_slurm_addr ( slurm_address , buffer , length ) ; + _slurm_pack_slurm_addr(slurm_address, buffer, length); } -void slurm_unpack_slurm_addr_no_alloc ( slurm_addr * slurm_address , void ** buffer , int * length ) +void slurm_unpack_slurm_addr_no_alloc(slurm_addr * slurm_address, + void **buffer, int *length) { - _slurm_unpack_slurm_addr_no_alloc ( slurm_address , buffer , length ) ; + _slurm_unpack_slurm_addr_no_alloc(slurm_address, buffer, length); } -void slurm_print_slurm_addr ( slurm_addr * address, char *buf, size_t n ) +void slurm_print_slurm_addr(slurm_addr * address, char *buf, size_t n) { - _slurm_print_slurm_addr ( address, buf, n ) ; + _slurm_print_slurm_addr(address, buf, n); } /*******************************************/ /***** slurm send highlevel msg functions */ /*******************************************/ -void slurm_send_rc_msg ( slurm_msg_t * request_msg , int rc ) +void slurm_send_rc_msg(slurm_msg_t * request_msg, int rc) { - slurm_msg_t response_msg ; - return_code_msg_t rc_msg ; + slurm_msg_t response_msg; + return_code_msg_t rc_msg; /* no change */ - rc_msg . return_code = rc ; + rc_msg.return_code = rc; /* init response_msg structure */ - response_msg . address = request_msg -> address ; - response_msg . msg_type = RESPONSE_SLURM_RC ; - response_msg . data = & rc_msg ; + response_msg.address = request_msg->address; + response_msg.msg_type = RESPONSE_SLURM_RC; + response_msg.data = &rc_msg; /* send message */ - slurm_send_node_msg( request_msg -> conn_fd , &response_msg ) ; + slurm_send_node_msg(request_msg->conn_fd, &response_msg); } -int slurm_send_recv_controller_msg ( slurm_msg_t * request_msg , slurm_msg_t * response_msg ) +int slurm_send_recv_controller_msg(slurm_msg_t * request_msg, + slurm_msg_t * response_msg) { - int msg_size ; - int rc ; - slurm_fd sockfd ; - int error_code = 0 ; + int msg_size; + int rc; + slurm_fd sockfd; + int error_code = 0; - /* init message connection for message communication with controller */ - if ( ( sockfd = slurm_open_controller_conn ( ) ) == SLURM_SOCKET_ERROR ) - return SLURM_SOCKET_ERROR ; + /* init message connection for message communication with controller */ + if ((sockfd = slurm_open_controller_conn()) == SLURM_SOCKET_ERROR) + return SLURM_SOCKET_ERROR; - /* send request message */ - if ( ( rc = slurm_send_controller_msg ( sockfd , request_msg ) ) == SLURM_SOCKET_ERROR ) - { - error_code = 1 ; - goto slurm_send_recv_controller_msg_cleanup; + /* send request message */ + if ((rc = + slurm_send_controller_msg(sockfd, + request_msg)) == + SLURM_SOCKET_ERROR) { + error_code = 1; + goto slurm_send_recv_controller_msg_cleanup; } - /* receive message */ - if ( ( msg_size = slurm_receive_msg ( sockfd , response_msg ) ) == SLURM_SOCKET_ERROR ) - { - error_code = 1 ; - goto slurm_send_recv_controller_msg_cleanup; + /* receive message */ + if ((msg_size = + slurm_receive_msg(sockfd, + response_msg)) == SLURM_SOCKET_ERROR) { + error_code = 1; + goto slurm_send_recv_controller_msg_cleanup; } - - slurm_send_recv_controller_msg_cleanup: - /* shutdown message connection */ - if ( ( rc = slurm_shutdown_msg_conn ( sockfd ) ) == SLURM_SOCKET_ERROR ) - return SLURM_SOCKET_ERROR ; - if ( error_code ) return SLURM_SOCKET_ERROR ; - - return SLURM_SUCCESS ; + + slurm_send_recv_controller_msg_cleanup: + /* shutdown message connection */ + if ((rc = slurm_shutdown_msg_conn(sockfd)) == SLURM_SOCKET_ERROR) + return SLURM_SOCKET_ERROR; + if (error_code) + return SLURM_SOCKET_ERROR; + + return SLURM_SUCCESS; } -int slurm_send_recv_node_msg ( slurm_msg_t * request_msg , slurm_msg_t * response_msg ) +int slurm_send_recv_node_msg(slurm_msg_t * request_msg, + slurm_msg_t * response_msg) { - int msg_size ; - int rc ; - slurm_fd sockfd ; - int error_code = 0 ; + int msg_size; + int rc; + slurm_fd sockfd; + int error_code = 0; - /* init message connection for message communication with controller */ - if ( ( sockfd = slurm_open_msg_conn ( & request_msg -> address ) ) == SLURM_SOCKET_ERROR ) - return SLURM_SOCKET_ERROR ; + /* init message connection for message communication with controller */ + if ((sockfd = + slurm_open_msg_conn(&request_msg->address)) == + SLURM_SOCKET_ERROR) + return SLURM_SOCKET_ERROR; - /* send request message */ - if ( ( rc = slurm_send_node_msg ( sockfd , request_msg ) ) == SLURM_SOCKET_ERROR ) - { - error_code = 1 ; - goto slurm_send_recv_node_msg_cleanup; + /* send request message */ + if ((rc = + slurm_send_node_msg(sockfd, + request_msg)) == SLURM_SOCKET_ERROR) { + error_code = 1; + goto slurm_send_recv_node_msg_cleanup; } - /* receive message */ - if ( ( msg_size = slurm_receive_msg ( sockfd , response_msg ) ) == SLURM_SOCKET_ERROR ) - { - error_code = 1 ; - goto slurm_send_recv_node_msg_cleanup; + /* receive message */ + if ((msg_size = + slurm_receive_msg(sockfd, + response_msg)) == SLURM_SOCKET_ERROR) { + error_code = 1; + goto slurm_send_recv_node_msg_cleanup; } - slurm_send_recv_node_msg_cleanup: - /* shutdown message connection */ - if ( ( rc = slurm_shutdown_msg_conn ( sockfd ) ) == SLURM_SOCKET_ERROR ) - return SLURM_SOCKET_ERROR ; - if ( error_code ) return SLURM_SOCKET_ERROR ; + slurm_send_recv_node_msg_cleanup: + /* shutdown message connection */ + if ((rc = slurm_shutdown_msg_conn(sockfd)) == SLURM_SOCKET_ERROR) + return SLURM_SOCKET_ERROR; + if (error_code) + return SLURM_SOCKET_ERROR; - return SLURM_SUCCESS ; + return SLURM_SUCCESS; } -int slurm_send_only_controller_msg ( slurm_msg_t * request_msg ) +int slurm_send_only_controller_msg(slurm_msg_t * request_msg) { - int rc ; - slurm_fd sockfd ; - int error_code = 0 ; + int rc; + slurm_fd sockfd; + int error_code = 0; - /* init message connection for message communication with controller */ - if ( ( sockfd = slurm_open_controller_conn ( ) ) == SLURM_SOCKET_ERROR ) - return SLURM_SOCKET_ERROR ; + /* init message connection for message communication with controller */ + if ((sockfd = slurm_open_controller_conn()) == SLURM_SOCKET_ERROR) + return SLURM_SOCKET_ERROR; - /* send request message */ - if ( ( rc = slurm_send_controller_msg ( sockfd , request_msg ) ) == SLURM_SOCKET_ERROR ) - { - error_code = 1 ; - goto slurm_send_only_controller_msg_cleanup; + /* send request message */ + if ((rc = + slurm_send_controller_msg(sockfd, + request_msg)) == + SLURM_SOCKET_ERROR) { + error_code = 1; + goto slurm_send_only_controller_msg_cleanup; } - slurm_send_only_controller_msg_cleanup: - /* shutdown message connection */ - if ( ( rc = slurm_shutdown_msg_conn ( sockfd ) ) == SLURM_SOCKET_ERROR ) - return SLURM_SOCKET_ERROR ; - if ( error_code ) return SLURM_SOCKET_ERROR ; + slurm_send_only_controller_msg_cleanup: + /* shutdown message connection */ + if ((rc = slurm_shutdown_msg_conn(sockfd)) == SLURM_SOCKET_ERROR) + return SLURM_SOCKET_ERROR; + if (error_code) + return SLURM_SOCKET_ERROR; - return SLURM_SUCCESS ; - + return SLURM_SUCCESS; + } -int slurm_send_only_node_msg ( slurm_msg_t * request_msg ) +int slurm_send_only_node_msg(slurm_msg_t * request_msg) { - int rc ; - slurm_fd sockfd ; - int error_code = 0 ; + int rc; + slurm_fd sockfd; + int error_code = 0; - /* init message connection for message communication with controller */ - if ( ( sockfd = slurm_open_msg_conn ( & request_msg -> address ) ) == SLURM_SOCKET_ERROR ) - return SLURM_SOCKET_ERROR ; + /* init message connection for message communication with controller */ + if ((sockfd = + slurm_open_msg_conn(&request_msg->address)) == + SLURM_SOCKET_ERROR) + return SLURM_SOCKET_ERROR; - /* send request message */ - if ( ( rc = slurm_send_node_msg ( sockfd , request_msg ) ) == SLURM_SOCKET_ERROR ) - { - error_code = 1 ; - goto slurm_send_only_node_msg_cleanup; + /* send request message */ + if ((rc = + slurm_send_node_msg(sockfd, + request_msg)) == SLURM_SOCKET_ERROR) { + error_code = 1; + goto slurm_send_only_node_msg_cleanup; } - slurm_send_only_node_msg_cleanup: - /* shutdown message connection */ - if ( ( rc = slurm_shutdown_msg_conn ( sockfd ) ) == SLURM_SOCKET_ERROR ) - return SLURM_SOCKET_ERROR ; - if ( error_code ) return SLURM_SOCKET_ERROR ; + slurm_send_only_node_msg_cleanup: + /* shutdown message connection */ + if ((rc = slurm_shutdown_msg_conn(sockfd)) == SLURM_SOCKET_ERROR) + return SLURM_SOCKET_ERROR; + if (error_code) + return SLURM_SOCKET_ERROR; - return SLURM_SUCCESS ; + return SLURM_SUCCESS; } -short int slurm_get_slurmd_port ( ) +short int slurm_get_slurmd_port() { - return slurmctld_conf . slurmd_port ; + return slurmctld_conf.slurmd_port; } -void slurm_free_msg ( slurm_msg_t * msg ) +void slurm_free_msg(slurm_msg_t * msg) { - xfree ( msg ) ; + xfree(msg); } diff --git a/src/common/slurm_protocol_common.h b/src/common/slurm_protocol_common.h index d2a91ac79a0714c2b1c1e48d7bd1d588000c9d09..2de7448eb06426bd1aa67a447c17ef437fe94197 100644 --- a/src/common/slurm_protocol_common.h +++ b/src/common/slurm_protocol_common.h @@ -8,7 +8,7 @@ /* for sendto and recvfrom commands */ #define SLURM_PROTOCOL_NO_SEND_RECV_FLAGS 0 /* for accpet commands */ -#define SLURM_PROTOCOL_DEFAULT_LISTEN_BACKLOG 10 +#define SLURM_PROTOCOL_DEFAULT_LISTEN_BACKLOG 128 /* used in interface methods */ #define SLURM_PROTOCOL_FUNCTION_NOT_IMPLEMENTED -2 /* max slurm message send and receive buffer size diff --git a/src/common/slurm_protocol_defs.h b/src/common/slurm_protocol_defs.h index 9fb3e2f426451bb27a13272a2cc4d66bad39d2f0..3d18b58e0ee4c05d7507889f7b987481b8a75d05 100644 --- a/src/common/slurm_protocol_defs.h +++ b/src/common/slurm_protocol_defs.h @@ -46,7 +46,7 @@ #include <src/common/macros.h> #include <src/common/xassert.h> #include <src/common/slurm_protocol_common.h> -#include <src/common/slurm_authentication.h> +#include <src/common/slurm_auth.h> /* used to define the size of the credential.signature size diff --git a/src/common/slurm_protocol_pack.c b/src/common/slurm_protocol_pack.c index e7a4713d9a7dd9d7cdb717461108a532166093cf..8fd0984d9ddf07db2d691be3fc92d0e93d5ce8e7 100644 --- a/src/common/slurm_protocol_pack.c +++ b/src/common/slurm_protocol_pack.c @@ -32,7 +32,7 @@ #include <src/common/bitstring.h> #include <src/common/slurm_protocol_pack.h> #include <src/common/slurm_protocol_api.h> -#include <src/common/slurm_authentication.h> +#include <src/common/slurm_auth.h> #include <src/common/pack.h> #include <src/common/log.h> #include <src/common/xmalloc.h> @@ -501,6 +501,7 @@ int unpack_resource_allocation_response_msg ( resource_allocation_response_msg_t tmp_ptr->cpu_count_reps = NULL; } *msg = tmp_ptr ; + info("job id is %ld", tmp_ptr->job_id); return 0 ; } diff --git a/src/common/slurm_protocol_util.c b/src/common/slurm_protocol_util.c index f92454c284914b9f89b9551cbaa79aa92c00822b..8dc893ca01604e82f8e004bf931f2ea620bb903d 100644 --- a/src/common/slurm_protocol_util.c +++ b/src/common/slurm_protocol_util.c @@ -7,7 +7,6 @@ #include <src/common/slurm_protocol_api.h> #include <src/common/slurm_protocol_common.h> #include <src/common/slurm_protocol_util.h> -#include <src/common/slurm_authentication.h> #include <src/common/log.h> /* checks to see that the specified header was sent from a node running the same version of the protocol as the current node */