From 91e8a532f4a7505e6428e739bb22fd41a6d8ecea Mon Sep 17 00:00:00 2001
From: Moe Jette <jette1@llnl.gov>
Date: Wed, 1 Mar 2006 17:24:53 +0000
Subject: [PATCH] svn merge -r7268:7311
 https://eris.llnl.gov/svn/slurm/branches/slurm-1.0

---
 NEWS                                          |   8 +
 src/common/slurm_auth.c                       |  47 +++--
 src/plugins/auth/munge/auth_munge.c           |   3 +-
 src/plugins/auth/none/auth_none.c             |   5 +-
 src/slurmd/slurmstepd/io.c                    |  10 +-
 .../slurm_unit/slurmctld/security_2_1.csh     |  55 ------
 .../slurm_unit/slurmctld/security_2_1.py      |  35 ++--
 testsuite/slurm_unit/slurmctld/security_2_2.c |  78 --------
 .../{security_2_2.bash => security_2_2.sh}    |   4 +-
 .../slurm_unit/slurmctld/security_2_4.sh      |   2 +
 .../slurm_unit/slurmctld/security_2_5.sh      |   2 +
 testsuite/slurm_unit/slurmd/security_3_1.c    | 168 ------------------
 12 files changed, 82 insertions(+), 335 deletions(-)
 delete mode 100755 testsuite/slurm_unit/slurmctld/security_2_1.csh
 delete mode 100644 testsuite/slurm_unit/slurmctld/security_2_2.c
 rename testsuite/slurm_unit/slurmctld/{security_2_2.bash => security_2_2.sh} (91%)
 create mode 100755 testsuite/slurm_unit/slurmctld/security_2_4.sh
 create mode 100755 testsuite/slurm_unit/slurmctld/security_2_5.sh
 delete mode 100644 testsuite/slurm_unit/slurmd/security_3_1.c

diff --git a/NEWS b/NEWS
index 6eeb50c689c..8a38dea5ca4 100644
--- a/NEWS
+++ b/NEWS
@@ -19,6 +19,14 @@ documents those changes that are of interest to users and admins.
  -- Remove some use of cr_enabled flag in slurmctld job record, use 
     new flag "test_only" in select_g_job_test() instead.
 
+* Changes in SLURM 1.0.7
+========================
+ -- Change in how AuthType=auth/dummy is handled for security testing.
+
+* Changes in SLURM 1.0.6
+========================
+ -- Prevent slurmstepd from crashing when srun attaches to batch job.
+
 * Changes in SLURM 1.0.5
 ========================
  -- Restructure logic for scheduling BlueGene small block jobs. Added
diff --git a/src/common/slurm_auth.c b/src/common/slurm_auth.c
index c793d5755f6..46b8e8833b6 100644
--- a/src/common/slurm_auth.c
+++ b/src/common/slurm_auth.c
@@ -1,7 +1,7 @@
 /*****************************************************************************\
  *  slurm_auth.c - implementation-independent authentication API definitions
  *****************************************************************************
- *  Copyright (C) 2002 The Regents of the University of California.
+ *  Copyright (C) 2002-2006 The Regents of the University of California.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
  *  Written by Jay Windley <jwindley@lnxi.com>
  *  UCRL-CODE-217948.
@@ -39,6 +39,8 @@
 #include "src/common/plugrack.h"
 #include "src/common/arg_desc.h"
 
+static bool auth_dummy = false;	/* for security testing */
+
 /*
  * WARNING:  Do not change the order of these fields or add additional
  * fields at the beginning of the structure.  If you do, authentication
@@ -287,7 +289,7 @@ slurm_auth_init( void )
 	auth_type = slurm_get_auth_type();
 	if (strcmp(auth_type, "auth/dummy") == 0) {
 		info( "warning: %s plugin selected", auth_type);
-		retval = SLURM_ERROR;
+		auth_dummy = true;
 		xfree(auth_type);
 		goto done;
 	}
@@ -339,9 +341,12 @@ g_slurm_auth_create( void *hosts, int timeout )
 {
         void **argv;
         void *ret;
-        
-        if ( slurm_auth_init() < 0 )
-                return NULL;
+
+	if ( slurm_auth_init() < 0 )
+		return NULL;
+
+	if ( auth_dummy )
+		return xmalloc(0);
 
         if ( ( argv = slurm_auth_marshal_args( hosts, timeout ) ) == NULL ) {
                 return NULL;
@@ -358,6 +363,9 @@ g_slurm_auth_destroy( void *cred )
         if ( slurm_auth_init() < 0 )
                 return SLURM_ERROR;
 
+	if ( auth_dummy )	/* don't worry about leak in testing */
+		return SLURM_SUCCESS;
+
         return (*(g_context->ops.destroy))( cred );
 }
 
@@ -366,10 +374,13 @@ g_slurm_auth_verify( void *cred, void *hosts, int timeout )
 {
         int ret;
         void **argv;
-        
+
         if ( slurm_auth_init() < 0 )
                 return SLURM_ERROR;
 
+	if ( auth_dummy )
+		return SLURM_SUCCESS;
+
         if ( ( argv = slurm_auth_marshal_args( hosts, timeout ) ) == NULL ) {
                 return SLURM_ERROR;
         }
@@ -382,7 +393,7 @@ g_slurm_auth_verify( void *cred, void *hosts, int timeout )
 uid_t
 g_slurm_auth_get_uid( void *cred )
 {
-        if ( slurm_auth_init() < 0 )
+	if (( slurm_auth_init() < 0 ) || auth_dummy )
                 return SLURM_AUTH_NOBODY;
         
         return (*(g_context->ops.get_uid))( cred );
@@ -391,7 +402,7 @@ g_slurm_auth_get_uid( void *cred )
 gid_t
 g_slurm_auth_get_gid( void *cred )
 {
-        if ( slurm_auth_init() < 0 )
+	if (( slurm_auth_init() < 0 ) || auth_dummy )
                 return SLURM_AUTH_NOBODY;
         
         return (*(g_context->ops.get_gid))( cred );
@@ -402,14 +413,17 @@ g_slurm_auth_pack( void *cred, Buf buf )
 {
         if ( slurm_auth_init() < 0 )
                 return SLURM_ERROR;
-        
+ 
+	if ( auth_dummy )
+		return SLURM_SUCCESS;
+
         return (*(g_context->ops.pack))( cred, buf );
 }
 
 void *
 g_slurm_auth_unpack( Buf buf )
 {
-        if ( slurm_auth_init() < 0 )
+	if (( slurm_auth_init() < 0 ) || auth_dummy )
                 return NULL;
         
         return (*(g_context->ops.unpack))( buf );
@@ -420,14 +434,17 @@ g_slurm_auth_print( void *cred, FILE *fp )
 {
         if ( slurm_auth_init() < 0 )
                 return SLURM_ERROR;
-        
+
+	if ( auth_dummy )
+		return SLURM_SUCCESS;
+
         return (*(g_context->ops.print))( cred, fp );
 }
 
 int
 g_slurm_auth_errno( void *cred )
 {
-        if ( slurm_auth_init() < 0 )
+        if (( slurm_auth_init() < 0 ) || auth_dummy )
                 return SLURM_ERROR;
 
         return (*(g_context->ops.sa_errno))( cred );
@@ -438,9 +455,9 @@ g_slurm_auth_errstr( int slurm_errno )
 {
         static char auth_init_msg[] = "authentication initialization failure";
         char *generic;
-        
-        if ( slurm_auth_init() < 0 )
-                return auth_init_msg;
+
+	if (( slurm_auth_init() < 0 ) || auth_dummy )
+		return auth_init_msg;
 
         if (( generic = (char *) slurm_auth_generic_errstr( slurm_errno ) ))
                 return generic;
diff --git a/src/plugins/auth/munge/auth_munge.c b/src/plugins/auth/munge/auth_munge.c
index 3bb6049f77a..e39a77c44c5 100644
--- a/src/plugins/auth/munge/auth_munge.c
+++ b/src/plugins/auth/munge/auth_munge.c
@@ -330,7 +330,8 @@ slurm_auth_unpack( Buf buf )
 		return NULL;
 	}
 	
-	if ( strcmp( type, plugin_type ) != 0 ) {
+	if (( type == NULL )
+	||  ( strcmp( type, plugin_type ) != 0 )) {
 		plugin_errno = SLURM_AUTH_MISMATCH;
 		return NULL;
 	}
diff --git a/src/plugins/auth/none/auth_none.c b/src/plugins/auth/none/auth_none.c
index dd99f6c92ce..5e6a9c256b2 100644
--- a/src/plugins/auth/none/auth_none.c
+++ b/src/plugins/auth/none/auth_none.c
@@ -283,7 +283,8 @@ slurm_auth_unpack( Buf buf )
 		plugin_errno = SLURM_AUTH_UNPACK_TYPE;
 		return NULL;
 	}
-	if ( strcmp( tmpstr, plugin_type ) != 0 ) {
+	if (( tmpstr == NULL )
+	||  ( strcmp( tmpstr, plugin_type ) != 0 )) {
 		plugin_errno = SLURM_AUTH_MISMATCH;
 		return NULL;
 	}
@@ -291,7 +292,7 @@ slurm_auth_unpack( Buf buf )
 		plugin_errno = SLURM_AUTH_UNPACK_VERSION;
 		return NULL;
 	}
-	if( version != plugin_version ) {
+	if ( version != plugin_version ) {
 		plugin_errno = SLURM_AUTH_MISMATCH;
 		return NULL;
 	}
diff --git a/src/slurmd/slurmstepd/io.c b/src/slurmd/slurmstepd/io.c
index 8dc0a5ca203..47e364f6a01 100644
--- a/src/slurmd/slurmstepd/io.c
+++ b/src/slurmd/slurmstepd/io.c
@@ -1068,8 +1068,14 @@ _send_io_init_msg(int sock, srun_key_t *key, slurmd_job_t *job)
 
 	memcpy(msg.cred_signature, key->data, SLURM_CRED_SIGLEN);
 	msg.nodeid = job->nodeid;
-	msg.stdout_objs = list_count(job->stdout_eio_objs);
-	msg.stderr_objs = list_count(job->stderr_eio_objs);
+	if (job->stdout_eio_objs == NULL)
+		msg.stdout_objs = 0;
+	else
+		msg.stdout_objs = list_count(job->stdout_eio_objs);
+	if (job->stderr_eio_objs == NULL)
+		msg.stderr_objs = 0;
+	else
+		msg.stderr_objs = list_count(job->stderr_eio_objs);
 	
 	if (io_init_msg_write_to_fd(sock, &msg) != SLURM_SUCCESS) {
 		error("Couldn't sent slurm_io_init_msg");
diff --git a/testsuite/slurm_unit/slurmctld/security_2_1.csh b/testsuite/slurm_unit/slurmctld/security_2_1.csh
deleted file mode 100755
index 55041aa5b7e..00000000000
--- a/testsuite/slurm_unit/slurmctld/security_2_1.csh
+++ /dev/null
@@ -1,55 +0,0 @@
-#!/bin/csh
-setenv CONFIG /etc/slurm
-setenv DEPLOY /usr
-
-echo ""
-echo "Insure that executable files are not world writable"
-ls -ld $DEPLOY/bin/srun
-ls -ld $DEPLOY/bin/sacct
-ls -ld $DEPLOY/bin/sinfo
-ls -ld $DEPLOY/bin/squeue
-ls -ld $DEPLOY/bin/scontrol
-ls -ld $DEPLOY/bin/scancel
-ls -ld $DEPLOY/sbin/slurm*
-
-echo ""
-echo "Insure that configuration directory and files are not world writable"
-ls -ld $CONFIG
-ls -l  $CONFIG
-
-echo ""
-echo "Insure that configured files are not world writable"
-grep "Prolog=" $CONFIG/slurm.conf
-ls -ld /etc/slurm/prolog
-ls -ld $DEPLOY/sbin/slurm_prolog
-echo ""
-grep "Epilog=" $CONFIG/slurm.conf
-ls -ld /etc/slurm/epilog
-ls -ld $DEPLOY/sbin/slurm_epilog
-
-echo ""
-echo "Both Job Keys are not world readable"
-echo "Private Key must not be world readable too"
-grep "JobCredentialPrivateKey=" $CONFIG/slurm.conf
-ls -ld /etc/slurm/slurm.key
-echo ""
-grep "JobCredentialPublicCertificate=" $CONFIG/slurm.conf
-ls -ld /etc/slurm/slurm.cert
-
-echo ""
-echo "Plugin directory and its contents must not be world writable"
-grep "PluginDir=" $CONFIG/slurm.conf
-ls -ld /usr/lib*/slurm
-ls -l  /usr/lib*/slurm
-
-echo ""
-echo "Spool and log files must be not be world writeable"
-grep "SlurmdSpoolDir=" $CONFIG/slurm.conf
-grep "StateSaveLocation=" $CONFIG/slurm.conf
-grep "SlurmctldLogFile=" $CONFIG/slurm.conf
-grep "SlurmdLogFile=" $CONFIG/slurm.conf
-grep "JobCompLog=" $CONFIG/slurm.conf
-ls -ld /usr/local/tmp/slurm/bgl
-ls -l  /usr/local/tmp/slurm/bgl
-ls -ld /var/log/slurm*
-ls -l  /var/log/slurm*
diff --git a/testsuite/slurm_unit/slurmctld/security_2_1.py b/testsuite/slurm_unit/slurmctld/security_2_1.py
index bf63beebd5b..b32a32c791b 100755
--- a/testsuite/slurm_unit/slurmctld/security_2_1.py
+++ b/testsuite/slurm_unit/slurmctld/security_2_1.py
@@ -1,6 +1,7 @@
 #!/usr/bin/env python
 
 from optparse import OptionParser
+import pwd
 import sys
 import os
 import re
@@ -79,22 +80,23 @@ def main(argv=None):
     append_file(files, confpairs, 'PluginDir')
     append_dir(files, confpairs, 'PluginDir')
 
+    pwname = pwd.getpwnam(confpairs['SlurmUser'])
     for fname in files:
-        rc = check_perms(fname, S_IWOTH)
-        if rc is True:
+        rc = verify_perms(fname, S_IWOTH, pwname)
+        if rc is False:
             error = True
 
     #
     # Make sure that these files are NOT world READABLE.
     #
     print
-    print "Ensuring the following are not world readble:"
+    print "Ensuring the following are not world readable:"
     files = []
     append_file(files, confpairs, 'JobCredentialPrivateKey')
 
     for fname in files:
-        rc = check_perms(fname, S_IROTH)
-        if rc is True:
+        rc = verify_perms(fname, S_IROTH, pwname)
+        if rc is False:
             error = True
 
     print
@@ -120,20 +122,29 @@ def append_dir(l, d, key):
         for fname in os.listdir(d[key]):
             l.append(d[key] + '/' + fname)
 
-def check_perms(filename, perm_bits):
-    """Returns 'True' if the file's permissions contain the bits 'perm_bits'"""
+def verify_perms(filename, perm_bits, pwname):
+    """Check file ownership and permission.
+    
+    Returns 'True' when the permission and ownership are verified, and 'False'
+    otherwise.  The checks fail if the file's permissions contain the bits
+    'perm_bits', of if the file's uid does not match the supplied entry from
+    passwd."""
     try:
-        perm = S_IMODE(os.stat(filename).st_mode)
+        s = os.stat(filename)
     except:
         print >>sys.stderr, 'WARNING: Unable to stat', filename
-        return False
-    
+        return True
+
+    perm = S_IMODE(s.st_mode)
     if perm & perm_bits:
         print >>sys.stderr, 'ERROR: %s: %o has bits %.3o set' % (filename, perm, perm_bits)
-        return True
+        return False
+    elif s.st_uid != 0 and s.st_uid != pwname.pw_uid:
+        print >>sys.stderr, 'ERROR: %s has incorrect uid %d' % (filename, s.st_uid)
+        return False
     else:
         print 'OK: %o %s ' % (perm, filename)
-        return False
+        return True
 
 if __name__ == "__main__":
     sys.exit(main())
diff --git a/testsuite/slurm_unit/slurmctld/security_2_2.c b/testsuite/slurm_unit/slurmctld/security_2_2.c
deleted file mode 100644
index b65cd19d65e..00000000000
--- a/testsuite/slurm_unit/slurmctld/security_2_2.c
+++ /dev/null
@@ -1,78 +0,0 @@
-/*****************************************************************************\
- *  security_2_2.c - test that job's user id is validated.
- *****************************************************************************
- *  Copyright (C) 2002 The Regents of the University of California.
- *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
- *  Written by Morris Jette <jette1@llnl.gov> et.al.
- *  UCRL-CODE-217948.
- *
- *  This file is part of SLURM, a resource management program.
- *  For details, see <http://www.llnl.gov/linux/slurm/>.
- *
- *  SLURM is free software; you can redistribute it and/or modify it under
- *  the terms of the GNU General Public License as published by the Free
- *  Software Foundation; either version 2 of the License, or (at your option)
- *  any later version.
- *
- *  SLURM is distributed in the hope that it will be useful, but WITHOUT ANY
- *  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
- *  FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
- *  details.
- *
- *  You should have received a copy of the GNU General Public License along
- *  with SLURM; if not, write to the Free Software Foundation, Inc.,
- *  59 Temple Place, Suite 330, Boston, MA  02111-1307  USA.
-\*****************************************************************************/
-
-#include <errno.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <sys/types.h>
-#include <unistd.h>
-
-#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 */
-int 
-main (int argc, char *argv[])
-{
-	int error_code;
-	job_desc_msg_t job_mesg;
-	resource_allocation_and_run_response_msg_t* run_resp_msg ;
-
-	slurm_init_job_desc_msg( &job_mesg );
-	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) {
-		fprintf (stderr, "ERROR: The allocate succeeded\n");
-		exit(1);
-	} else if (slurm_get_errno() != SLURM_PROTOCOL_AUTHENTICATION_ERROR) {
-		fprintf (stderr, "ERROR: The allocation failed for some "
-			 "reason other then authentication\n");
-		fprintf (stderr, "Error message was: %s\n",
-			 slurm_strerror(slurm_get_errno()));
-	} else {
-		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);
-	}
-}
diff --git a/testsuite/slurm_unit/slurmctld/security_2_2.bash b/testsuite/slurm_unit/slurmctld/security_2_2.sh
similarity index 91%
rename from testsuite/slurm_unit/slurmctld/security_2_2.bash
rename to testsuite/slurm_unit/slurmctld/security_2_2.sh
index 24231b47464..02e8a44b30c 100755
--- a/testsuite/slurm_unit/slurmctld/security_2_2.bash
+++ b/testsuite/slurm_unit/slurmctld/security_2_2.sh
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/bin/sh
 # Define location of slurm executables (if not in default search path)
 #slurm_bin="/home/jette/slurm.way/bin/"
 
@@ -10,7 +10,7 @@ echo "AuthType=auth/dummy" >>tmp.$$
 
 # Run srun using this config file
 export SLURM_CONF=tmp.$$ 
-${slurm_bin}srun /bin/id
+${slurm_bin}srun /usr/bin/id
 
 # Clean up
 rm tmp.$$
diff --git a/testsuite/slurm_unit/slurmctld/security_2_4.sh b/testsuite/slurm_unit/slurmctld/security_2_4.sh
new file mode 100755
index 00000000000..bb61a6f1657
--- /dev/null
+++ b/testsuite/slurm_unit/slurmctld/security_2_4.sh
@@ -0,0 +1,2 @@
+#!/bin/sh
+/usr/bin/id
diff --git a/testsuite/slurm_unit/slurmctld/security_2_5.sh b/testsuite/slurm_unit/slurmctld/security_2_5.sh
new file mode 100755
index 00000000000..eccb77acc31
--- /dev/null
+++ b/testsuite/slurm_unit/slurmctld/security_2_5.sh
@@ -0,0 +1,2 @@
+#!/bin/sh
+/bin/sleep 300
diff --git a/testsuite/slurm_unit/slurmd/security_3_1.c b/testsuite/slurm_unit/slurmd/security_3_1.c
deleted file mode 100644
index 2fcb218f70b..00000000000
--- a/testsuite/slurm_unit/slurmd/security_3_1.c
+++ /dev/null
@@ -1,168 +0,0 @@
-/*****************************************************************************\
- *  security_3_1.c - Spawn a bogus batch job launch request (not from 
- *  privileged user). Make sure that slurmd rejects the request and logs it.
- *  Much of this code is lifted from slurmctld/job_scheduler.c:_launch_job
- *****************************************************************************
- *  Copyright (C) 2002 The Regents of the University of California.
- *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
- *  Written by Morris Jette <jette1@llnl.gov> et.al.
- *  UCRL-CODE-217948.
- *
- *  This file is part of SLURM, a resource management program.
- *  For details, see <http://www.llnl.gov/linux/slurm/>.
- *
- *  SLURM is free software; you can redistribute it and/or modify it under
- *  the terms of the GNU General Public License as published by the Free
- *  Software Foundation; either version 2 of the License, or (at your option)
- *  any later version.
- *
- *  SLURM is distributed in the hope that it will be useful, but WITHOUT ANY
- *  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
- *  FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
- *  details.
- *
- *  You should have received a copy of the GNU General Public License along
- *  with SLURM; if not, write to the Free Software Foundation, Inc.,
- *  59 Temple Place, Suite 330, Boston, MA  02111-1307  USA.
-\*****************************************************************************/
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <sys/types.h>
-#include <unistd.h>
-
-#include <slurm/slurm.h>
-#include <slurm/slurm_errno.h>
-#include "config.h"
-#include "src/common/log.h"
-#include "src/common/slurm_protocol_api.h"
-#include "src/common/slurm_protocol_defs.h"
-
-static void _detailed_logs(char *prog_name);
-static int  _report_results(slurm_msg_t *response_msg_ptr);
-static int  _send_launch_msg(batch_job_launch_msg_t *launch_msg_ptr);
-static void _usage(char *prog_name);
-
-int main(int argc, char *argv[])
-{
-	batch_job_launch_msg_t launch_msg;
-	int uid;
-	uint32_t jid, cpu_arr[1];
-
-	if (argc != 2) {
-		_usage(argv[0]);
-		exit(1);
-	}
-
-	_detailed_logs(argv[0]);
-	uid = getuid();
-	jid = 0xffffff;
-	printf("Trying to run job %d on node %s as user %u\n",
-		jid, argv[1], uid);
-
-	/* Initialization of data structures */
-	launch_msg.job_id	= jid;
-	launch_msg.uid		= uid;
-	launch_msg.nodes	= argv[1];
-	launch_msg.num_cpu_groups	= 1;
-	cpu_arr[0]			= 1;
-	launch_msg.cpus_per_node	= cpu_arr;
-	launch_msg.cpu_count_reps	= cpu_arr;
-	launch_msg.err		= "/dev/null";
-	launch_msg.in		= "/dev/null";
-	launch_msg.out		= "/dev/null";
-	launch_msg.work_dir	= "/tmp";
-	launch_msg.argc		= 0;
-	launch_msg.argv		= NULL;
-	launch_msg.script	= "/bin/hostname\n";
-	launch_msg.envc 	= 0;
-	launch_msg.environment 	= NULL;
-
-	if (_send_launch_msg(&launch_msg) == SLURM_SUCCESS) {
-		printf("Now check SlurmdLog for an error message.\n");
-		exit(0);
-	} else
-		exit(1);
-}
-
-static int _send_launch_msg(batch_job_launch_msg_t *launch_msg_ptr)
-{
-	short int slurmd_port = slurm_get_slurmd_port();
-	slurm_addr slurm_address;
-	slurm_fd sockfd;
-	slurm_msg_t request_msg;
-	slurm_msg_t response_msg;
-	int msg_size = 0;
-
-	if (slurm_api_set_default_config() != SLURM_SUCCESS) {
-		slurm_perror("slurm_api_set_default_config");
-		return SLURM_ERROR;
-	}
-	slurm_set_addr(&slurm_address, slurmd_port, launch_msg_ptr->nodes);
-
-	/* init message connection for message communication */
-	if ((sockfd = slurm_open_msg_conn(&slurm_address))
-	    == SLURM_SOCKET_ERROR) {
-		slurm_perror("slurm_open_msg_conn");
-		return SLURM_ERROR;
-	}
-
-	/* send request message */
-	request_msg.msg_type	= REQUEST_BATCH_JOB_LAUNCH;
-	request_msg.data	= launch_msg_ptr;
-	request_msg.address	= slurm_address;
-	if (slurm_send_node_msg(sockfd, &request_msg) == SLURM_SOCKET_ERROR) {
-		slurm_perror("slurm_send_node_msg");
-		return SLURM_ERROR;
-	}
-
-	/* receive message */
-	if ((msg_size = slurm_receive_msg(sockfd, &response_msg, 0))
-	     == SLURM_SOCKET_ERROR) {
-		slurm_perror("slurm_receive_msg");
-		return SLURM_ERROR;
-	}
-
-	/* shutdown message connection */
-	if (slurm_shutdown_msg_conn(sockfd) == SLURM_SOCKET_ERROR) {
-		slurm_perror("slurm_shutdown_msg_conn");
-		return SLURM_ERROR;
-	}
-
-	return _report_results(&response_msg);
-}
-
-static int _report_results(slurm_msg_t *response_msg_ptr)
-{
-	return_code_msg_t *slurm_rc_msg_ptr;
-
-	if (response_msg_ptr->msg_type != RESPONSE_SLURM_RC) {
-		fprintf(stderr, "Wrong response type: %u\n", 
-			response_msg_ptr->msg_type);
-		return SLURM_ERROR;
-	}
-
-	slurm_rc_msg_ptr = (return_code_msg_t *) response_msg_ptr->data;
-	if (slurm_rc_msg_ptr->return_code != ESLURM_USER_ID_MISSING) {
-		fprintf(stderr, "Wrong response code: %u\n", 
-			slurm_rc_msg_ptr->return_code);
-		return SLURM_ERROR;
-	}
-
-	printf("Authentication failure (as expected).\n");
-	return SLURM_SUCCESS;
-}
-
-static void _detailed_logs(char *prog_name) 
-{
-#if DEBUG
-	log_options_t logopts = LOG_OPTS_STDERR_ONLY;
-	logopts.stderr_level = LOG_LEVEL_DEBUG3;
-	log_init(prog_name, logopts, SYSLOG_FACILITY_DAEMON, NULL);
-#endif
-}
-
-static void _usage(char *prog_name)
-{
-	printf("Usage: %s host_name\n", prog_name);
-}
-- 
GitLab