Skip to content

Change keyring priority #779

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Feb 2, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 18 additions & 14 deletions src/vorta/keyring/abc.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,23 +20,27 @@ def get_keyring(cls):
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
else:
# Try to use KWallet (KDE)
from .kwallet import VortaKWallet5Keyring, KWalletNotAvailableException
try:
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
# 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 = VortaSecretStorageKeyring()
except (secretstorage.exceptions.SecretStorageException, DBusException): # Try to use KWallet (KDE)
from .kwallet import VortaKWallet5Keyring, KWalletNotAvailableException
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
Expand Down