From a01cbe9bd5f4d69a39d5a64ed725f0a9dfa5db39 Mon Sep 17 00:00:00 2001 From: "Christopher J. Morrone" <morrone2@llnl.gov> Date: Fri, 13 Jan 2006 01:51:13 +0000 Subject: [PATCH] Handle a couple of errors better --- testsuite/slurm_unit/slurmctld/security_2_1.py | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/testsuite/slurm_unit/slurmctld/security_2_1.py b/testsuite/slurm_unit/slurmctld/security_2_1.py index cd063577c36..8ca9a783eeb 100755 --- a/testsuite/slurm_unit/slurmctld/security_2_1.py +++ b/testsuite/slurm_unit/slurmctld/security_2_1.py @@ -27,11 +27,15 @@ def main(argv=None): options.prefix = '/usr/local' print 'Assuming installation prefix is "%s"' % (options.prefix) if options.conf is None: - options.conf = options.prefix + '/etc' + options.conf = options.prefix + '/etc/slurm.conf' print 'Assuming slurm conf file is "%s"' % (options.conf) # Parse the slurm.conf file - conf = open(options.conf, 'r') + try: + conf = open(options.conf, 'r') + except: + print >>sys.stderr, "Unable to open slurm configuration file", options.conf + return -3 for line in conf.readlines(): line = line.rstrip() line = line.split('#')[0] # eliminate comments @@ -114,7 +118,12 @@ def append_dir(l, d, key): def check_perms(filename, perm_bits): """Returns 'True' if the file's permissions contain the bits 'perm_bits'""" - perm = S_IMODE(os.stat(filename).st_mode) + try: + perm = S_IMODE(os.stat(filename).st_mode) + except: + print >>sys.stderr, 'ERROR: Unable to stat', filename + return True + if perm & perm_bits: print >>sys.stderr, 'ERROR: %s: %o has bits %.3o set' % (filename, perm, perm_bits) return True -- GitLab