Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
SUSE:SLE-12-SP1:GA
salt.3314
0067-Bugfix-prevent-crash-if-python-dbus-module...
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File 0067-Bugfix-prevent-crash-if-python-dbus-module-is-instal.patch of Package salt.3314
From 2ca7171f334fa17095defd9fb35fd3d30788b407 Mon Sep 17 00:00:00 2001 From: Bo Maryniuk <bo@suse.de> Date: Thu, 11 Aug 2016 15:36:20 +0200 Subject: [PATCH 67/67] Bugfix: prevent crash, if python dbus module is installed, but no real dbus is around in the system (e.g. minimal RHEL6) * Add error check for snapper's object init * Add error message for missing snapper in a whole * Disable pylint on module-level non-constant variables * Turn off pylint on non-constant names in init block --- salt/modules/snapper.py | 41 +++++++++++++++++++++++++++++------------ 1 file changed, 29 insertions(+), 12 deletions(-) diff --git a/salt/modules/snapper.py b/salt/modules/snapper.py index 9a73820..edecd87 100644 --- a/salt/modules/snapper.py +++ b/salt/modules/snapper.py @@ -46,26 +46,43 @@ SNAPPER_DBUS_OBJECT = 'org.opensuse.Snapper' SNAPPER_DBUS_PATH = '/org/opensuse/Snapper' SNAPPER_DBUS_INTERFACE = 'org.opensuse.Snapper' -log = logging.getLogger(__name__) # pylint: disable=invalid-name +# pylint: disable=invalid-name +log = logging.getLogger(__name__) -bus = None # pylint: disable=invalid-name -snapper = None # pylint: disable=invalid-name +bus = None +system_bus_error = None +snapper = None +snapper_error = None if HAS_DBUS: - bus = dbus.SystemBus() # pylint: disable=invalid-name - if SNAPPER_DBUS_OBJECT in bus.list_activatable_names(): - snapper = dbus.Interface(bus.get_object(SNAPPER_DBUS_OBJECT, # pylint: disable=invalid-name - SNAPPER_DBUS_PATH), - dbus_interface=SNAPPER_DBUS_INTERFACE) + try: + bus = dbus.SystemBus() + except dbus.DBusException as exc: + log.error(exc) + system_bus_error = exc + else: + if SNAPPER_DBUS_OBJECT in bus.list_activatable_names(): + try: + snapper = dbus.Interface(bus.get_object(SNAPPER_DBUS_OBJECT, + SNAPPER_DBUS_PATH), + dbus_interface=SNAPPER_DBUS_INTERFACE) + except (dbus.DBusException, ValueError) as exc: + log.error(exc) + snapper_error = exc + else: + snapper_error = 'snapper is missing' +# pylint: enable=invalid-name def __virtual__(): + error_msg = 'The snapper module cannot be loaded: {0}' if not HAS_DBUS: - return (False, 'The snapper module cannot be loaded:' - ' missing python dbus module') + return False, error_msg.format('missing python dbus module') elif not snapper: - return (False, 'The snapper module cannot be loaded:' - ' missing snapper') + return False, error_msg.format(snapper_error) + elif not bus: + return False, error_msg.format(system_bus_error) + return 'snapper' -- 2.9.2
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor