commit 0c9eef9d1270b9197a609ac46fdd5837c04a90dd Author: Bryn M. Reeves Date: Wed Oct 30 12:02:51 2013 +0000 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 diff --git a/sos/sosreport.py b/sos/sosreport.py index 88c6730..3fb60c7 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()