Bug 976242 - hostname handling needs sanity improvement
hostname handling needs sanity improvement
Product: Red Hat Enterprise Linux 5
Classification: Red Hat
Component: sos (Show other bugs)
Unspecified Unspecified
low Severity unspecified
: rc
: ---
Assigned To: Bryn M. Reeves
Miroslav Hradílek
Depends On: 822174
  Show dependency treegraph
Reported: 2013-06-20 03:59 EDT by Miroslav Hradílek
Modified: 2013-09-30 20:37 EDT (History)
7 users (show)

See Also:
Fixed In Version: sos-1.7-9.65.el5
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: 822174
Last Closed: 2013-09-30 20:37:30 EDT
Type: Bug
Regression: ---
Mount Type: ---
Documentation: ---
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---

Attachments (Terms of Use)

  None (edit)
Comment 1 Miroslav Hradílek 2013-06-20 04:03:41 EDT
Bug 822174 also affects RHEL-5 (5.9 reproduced)

# rpm -q sos

# hostname 'f/t_u-r:!§@#$%^>._ha_*()=+"`;/\?~|}{][hěščÁŤh'

# hostname

# sosreport --batch -o general

sosreport (version 1.7)

This utility will collect some detailed  information about the
hardware and  setup of your  Red Hat Enterprise Linux  system.
The information is collected and an archive is  packaged under
/tmp, which you can send to a support representative.
Red Hat will use this information for diagnostic purposes ONLY
and it will be considered confidential information.

This process may take a while to complete.
No changes will be made to your system.

 plugin general finished ...                   

Creating compressed archive...
/bin/mv: cannot move `/tmp/sos_QRLfBo' to `/tmp/f/t_u-r:!§@#$%^': No such file or directory
sh: gt: command not found
sh: -379509: command not found
/bin/mv: missing destination file operand after `/tmp/f/t_u-r:!§@#$%^'
Try `/bin/mv --help' for more information.
sh: gt: command not found
sh: -379509: command not found
Traceback (most recent call last):
  File "/usr/sbin/sosreport", line 734, in ?
  File "/usr/sbin/sosreport", line 723, in sosreport
  File "/usr/lib/python2.4/site-packages/sos/policyredhat.py", line 201, in packageResults
    fp = open(os.path.join(ourtempdir, tarballName), "r")
IOError: [Errno 2] No such file or directory: '/tmp/sosreport-f/t_u-r:!\xc2\xa7@#$%^>.tar.bz2'
Comment 2 Miroslav Hradílek 2013-06-20 07:37:12 EDT
Also related to this bug 771393.

Was sosreport in RHEL-5 ever capable of using info from
/etc/sysconfig/rhn/systemid ?

On sos-1.7-9.62.el5 it seems to ignore it entirely and use hostname instead.

On the same package, the sanitization seems to be in place although not consistent with RHEL-6. When crippled username (containing weird characters) is given using --name parameter it only outputs alphanumeric characters (no '-' dashes) unlike in RHEL-6.
Comment 4 RHEL Product and Program Management 2013-06-24 06:38:56 EDT
This request was evaluated by Red Hat Product Management for inclusion
in a Red Hat Enterprise Linux release.  Product Management has
requested further review of this request by Red Hat Engineering, for
potential inclusion in a Red Hat Enterprise Linux release for currently
deployed products.  This request is not yet committed for inclusion in
a release.
Comment 6 Bryn M. Reeves 2013-07-24 09:24:25 EDT
This change brings hostname handling in line with rhel6:

- Strip all non-alphanumeric/dash characters
- If string is empty substitute 'default' (date/time will make unique)

# gendiff sos .orig
diff -up sos/policyredhat.py.orig sos/policyredhat.py
--- sos/policyredhat.py.orig	2013-07-23 17:13:46.000000000 +0100
+++ sos/policyredhat.py	2013-07-23 17:13:51.000000000 +0100
@@ -152,6 +152,7 @@ class SosPolicy:
         if len(self.reportName) == 0:
+            localname = re.sub(r"[^_a-zA-Z.0-9-]", "", localname)
             self.reportName = localname
         if self.cInfo['cmdlineopts'].customerName:
@@ -162,6 +163,9 @@ class SosPolicy:
             self.ticketNumber = self.cInfo['cmdlineopts'].ticketNumber
             self.ticketNumber = re.sub(r"[^0-9]", "", self.ticketNumber)
+        if len(self.reportName) == 0:
+            self.reportName = "default"
     def packageResults(self):
Comment 9 errata-xmlrpc 2013-09-30 20:37:30 EDT
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, and where to find the updated
files, follow the link below.

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


Note You need to log in before you can comment on or make changes to this bug.