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
Same problem with unguarded parseFile calls in the gfs2 plugin.
Created attachment 531158 [details] Avoid user visible exceptions when parsing XML Wrap calls to libxml2.parseFile() with try/catch blocks.
Created attachment 531159 [details] Avoid user visible exceptions when parsing XML Also make sure we release libxml2 objects since they are not reference counted.
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.
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