Skip to content

Fix: prevent KWallet from triggering creation UI on read queries (#496) - #764

Open
newchannelid432-code wants to merge 1 commit into
jaraco:mainfrom
newchannelid432-code:fix/kwallet-prevent-creation-ui-on-query-496
Open

newchannelid432-code wants to merge 1 commit into
jaraco:mainfrom
newchannelid432-code:fix/kwallet-prevent-creation-ui-on-query-496

Conversation

@newchannelid432-code

Copy link
Copy Markdown

Fixes #496.

Problem

As discussed in #496, when a user is on a Gnome desktop environment but has `kwallet` installed (often pulled as a dependency by unrelated software), the `ChainerBackend` queries `SecretService` first. Since the password hasn't been set yet, it registers as a 'miss'. The `Chainer` then falls back to `kwallet`.

Because KWallet has never been initialized in this Gnome environment, querying it via DBus unconditionally calls `self.iface.open()`. This triggers the KDE Wallet creation UI, which is extremely annoying and surprising to the user who never intended to use KDE.

Solution

This PR implements the exact solution requested by @jaraco in #496:

  1. Adds a `create=True` flag to `connected()`.
  2. `get_password()` and `get_credential()` now pass `create=False`.
  3. If `create=False`, `connected()` queries `self.iface.wallets()` to check if the target wallet exists. If it does not, it returns `False` immediately without calling `open()`, completely preventing the UI from triggering.
  4. `get_password` and `get_credential` now return `None` instead of raising `KeyringLocked` when the wallet doesn't exist. This allows the `Chainer` to gracefully move to the next backend without crashing the application.

This ensures that KWallet only presents its initialization UI when a user is explicitly setting a password, perfectly resolving the first-time usage flaw on mixed desktop environments.

…aco#496)

When using the ChainerBackend on a Gnome environment with kwallet installed
but never initialized, querying for a password triggers the KDE Wallet
creation UI. This happens because connected() unconditionally calls
iface.open(), which implicitly creates the wallet if it doesn't exist.

This patch implements the solution requested in jaraco#496:
1. Adds a `create=True` flag to connected().
2. get_password() and get_credential() now pass `create=False`.
3. If `create=False`, connected() queries iface.wallets() to check if
   the target wallet exists. If it does not, it returns False immediately
   without calling open(), completely preventing the UI from triggering.
4. get_password/get_credential now return None instead of raising
   KeyringLocked when the wallet doesn't exist, allowing the Chainer
   to gracefully move to the next backend without crashing.

Closes jaraco#496
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

Successfully merging this pull request may close these issues.

Backend inference between KWallet and Gnome leads to unexpected results

1 participant