Skip to content
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

ItemNotFoundException while iterating all items #42

Open
alanfranz opened this issue Dec 28, 2022 · 4 comments
Open

ItemNotFoundException while iterating all items #42

alanfranz opened this issue Dec 28, 2022 · 4 comments

Comments

@alanfranz
Copy link

Using this script:

#!/usr/bin/env python3
import secretstorage
connection = secretstorage.dbus_init()
collections = secretstorage.get_all_collections(connection)
for coll in collections:
    if not coll.is_locked():
        print(f"Keyring: {coll.get_label()}")
        for item in coll.get_all_items():
            print(f"{item.get_label()} -> {item.get_secret()}")

OS: Ubuntu Linux 22.04 64 bit intel, fully updated
Package versions:

 python3-secretstorage                      3.3.1-1
python3-jeepney                            0.7.1-3
python3-cryptography                       3.4.8-1ubuntu2

It's a freshly installed VM I was used for testing. There're two keyrings (Login and awsvault) with one entry each. Output:

user@user-ubuntu:~/Desktop$ ./dumpall.py
Keyring: Login
My first item -> b'pa$$word'
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/secretstorage/util.py", line 46, in send_and_get_reply
    return self._connection.send_and_get_reply(msg, unwrap=True)
  File "/usr/lib/python3/dist-packages/jeepney/io/blocking.py", line 190, in send_and_get_reply
    return unwrap_msg(msg_in)
  File "/usr/lib/python3/dist-packages/jeepney/wrappers.py", line 214, in unwrap_msg
    raise DBusErrorResponse(msg)
jeepney.wrappers.DBusErrorResponse: [org.freedesktop.DBus.Error.UnknownMethod] ('Object does not exist at path “/org/freedesktop/secrets/collection/login/1”',)

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

Traceback (most recent call last):
  File "/home/user/Desktop/./dumpall.py", line 8, in <module>
    for item in coll.get_all_items():
  File "/usr/lib/python3/dist-packages/secretstorage/collection.py", line 86, in get_all_items
    yield Item(self.connection, item_path, self.session)
  File "/usr/lib/python3/dist-packages/secretstorage/item.py", line 31, in __init__
    self._item.get_property('Label')
  File "/usr/lib/python3/dist-packages/secretstorage/util.py", line 64, in get_property
    (signature, value), = self.send_and_get_reply(msg)
  File "/usr/lib/python3/dist-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!

It appears that the get_all_items() method fumble after properly fetching the only entry in the keyring.

I tried dumping the Items property in the get_all_items() method call and I get this:

['/org/freedesktop/secrets/collection/login/2', '/org/freedesktop/secrets/collection/login/1']

So, it seems more items are enumerated than actually there?

@mitya57
Copy link
Owner

mitya57 commented Dec 28, 2022

So, it seems more items are enumerated than actually there?

Yes, it seems like that. I think it's a server-side problem. Are you using gnome-keyring or another daemon?

@alanfranz
Copy link
Author

alanfranz commented Dec 28, 2022

gnome-keyring. It's a default installation of ubuntu 22.04 desktop with standard gnome DE. No tweaking on my part. I've probably deleted and added a couple of entries, though; maybe there's some tombstone for deleted entries, rather than a removal, or something like this? Can I give you some additional debug info somehow?

@mitya57
Copy link
Owner

mitya57 commented Dec 28, 2022

Can you try building and running this small C++ program and see if it shows the same error message?
https://gitlab.com/GrantMoyer/lssecret

Also does that error persist after restarting gnome-keyring?

Do you know a way to reproduce it on a clean installation?

@DamjanJovanovic
Copy link

I can't reproduce this, despite adding hundreds of keys through the API and deleting and re-adding many times. Enumeration is always fully successful with the given Python sample code.

@alanfranz please try to move or rename your ~/.local/share/keyrings directory, reboot, and then create/delete some keys and test whether enumeration still fails. If not, then it's probably some kind of corruption in your current file(s).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants