Bug 790458

Summary: yum doesn't write to stderr raised exception by plugin, which inherits from YumBaseError
Product: Red Hat Enterprise Linux 6 Reporter: Jiří Mikulka <jmikulka>
Component: yumAssignee: James Antill <james.antill>
Status: CLOSED NOTABUG QA Contact: BaseOS QE Security Team <qe-baseos-security>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 6.2   
Target Milestone: rc   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2012-03-02 21:35:08 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:

Description Jiří Mikulka 2012-02-14 15:19:21 UTC
Description of problem:
When some yum plugin (in this case yum-rhn-plugin) raises an exception which inherits from YumBaseError, yum doesn't handle this exception properly (given parametr ~ error message ~ is omitted).

I hit this problem when I added `raise SSL.SysCallError('error message')` to /usr/lib/python2.6/site-packages/rhn/SSL.py (line 217). Then I ran `yum repolist` and check the output.

Version-Release number of selected component (if applicable):
yum-rhn-plugin-0.9.1-39.el6
rhn-client-tools-1.0.0-79.el6

How reproducible:


Steps to Reproduce:
1.  
2.
3.
  
Actual results:
# yum repolist
Loaded plugins: product-id, refresh-packagekit, rhnplugin, security, subscription-manager
Updating certificate-based repositories.


Network error:

Expected results:
# yum repolist
Loaded plugins: product-id, refresh-packagekit, rhnplugin, security, subscription-manager
Updating certificate-based repositories.


Network error: error message

Additional info:
This might be related to bug 751294 (on RHEL5).
Hit this issue while testing bug 751292 (on RHEL6).

Comment 2 James Antill 2012-03-02 21:35:08 UTC
unless I'm missing something SSL.SysCallError() is actually OpenSSL.SSL.SysCallError() ... which isn't a YumBaseError().

According to http://pyopenssl.sourceforge.net/pyOpenSSL.txt it's defined as:

   exception SysCallError
          The SysCallError occurs when there's an I/O error and OpenSSL's
          error queue does not contain any information. This can mean two
          things: An error in the transport protocol, or an end of file
          that violates the protocol. The parameter to the exception is
          always a pair (errnum, errstr).

...which probably means it inherits from IOError ... so uses this path in yum:

    def exIOError(e):
        if e.errno == 32:
            logger.critical(_('\n\nExiting on Broken Pipe'))
        else:
            logger.critical(_('\n\n%s') % exception2msg(e))
        if unlock(): return 200
        return 1

...which does:

def exception2msg(e):
    """ DIE python DIE! Which one works:
        to_unicode(e.value); unicode(e); str(e); 
        Call this so you don't have to care. """
    try:
        return to_unicode(e.value)
    except:
        pass

    try:
        return unicode(e)
    except:
        pass

    try:
        return str(e)
    except:
        pass
    return "<exception failed to convert to text>"