1
0
mirror of https://github.com/altlinux/gpupdate.git synced 2025-03-10 04:58:46 +03:00

Avoid error in forked process with dconf-service killing

This commit is contained in:
Evgeny Sinelnikov 2021-07-18 00:56:13 +04:00
parent c8542fa477
commit a6e8f0b352
3 changed files with 12 additions and 5 deletions

View File

@ -123,6 +123,7 @@ def debug_code(code):
debug_ids[55] = 'Run user context applier with dropped privileges'
debug_ids[56] = 'Kill dbus-daemon and dconf-service in user context'
debug_ids[57] = 'Found connection by org.freedesktop.DBus.GetConnectionUnixProcessID'
debug_ids[58] = 'Connection search return org.freedesktop.DBus.Error.NameHasNoOwner'
return debug_ids.get(code, 'Unknown debug code')

View File

@ -188,7 +188,9 @@ class dbus_session:
pid = self.session_iface.GetConnectionUnixProcessID(connection)
log('D57', {"pid": pid})
except dbus.exceptions.DBusException as exc:
logdata = dict({'error': str(exc)})
log('E32', logdata)
raise exc
if exc.get_dbus_name() != 'org.freedesktop.DBus.Error.NameHasNoOwner':
logdata = dict({'error': str(exc)})
log('E32', logdata)
raise exc
log('D58', {'connection': connection})
return int(pid)

View File

@ -113,8 +113,12 @@ def with_privileges(username, func):
func()
# Save pid of dconf-service
session = dbus_session()
dconf_pid = session.get_connection_pid("ca.desrt.dconf")
dconf_connection = "ca.desrt.dconf"
try:
session = dbus_session()
dconf_pid = session.get_connection_pid(dconf_connection)
except Exception:
pass
except Exception as exc:
logdata = dict()