Package gir1.2-secret-1 changes behaviour
- Dominant language
- Python
- Stars
- 1.5k
- Forks
- 196
- PR merge metrics
- No merged PRs in 30d
Description
**Describe the bug**
I ran into an error which prevented me from using `devpi`, cause by the presence of `gir1.2-secret-1` package. `devpi` ended up in error
```
$ devpi login vzima
Traceback (most recent call last):
File "/home/vzima/.local/bin/devpi", line 8, in
sys.exit(main())
File "/home/vzima/.local/lib/python3.9/site-packages/devpi/main.py", line 36, in main
return method(hub, hub.args)
File "/home/vzima/.local/lib/python3.9/site-packages/devpi/login.py", line 13, in main
password = hub.hook.devpiclient_get_password(
File "/home/vzima/.local/lib/python3.9/site-packages/pluggy/hooks.py", line 286, in __call__
return self._hookexec(self, self.get_hookimpls(), kwargs)
File "/home/vzima/.local/lib/python3.9/site-packages/pluggy/manager.py", line 93, in _hookexec
return self._inner_hookexec(hook, methods, kwargs)
File "/home/vzima/.local/lib/python3.9/site-packages/pluggy/manager.py", line 84, in
self._inner_hookexec = lambda hook, methods, kwargs: hook.multicall(
File "/home/vzima/.local/lib/python3.9/site-packages/pluggy/callers.py", line 208, in _multicall
return outcome.get_result()
File "/home/vzima/.local/lib/python3.9/site-packages/pluggy/callers.py", line 80, in get_result
raise ex[1].with_traceback(ex[2])
File "/home/vzima/.local/lib/python3.9/site-packages/pluggy/callers.py", line 187, in _multicall
res = hook_impl.function(*args)
File "/usr/lib/python3/dist-packages/keyring/devpi_client.py", line 11, in devpiclient_get_password
return keyring.get_password(url, username)
File "/usr/lib/python3/dist-packages/keyring/core.py", line 55, in get_password
return get_keyring().get_password(service_name, username)
File "/usr/lib/python3/dist-packages/keyring/backends/chainer.py", line 51, in get_password
password = keyring.get_password(service, username)
File "/usr/lib/python3/dist-packages/keyring/backends/libsecret.py", line 62, in get_password
items = Secret.password_search_sync(
gi.repository.GLib.GError: g-dbus-error-quark: The name org.freedesktop.secrets was not provided by any .service files (2)
```
although the `gnome-keyring` is not installed and there is no backend for the keyring available (that I'm aware of). Anyway the uninstallation of `gir1.2-secret-1` resolved the problem. The issue may be related to #19.
**To Reproduce**
I wan able to reproduce the issue using docker:
`Dockerfile`
```dockerfile
FROM debian:testing-slim
# Install build dependencies from debian
RUN apt-get update \
&& apt-get install --yes --no-install-recommends \
gir1.2-secret-1 \
python3-gi \
python3-keyring \
python3-pip \
&& rm -rf /var/lib/apt/lists/* \
# And a devpi client
&& /usr/bin/pip install devpi-client
WORKDIR /app
```
```sh
docker build -t devpi-test .
docker run --privileged -ti --rm devpi-test:latest /bin/bash -c "dbus-run-session -- python3 -c 'from keyring.devpi_client import devpiclient_get_password; devpiclient_get_password(\"http://example.org/\", \"username\")'"
```
This produces the error same as above
```
Traceback (most recent call last):
File "", line 1, in
File "/usr/lib/python3/dist-packages/keyring/devpi_client.py", line 11, in devpiclient_get_password
return keyring.get_password(url, username)
File "/usr/lib/python3/dist-packages/keyring/core.py", line 55, in get_password
return get_keyring().get_password(service_name, username)
File "/usr/lib/python3/dist-packages/keyring/backends/libsecret.py", line 62, in get_password
items = Secret.password_search_sync(
gi.repository.GLib.GError: g-dbus-error-quark: The name org.freedesktop.secrets was not provided by any .service files (2)
```
but a different output if `gir1.2-secret-1` is not installed:
```
Traceback (most recent call last):
File "", line 1, in
File "/usr/lib/python3/dist-packages/keyring/devpi_client.py", line 11, in devpiclient_get_password
return keyring.get_password(url, username)
File "/usr/lib/python3/dist-packages/keyring/core.py", line 55, in get_password
return get_keyring().get_password(service_name, username)
File "/usr/lib/python3/dist-packages/keyring/backends/fail.py", line 25, in get_password
raise NoKeyringError(msg)
keyring.errors.NoKeyringError: 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://pypi.org/project/keyring for details.
```
**Expected behavior**
Same behavior for cases when `gir1.2-secret-1` is installed and when it isn't. In case of `devpi login`, it should result in devpi asking for password directly.
**Environment**
- OS: Linux Debian testing
```
$ pip list | grep keyring
## Desktop
keyring 23.3.0
keyrings.alt 4.1.0
## Docker
keyring 23.5.0
...
$ keyring --list-backends
## Desktop
keyring.backends.chainer.ChainerBackend (priority: 10)
keyrings.alt.file.EncryptedKeyring (priority: 0.6)
keyring.backends.fail.Keyring (priority: 0)
keyrings.alt.file.PlaintextKeyring (priority: 0.5)
## Docker
keyring.backends.chainer.ChainerBackend (priority: -1)
keyring.backends.fail.Keyring (priority: 0)
keyring.backends.libsecret.Keyring (priority: 4.8)
...
```
**Additional context**
Add any other context about the problem here.
Contributor guide
No contributing guide indexed for this repository
Research direction
Start by reproducing the behavior with the Dockerfile and command in the issue, then inspect the keyring.backends.chainer and keyring.backends.libsecret paths shown in the traceback. Done means installing gir1.2-secret-1 without a secrets service produces the same usable fallback behavior as when it is absent, allowing devpi login to request a password.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- linux, python
- Domain
- authentication, backend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100