aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBryn M. Reeves <bmr@redhat.com>2015-01-26 15:39:16 -0500
committerBryn M. Reeves <bmr@redhat.com>2015-07-08 17:05:22 +0100
commitf8a1746a871e560e548d21f1fc68067d452140a0 (patch)
treeb6c73648cda4339c89edb272ec8fe76a87af0b9c
parent63805ed15d63ddfebb06cd03f96f310bbf60d3b2 (diff)
downloadsos-f8a1746a871e560e548d21f1fc68067d452140a0.tar.gz
[sosreport] set SYSROOT by policy
If --sysroot is not given on the command line and Policy.in_container() is True set sysroot automatically if Policy.get_host_sysroot() is not '/'. Signed-off-by: Bryn M. Reeves <bmr@redhat.com>
-rw-r--r--sos/sosreport.py13
1 files changed, 10 insertions, 3 deletions
diff --git a/sos/sosreport.py b/sos/sosreport.py
index a0b89e78..835d8281 100644
--- a/sos/sosreport.py
+++ b/sos/sosreport.py
@@ -648,7 +648,7 @@ class SoSOptions(object):
help="Disable HTML/XML reporting", default=False)
parser.add_option("-s", "--sysroot", action="store", dest="sysroot",
help="system root directory path (default='/')",
- default="/")
+ default=None)
parser.add_option("-c", "--chroot", action="store", dest="chroot",
help="chroot executed commands to SYSROOT "
"[auto, always, never] (default=auto)",
@@ -705,11 +705,18 @@ class SoSReport(object):
self.tempfile_util = TempFileUtil(self.tmpdir)
self._set_directories()
+ self._setup_logging()
+
+ msg = "default"
+ host_sysroot = self.policy.host_sysroot()
# set alternate system root directory
if self.opts.sysroot:
+ msg = "cmdline"
self.sysroot = self.opts.sysroot
-
- self._setup_logging()
+ elif self.policy.in_container() and host_sysroot != os.sep:
+ msg = "policy"
+ self.sysroot = host_sysroot
+ self.soslog.debug("set sysroot to '%s' (%s)" % (self.sysroot, msg))
if self.opts.chroot not in chroot_modes:
self.soslog.error("invalid chroot mode: %s" % self.opts.chroot)