From bf5f46c3d597c3914ba8fa138e172aa5db10ede2 Mon Sep 17 00:00:00 2001 From: Steven Hiscocks Date: Wed, 30 Jan 2013 19:57:03 +0000 Subject: [PATCH 1/2] Warn if config file present but unreadable --- client/configreader.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/client/configreader.py b/client/configreader.py index 063484e8..e435b254 100644 --- a/client/configreader.py +++ b/client/configreader.py @@ -59,6 +59,16 @@ class ConfigReader(SafeConfigParserWithIncludes): bConf = basename + ".conf" bLocal = basename + ".local" if os.path.exists(bConf) or os.path.exists(bLocal): + if not os.access(bConf, os.R_OK) and not os.access(bLocal, os.R_OK): + logSys.warning( + "Unable to read either \"%s\" or \"%s\"" % (bConf, bLocal)) + return False + elif os.path.exists(bConf) and not os.access(bConf, os.R_OK): + logSys.warning( + "\"%s\" read, but unable to read \"%s\"" % (bLocal, bConf)) + elif os.path.exists(bLocal) and not os.access(bLocal, os.R_OK): + logSys.warning( + "\"%s\" read, but unable to read \"%s\"" % (bConf, bLocal)) SafeConfigParserWithIncludes.read(self, [bConf, bLocal]) return True else: From 9c2e0cbbc86569108fd729c9710e42b96b1c03fa Mon Sep 17 00:00:00 2001 From: Steven Hiscocks Date: Thu, 31 Jan 2013 18:36:23 +0000 Subject: [PATCH 2/2] Fix up for warning/error for inaccessible config files --- client/configreader.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/client/configreader.py b/client/configreader.py index e435b254..4e783ebb 100644 --- a/client/configreader.py +++ b/client/configreader.py @@ -60,8 +60,13 @@ class ConfigReader(SafeConfigParserWithIncludes): bLocal = basename + ".local" if os.path.exists(bConf) or os.path.exists(bLocal): if not os.access(bConf, os.R_OK) and not os.access(bLocal, os.R_OK): - logSys.warning( - "Unable to read either \"%s\" or \"%s\"" % (bConf, bLocal)) + if os.path.exists(bConf) and not os.path.exists(bLocal): + logSys.error("Unable to read \"%s\" " % bConf) + elif os.path.exists(bLocal) and not os.path.exists(bConf): + logSys.error("Unable to read \"%s\" " % bLocal) + else: + logSys.error( + "Unable to read \"%s\" and \"%s\"" % (bConf, bLocal)) return False elif os.path.exists(bConf) and not os.access(bConf, os.R_OK): logSys.warning(