nondeterministic failure when no keyring backends are available
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
Python Keyring |
Fix Released
|
Unknown
|
|||
launchpadlib |
Fix Released
|
High
|
Dan Streetman | ||
python-keyring (Ubuntu) |
Fix Released
|
Medium
|
Dan Streetman | ||
Eoan |
Fix Released
|
Medium
|
Dan Streetman | ||
Focal |
Fix Released
|
Medium
|
Dan Streetman | ||
python-launchpadlib (Ubuntu) |
Fix Released
|
Medium
|
Dan Streetman | ||
Eoan |
Won't Fix
|
Medium
|
Dan Streetman | ||
Focal |
Fix Released
|
Medium
|
Dan Streetman |
Bug Description
[impact]
when no backends are available for python-keyring, it will sometimes silently ignore all requests to set or get credentials, and sometimes it will raise RuntimeError for all requests.
[test case]
when there are no backends, there are 2 built-in backends that will be the only ones available, the 'chainer' backend and the 'fail' backend. The 'fail' backend always has priority 0, while the 'chainer' backend has priority 10 if it contains any actual backends, and priority 0 if it is empty. So in the situtation where there are no actual backends, both 'chainer' and 'fail' will have priority 0. Since the 'backends' class stores its backend implementation instances in a python set(), which is unordered, it is non-deterministic which of those backends are used at any given time.
Since the behavior is non-deterministic, simply trying this multiple times may result in each behavior. Rebooting or logout/login can help 'switch' the behavior, although simply re-running the test multiple times should be enough to eventually test both backends.
>>> import keyring
>>> [keyring.
the above python code will show the current list of backends, and since they both have the same priority (in this situation) the first in the list will be used. If the list looks like:
[[<keyring.
with 'ChainerBackend' first, all keyring functions will return silently with None, e.g.:
>>> keyring.
>>> keyring.
>>>
with 'fail.Keyring' first, all keyring functions will raise RuntimeError:
>>> import keyring
>>> [keyring.
[[<keyring.
>>> keyring.
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/
_keyring_
File "/usr/lib/
raise RuntimeError(msg)
RuntimeError: No recommended backend was available. Install a recommended 3rd party backend package; or, install the keyrings.alt package if you want to use the non-recommended backends. See https:/
>>> keyring.
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/
return _keyring_
File "/usr/lib/
raise RuntimeError(msg)
RuntimeError: No recommended backend was available. Install a recommended 3rd party backend package; or, install the keyrings.alt package if you want to use the non-recommended backends. See https:/
[regression potential]
And regressions would likely occur when no keyring backends, or only a single keyring backend, are/is availble, since this lowers the priority of the 'chainer' keyring backend, and the intention of this is to fix the existing problem when there is no keyring backend.
It should be noted that because the current behavior is non-deterministic, alternating between no error at all and raised RuntimeError, some existing users of python-keyring that occasionally do not see any error (but then also occasionally see RuntimeError raised) will now always see NoKeyringError raised (which does inherit from RuntimeError, to keep backwards compatibility for users that currently catch RuntimeError).
That is not actually a regression, since the behavior was non-deterministic; one way had to be chosen, and always raising error when there are no keyring backends is more appropriate than always silently failing when there are no keyring backends.
[scope]
This affects Eoan and later, including upstream.
This does not affect Bionic or earlier, as they do not have the commit that introduces the bug.
this was introduced upstream by commit 0114733e91f2492
[other info]
this affects any application that uses the python-launchpadlib library, as that internally uses keyrings.
Opened upstream PR to at least make the behavior deterministic:
https:/
Also adds new 'NoKeyringError' so callers can catch that specific error instead of raising generic RuntimeError.
Related branches
- Colin Watson: Approve
-
Diff: 322 lines (+171/-44)2 files modifiedsrc/launchpadlib/credentials.py (+151/-43)
src/launchpadlib/launchpad.py (+20/-1)
Changed in python-keyring (Ubuntu): | |
importance: | Undecided → Medium |
Changed in python-keyring: | |
status: | Unknown → New |
description: | updated |
Changed in python-keyring (Ubuntu Eoan): | |
importance: | Undecided → Medium |
Changed in python-launchpadlib (Ubuntu Eoan): | |
importance: | Undecided → Medium |
Changed in python-launchpadlib (Ubuntu Focal): | |
importance: | Undecided → Medium |
description: | updated |
description: | updated |
description: | updated |
Changed in launchpadlib: | |
importance: | Undecided → High |
Changed in python-keyring: | |
status: | New → Fix Released |
Status changed to 'Confirmed' because the bug affects multiple users.