Skip to content

Commit

Permalink
Handle DBus UnknownObject error when no collection is found (#43)
Browse files Browse the repository at this point in the history
On Kubuntu 23.04, when trying to access a collection that doesn't
exist, it returns a UknownObject error instead of NoSuchObject.
Which makes me unable of installing the package on the system.

Handling this case, makes the KWallet dialog for creating the wallet
appear and the rest of workflow works as expected.

Co-authored-by: Dmitry Shachnev <[email protected]>
  • Loading branch information
renatoalencar and mitya57 committed Aug 30, 2023
1 parent 1e6af18 commit 0ca29b2
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
1 change: 1 addition & 0 deletions secretstorage/defines.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
DBUS_NO_REPLY = 'org.freedesktop.DBus.Error.NoReply'
DBUS_NOT_SUPPORTED = 'org.freedesktop.DBus.Error.NotSupported'
DBUS_NO_SUCH_OBJECT = 'org.freedesktop.Secret.Error.NoSuchObject'
DBUS_UNKNOWN_OBJECT = 'org.freedesktop.DBus.Error.UnknownObject'

ALGORITHM_PLAIN = 'plain'
ALGORITHM_DH = 'dh-ietf1024-sha256-aes128-cbc-pkcs7'
8 changes: 6 additions & 2 deletions secretstorage/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
from jeepney.io.blocking import DBusConnection
from secretstorage.defines import DBUS_UNKNOWN_METHOD, DBUS_NO_SUCH_OBJECT, \
DBUS_SERVICE_UNKNOWN, DBUS_NO_REPLY, DBUS_NOT_SUPPORTED, DBUS_EXEC_FAILED, \
SS_PATH, SS_PREFIX, ALGORITHM_DH, ALGORITHM_PLAIN
DBUS_UNKNOWN_OBJECT, SS_PATH, SS_PREFIX, ALGORITHM_DH, ALGORITHM_PLAIN
from secretstorage.dhcrypto import Session, int_to_bytes
from secretstorage.exceptions import ItemNotFoundException, \
SecretServiceNotAvailableException
Expand Down Expand Up @@ -48,7 +48,11 @@ def send_and_get_reply(self, msg: Message) -> Any:
raise DBusErrorResponse(resp_msg)
return resp_msg.body
except DBusErrorResponse as resp:
if resp.name in (DBUS_UNKNOWN_METHOD, DBUS_NO_SUCH_OBJECT):
if resp.name in (
DBUS_UNKNOWN_METHOD,
DBUS_NO_SUCH_OBJECT,
DBUS_UNKNOWN_OBJECT,
):
raise ItemNotFoundException('Item does not exist!') from resp
elif resp.name in (DBUS_SERVICE_UNKNOWN, DBUS_EXEC_FAILED,
DBUS_NO_REPLY):
Expand Down

0 comments on commit 0ca29b2

Please sign in to comment.