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

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