jaraco / jaraco/keyring

Error communicating with dbus

Open
#514 7 comments 0 reactions 0 assignees View on GitHub
Linux
Dominant language
Python
Stars
1.5k
Forks
196
PR merge metrics
No merged PRs in 30d

Description

**Describe the bug**

This command fails if I issue it when I `ssh` directly to the remote system, whereas it succeeds if I `ssh` as a different user and then `su` to the user running the test.

Direct `ssh` as `bennetsw`
```
$ python -c "import keyring; keyring.set_password('system', 'username', 'password')"
[bennetsw@gls8-build ~]$ python -c "import keyring; keyring.set_password('system', 'username', 'password')"
Traceback (most recent call last):
File "/home/bennetsw/.local/lib/python3.6/site-packages/secretstorage/util.py", line 46, in send_and_get_reply
return self._connection.send_and_get_reply(msg, unwrap=True)
File "/home/bennetsw/.local/lib/python3.6/site-packages/jeepney/io/blocking.py", line 140, in send_and_get_reply
return unwrap_msg(msg_in)
File "/home/bennetsw/.local/lib/python3.6/site-packages/jeepney/wrappers.py", line 214, in unwrap_msg
raise DBusErrorResponse(msg)
jeepney.wrappers.DBusErrorResponse: [org.freedesktop.DBus.Error.UnknownMethod] ("No such interface 'org.freedesktop.DBus.Properties' on object at path /org/freedesktop/secrets/collection/login",)

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File "/home/bennetsw/.local/lib/python3.6/site-packages/secretstorage/collection.py", line 161, in get_default_collection
return Collection(connection)
File "/home/bennetsw/.local/lib/python3.6/site-packages/secretstorage/collection.py", line 44, in __init__
self._collection.get_property('Label')
File "/home/bennetsw/.local/lib/python3.6/site-packages/secretstorage/util.py", line 64, in get_property
(signature, value), = self.send_and_get_reply(msg)
File "/home/bennetsw/.local/lib/python3.6/site-packages/secretstorage/util.py", line 49, in send_and_get_reply
raise ItemNotFoundException('Item does not exist!') from resp
secretstorage.exceptions.ItemNotFoundException: Item does not exist!

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/home/bennetsw/.local/lib/python3.6/site-packages/keyring/backends/SecretService.py", line 61, in get_preferred_collection
collection = secretstorage.get_default_collection(bus)
File "/home/bennetsw/.local/lib/python3.6/site-packages/secretstorage/collection.py", line 164, in get_default_collection
'default', session)
File "/home/bennetsw/.local/lib/python3.6/site-packages/secretstorage/collection.py", line 145, in create_collection
raise PromptDismissedException('Prompt dismissed.')
secretstorage.exceptions.PromptDismissedException: Prompt dismissed.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "", line 1, in
File "/home/bennetsw/.local/lib/python3.6/site-packages/keyring/core.py", line 60, in set_password
get_keyring().set_password(service_name, username, password)
File "/home/bennetsw/.local/lib/python3.6/site-packages/keyring/backends/chainer.py", line 58, in set_password
return keyring.set_password(service, username, password)
File "/home/bennetsw/.local/lib/python3.6/site-packages/keyring/backends/SecretService.py", line 87, in set_password
collection = self.get_preferred_collection()
File "/home/bennetsw/.local/lib/python3.6/site-packages/keyring/backends/SecretService.py", line 63, in get_preferred_collection
raise InitError("Failed to create the collection: %s." % e)
keyring.errors.InitError: Failed to create the collection: Prompt dismissed..
```

After logging in as a different user, and then `/bin/su - bennetsw`
```
$ python -c "import keyring; keyring.set_password('system', 'username', 'password')"'
$ echo $?
0
```
**To Reproduce**

Steps to reproduce the behavior:

Login into remote host with ssh, then run the command above to get the error. To cause the error to go away, login as a different user of the same system, then
```
$ /bin/su - realuser
$ python -c "import keyring; keyring.set_password('system', 'username', 'password')"
$
```
and it succeeds.

**Expected behavior**
The command should succeed in both circumstances.

**Environment**

Red Hat Enterprise Linux release 8.3 (Ootpa)
$ python --version
Python 3.6.8

$ pip3 install --user keyring keyrings.alt GitPython

$ pip3 list --user
gitdb (4.0.7)
GitPython (3.1.17)
importlib-metadata (4.3.1)
jeepney (0.6.0)
keyring (23.0.1)
keyrings.alt (4.0.2)
SecretStorage (3.3.1)
smmap (4.0.0)
typing-extensions (3.10.0.0)
zipp (3.4.1)

$ rpm -qa | grep "python3-.*dbus"
python3-slip-dbus-0.6.4-11.el8.noarch
python3-dbus-1.2.4-15.el8.x86_64
python3-pydbus-0.6.0-5.el8.noarch

```
$ pip list | grep keyring
keyring (23.0.1)
keyrings.alt (4.0.2)

$ keyring --list-backends
keyring.backends.fail.Keyring (priority: 0)
keyring.backends.chainer.ChainerBackend (priority: -1)
keyrings.alt.file.PlaintextKeyring (priority: 0.5)
```

**Additional context**

I am not the administrator of the system.

Contributor guide

No contributing guide indexed for this repository

Research direction

Start with the direct-SSH reproduction using keyring.set_password and trace the SecretService backend in keyring/backends/SecretService.py, especially the collection creation path shown in the traceback. Compare it with the successful /bin/su - realuser case; done means the command succeeds when the user logs in directly over SSH.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
security
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.