Blob Blame History Raw
From 5c5fde328585732923f3f0a8e966c4daaec3c7ed Mon Sep 17 00:00:00 2001
From: "Bryn M. Reeves" <bmr@redhat.com>
Date: Mon, 19 Jan 2015 18:54:09 +0000
Subject: [PATCH 51/93] [sosreport] add --sysroot option

Add a --sysroot=SYSROOT option to specify that the root file system to
be inspected is mounted at SYSROOT.

This allows basic support for container environments where sos is
running in a container and inspecting the containing host and its
environment ('superspection').

For this to work currently the following conditions must be met:

- sos is sufficiently privileged to read and search relevant file
  system paths within SYSROOT

- sos must share the PID and network namespace of the target host

- binaries called by sos must be present and executable in the
  SYSROOT inherited by sos. If PATH includes paths inside SYSROOT
  appropriate values must be set for LD_LIBRARY_PATH to allow
  shared executables to be linked.

Signed-off-by: Bryn M. Reeves <bmr@redhat.com>
---
 sos/sosreport.py | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/sos/sosreport.py b/sos/sosreport.py
index e83e718..edc9cba 100644
--- a/sos/sosreport.py
+++ b/sos/sosreport.py
@@ -514,6 +514,17 @@ class SoSOptions(object):
         self._report = value
 
     @property
+    def sysroot(self):
+        if self._options is not None:
+            return self._options.sysroot
+        return self._sysroot
+
+    @sysroot.setter
+    def sysroot(self, value):
+        self._check_options_initialized()
+        self._sysroot = value
+
+    @property
     def compression_type(self):
         if self._options is not None:
             return self._options.compression_type
@@ -598,6 +609,9 @@ class SoSOptions(object):
         parser.add_option("--no-report", action="store_true",
                           dest="report",
                           help="Disable HTML/XML reporting", default=False)
+        parser.add_option("-s", "--sysroot", action="store", dest="sysroot",
+                          help="system root directory path (default='/')",
+                          default="/")
         parser.add_option("-z", "--compression-type", dest="compression_type",
                           help="compression technology to use [auto, "
                                "gzip, bzip2, xz] (default=auto)",
-- 
1.9.3