config: Make keyring log messages explain more
...as a lot of users see debug-level errors from the keyring code and think they explain some larger issue. These are currently *always* red herrings as there is no command for setting configuration values in the keyring yet. Fixes #681
This commit is contained in:
parent
01bc7a0a2c
commit
e255afb97f
@ -19,20 +19,25 @@ else:
|
|||||||
EMPTY_STRING = ''
|
EMPTY_STRING = ''
|
||||||
|
|
||||||
|
|
||||||
|
FETCH_ERROR = (
|
||||||
|
'Fetching passwords from your keyring failed. Any passwords '
|
||||||
|
'stored in the keyring will not be available.')
|
||||||
|
|
||||||
|
|
||||||
def fetch():
|
def fetch():
|
||||||
if not dbus:
|
if not dbus:
|
||||||
logger.debug('Fetching from keyring failed: dbus not installed.')
|
logger.debug('%s (dbus not installed)', FETCH_ERROR)
|
||||||
return []
|
return []
|
||||||
|
|
||||||
try:
|
try:
|
||||||
bus = dbus.SessionBus()
|
bus = dbus.SessionBus()
|
||||||
except dbus.exceptions.DBusException as e:
|
except dbus.exceptions.DBusException as e:
|
||||||
logger.debug('Fetching from keyring failed: %s', e)
|
logger.debug('%s (%s)', FETCH_ERROR, e)
|
||||||
return []
|
return []
|
||||||
|
|
||||||
if not bus.name_has_owner('org.freedesktop.secrets'):
|
if not bus.name_has_owner('org.freedesktop.secrets'):
|
||||||
logger.debug(
|
logger.debug(
|
||||||
'Fetching from keyring failed: secrets service not running.')
|
'%s (org.freedesktop.secrets service not running)', FETCH_ERROR)
|
||||||
return []
|
return []
|
||||||
|
|
||||||
service = _service(bus)
|
service = _service(bus)
|
||||||
@ -47,7 +52,7 @@ def fetch():
|
|||||||
items, prompt = service.Unlock(locked)
|
items, prompt = service.Unlock(locked)
|
||||||
if prompt != '/':
|
if prompt != '/':
|
||||||
_prompt(bus, prompt).Dismiss()
|
_prompt(bus, prompt).Dismiss()
|
||||||
logger.debug('Fetching from keyring failed: keyring is locked.')
|
logger.debug('%s (Keyring is locked)', FETCH_ERROR)
|
||||||
return []
|
return []
|
||||||
|
|
||||||
result = []
|
result = []
|
||||||
@ -65,19 +70,20 @@ def set(section, key, value):
|
|||||||
Indicates if storage failed or succeeded.
|
Indicates if storage failed or succeeded.
|
||||||
"""
|
"""
|
||||||
if not dbus:
|
if not dbus:
|
||||||
logger.debug('Saving %s/%s to keyring failed: dbus not installed.',
|
logger.debug('Saving %s/%s to keyring failed. (dbus not installed)',
|
||||||
section, key)
|
section, key)
|
||||||
return False
|
return False
|
||||||
|
|
||||||
try:
|
try:
|
||||||
bus = dbus.SessionBus()
|
bus = dbus.SessionBus()
|
||||||
except dbus.exceptions.DBusException as e:
|
except dbus.exceptions.DBusException as e:
|
||||||
logger.debug('Saving %s/%s to keyring failed: %s', section, key, e)
|
logger.debug('Saving %s/%s to keyring failed. (%s)', section, key, e)
|
||||||
return False
|
return False
|
||||||
|
|
||||||
if not bus.name_has_owner('org.freedesktop.secrets'):
|
if not bus.name_has_owner('org.freedesktop.secrets'):
|
||||||
logger.debug(
|
logger.debug(
|
||||||
'Saving %s/%s to keyring failed: secrets service not running.',
|
'Saving %s/%s to keyring failed. '
|
||||||
|
'(org.freedesktop.secrets service not running)',
|
||||||
section, key)
|
section, key)
|
||||||
return False
|
return False
|
||||||
|
|
||||||
@ -101,14 +107,14 @@ def set(section, key, value):
|
|||||||
item, prompt = collection.CreateItem(properties, secret, True)
|
item, prompt = collection.CreateItem(properties, secret, True)
|
||||||
except dbus.exceptions.DBusException as e:
|
except dbus.exceptions.DBusException as e:
|
||||||
# TODO: catch IsLocked errors etc.
|
# TODO: catch IsLocked errors etc.
|
||||||
logger.debug('Saving %s/%s to keyring failed: %s', section, key, e)
|
logger.debug('Saving %s/%s to keyring failed. (%s)', section, key, e)
|
||||||
return False
|
return False
|
||||||
|
|
||||||
if prompt == '/':
|
if prompt == '/':
|
||||||
return True
|
return True
|
||||||
|
|
||||||
_prompt(bus, prompt).Dismiss()
|
_prompt(bus, prompt).Dismiss()
|
||||||
logger.debug('Saving secret %s/%s failed: Keyring is locked',
|
logger.debug('Saving secret %s/%s failed. (Keyring is locked)',
|
||||||
section, key)
|
section, key)
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user