From c99ac04b36ff40e5f813bebf2268dc1fd515e944 Mon Sep 17 00:00:00 2001 From: samuel-w Date: Mon, 1 Feb 2021 19:10:39 -0600 Subject: [PATCH] Change keyring priority (#779) --- src/vorta/keyring/abc.py | 34 +++++++++++++++++++--------------- 1 file changed, 19 insertions(+), 15 deletions(-) diff --git a/src/vorta/keyring/abc.py b/src/vorta/keyring/abc.py index 98c0e5c7..4f49e655 100644 --- a/src/vorta/keyring/abc.py +++ b/src/vorta/keyring/abc.py @@ -20,23 +20,27 @@ class VortaKeyring: if sys.platform == 'darwin': # Use Keychain on macOS from .darwin import VortaDarwinKeyring cls._keyring = VortaDarwinKeyring() - else: # Try to use DBus and Gnome-Keyring (available on Linux and *BSD) - import secretstorage - from .secretstorage import VortaSecretStorageKeyring - - # secretstorage has two different libraries based on version - if parse_version(secretstorage.__version__) >= parse_version("3.0.0"): - from jeepney.wrappers import DBusErrorResponse as DBusException - else: - from dbus.exceptions import DBusException - + else: + # Try to use KWallet (KDE) + from .kwallet import VortaKWallet5Keyring, KWalletNotAvailableException try: - cls._keyring = VortaSecretStorageKeyring() - except (secretstorage.exceptions.SecretStorageException, DBusException): # Try to use KWallet (KDE) - from .kwallet import VortaKWallet5Keyring, KWalletNotAvailableException + cls._keyring = VortaKWallet5Keyring() + except KWalletNotAvailableException: + # Try to use DBus and Gnome-Keyring (available on Linux and *BSD) + # Put this last as gnome keyring is included by default on many distros + import secretstorage + from .secretstorage import VortaSecretStorageKeyring + + # secretstorage has two different libraries based on version + if parse_version(secretstorage.__version__) >= parse_version("3.0.0"): + from jeepney.wrappers import DBusErrorResponse as DBusException + else: + from dbus.exceptions import DBusException + try: - cls._keyring = VortaKWallet5Keyring() - except KWalletNotAvailableException: # Save passwords in DB, if all else fails. + cls._keyring = VortaSecretStorageKeyring() + except (secretstorage.exceptions.SecretStorageException, DBusException): + # Save passwords in DB, if all else fails. from .db import VortaDBKeyring cls._keyring = VortaDBKeyring() return cls._keyring