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

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