Bug 976242 - hostname handling needs sanity improvement
Summary: hostname handling needs sanity improvement
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 5
Classification: Red Hat
Component: sos
Version: 5.9
Hardware: Unspecified
OS: Unspecified
low
unspecified
Target Milestone: rc
: ---
Assignee: Bryn M. Reeves
QA Contact: Miroslav Hradílek
URL:
Whiteboard:
Depends On: 822174
Blocks:
TreeView+ depends on / blocked
 
Reported: 2013-06-20 07:59 UTC by Miroslav Hradílek
Modified: 2013-10-01 00:37 UTC (History)
7 users (show)

Fixed In Version: sos-1.7-9.65.el5
Doc Type: Bug Fix
Doc Text:
Clone Of: 822174
Environment:
Last Closed: 2013-10-01 00:37:30 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Red Hat Product Errata RHBA-2013:1356 0 normal SHIPPED_LIVE sos bug fix and enhancement update 2013-09-30 21:12:32 UTC

Comment 1 Miroslav Hradílek 2013-06-20 08:03:41 UTC
Bug 822174 also affects RHEL-5 (5.9 reproduced)

# rpm -q sos
sos-1.7-9.62.el5

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

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

# 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 ...                   
 Completed.

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 ?
    sosreport()
  File "/usr/sbin/sosreport", line 723, in sosreport
    policy.packageResults()
  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 11:37:12 UTC
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 Program Management 2013-06-24 10:38:56 UTC
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 13:24:25 UTC
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:
                 sys.exit(0)
 
         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"
+
         return
 
     def packageResults(self):

Comment 9 errata-xmlrpc 2013-10-01 00:37:30 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, and where to find the updated
files, follow the link below.

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

http://rhn.redhat.com/errata/RHBA-2013-1356.html


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