From 3b03cb9ecacc73d930d414bf3dedd264427705d2 Mon Sep 17 00:00:00 2001 From: eabdullin Date: Wed, 28 Aug 2024 00:10:07 +0000 Subject: [PATCH 1/3] import UBI sos-4.7.2-2.el8_10 --- .gitignore | 2 +- .sos.metadata | 2 +- SOURCES/sos-RHEL-22732-reverted.patch | 77 +++++++++++++++++++ .../sos-RHEL-35945-sos-clean-on-archive.patch | 30 -------- SPECS/sos.spec | 20 +++-- 5 files changed, 94 insertions(+), 37 deletions(-) create mode 100644 SOURCES/sos-RHEL-22732-reverted.patch delete mode 100644 SOURCES/sos-RHEL-35945-sos-clean-on-archive.patch diff --git a/.gitignore b/.gitignore index 4aaeab5..6236213 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,2 @@ -SOURCES/sos-4.7.1.tar.gz +SOURCES/sos-4.7.2.tar.gz SOURCES/sos-audit-0.3.tgz diff --git a/.sos.metadata b/.sos.metadata index 273af72..961606c 100644 --- a/.sos.metadata +++ b/.sos.metadata @@ -1,2 +1,2 @@ -9ced981872d308e13c5dc47fee21071592ceefc2 SOURCES/sos-4.7.1.tar.gz +e01a25f05322cf56b75e07b5102dd61dbd4f0869 SOURCES/sos-4.7.2.tar.gz 9d478b9f0085da9178af103078bbf2fd77b0175a SOURCES/sos-audit-0.3.tgz diff --git a/SOURCES/sos-RHEL-22732-reverted.patch b/SOURCES/sos-RHEL-22732-reverted.patch new file mode 100644 index 0000000..2738138 --- /dev/null +++ b/SOURCES/sos-RHEL-22732-reverted.patch @@ -0,0 +1,77 @@ +From 11879fbb1adc33d8abc0cb70dc63e7e88c39fc3f Mon Sep 17 00:00:00 2001 +From: Jose Castillo +Date: Wed, 21 Feb 2024 12:24:37 +0000 +Subject: [PATCH] [redhat|policy] Check for archive size before upload + +The Red Hat Customer Portal has a max limit for +single http requests of 1Gb. From sos side, we never checked this +and so customers had to wait for the whole upload to be attempted +before receiving an error from the portal. +This patch attempts to stop the upload before it starts, informing +customers of such limit, and switching to secure FTP where there's +no limit. + +Related: RHEL-22732 + +Signed-off-by: Jose Castillo +--- + sos/policies/distros/redhat.py | 29 +++++++++++++++++++++++------ + 1 file changed, 23 insertions(+), 6 deletions(-) + +diff --git a/sos/policies/distros/redhat.py b/sos/policies/distros/redhat.py +index edea151e2..2fb0df3fa 100644 +--- a/sos/policies/distros/redhat.py ++++ b/sos/policies/distros/redhat.py +@@ -22,7 +22,7 @@ + from sos.policies.package_managers.rpm import RpmPackageManager + from sos.policies.package_managers.flatpak import FlatpakPackageManager + from sos.policies.package_managers import MultiPackageManager +-from sos.utilities import bold ++from sos.utilities import bold, convert_bytes + from sos import _sos as _ + + try: +@@ -232,6 +232,8 @@ class RHELPolicy(RedHatPolicy): + _upload_url = RH_SFTP_HOST + _upload_method = 'post' + _device_token = None ++ # Max size for an http single request is 1Gb ++ _max_size_request = 1073741824 + + def __init__(self, sysroot=None, init=None, probe_runtime=True, + remote_exec=None): +@@ -429,15 +429,30 @@ support representative. + return super().upload_sftp(user=_user, password=_token) + raise Exception("Could not retrieve valid or anonymous credentials") + ++ def check_file_too_big(self, archive): ++ size = os.path.getsize(archive) ++ # Lets check if the size is bigger than the limit. ++ # There's really no need to transform the size to Gb, ++ # so we don't need to call any size converter implemented ++ # in tools.py ++ if (size >= self._max_size_request): ++ self.ui_log.warning( ++ _("Size of archive is bigger than Red Hat Customer Portal " ++ "limit for uploads of " ++ f"{convert_bytes(self._max_size_request)} " ++ " via sos http upload. \n") ++ ) ++ return RH_SFTP_HOST ++ else: ++ return RH_API_HOST ++ + def upload_archive(self, archive): + """Override the base upload_archive to provide for automatic failover + from RHCP failures to the public RH dropbox + """ + try: +- if self.upload_url and self.upload_url.startswith(RH_API_HOST) and\ +- (not self.get_upload_user() or +- not self.get_upload_password()): +- self.upload_url = RH_SFTP_HOST ++ if self.get_upload_url().startswith(RH_API_HOST): ++ self.upload_url = self.check_file_too_big(archive) + uploaded = super().upload_archive(archive) + except Exception as e: + uploaded = False diff --git a/SOURCES/sos-RHEL-35945-sos-clean-on-archive.patch b/SOURCES/sos-RHEL-35945-sos-clean-on-archive.patch deleted file mode 100644 index ddfeaca..0000000 --- a/SOURCES/sos-RHEL-35945-sos-clean-on-archive.patch +++ /dev/null @@ -1,30 +0,0 @@ -From a0c2586e230c9600d3d3f70ab89c9f6eb52ed3ed Mon Sep 17 00:00:00 2001 -From: Pavel Moravec -Date: Tue, 23 Apr 2024 11:00:11 +0200 -Subject: [PATCH] [archive] Fix get_archive_root after files reordering - -Commit d5d8c21 reordered files in the archive, such that the first -member is not the archive root directory further more. Let change the -get_archive_root method accordingly to prevent self.archive_root being -empty. - -Resolves: #3616 - -Signed-off-by: Pavel Moravec ---- - sos/cleaner/archives/__init__.py | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/sos/cleaner/archives/__init__.py b/sos/cleaner/archives/__init__.py -index f7c5eb587..0fa1ef43f 100644 ---- a/sos/cleaner/archives/__init__.py -+++ b/sos/cleaner/archives/__init__.py -@@ -104,7 +104,7 @@ def get_archive_root(self): - if toplevel.isdir(): - return toplevel.name - else: -- return os.sep -+ return os.path.dirname(toplevel.name) or os.sep - return os.path.abspath(self.archive_path) - - def report_msg(self, msg): diff --git a/SPECS/sos.spec b/SPECS/sos.spec index c1d2b89..1ddddd8 100644 --- a/SPECS/sos.spec +++ b/SPECS/sos.spec @@ -4,8 +4,8 @@ Summary: A set of tools to gather troubleshooting information from a system Name: sos -Version: 4.7.1 -Release: 3%{?dist} +Version: 4.7.2 +Release: 2%{?dist} Group: Applications/System Source0: https://github.com/sosreport/sos/archive/%{version}/sos-%{version}.tar.gz Source1: sos-audit-%{auditversion}.tgz @@ -22,7 +22,7 @@ Recommends: python3-pexpect Recommends: python3-pyyaml Conflicts: vdsm < 4.40 Obsoletes: sos-collector -Patch1: sos-RHEL-35945-sos-clean-on-archive.patch +Patch0: sos-RHEL-22732-reverted.patch %description Sos is a set of tools that gathers information about system @@ -33,11 +33,11 @@ support technicians and developers. %prep %setup -qn %{name}-%{version} %setup -T -D -a1 -q -%patch1 -p1 +%patch0 -p1 -R %build -%py3_build +%py3_build %install %py3_install '--install-scripts=%{_sbindir}' @@ -107,6 +107,16 @@ of the system. Currently storage and filesystem commands are audited. %ghost /etc/audit/rules.d/40-sos-storage.rules %changelog +* Wed Aug 21 2024 Pavel Moravec = 4.7.2-2 +- reverting RHEL-22732 patch due to regressions + Resolves: RHEL-49779 + +* Fri Jun 21 2024 Pierguido Lambri = 4.7.2-1 +- New upstream release + Resolves: RHEL-40871 + Resolves: RHEL-33703 + Resolves: RHEL-22732 + * Thu May 09 2024 Pavel Moravec = 4.7.1-3 - [archive] Fix get_archive_root after files reordering Resolves: RHEL-35945 From c37e46b1d46bf634a85551fc6dfca4e3a74e8896 Mon Sep 17 00:00:00 2001 From: eabdullin Date: Mon, 2 Dec 2024 12:27:45 +0000 Subject: [PATCH 2/3] import UBI sos-4.8.1-1.el8_10 --- .gitignore | 2 +- .sos.metadata | 2 +- SOURCES/sos-RHEL-22732-reverted.patch | 77 --------------------------- SPECS/sos.spec | 23 ++++++-- 4 files changed, 20 insertions(+), 84 deletions(-) delete mode 100644 SOURCES/sos-RHEL-22732-reverted.patch diff --git a/.gitignore b/.gitignore index 6236213..bdf5bc2 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,2 @@ -SOURCES/sos-4.7.2.tar.gz +SOURCES/sos-4.8.1.tar.gz SOURCES/sos-audit-0.3.tgz diff --git a/.sos.metadata b/.sos.metadata index 961606c..266190d 100644 --- a/.sos.metadata +++ b/.sos.metadata @@ -1,2 +1,2 @@ -e01a25f05322cf56b75e07b5102dd61dbd4f0869 SOURCES/sos-4.7.2.tar.gz +26aee6ec0ad73c12a4ad0cf50c02082777d654cc SOURCES/sos-4.8.1.tar.gz 9d478b9f0085da9178af103078bbf2fd77b0175a SOURCES/sos-audit-0.3.tgz diff --git a/SOURCES/sos-RHEL-22732-reverted.patch b/SOURCES/sos-RHEL-22732-reverted.patch deleted file mode 100644 index 2738138..0000000 --- a/SOURCES/sos-RHEL-22732-reverted.patch +++ /dev/null @@ -1,77 +0,0 @@ -From 11879fbb1adc33d8abc0cb70dc63e7e88c39fc3f Mon Sep 17 00:00:00 2001 -From: Jose Castillo -Date: Wed, 21 Feb 2024 12:24:37 +0000 -Subject: [PATCH] [redhat|policy] Check for archive size before upload - -The Red Hat Customer Portal has a max limit for -single http requests of 1Gb. From sos side, we never checked this -and so customers had to wait for the whole upload to be attempted -before receiving an error from the portal. -This patch attempts to stop the upload before it starts, informing -customers of such limit, and switching to secure FTP where there's -no limit. - -Related: RHEL-22732 - -Signed-off-by: Jose Castillo ---- - sos/policies/distros/redhat.py | 29 +++++++++++++++++++++++------ - 1 file changed, 23 insertions(+), 6 deletions(-) - -diff --git a/sos/policies/distros/redhat.py b/sos/policies/distros/redhat.py -index edea151e2..2fb0df3fa 100644 ---- a/sos/policies/distros/redhat.py -+++ b/sos/policies/distros/redhat.py -@@ -22,7 +22,7 @@ - from sos.policies.package_managers.rpm import RpmPackageManager - from sos.policies.package_managers.flatpak import FlatpakPackageManager - from sos.policies.package_managers import MultiPackageManager --from sos.utilities import bold -+from sos.utilities import bold, convert_bytes - from sos import _sos as _ - - try: -@@ -232,6 +232,8 @@ class RHELPolicy(RedHatPolicy): - _upload_url = RH_SFTP_HOST - _upload_method = 'post' - _device_token = None -+ # Max size for an http single request is 1Gb -+ _max_size_request = 1073741824 - - def __init__(self, sysroot=None, init=None, probe_runtime=True, - remote_exec=None): -@@ -429,15 +429,30 @@ support representative. - return super().upload_sftp(user=_user, password=_token) - raise Exception("Could not retrieve valid or anonymous credentials") - -+ def check_file_too_big(self, archive): -+ size = os.path.getsize(archive) -+ # Lets check if the size is bigger than the limit. -+ # There's really no need to transform the size to Gb, -+ # so we don't need to call any size converter implemented -+ # in tools.py -+ if (size >= self._max_size_request): -+ self.ui_log.warning( -+ _("Size of archive is bigger than Red Hat Customer Portal " -+ "limit for uploads of " -+ f"{convert_bytes(self._max_size_request)} " -+ " via sos http upload. \n") -+ ) -+ return RH_SFTP_HOST -+ else: -+ return RH_API_HOST -+ - def upload_archive(self, archive): - """Override the base upload_archive to provide for automatic failover - from RHCP failures to the public RH dropbox - """ - try: -- if self.upload_url and self.upload_url.startswith(RH_API_HOST) and\ -- (not self.get_upload_user() or -- not self.get_upload_password()): -- self.upload_url = RH_SFTP_HOST -+ if self.get_upload_url().startswith(RH_API_HOST): -+ self.upload_url = self.check_file_too_big(archive) - uploaded = super().upload_archive(archive) - except Exception as e: - uploaded = False diff --git a/SPECS/sos.spec b/SPECS/sos.spec index 1ddddd8..d3b35f2 100644 --- a/SPECS/sos.spec +++ b/SPECS/sos.spec @@ -4,8 +4,8 @@ Summary: A set of tools to gather troubleshooting information from a system Name: sos -Version: 4.7.2 -Release: 2%{?dist} +Version: 4.8.1 +Release: 1%{?dist} Group: Applications/System Source0: https://github.com/sosreport/sos/archive/%{version}/sos-%{version}.tar.gz Source1: sos-audit-%{auditversion}.tgz @@ -22,7 +22,6 @@ Recommends: python3-pexpect Recommends: python3-pyyaml Conflicts: vdsm < 4.40 Obsoletes: sos-collector -Patch0: sos-RHEL-22732-reverted.patch %description Sos is a set of tools that gathers information about system @@ -33,8 +32,6 @@ support technicians and developers. %prep %setup -qn %{name}-%{version} %setup -T -D -a1 -q -%patch0 -p1 -R - %build %py3_build @@ -107,6 +104,22 @@ of the system. Currently storage and filesystem commands are audited. %ghost /etc/audit/rules.d/40-sos-storage.rules %changelog +* Wed Oct 23 2024 Jan Jansky = 4.8.1-1 +- Update to 4.8.1 in RHEL 8 + Resolves: RHEL-64160 + +* Fri Sep 27 2024 Jan Jansky = 4.8.0-3 +- Added credentials obfuscation from multiple files + Resolves: RHEL-58097 + +* Sat Sep 14 2024 Pierguido Lambri = 4.8.0-2 +- Resolves: RHEL-22732 + Fix wrong formatting + +* Mon Sep 09 2024 Pierguido Lambri = 4.8.0-1 +- New upstream release + Resolves: RHEL-58097 + * Wed Aug 21 2024 Pavel Moravec = 4.7.2-2 - reverting RHEL-22732 patch due to regressions Resolves: RHEL-49779 From d2bbec30bff01677cad1565a738e4a1c2ea1de04 Mon Sep 17 00:00:00 2001 From: Koichiro Iwao Date: Wed, 11 Dec 2024 18:13:49 +0900 Subject: [PATCH 3/3] Backport upstream patch to fix distro detection Obtained from: https://github.com/sosreport/sos/pull/3870 (cherry picked from commit 4ac73599d418bc4f34552708453587274b9189f9) --- SOURCES/sos-patch-upstream-3870.patch | 43 +++++++++++++++++++++++++++ SPECS/sos.spec | 12 +++++++- 2 files changed, 54 insertions(+), 1 deletion(-) create mode 100644 SOURCES/sos-patch-upstream-3870.patch diff --git a/SOURCES/sos-patch-upstream-3870.patch b/SOURCES/sos-patch-upstream-3870.patch new file mode 100644 index 0000000..c807edb --- /dev/null +++ b/SOURCES/sos-patch-upstream-3870.patch @@ -0,0 +1,43 @@ +From e2bd0d93a73c3613dd6eb758437fd54f72e83433 Mon Sep 17 00:00:00 2001 +From: Koichiro Iwao +Date: Wed, 11 Dec 2024 14:59:00 +0900 +Subject: [PATCH] [policies] Fix bug in distro identification + +Fixes a bug in #3764. + +A bug in the distro-identifying logic caused incorrect identification +of the distro as CentOS, Fedora, or RHEL under the following conditions: + +1. Distro inherits RedHatPolicy +2. Distro has either of /etc/{centos,fedora,redhat}-release +3. Policy file appears earlier than redhat.py in dictionary order + +The issue occurs because the distro-identifying logic relies on the +existence of the above os_release_file without examining its contents, +more than checking NAME or ID in the /etc/os-release file. As a result, +once /etc/{centos,fedora,redhat}-release is found, the contents of +/etc/os-release are never checked, leading to distro misidentification. + +At least AlmaLinux is affected by this bug. + +Signed-off-by: Koichiro Iwao +--- + sos/policies/distros/__init__.py | 5 ++++- + 1 file changed, 4 insertions(+), 1 deletion(-) + +diff --git a/sos/policies/distros/__init__.py b/sos/policies/distros/__init__.py +index 66970c72d..a2a07a91f 100644 +--- a/sos/policies/distros/__init__.py ++++ b/sos/policies/distros/__init__.py +@@ -164,7 +164,10 @@ def _check_release(content): + if remote: + return _check_release(remote) + # use the os-specific file primarily +- if os.path.isfile(cls.os_release_file): ++ # also check the symlink destination ++ if (os.path.isfile(cls.os_release_file) and ++ os.path.basename(cls.os_release_file) ++ == os.path.basename(os.path.realpath(cls.os_release_file))): + return True + # next check os-release for a NAME or ID value we expect + with open(OS_RELEASE, "r", encoding='utf-8') as f: diff --git a/SPECS/sos.spec b/SPECS/sos.spec index d3b35f2..157c13c 100644 --- a/SPECS/sos.spec +++ b/SPECS/sos.spec @@ -5,7 +5,7 @@ Summary: A set of tools to gather troubleshooting information from a system Name: sos Version: 4.8.1 -Release: 1%{?dist} +Release: 1%{?dist}.alma.1 Group: Applications/System Source0: https://github.com/sosreport/sos/archive/%{version}/sos-%{version}.tar.gz Source1: sos-audit-%{auditversion}.tgz @@ -23,6 +23,9 @@ Recommends: python3-pyyaml Conflicts: vdsm < 4.40 Obsoletes: sos-collector +# AlmaLinux patches +Patch1000: sos-patch-upstream-3870.patch + %description Sos is a set of tools that gathers information about system hardware and configuration. The information can then be used for @@ -33,6 +36,9 @@ support technicians and developers. %setup -qn %{name}-%{version} %setup -T -D -a1 -q +# AlmaLinux patches +%patch1000 -p1 + %build %py3_build @@ -104,6 +110,10 @@ of the system. Currently storage and filesystem commands are audited. %ghost /etc/audit/rules.d/40-sos-storage.rules %changelog +* Fri Dec 13 2024 Koichiro Iwao - 4.8.1-1.alma.1 +- Backport upstream patch to fix distro detection + Obtained from: https://github.com/sosreport/sos/pull/3870 + * Wed Oct 23 2024 Jan Jansky = 4.8.1-1 - Update to 4.8.1 in RHEL 8 Resolves: RHEL-64160