Blame SOURCES/sos-bz2176218-sos-clean-tmp.patch

f3f61a
From d4d4d5509fe4f0e29260b33a1c51bf62297ef0b9 Mon Sep 17 00:00:00 2001
f3f61a
From: Pavel Moravec <pmoravec@redhat.com>
f3f61a
Date: Tue, 7 Mar 2023 13:16:02 +0100
f3f61a
Subject: [PATCH 1/2] [cleaner] dont clean sys_tmp from final_path
f3f61a
f3f61a
When generating location of final tarball, apply cleaner obfuscation to
f3f61a
the filename but not to the tmp path itself. Otherwise
f3f61a
f3f61a
sos clean --keywords tmp
f3f61a
f3f61a
fails in attempt to move file to nonexisting /var/obfuscatedword0
f3f61a
directory.
f3f61a
f3f61a
Resolves: #3160
f3f61a
f3f61a
Signed-off-by: Pavel Moravec <pmoravec@redhat.com>
f3f61a
---
f3f61a
 sos/cleaner/__init__.py | 5 +++--
f3f61a
 1 file changed, 3 insertions(+), 2 deletions(-)
f3f61a
f3f61a
diff --git a/sos/cleaner/__init__.py b/sos/cleaner/__init__.py
f3f61a
index d3e32992..b8e4aafd 100644
f3f61a
--- a/sos/cleaner/__init__.py
f3f61a
+++ b/sos/cleaner/__init__.py
f3f61a
@@ -400,8 +400,9 @@ third party.
f3f61a
                     cf.write(checksum)
f3f61a
             self.write_cleaner_log()
f3f61a
 
f3f61a
-        final_path = self.obfuscate_string(
f3f61a
-            os.path.join(self.sys_tmp, arc_path.split('/')[-1])
f3f61a
+        final_path = os.path.join(
f3f61a
+            self.sys_tmp,
f3f61a
+            self.obfuscate_string(arc_path.split('/')[-1])
f3f61a
         )
f3f61a
         shutil.move(arc_path, final_path)
f3f61a
         arcstat = os.stat(final_path)
f3f61a
-- 
f3f61a
2.39.2
f3f61a
f3f61a
f3f61a
From 622a26ee2faff91df03532892ca386c39e36a5fe Mon Sep 17 00:00:00 2001
f3f61a
From: Pavel Moravec <pmoravec@redhat.com>
f3f61a
Date: Tue, 7 Mar 2023 17:55:19 +0100
f3f61a
Subject: [PATCH 2/2] [tests] add a test covering #3160
f3f61a
f3f61a
Run the cleaner tests with obfuscating (also) "tmp" to cover files
f3f61a
handling under sys_tmp.
f3f61a
f3f61a
Related to: #3160
f3f61a
f3f61a
Signed-off-by: Pavel Moravec <pmoravec@redhat.com>
f3f61a
---
f3f61a
 tests/cleaner_tests/existing_archive.py | 19 +++++++++++++++++++
f3f61a
 1 file changed, 19 insertions(+)
f3f61a
f3f61a
diff --git a/tests/cleaner_tests/existing_archive.py b/tests/cleaner_tests/existing_archive.py
f3f61a
index e13d1cae..7f31f88e 100644
f3f61a
--- a/tests/cleaner_tests/existing_archive.py
f3f61a
+++ b/tests/cleaner_tests/existing_archive.py
f3f61a
@@ -89,3 +89,22 @@ class ExistingArchiveCleanTest(StageTwoReportTest):
f3f61a
         """Ensure that the 'testuser1' user created at install is obfuscated
f3f61a
         """
f3f61a
         self.assertFileNotHasContent('var/log/anaconda/journal.log', 'testuser1')
f3f61a
+
f3f61a
+class ExistingArchiveCleanTmpTest(StageTwoReportTest):
f3f61a
+    """Continuation of above tests which requires cleaning var / tmp keywords
f3f61a
+
f3f61a
+    Note that this copies heavily from the full_report_run test.
f3f61a
+
f3f61a
+    :avocado: tags=stagetwo
f3f61a
+    """
f3f61a
+
f3f61a
+    sos_cmd = '-v --keywords var,tmp,avocado --disable-parsers ip,ipv6,mac,username \
f3f61a
+        --no-update tests/test_data/%s.tar.xz' % ARCHIVE
f3f61a
+    sos_component = 'clean'
f3f61a
+
f3f61a
+    def test_sys_tmp_not_obfuscated(self):
f3f61a
+        """ Ensure that keywords var, tmp and avocado remains in the final archive
f3f61a
+        path despite they are parts of the --tmp-dir
f3f61a
+        """
f3f61a
+        self.assertTrue(self.archive.startswith(os.getenv('AVOCADO_TESTS_COMMON_TMPDIR')))
f3f61a
+
f3f61a
-- 
f3f61a
2.39.2
f3f61a