Bug 2218279

Summary: sos clean - Respect permissions of sanitised files
Product: Red Hat Enterprise Linux 8 Reporter: Jan Jansky <jjansky>
Component: sosAssignee: Pavel Moravec <pmoravec>
Status: CLOSED ERRATA QA Contact: Daniel Záležák <dzalezak>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 8.8CC: agk, dzalezak, jcastillo, jjansky, mhradile, pgm-rhel-tools, plambri, sbradley, theute, toneata
Target Milestone: rcKeywords: Triaged, ZStream
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: sos-4.5.5-2.el8 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of:
: 2221104 (view as bug list) Environment:
Last Closed: 2023-07-26 08:37:56 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On:    
Bug Blocks: 2221104    

Description Jan Jansky 2023-06-28 14:30:19 UTC
Description of problem:
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).

Version-Release number of selected component (if applicable):
4.5.5

Comment 2 Pavel Moravec 2023-06-28 14:52:39 UTC
Trivial reproducer:

1) Ensure /etc/hosts has system's FQDN, e.g. add there:

echo $(ip a | grep -v "127.0.0.1/8" | grep -m1 "inet " | cut -d/ -f1 | awk '{ print $2 }') $(hostname -f) $(hostname -s) >> /etc/hosts

2) Run:
# sos report --clean -o networking --batch --build
..
Your sosreport build tree has been generated in:
	/var/tmp/sosreport-host4-8675309-2023-06-28-cxezxnp

3) Compare permissions:
# ll /etc/hosts /var/tmp/sosreport-host4-8675309-2023-06-28-cxezxnp/etc/hosts
-rw-r--r--. 1 root root 1134 Jun 12 08:37 /etc/hosts
-rw-------. 1 root root  798 Jun 28 16:49 /var/tmp/sosreport-host4-8675309-2023-06-28-cxezxnp/etc/hosts
#

See the missing go+r flags.

Comment 3 Daniel Záležák 2023-07-05 18:46:29 UTC
Switched Tested based on positive results from manual test:

OLD
RHEL-8.9
x86_64
sos-4.5.1-3.el8.noarch

# echo $(ip a | grep -v "127.0.0.1/8" | grep -m1 "inet " | cut -d/ -f1 | awk '{ print $2 }') $(hostname -f) $(hostname -s) >> /etc/hosts
# sos report --clean -o networking --batch --build
# ll /etc/hosts /var/tmp/sosreport-host0-2023-07-05-ihejuje/etc/host66
-rw-r--r--. 1 root root 304 Jul  5 14:35 /etc/hosts
-rw-------. 1 root root 202 Jul  5 14:29 /var/tmp/sosreport-host0-2023-07-05-ihejuje/etc/host66

``````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````````

NEW
RHEL-8.9
x86_64
sos-4.5.5-1.el8.noarch

# echo $(ip a | grep -v "127.0.0.1/8" | grep -m1 "inet " | cut -d/ -f1 | awk '{ print $2 }') $(hostname -f) $(hostname -s) >> /etc/hosts
# sos report --clean -o networking --batch --build
# ll /etc/hosts /var/tmp/sosreport-host0-2023-07-05-peqncnf/etc/host66
-rw-r--r--. 1 root root 377 Jul  5 14:37 /etc/hosts
-rw-r--r--. 1 root root 290 Jul  5 14:37 /var/tmp/sosreport-host0-2023-07-05-peqncnf/etc/host66

Comment 6 Jan Jansky 2023-07-19 07:09:26 UTC
*** Bug 2221104 has been marked as a duplicate of this bug. ***

Comment 10 errata-xmlrpc 2023-07-26 08:37:56 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory (sos bug fix and enhancement update), and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHBA-2023:4279