aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBryn M. Reeves <bmr@redhat.com>2013-10-30 12:02:51 +0000
committerBryn M. Reeves <bmr@redhat.com>2013-10-30 12:02:51 +0000
commit7bd32b25ec04164f33edd016a570aea1d5241f46 (patch)
treee029e94ed0083af34a66d292c2abec5fa7eaa1cb
parentcb95bc4059dc7e3c88071934c936c387f1829460 (diff)
downloadsos-7bd32b25ec04164f33edd016a570aea1d5241f46.tar.gz
Check for usable temporary directory
A user may override the sos temporary directory via --tmp-dir to a non-existent or unwritable location. Check for this before initialising temporary files and exit with an error message. Signed-off-by: Bryn M. Reeves <bmr@redhat.com>
-rw-r--r--sos/sosreport.py6
1 files changed, 6 insertions, 0 deletions
diff --git a/sos/sosreport.py b/sos/sosreport.py
index 88c67301..3fb60c70 100644
--- a/sos/sosreport.py
+++ b/sos/sosreport.py
@@ -534,6 +534,12 @@ class SoSReport(object):
self.policy = sos.policies.load()
self._is_root = self.policy.is_root()
self.tmpdir = self.policy.get_tmp_dir(self.opts.tmp_dir)
+ if not os.path.isdir(self.tmpdir) \
+ or not os.access(self.tmpdir, os.W_OK):
+ # write directly to stderr as logging is not initialised yet
+ sys.stderr.write("temporary directory %s " % self.tmpdir \
+ + "does not exist or is not writable\n")
+ self._exit(1)
self.tempfile_util = TempFileUtil(self.tmpdir)
self._set_directories()