Bug 512135 - KWallet acting as proxy for KeePassXC wrongly asks to create new database (sometimes)
Summary: KWallet acting as proxy for KeePassXC wrongly asks to create new database (so...
Status: RESOLVED FIXED
Alias: None
Product: frameworks-kwallet
Classification: Frameworks and Libraries
Component: general (other bugs)
Version First Reported In: 6.17.0
Platform: Fedora RPMs Linux
: NOR normal
Target Milestone: ---
Assignee: Valentin Rusu
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2025-11-15 15:26 UTC by michaelk83
Modified: 2025-11-22 10:28 UTC (History)
3 users (show)

See Also:
Latest Commit:
Version Fixed/Implemented In: 6.21
Sentry Crash Report:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description michaelk83 2025-11-15 15:26:33 UTC
SUMMARY
Reporting on behalf of Miha Markič, original report at https://github.com/keepassxreboot/keepassxc/discussions/12445 :

> I'm using KeepassXC as secret service on Fedora 42 KDE and migrated
> KWalletManager so keepassxc is used for wallets as well.
> https://notmart.org/blog/2025/04/towards-a-transition-from-kwallet-to-secret-service/
> Now, this almost works except for randomly seeing KeepassXC dialogs
> to create a new database - sometime one at the time, sometimes more
> than one. I'd dismiss all of them and then it works normally.

STEPS TO REPRODUCE
The user wasn't able to determine reliable steps to reproduce, but reports that "it always happen sooner or later", and apparently more often after resuming from sleep.
In one test case, he was able to trigger the behavior by trying to connect to KRDC.
Having "org.freedesktop.secrets" "not activatable", but started manually, may contribute to the issue.

OBSERVED RESULT
- KeePassXC displays a create database dialog.
- The DBus log shows a `CreateCollection` call from KWallet, and no calls to list existing collections.

EXPECTED RESULT
- KWallet should list the existing collections, and access the relevant one.
- User should not be prompted to create a new database if a suitable one already exists.

SOFTWARE/OS VERSIONS
Linux/KDE Plasma: KDE Fedora 42-43
KDE Plasma Version: ?
KDE Frameworks Version: ? (standard for Fedora 42 is 6.17.0)
Qt Version: ?

ADDITIONAL INFORMATION
See the DBus log and discussion at https://github.com/keepassxreboot/keepassxc/discussions/12445#discussioncomment-14922681
(Log at https://github.com/keepassxreboot/keepassxc/discussions/12445#discussioncomment-14946327 )

It appears `SecretServiceClient::listFolders()` skips the actual calls to list existing collections, causing `KWalletD::openInternal()` to fall back to the `createCollection()` call. This might be caused by a partial failure of `attemptConnection()`.
https://invent.kde.org/frameworks/kwallet/-/blob/master/src/runtime/kwalletd/secretserviceclient.cpp?ref_type=heads#L487
https://invent.kde.org/frameworks/kwallet/-/blob/master/src/runtime/kwalletd/kwalletd.cpp?ref_type=heads#L342

The log shows that the user's "org.freedesktop.secrets" was "not activatable", resulting in an error being returned by DBus, despite the service having been manually started with KeePassXC. But the user reports that adding the DBus service auto-start file did _not_ resolve the problem.

Restarting kwalletmanager5 and kwalletd6 seems to resolve the problem temporarily, but restarting KeePassXC usually does not help.
Comment 1 Miha Markic 2025-11-16 09:28:06 UTC
Report author here. Relevant system details below, but it happens since Fedora 42 (I did not use it before).
I'm not exactly sure what causes it, but it eventually always start happening. Sometimes killing kwalletd6 and kwalletmanager5 processes helps. But it's not easy to pinpoint the cause reliably.

Operating System: Fedora Linux 43
KDE Plasma Version: 6.5.2
KDE Frameworks Version: 6.19.0
Qt Version: 6.10.0
Kernel Version: 6.17.7-300.fc43.x86_64 (64-bit)
Graphics Platform: Wayland
Comment 2 michaelk83 2025-11-16 11:27:43 UTC
(In reply to michaelk83 from comment #0)
> It appears `SecretServiceClient::listFolders()` skips the actual calls to
> list existing collections, causing `KWalletD::openInternal()` to fall back
> to the `createCollection()` call. This might be caused by a partial failure
> of `attemptConnection()`.

This should say `listCollections()`, not `listFolders()`.

On 2nd look at the log, there are actually no other calls at all to Secret Service between the `KWallet open` call and the `Secret.Service CreateCollection` call, including no connection or service start attempts. So this looks more like KWallet may be using a cached (and incorrect) collections list. Restarting KWallet would re-read the list, which would explain why that fixes the problem.

Miha, can you post the kwalletd log for when the bug occurs? There might be some useful warnings in there.
Comment 3 Bug Janitor Service 2025-11-18 10:05:00 UTC
A possibly relevant merge request was started @ https://invent.kde.org/frameworks/kwallet/-/merge_requests/136
Comment 4 michaelk83 2025-11-18 10:44:06 UTC
(In reply to Bug Janitor Service from comment #3)
> A possibly relevant merge request was started @
> https://invent.kde.org/frameworks/kwallet/-/merge_requests/136

Miha, can you test with the linked patch?
Comment 5 Marco Martin 2025-11-19 10:23:23 UTC
Git commit f44433933742bc7093cf5ecf67aeb00335efc238 by Marco Martin.
Committed on 19/11/2025 at 10:23.
Pushed by mart into branch 'master'.

Always reload collections prior to secret_service_get_collections

secret_service_get_collections might be cached and can return stale contents.
Force a reload of the collection list

M  +10   -1    src/runtime/kwalletd/secretserviceclient.cpp

https://invent.kde.org/frameworks/kwallet/-/commit/f44433933742bc7093cf5ecf67aeb00335efc238
Comment 6 Miha Markic 2025-11-19 16:07:42 UTC
(In reply to michaelk83 from comment #4)
> (In reply to Bug Janitor Service from comment #3)
> > A possibly relevant merge request was started @
> > https://invent.kde.org/frameworks/kwallet/-/merge_requests/136
> 
> Miha, can you test with the linked patch?

I might, can you tell me what to do? I guess building kwalletmanager from sources and replacing existing binary on my system?
Comment 7 michaelk83 2025-11-19 16:48:13 UTC
(In reply to Miha Markic from comment #6)

Not KWalletManager, but kwalletd.
Comment 8 Miha Markic 2025-11-22 09:46:39 UTC
I've tried building it but got stuck at:
CMake Error at CMakeLists.txt:48 (find_package):
  By not providing "FindKF6Config.cmake" in CMAKE_MODULE_PATH this project
  has asked CMake to find a package configuration file provided by
  "KF6Config", but CMake did not find one.

Are there any build instructions (for an average joe developer)? If that even still matters now as I see it has been merged.
Comment 9 michaelk83 2025-11-22 10:28:33 UTC
(In reply to Miha Markic from comment #8)
> Are there any build instructions (for an average joe developer)? If that
> even still matters now as I see it has been merged.

Don't know about instructions. You could try building it on KDE Neon Developer Edition live DVD, and copy the binary from there. But I'm not sure how well that would work. Probably not worth the effort at this point.

The patched version should be out Dec 12, so I think let's just wait until then.