Bug 771393

Summary: Sosreport fails for default values when rhn user name contains character '/' in it.
Product: Red Hat Enterprise Linux 6 Reporter: Yogesh <ychavan>
Component: sosAssignee: Bryn M. Reeves <bmr>
Status: CLOSED ERRATA QA Contact: David Kutálek <dkutalek>
Severity: medium Docs Contact:
Priority: medium    
Version: 6.2CC: agk, bmr, dkutalek, gavin, prc, psplicha, vgaikwad
Target Milestone: rc   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: sos-2.2-18.el6 Doc Type: Bug Fix
Doc Text:
* Previous releases of sos used inconsistent input sanitization rules depending on whether user name and case information was supplied interactively or read from system configuration files * This caused sos to fail to properly sanitize certain invalid strings when read from configuration files and to apply different sanitization to the same strings when input interactively * All name and number sanitization is now carried out in a single location and all input routines have been modified to use these routines * Name and number sanitization rules are now applied consistently regardless of the source of the data
Story Points: ---
Clone Of: Environment:
Last Closed: 2012-06-20 07:25:15 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Yogesh 2012-01-03 15:44:51 UTC
Description of problem:
when rhn user name contains character '/' in it, Sosreport is giving following error
/bin/sh: /tmp/sosreport-ABCD/XYZ-20111230154705.tar.xz: No such file or directory
/bin/tar: -: Cannot write: Broken pipe
/bin/tar: Error is not recoverable: exiting now
Traceback (most recent call last):
  File "/usr/sbin/sosreport", line 23, in <module>
    sosreport(sys.argv[1:])
  File "/usr/lib/python2.6/site-packages/sos/sosreport.py", line 843, in sosreport
    GlobalVars.policy.displayResults()
  File "/usr/lib/python2.6/site-packages/sos/policyredhat.py", line 329, in displayResults
    fp = open(self.report_file, "r")
IOError: [Errno 2] No such file or directory: '/tmp/sosreport-ABCD/XYZ-20111230154705.tar.xz'


Version-Release number of selected component (if applicable):
sos-2.2-17


How reproducible:
Always

Steps to Reproduce:
1. Open /etc/sysconfig/rhn/systemid
2. Edit value of field 'username'. Add '/' character in username. e.g.
<name>username</name>
<value><string>abc/xyz</string></value>
3. Run command
# sosreport

  
Actual results:
Sosreport is giving following error
/bin/sh: /tmp/sosreport-ABCD/XYZ-20111230154705.tar.xz: No such file or directory
/bin/tar: -: Cannot write: Broken pipe
/bin/tar: Error is not recoverable: exiting now
Traceback (most recent call last):
  File "/usr/sbin/sosreport", line 23, in <module>
    sosreport(sys.argv[1:])
  File "/usr/lib/python2.6/site-packages/sos/sosreport.py", line 843, in sosreport
    GlobalVars.policy.displayResults()
  File "/usr/lib/python2.6/site-packages/sos/policyredhat.py", line 329, in displayResults
    fp = open(self.report_file, "r")
IOError: [Errno 2] No such file or directory: '/tmp/sosreport-ABCD/XYZ-20111230154705.tar.xz'

Expected results:
Sosreport should trim down character '/' from rhn username and continue..

Additional info:
Trivial patch to file - /usr/lib/python2.6/site-packages/sos/policyredhat.py
--- policyredhat.py.bkup	2012-01-03 21:18:23.223920912 +0530
+++ policyredhat.py	2012-01-03 21:06:52.627932715 +0530
@@ -246,6 +246,7 @@
         else:
             self.reportName = self.reportName
 
+	self.reportName = self.reportName.replace('/','')
         curwd = os.getcwd()
         os.chdir(os.path.dirname(self.cInfo['dstroot']))
         oldmask = os.umask(077)

Comment 21 Bryn M. Reeves 2012-05-01 13:18:05 UTC
    Technical note added. If any revisions are required, please edit the "Technical Notes" field
    accordingly. All revisions will be proofread by the Engineering Content Services team.
    
    New Contents:
* Previous releases of sos used inconsistent input sanitization rules depending on whether user name and case information was supplied interactively or read from system configuration files
* This caused sos to fail to properly sanitize certain invalid strings when read from configuration files and to apply different sanitization to the same strings when input interactively
* All name and number sanitization is now carried out in a single location and all input routines have been modified to use these routines
* Name and number sanitization rules are now applied consistently regardless of the source of the data

Comment 23 errata-xmlrpc 2012-06-20 07:25:15 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/RHSA-2012-0958.html