mirror of
https://github.com/borgbase/vorta
synced 2025-01-03 13:45:49 +00:00
Fall back to DB-based password storage when Gnome-Keyring is missing. Fixes #235
This commit is contained in:
parent
e40f571b5e
commit
414de1d36b
4 changed files with 10 additions and 3 deletions
|
@ -12,12 +12,13 @@ def get_keyring(cls):
|
|||
if sys.platform == 'darwin': # Use Keychain on macOS
|
||||
from .darwin import VortaDarwinKeyring
|
||||
return VortaDarwinKeyring()
|
||||
else: # Try to use DBus (available on Linux and *BSD)
|
||||
else: # Try to use DBus and Gnome-Keyring (available on Linux and *BSD)
|
||||
import secretstorage
|
||||
from .secretstorage import VortaSecretStorageKeyring
|
||||
try:
|
||||
return VortaSecretStorageKeyring()
|
||||
except secretstorage.SecretServiceNotAvailableException: # Save passwords in DB, if all else fails.
|
||||
# Save passwords in DB, if all else fails.
|
||||
except secretstorage.SecretServiceNotAvailableException:
|
||||
from .db import VortaDBKeyring
|
||||
return VortaDBKeyring()
|
||||
|
||||
|
|
|
@ -7,7 +7,6 @@
|
|||
|
||||
Adapted from https://gist.github.com/apettinen/5dc7bf1f6a07d148b2075725db6b1950
|
||||
"""
|
||||
|
||||
from .abc import VortaKeyring
|
||||
|
||||
|
||||
|
|
|
@ -8,7 +8,12 @@ class VortaSecretStorageKeyring(VortaKeyring):
|
|||
"""A wrapper for the secretstorage package to support the custom keyring backend"""
|
||||
|
||||
def __init__(self):
|
||||
"""
|
||||
Test whether DBus and Gnome-Keyring are available.
|
||||
"""
|
||||
self.connection = secretstorage.dbus_init()
|
||||
asyncio.set_event_loop(asyncio.new_event_loop())
|
||||
secretstorage.get_default_collection(self.connection)
|
||||
|
||||
def set_password(self, service, repo_url, password):
|
||||
asyncio.set_event_loop(asyncio.new_event_loop())
|
||||
|
|
|
@ -21,8 +21,10 @@
|
|||
from PyQt5.QtGui import QIcon
|
||||
from PyQt5 import QtCore
|
||||
from vorta.keyring.abc import VortaKeyring
|
||||
from vorta.log import logger
|
||||
|
||||
keyring = VortaKeyring.get_keyring()
|
||||
logger.info('Using %s Keyring implementation.', keyring.__class__.__name__)
|
||||
|
||||
|
||||
def nested_dict():
|
||||
|
|
Loading…
Reference in a new issue