yum fails with AttributeError: '_socketobject' object has no attribute 'state_string'

Solution Verified - Updated -

Environment

  • Red Hat Enterprise Linux 7
  • Red Hat Virtualization (RHV) 4.2
  • rhnlib / yum-rhn-plugin
  • python-pyOpenSSL-16.2.0-3.el7ost.noarch
  • Red Hat Satellite 5.x

Issue

After updating rhnlib package on a system registered to Red Hat Satellite 5.x, yum starts failing with the below traceback :-

Traceback (most recent call last):
  File "/usr/bin/yum", line 29, in <module>
    yummain.user_main(sys.argv[1:], exit_code=True)
  File "/usr/share/yum-cli/yummain.py", line 375, in user_main
    errcode = main(args)
  File "/usr/share/yum-cli/yummain.py", line 170, in main
    base.getOptionsConfig(args)
  File "/usr/share/yum-cli/cli.py", line 262, in getOptionsConfig
    self.conf
  File "/usr/lib/python2.7/site-packages/yum/__init__.py", line 1078, in <lambda>
    conf = property(fget=lambda self: self._getConfig(),
  File "/usr/lib/python2.7/site-packages/yum/__init__.py", line 420, in _getConfig
    self.plugins.run('init')
  File "/usr/lib/python2.7/site-packages/yum/plugins.py", line 188, in run
    func(conduitcls(self, self.base, conf, **kwargs))
  File "/usr/share/yum-plugins/rhnplugin.py", line 121, in init_hook
    login_info = up2dateAuth.getLoginInfo(timeout=timeout)
  File "/usr/share/rhn/up2date_client/up2dateAuth.py", line 228, in getLoginInfo
    login(timeout=timeout)
  File "/usr/share/rhn/up2date_client/up2dateAuth.py", line 195, in login
    li = server.up2date.login(systemId)
  File "/usr/share/rhn/up2date_client/rhnserver.py", line 63, in __call__
    return rpcServer.doCall(method, *args, **kwargs)
  File "/usr/share/rhn/up2date_client/rpcServer.py", line 204, in doCall
    ret = method(*args, **kwargs)
  File "/usr/lib64/python2.7/xmlrpclib.py", line 1233, in __call__
    return self.__send(self.__name, args)
  File "/usr/share/rhn/up2date_client/rpcServer.py", line 38, in _request1
    ret = self._request(methodname, params)
  File "/usr/lib/python2.7/site-packages/rhn/rpclib.py", line 384, in _request
    self._handler, request, verbose=self._verbose)
  File "/usr/lib/python2.7/site-packages/rhn/transports.py", line 188, in request
    return self._process_response(fd, connection)
  File "/usr/lib/python2.7/site-packages/rhn/transports.py", line 195, in _process_response
    fd = resp.decode(fd)
  File "/usr/lib/python2.7/site-packages/rhn/transports.py", line 442, in decode
    self.read(fd)
  File "/usr/lib/python2.7/site-packages/rhn/transports.py", line 420, in read
    max_mem_size=self.max_mem_size)
  File "/usr/lib/python2.7/site-packages/rhn/transports.py", line 528, in _smart_read
    chunk = fd.read(l)
  File "/usr/lib64/python2.7/httplib.py", line 610, in read
    self.close()
  File "/usr/lib64/python2.7/httplib.py", line 555, in close
    self.fp.close()
  File "/usr/lib/python2.7/site-packages/rhn/SSL.py", line 133, in close
    self._really_close()
  File "/usr/lib/python2.7/site-packages/rhn/SSL.py", line 148, in _really_close
    if self._connection.state_string() == 'SSL negotiation finished successfully':
  File "/usr/lib/python2.7/site-packages/OpenSSL/SSL.py", line 1135, in __getattr__
    return getattr(self._socket, name)
AttributeError: '_socketobject' object has no attribute 'state_string'

Resolution

  • This issue has been reported to Red Hat, and bug reports (BZ #1581424 and BZ #1597711) have been filed for the same.
  • Contact Red Hat Technical Support for further information.

  • The below workaround can be tried in order to get rid of this error:

(Note Make sure that you have a backup of the file brfore proceeding with these steps)
Change line #149 of the /usr/lib/python2.7/site-packages/rhn/SSL.py file

from :-

 # for Python 2
        else:
            if self._connection.state_string() == 'SSL negotiation finished successfully':
                self._connection.shutdown()

to :-

# for Python 2
        else:
            if self._connection.get_state_string() == 'SSL negotiation finished successfully':
                self._connection.shutdown()

Root Cause

  • This issue is caused due to some discrepancies between the python-pyOpenSSL and the rhnlib packages.

This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.

1 Comments

This solution does not seem to work.

# for Python 3 if sys.version_info[0] == 3: if self._connection.get_state_string() == 'SSL negotiation finished successfully': self._connection.shutdown() # for Python 2 else: if self._connection.get_state_string() == 'SSL negotiation finished successfully': self._connection.shutdown()

The update fails now with following error:

File "/usr/lib/python2.7/site-packages/rhn/SSL.py", line 148, in _really_close if self._connection.get_state_string() == 'SSL negotiation finished successfully': AttributeError: '_socketobject' object has no attribute 'get_state_string' Command '['sudo', 'yum', 'update', '-y', 'instack-undercloud']' returned non-zero exit status 1