sos updates to 9.3

Resolves: bz2217943

Signed-off-by: Jan Jansky <jjansky@redhat.com>
This commit is contained in:
Jan Jansky 2023-07-03 15:05:52 +02:00
parent 202ea4ca33
commit 0a59a91eda
4 changed files with 102 additions and 3 deletions

1
.gitignore vendored
View File

@ -20,3 +20,4 @@ sos-2.2.tar.gz
/sos-4.5.0.tar.gz
/sos-4.5.1.tar.gz
/sos-4.5.3.tar.gz
/sos-4.5.5.tar.gz

View File

@ -0,0 +1,93 @@
From cca04c1e1fdc97632cdefdc1d1d7a3dea9cb4aea Mon Sep 17 00:00:00 2001
From: Pavel Moravec <pmoravec@redhat.com>
Date: Wed, 28 Jun 2023 11:49:56 +0200
Subject: [PATCH 1/2] [clean] Respect permissions of sanitised files
When copying files we applied a substitution in, we must replace just
original file content (shutil.copyfile) and not also its stat data
(shutil.copy).
Resolves: #3292
Signed-off-by: Pavel Moravec <pmoravec@redhat.com>
---
sos/cleaner/__init__.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/sos/cleaner/__init__.py b/sos/cleaner/__init__.py
index feeedf66..fbcaa9c3 100644
--- a/sos/cleaner/__init__.py
+++ b/sos/cleaner/__init__.py
@@ -778,7 +778,7 @@ third party.
% (short_name, err), caller=arc_name)
tfile.seek(0)
if subs:
- shutil.copy(tfile.name, filename)
+ shutil.copyfile(tfile.name, filename)
tfile.close()
_ob_short_name = self.obfuscate_string(short_name.split('/')[-1])
--
2.31.1
From fc1489a621108d3613d3337489a64950e52d77c3 Mon Sep 17 00:00:00 2001
From: Pavel Moravec <pmoravec@redhat.com>
Date: Thu, 29 Jun 2023 22:57:46 +0200
Subject: [PATCH 2/2] [tests] add test for #3292
Add a test that cleaner keeps permissions of a sanitised file
Relevant to: #3292
Signed-off-by: Pavel Moravec <pmoravec@redhat.com>
---
.../basic_function_tests/report_with_mask.py | 18 ++++++++++++++++++
1 file changed, 18 insertions(+)
diff --git a/tests/cleaner_tests/basic_function_tests/report_with_mask.py b/tests/cleaner_tests/basic_function_tests/report_with_mask.py
index 7c4d3905..baee836a 100644
--- a/tests/cleaner_tests/basic_function_tests/report_with_mask.py
+++ b/tests/cleaner_tests/basic_function_tests/report_with_mask.py
@@ -9,6 +9,7 @@
from sos_tests import StageOneReportTest, StageTwoReportTest
import re
+from os import stat
class ReportWithMask(StageOneReportTest):
@@ -18,6 +19,17 @@ class ReportWithMask(StageOneReportTest):
"""
sos_cmd = '--mask -o host,networking'
+ hosts_obfuscated = None
+
+ def pre_sos_setup(self):
+ # obfuscate a random word from /etc/hosts and ensure the updated
+ # sanitised file has same permissions (a+r)
+ try:
+ self.hosts_obfuscated = open('/etc/hosts').read().strip('#\n').split()[-1]
+ except (FileNotFoundError, IndexError) as e:
+ self.warning(f"Unable to process /etc/hosts: {e}")
+ if self.hosts_obfuscated:
+ self.sos_cmd += f' --keywords={self.hosts_obfuscated}'
def test_mask_was_run(self):
self.assertOutputContains('Beginning obfuscation')
@@ -53,6 +65,12 @@ class ReportWithMask(StageOneReportTest):
mac = line.strip().split()[1]
assert mac.startswith('53:4f:53'), "Found unobfuscated mac addr %s" % mac
+ def test_perms_unchanged_on_modified_file(self):
+ if self.hosts_obfuscated:
+ imode_orig = stat('/etc/hosts').st_mode
+ imode_obfuscated = stat(self.get_name_in_archive('etc/hosts')).st_mode
+ self.assertEqual(imode_orig, imode_obfuscated)
+
class ReportWithCleanedKeywords(StageOneReportTest):
"""Testing for obfuscated keywords provided by the user
--
2.31.1

View File

@ -4,7 +4,7 @@
Summary: A set of tools to gather troubleshooting information from a system
Name: sos
Version: 4.5.4
Version: 4.5.5
Release: 1%{?dist}
Group: Applications/System
Source0: https://github.com/sosreport/sos/archive/%{version}/sos-%{version}.tar.gz
@ -22,7 +22,7 @@ Recommends: python3-pexpect
Recommends: python3-pyyaml
Conflicts: vdsm < 4.40
Obsoletes: sos-collector <= 1.9
Patch1: sos-bz2218279-clean-respect-permissions.patch
%description
Sos is a set of tools that gathers information about system
@ -33,6 +33,7 @@ support technicians and developers.
%prep
%setup -qn %{name}-%{version}
%setup -T -D -a1 -q
%patch1 -p1
%build
@ -106,6 +107,10 @@ of the system. Currently storage and filesystem commands are audited.
%changelog
* Mon Jul 03 2023 Jan Jansky <jjansky@redhat.com> = 4.5.5-1
- Rebase on upstream 4.5.5
Resolves: bz2217943
* Tue May 31 2023 Pavel Moravec <pmoravec@redhat.com> = 4.5.4-1
- [specfile] add runtime requirement to python3-setuptools
Resolves: bz2207776

View File

@ -1,2 +1,2 @@
SHA512 (sos-4.5.4.tar.gz) = a883e277c749ad053d763b57e50d83f577d67dad76cc4307e08854361fb0046b4222c64a69daba0258cf3acef8ccb7b4e905a86feb143805f96be5c09ece2c9f
SHA512 (sos-4.5.5.tar.gz) = 6731d2b9671350eeb8dd738516fa484f2b8a3eb17e9caef9ade1aeee1fe581a67e4c2ea0cc8e89838770ffc85f052e0dd6422f2121efb4a99728b1e865780c50
SHA512 (sos-audit-0.3.tgz) = 32597baf6350804d08179a0dbe48470a93df148e83d2e49bb3288f6bcc2d151bb1433761913bfbccd912c14de92435939fef5bcd7e091dfe33a345d61ea842ea