Blame SOURCES/sos-bz1766915-interim-sysroot-forbidden-paths.patch

3c65ef
From 9a0ab16793a8388b2c3d3909fd3a087c5b6296d4 Mon Sep 17 00:00:00 2001
3c65ef
From: Pavel Moravec <pmoravec@redhat.com>
3c65ef
Date: Fri, 1 Nov 2019 12:13:23 -0400
3c65ef
Subject: [PATCH 01/10] [Plugin] remove invalid {strip/join}_sysroot()
3c65ef
3c65ef
Do not strip the sysroot path prefix when calling _do_copy_path()
3c65ef
for a symlink target and do not add the sysroot prefix when
3c65ef
testing for a forbidden path.
3c65ef
3c65ef
Related: #1842
3c65ef
3c65ef
Signed-off-by: Pavel Moravec <pmoravec@redhat.com>
3c65ef
Signed-off-by: Bryn M. Reeves <bmr@redhat.com>
3c65ef
---
3c65ef
 sos/plugins/__init__.py | 4 +---
3c65ef
 1 file changed, 1 insertion(+), 3 deletions(-)
3c65ef
3c65ef
diff --git a/sos/plugins/__init__.py b/sos/plugins/__init__.py
3c65ef
index e75ec82e..4f1b73ce 100644
3c65ef
--- a/sos/plugins/__init__.py
3c65ef
+++ b/sos/plugins/__init__.py
3c65ef
@@ -731,7 +731,7 @@ class Plugin(object):
3c65ef
 
3c65ef
         # skip recursive copying of symlink pointing to itself.
3c65ef
         if (absdest != srcpath):
3c65ef
-            self._do_copy_path(self.strip_sysroot(absdest))
3c65ef
+            self._do_copy_path(absdest)
3c65ef
         else:
3c65ef
             self._log_debug("link '%s' points to itself, skipping target..."
3c65ef
                             % linkdest)
3c65ef
@@ -758,8 +758,6 @@ class Plugin(object):
3c65ef
         return None
3c65ef
 
3c65ef
     def _is_forbidden_path(self, path):
3c65ef
-        if self.use_sysroot():
3c65ef
-            path = self.join_sysroot(path)
3c65ef
         return _path_in_path_list(path, self.forbidden_paths)
3c65ef
 
3c65ef
     def _copy_node(self, path, st):
3c65ef
-- 
3c65ef
2.21.0
3c65ef
3c65ef
3c65ef
From aeeebf126fc9fdb0fd8c3b01418bef742bce78c3 Mon Sep 17 00:00:00 2001
3c65ef
From: "Bryn M. Reeves" <bmr@redhat.com>
3c65ef
Date: Fri, 1 Nov 2019 12:22:51 -0400
3c65ef
Subject: [PATCH 02/10] [Plugin] fix destination paths in _do_copy_path()
3c65ef
3c65ef
The path used to copy special device nodes and directories in
3c65ef
_do_copy_path() should be the destination path in the archive
3c65ef
(without sysroot prefix), and not the source path in the host
3c65ef
file system that includes this prefix.
3c65ef
3c65ef
Related: #1842
3c65ef
3c65ef
Signed-off-by: Bryn M. Reeves <bmr@redhat.com>
3c65ef
---
3c65ef
 sos/plugins/__init__.py | 6 +++---
3c65ef
 1 file changed, 3 insertions(+), 3 deletions(-)
3c65ef
3c65ef
diff --git a/sos/plugins/__init__.py b/sos/plugins/__init__.py
3c65ef
index 4f1b73ce..60fbeaf7 100644
3c65ef
--- a/sos/plugins/__init__.py
3c65ef
+++ b/sos/plugins/__init__.py
3c65ef
@@ -651,9 +651,13 @@ class Plugin(object):
3c65ef
             self._copy_symlink(srcpath)
3c65ef
             return
3c65ef
         else:
3c65ef
-            if stat.S_ISDIR(st.st_mode) and os.access(srcpath, os.R_OK):
3c65ef
-                self._copy_dir(srcpath)
3c65ef
-                return
3c65ef
+             if stat.S_ISDIR(st.st_mode) and os.access(srcpath, os.R_OK):
3c65ef
+                 # copy empty directory
3c65ef
+                 if not os.listdir(srcpath):
3c65ef
+                     self.archive.add_dir(dest)
3c65ef
+                     return
3c65ef
+                 self._copy_dir(dest)
3c65ef
+                 return
3c65ef
 
3c65ef
         # handle special nodes (block, char, fifo, socket)
3c65ef
         if not (stat.S_ISREG(st.st_mode) or stat.S_ISDIR(st.st_mode)):
3c65ef
@@ -808,7 +808,7 @@ class Plugin(object):
3c65ef
             ntype = _node_type(st)
3c65ef
             self._log_debug("creating %s node at archive:'%s'"
3c65ef
                             % (ntype, dest))
3c65ef
-            self._copy_node(srcpath, st)
3c65ef
+            self._copy_node(dest, st)
3c65ef
             return
3c65ef
 
3c65ef
         # if we get here, it's definitely a regular file (not a symlink or dir)
3c65ef
-- 
3c65ef
2.21.0
3c65ef
3c65ef
3c65ef
From 05f3d5bda8f548459fabcd38f2d087d6ecef98a2 Mon Sep 17 00:00:00 2001
3c65ef
From: "Bryn M. Reeves" <bmr@redhat.com>
3c65ef
Date: Fri, 1 Nov 2019 12:25:09 -0400
3c65ef
Subject: [PATCH 03/10] [kernel] remove trailing directory globs in forbidden
3c65ef
 paths
3c65ef
3c65ef
Since the forbidden path test now uses an exact match the trailing
3c65ef
globs ("/some/directory/path/to/exclude/*") used to exclude trace
3c65ef
related directories from collection lead to a failure to properly
3c65ef
blacklist these files:
3c65ef
3c65ef
The glob is expanded, for e.g.:
3c65ef
3c65ef
  "/sys/kernel/debug/tracing/per_cpu/*"
3c65ef
3c65ef
Expands to unclude a 'cpuN' sub-directory for each CPU present on
3c65ef
the machine. These expanded paths are then added to the forbidden
3c65ef
paths list for the plugin:
3c65ef
3c65ef
  /sys/kernel/debug/tracing/per_cpu/cpu0
3c65ef
  /sys/kernel/debug/tracing/per_cpu/cpu1
3c65ef
  ...
3c65ef
3c65ef
When an attempt is made to collect the entire "per_cpu" directory
3c65ef
a check is made for the full "/sys/kernel/debug/tracing/per_cpu"
3c65ef
path against each entry in the forbidden paths list. Since this is
3c65ef
a prefix of the actual paths stored no match is returned and the
3c65ef
collection is permitted.
3c65ef
3c65ef
Remove the trailing globs from these directory paths and prevent
3c65ef
any collection of the directories they reference by the plugin.
3c65ef
3c65ef
Related: #1842
3c65ef
3c65ef
Signed-off-by: Bryn M. Reeves <bmr@redhat.com>
3c65ef
---
3c65ef
 sos/plugins/kernel.py | 6 +++---
3c65ef
 1 file changed, 3 insertions(+), 3 deletions(-)
3c65ef
3c65ef
diff --git a/sos/plugins/kernel.py b/sos/plugins/kernel.py
3c65ef
index 88b14689..5c852143 100644
3c65ef
--- a/sos/plugins/kernel.py
3c65ef
+++ b/sos/plugins/kernel.py
3c65ef
@@ -89,9 +89,9 @@ class Kernel(Plugin, RedHatPlugin, DebianPlugin, UbuntuPlugin):
3c65ef
         self.add_forbidden_path([
3c65ef
             '/sys/kernel/debug/tracing/trace_pipe',
3c65ef
             '/sys/kernel/debug/tracing/README',
3c65ef
-            '/sys/kernel/debug/tracing/trace_stat/*',
3c65ef
-            '/sys/kernel/debug/tracing/per_cpu/*',
3c65ef
-            '/sys/kernel/debug/tracing/events/*',
3c65ef
+            '/sys/kernel/debug/tracing/trace_stat',
3c65ef
+            '/sys/kernel/debug/tracing/per_cpu',
3c65ef
+            '/sys/kernel/debug/tracing/events',
3c65ef
             '/sys/kernel/debug/tracing/free_buffer',
3c65ef
             '/sys/kernel/debug/tracing/trace_marker',
3c65ef
             '/sys/kernel/debug/tracing/trace_marker_raw',
3c65ef
-- 
3c65ef
2.21.0
3c65ef
3c65ef
3c65ef
From 801c71b33dcfeaa980baa9f377b721bdd26aa5e8 Mon Sep 17 00:00:00 2001
3c65ef
From: "Bryn M. Reeves" <bmr@redhat.com>
3c65ef
Date: Fri, 1 Nov 2019 16:53:29 +0000
3c65ef
Subject: [PATCH 04/10] [tests] fix test_copy_dir_forbidden_path
3c65ef
3c65ef
Rather than call just Plugin.setup() and Plugin._do_copy_path(),
3c65ef
add an add_copy_spec() call to the mock plugin setup() method,
3c65ef
and invoke copying by calling the Plugin.collect() method.
3c65ef
3c65ef
Related: #1845
3c65ef
3c65ef
Signed-off-by: Bryn M. Reeves <bmr@redhat.com>
3c65ef
---
3c65ef
 tests/plugin_tests.py | 3 ++-
3c65ef
 1 file changed, 2 insertions(+), 1 deletion(-)
3c65ef
3c65ef
diff --git a/tests/plugin_tests.py b/tests/plugin_tests.py
3c65ef
index b8760429..6522fe14 100644
3c65ef
--- a/tests/plugin_tests.py
3c65ef
+++ b/tests/plugin_tests.py
3c65ef
@@ -81,6 +81,7 @@ class ForbiddenMockPlugin(Plugin):
3c65ef
     plugin_name = "forbidden"
3c65ef
 
3c65ef
     def setup(self):
3c65ef
+        self.add_copy_spec("tests")
3c65ef
         self.add_forbidden_path("tests")
3c65ef
 
3c65ef
 
3c65ef
@@ -235,7 +236,7 @@ class PluginTests(unittest.TestCase):
3c65ef
         })
3c65ef
         p.archive = MockArchive()
3c65ef
         p.setup()
3c65ef
-        p._do_copy_path("tests")
3c65ef
+        p.collect()
3c65ef
         self.assertEquals(p.archive.m, {})
3c65ef
 
3c65ef
 
3c65ef
-- 
3c65ef
2.21.0
3c65ef
3c65ef
3c65ef
From c4182ebd52af523261d2e7ef75affbb88eaf31fb Mon Sep 17 00:00:00 2001
3c65ef
From: "Bryn M. Reeves" <bmr@redhat.com>
3c65ef
Date: Mon, 4 Nov 2019 10:45:15 +0000
3c65ef
Subject: [PATCH 05/10] [Plugin] use correct source path when copying
3c65ef
 directories
3c65ef
3c65ef
Signed-off-by: Bryn M. Reeves <bmr@redhat.com>
3c65ef
---
3c65ef
 sos/plugins/__init__.py | 2 +-
3c65ef
 1 file changed, 1 insertion(+), 1 deletion(-)
3c65ef
3c65ef
diff --git a/sos/plugins/__init__.py b/sos/plugins/__init__.py
3c65ef
index 60fbeaf7..240fe9f1 100644
3c65ef
--- a/sos/plugins/__init__.py
3c65ef
+++ b/sos/plugins/__init__.py
3c65ef
@@ -656,7 +656,7 @@ class Plugin(object):
3c65ef
                  if not os.listdir(srcpath):
3c65ef
                      self.archive.add_dir(dest)
3c65ef
                      return
3c65ef
-                 self._copy_dir(dest)
3c65ef
+                 self._copy_dir(srcpath)
3c65ef
                  return
3c65ef
 
3c65ef
         # handle special nodes (block, char, fifo, socket)
3c65ef
-- 
3c65ef
2.21.0
3c65ef
3c65ef
3c65ef
From 68f4d7cc7adde00171af842b5bc808f41d888a87 Mon Sep 17 00:00:00 2001
3c65ef
From: "Bryn M. Reeves" <bmr@redhat.com>
3c65ef
Date: Mon, 4 Nov 2019 10:48:01 +0000
3c65ef
Subject: [PATCH 06/10] [Plugin] improve _copy_dir() variable naming
3c65ef
3c65ef
Directory entries found in _copy_dir() may be either files or
3c65ef
sub-directories: reflect this in the names of local variables.
3c65ef
3c65ef
Signed-off-by: Bryn M. Reeves <bmr@redhat.com>
3c65ef
---
3c65ef
 sos/plugins/__init__.py | 7 ++++---
3c65ef
 1 file changed, 4 insertions(+), 3 deletions(-)
3c65ef
3c65ef
diff --git a/sos/plugins/__init__.py b/sos/plugins/__init__.py
3c65ef
index 240fe9f1..1a1464c1 100644
3c65ef
--- a/sos/plugins/__init__.py
3c65ef
+++ b/sos/plugins/__init__.py
3c65ef
@@ -738,10 +738,11 @@ class Plugin(object):
3c65ef
 
3c65ef
     def _copy_dir(self, srcpath):
3c65ef
         try:
3c65ef
-            for afile in os.listdir(srcpath):
3c65ef
+            for name in os.listdir(srcpath):
3c65ef
                 self._log_debug("recursively adding '%s' from '%s'"
3c65ef
-                                % (afile, srcpath))
3c65ef
-                self._do_copy_path(os.path.join(srcpath, afile), dest=None)
3c65ef
+                                % (name, srcpath))
3c65ef
+                path = os.path.join(srcpath, name)
3c65ef
+                self._do_copy_path(path)
3c65ef
         except OSError as e:
3c65ef
             if e.errno == errno.ELOOP:
3c65ef
                 msg = "Too many levels of symbolic links copying"
3c65ef
-- 
3c65ef
2.21.0
3c65ef
3c65ef
3c65ef
From ad3adef07c32aee5bdd438706c6c1d4590ff8297 Mon Sep 17 00:00:00 2001
3c65ef
From: "Bryn M. Reeves" <bmr@redhat.com>
3c65ef
Date: Mon, 4 Nov 2019 14:13:00 +0000
3c65ef
Subject: [PATCH 07/10] [ceph] fix directory blacklist style
3c65ef
3c65ef
Plugins must use 'path/to/exclude' rather than 'path/to/exclude/*'
3c65ef
in order to omit a directory and all its content from the report.
3c65ef
3c65ef
Signed-off-by: Bryn M. Reeves <bmr@redhat.com>
3c65ef
---
3c65ef
 sos/plugins/ceph.py | 4 ++--
3c65ef
 1 file changed, 2 insertions(+), 2 deletions(-)
3c65ef
3c65ef
diff --git a/sos/plugins/ceph.py b/sos/plugins/ceph.py
3c65ef
index 6e340c69..43284bc8 100644
3c65ef
--- a/sos/plugins/ceph.py
3c65ef
+++ b/sos/plugins/ceph.py
3c65ef
@@ -103,8 +103,8 @@ class Ceph(Plugin, RedHatPlugin, UbuntuPlugin):
3c65ef
             "/var/lib/ceph/*keyring*",
3c65ef
             "/var/lib/ceph/*/*keyring*",
3c65ef
             "/var/lib/ceph/*/*/*keyring*",
3c65ef
-            "/var/lib/ceph/osd/*",
3c65ef
-            "/var/lib/ceph/mon/*",
3c65ef
+            "/var/lib/ceph/osd",
3c65ef
+            "/var/lib/ceph/mon",
3c65ef
             # Excludes temporary ceph-osd mount location like
3c65ef
             # /var/lib/ceph/tmp/mnt.XXXX from sos collection.
3c65ef
             "/var/lib/ceph/tmp/*mnt*",
3c65ef
-- 
3c65ef
2.21.0
3c65ef
3c65ef
3c65ef
From 4d1576b04d35902ce44d26d6a5b2219e6f9c175a Mon Sep 17 00:00:00 2001
3c65ef
From: "Bryn M. Reeves" <bmr@redhat.com>
3c65ef
Date: Mon, 4 Nov 2019 14:15:55 +0000
3c65ef
Subject: [PATCH 09/10] [openstack_octavia] fix directory blacklist style
3c65ef
3c65ef
Plugins must use 'path/to/exclude' rather than 'path/to/exclude/*'
3c65ef
in order to omit a directory and all its content from the report.
3c65ef
3c65ef
Signed-off-by: Bryn M. Reeves <bmr@redhat.com>
3c65ef
---
3c65ef
 sos/plugins/openstack_octavia.py | 2 +-
3c65ef
 1 file changed, 1 insertion(+), 1 deletion(-)
3c65ef
3c65ef
diff --git a/sos/plugins/openstack_octavia.py b/sos/plugins/openstack_octavia.py
3c65ef
index b97c83fa..ccdcd4c9 100644
3c65ef
--- a/sos/plugins/openstack_octavia.py
3c65ef
+++ b/sos/plugins/openstack_octavia.py
3c65ef
@@ -30,7 +30,7 @@ class OpenStackOctavia(Plugin):
3c65ef
         ])
3c65ef
 
3c65ef
         # don't collect certificates
3c65ef
-        self.add_forbidden_path("/etc/octavia/certs/")
3c65ef
+        self.add_forbidden_path("/etc/octavia/certs")
3c65ef
 
3c65ef
         # logs
3c65ef
         if self.get_option("all_logs"):
3c65ef
-- 
3c65ef
2.21.0
3c65ef
3c65ef
3c65ef
From 1fd194191a56c51052f0c24ddeb3bbf9088ae0ca Mon Sep 17 00:00:00 2001
3c65ef
From: "Bryn M. Reeves" <bmr@redhat.com>
3c65ef
Date: Mon, 4 Nov 2019 14:16:13 +0000
3c65ef
Subject: [PATCH 10/10] [vdsm] fix directory blacklist style
3c65ef
3c65ef
Plugins must use 'path/to/exclude' rather than 'path/to/exclude/*'
3c65ef
in order to omit a directory and all its content from the report.
3c65ef
3c65ef
Signed-off-by: Bryn M. Reeves <bmr@redhat.com>
3c65ef
---
3c65ef
 sos/plugins/vdsm.py | 4 ++--
3c65ef
 1 file changed, 2 insertions(+), 2 deletions(-)
3c65ef
3c65ef
diff --git a/sos/plugins/vdsm.py b/sos/plugins/vdsm.py
3c65ef
index b2a1ca58..69672643 100644
3c65ef
--- a/sos/plugins/vdsm.py
3c65ef
+++ b/sos/plugins/vdsm.py
3c65ef
@@ -60,9 +60,9 @@ class Vdsm(Plugin, RedHatPlugin):
3c65ef
     plugin_name = 'vdsm'
3c65ef
 
3c65ef
     def setup(self):
3c65ef
-        self.add_forbidden_path('/etc/pki/vdsm/keys/*')
3c65ef
+        self.add_forbidden_path('/etc/pki/vdsm/keys')
3c65ef
         self.add_forbidden_path('/etc/pki/vdsm/libvirt-spice/*-key.*')
3c65ef
-        self.add_forbidden_path('/etc/pki/libvirt/private/*')
3c65ef
+        self.add_forbidden_path('/etc/pki/libvirt/private')
3c65ef
 
3c65ef
         self.add_cmd_output('service vdsmd status')
3c65ef
         self.add_cmd_output('service supervdsmd status')
3c65ef
3c65ef
-- 
3c65ef
2.21.0
3c65ef