Bug 1929267

Summary: cleaner - default hostname not obfuscated unless host plugin ran
Product: Red Hat Enterprise Linux 8 Reporter: Miroslav Hradílek <mhradile>
Component: sosAssignee: Pavel Moravec <pmoravec>
Status: CLOSED ERRATA QA Contact: Miroslav Hradílek <mhradile>
Severity: medium Docs Contact:
Priority: medium    
Version: 8.4CC: agk, bmr, jhunsaker, plambri, sbradley, theute
Target Milestone: rc   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: sos-4.1-1.el8 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2021-11-09 19:36:07 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:

Description Miroslav Hradílek 2021-02-16 15:31:58 UTC
Description of problem:
Default hostname obfuscation provided by "sos clean" only works when sosreport contains files from "host" plugin of "sos report" component.

The cleanup is not performed despite default mapping containing the obfuscation of such hostname. Usage of the default mapping is confirmed by such hostname being included even in private mapping produced by cleaner run.

Version-Release number of selected component (if applicable):
sos-4.0-7.el8.noarch

How reproducible:
100%

Steps to Reproduce:
# rpm -q sos
sos-4.0-7.el8.noarch
# hostname
sostesthost.sossubdomain.redhat.com


# mkdir /etc/sos/cleaner/ # Overcome BZ#1923937
# sosreport -o logs -o host --batch
. . .
# tar -xf /var/tmp/sosreport-sostesthost-2021-02-16-iktgdbf.tar.xz
# cat sosreport-sostesthost-2021-02-16-iktgdbf/sos_commands/host/hostname
sostesthost.sossubdomain.redhat.com
# tail -n 2 sosreport-sostesthost-2021-02-16-iktgdbf/var/log/messages
Feb 16 13:51:23 sostesthost systemd[1]: Started Hostname Service.
Feb 16 13:51:53 sostesthost systemd[1]: systemd-hostnamed.service: Succeeded.
# sos clean --batch /var/tmp/sosreport-sostesthost-2021-02-16-iktgdbf.tar.xz
. . .
# tar -xf /var/tmp/sosreport-host0-2021-02-16-iktgdbf-obfuscated.tar.xz
# cat sosreport-host0-2021-02-16-iktgdbf/sos_commands/host/hostname
host0.obfuscateddomain1.com
# tail -n 2 sosreport-host0-2021-02-16-iktgdbf/var/log/messages
Feb 16 13:51:23 host0 systemd[1]: Started Hostname Service.
Feb 16 13:51:53 host0 systemd[1]: systemd-hostnamed.service: Succeeded.

# # At this point it correctly replaced hostnames and adds the hostname into mapping.

# cat /etc/sos/cleaner/default_mapping 
{
    "hostname_map": {
        "redhat.com": "obfuscateddomain0.com",
        "sostesthost.sossubdomain.redhat.com": "host0.obfuscateddomain1.com",
. . .
        "sostesthost": "host0",
. . .
# sosreport -o logs --batch
. . .
# tar -xf /var/tmp/sosreport-sostesthost-2021-02-16-qzbkssg.tar.xz
# tail -n 2 sosreport-sostesthost-2021-02-16-qzbkssg/var/log/messages
Feb 16 14:53:03 sostesthost systemd[1]: Started Network Manager Script Dispatcher Service.
Feb 16 14:53:14 sostesthost systemd[1]: NetworkManager-dispatcher.service: Succeeded.
# sos clean --batch /var/tmp/sosreport-sostesthost-2021-02-16-qzbkssg.tar.xz
. . .
# cat /var/tmp/sosreport-host0-2021-02-16-qzbkssg-private_map
{
    "hostname_map": {
        "redhat.com": "obfuscateddomain0.com",
        "sostesthost.sossubdomain.redhat.com": "host0.obfuscateddomain1.com",
. . .
        "sostesthost": "host0",
. . .
# tar -xf /var/tmp/sosreport-host0-2021-02-16-qzbkssg-obfuscated.tar.xz
. . .
# tail -n 2 sosreport-host0-2021-02-16-qzbkssg/var/log/messages
Feb 16 14:53:03 sostesthost systemd[1]: Started Network Manager Script Dispatcher Service.
Feb 16 14:53:14 sostesthost systemd[1]: NetworkManager-dispatcher.service: Succeeded.

# # At this point hostname is not replaced (is still sostesthost) despite private mapping containing it.

Comment 1 Jake Hunsaker 2021-02-16 15:38:50 UTC
This should be resolved by upstream PR #2406 - https://github.com/sosreport/sos/pull/2406.

As of right now this PR has not been merged as it is still awaiting further testing in upstream.

Comment 5 errata-xmlrpc 2021-11-09 19:36:07 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/RHEA-2021:4388