Bug 750573 - sosreport cluster modules fail with badly formed cluster.conf
Summary: sosreport cluster modules fail with badly formed cluster.conf
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 5
Classification: Red Hat
Component: sos
Version: 5.7
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: rc
: ---
Assignee: Bryn M. Reeves
QA Contact: BaseOS QE - Apps
URL:
Whiteboard:
Depends On:
Blocks: 773350 782064
TreeView+ depends on / blocked
 
Reported: 2011-11-01 15:58 UTC by Bryn M. Reeves
Modified: 2012-08-10 09:01 UTC (History)
7 users (show)

Fixed In Version: sos-1.7-9.58.el5
Doc Type: Bug Fix
Doc Text:
Cause: The sosreport command uses the python libxml2 bindings to parse XML formatted files such as /etc/cluster/cluster.conf. Malformed XML will trigger a parser exception. This exception was caught by the generic module handling routines and was not reported to the user. Consequence: Systems having a malformed cluster.conf will report no errors but the cluster module terminates abnormally without collecting a full set of data. Fix: The cluster module has been modified to catch parser exceptions internally and alter the user to the problem via a diagnostic message. Result: The sosreport command's cluster module now correctly identifies and reports these problems as well as collecting the complete set of information on such systems.
Clone Of:
: 773350 (view as bug list)
Environment:
Last Closed: 2012-02-21 03:25:53 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)
Avoid user visible exceptions when parsing XML (1.68 KB, patch)
2011-11-01 16:14 UTC, Bryn M. Reeves
no flags Details | Diff
Avoid user visible exceptions when parsing XML (2.64 KB, application/octet-stream)
2011-11-01 16:24 UTC, Bryn M. Reeves
no flags Details


Links
System ID Private Priority Status Summary Last Updated
Red Hat Product Errata RHSA-2012:0153 0 normal SHIPPED_LIVE Low: sos security, bug fix, and enhancement update 2012-02-21 07:25:08 UTC

Description Bryn M. Reeves 2011-11-01 15:58:46 UTC
Description of problem:
Unhandled parserError exception from xmlParseFile generates an ugly backtrace if the cluster.conf contains malformed XML:

#sosreport --batch

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.


/etc/cluster/cluster.conf:27: parser error : AttValue: " or ' expected
                <fs device=/dev/el5-gfs2_vg0/ext3-1 force_fsck="1" force_unmount
                           ^
/etc/cluster/cluster.conf:27: parser error : attributes construct error
                <fs device=/dev/el5-gfs2_vg0/ext3-1 force_fsck="1" force_unmount
                           ^
/etc/cluster/cluster.conf:27: parser error : Couldn't find end of Start Tag fs line 27
                <fs device=/dev/el5-gfs2_vg0/ext3-1 force_fsck="1" force_unmount
                           ^
/etc/cluster/cluster.conf:29: parser error : Opening and ending tag mismatch: rm line 25 and cluster
</cluster>
          ^
/etc/cluster/cluster.conf:30: parser error : Premature end of data in tag cluster line 2

^
Traceback (most recent call last):
  File "/usr/sbin/sosreport", line 704, in ?
    sosreport()
  File "/usr/sbin/sosreport", line 525, in sosreport
    plug.diagnose()
  File "/usr/lib/python2.4/site-packages/sos/plugins/cluster.py", line 119, in diagnose
    xml = libxml2.parseFile("/etc/cluster/cluster.conf")
  File "/usr/lib64/python2.4/site-packages/libxml2.py", line 1240, in parseFile
    if ret is None:raise parserError('xmlParseFile() failed')
libxml2.parserError: xmlParseFile() failed


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


How reproducible:
100%

Steps to Reproduce:
1. Put some malformed XML in cluster.conf, e.g. unquoted attribute value.
2. run sosreport

  
Actual results:
uncaught parserError backtraces onto terminal

Expected results:
no exception, sos terminates normally

Additional info:
Found while testing fix for bug 655046

Comment 1 Bryn M. Reeves 2011-11-01 16:07:18 UTC
Same problem with unguarded parseFile calls in the gfs2 plugin.

Comment 2 Bryn M. Reeves 2011-11-01 16:14:58 UTC
Created attachment 531158 [details]
Avoid user visible exceptions when parsing XML

Wrap calls to libxml2.parseFile() with try/catch blocks.

Comment 3 Bryn M. Reeves 2011-11-01 16:24:22 UTC
Created attachment 531159 [details]
Avoid user visible exceptions when parsing XML

Also make sure we release libxml2 objects since they are not reference counted.

Comment 9 Bryn M. Reeves 2012-01-26 13:13:49 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:
Cause: The sosreport command uses the python libxml2 bindings to parse XML formatted files such as /etc/cluster/cluster.conf. Malformed XML will trigger a parser exception. This exception was caught by the generic module handling routines and was not reported to the user.

Consequence: Systems having a malformed cluster.conf will report no errors but the cluster module terminates abnormally without collecting a full set of data.

Fix: The cluster module has been modified to catch parser exceptions internally and alter the user to the problem via a diagnostic message.

Result: The sosreport command's cluster module now correctly identifies and reports these problems as well as collecting the complete set of information on such systems.

Comment 10 errata-xmlrpc 2012-02-21 03:25:53 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-0153.html


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