Skip to content

Commit

Permalink
Merge pull request #603 from lazka/libsecret-check-session
Browse files Browse the repository at this point in the history
libsecret: skip if there is no secret service running
  • Loading branch information
jaraco committed Nov 4, 2022
2 parents 8b18015 + c3eb39b commit f3b14d0
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
6 changes: 6 additions & 0 deletions CHANGES.rst
@@ -1,3 +1,9 @@
v23.11.0
--------

* #603: In ``libsecret``, check that the service is available before
declaring viability.

v23.10.0
--------

Expand Down
12 changes: 8 additions & 4 deletions keyring/backends/libsecret.py
Expand Up @@ -7,7 +7,6 @@
from ..errors import (
PasswordDeleteError,
PasswordSetError,
ExceptionRaisedContext,
KeyringLocked,
)

Expand Down Expand Up @@ -50,10 +49,15 @@ def collection(self):

@properties.classproperty
def priority(cls):
with ExceptionRaisedContext() as exc:
Secret.__name__
if exc:
if not available:
raise RuntimeError("libsecret required")

# Make sure there is actually a secret service running
try:
Secret.Service.get_sync(Secret.ServiceFlags.OPEN_SESSION, None)
except GLib.Error as error:
raise RuntimeError("Can't open a session to the secret service") from error

return 4.8

def get_password(self, service, username):
Expand Down

0 comments on commit f3b14d0

Please sign in to comment.