keepassxreboot / keepassxc

KeePassXC is a cross-platform community-driven port of the Windows application “Keepass Password Safe”.
https://keepassxc.org/
Other
20.91k stars 1.44k forks source link

keepassxc not waiting for davfs2 mount #8081

Closed Massimo-B closed 1 year ago

Massimo-B commented 2 years ago

Overview

If using a DB file located on a WebDAV server mounting via davfs2 and autofs and starting keepassxc in Autostart of Xfce, the process dies before getting access to the mount.

Expected Behavior

Keepassxc should start and open the gui, ask for the password and wait for the mount to finish.

Actual Behavior

It dies before getting access

Context

I try to start keepassxc in Autostart of Xfce, but it fails. I created a wrapper script logging it's start and also doing /usr/bin/keepassxc & > keepassxc.log Right after Xfce Login, the script got called, the keepassxc.log is created but empty, no keepassxc process is running. My DB is located on a davfs2 fuse mount, mounted by autofs. So in the syslog I also see this:

May 16 07:52:05 [massimo] 1keepassxc started
May 16 07:52:05 [polkitd] Registered Authentication Agent for unix-session:7 (system bus name :1.46 [/usr/libexec/polkit-gnome-authentication-agent-1], object path /org/gnome/PolicyKit1/AuthenticationAgent, locale de_DE.UTF-8)
May 16 07:52:06 [NetworkManager] <info>  [1652680326.0195] agent-manager: agent[9306bf32e6f2a488,:1.48/org.freedesktop.nm-applet/4728]: agent registered
May 16 07:52:06 [dbus-daemon] [session uid=4728 pid=9067] Activating service name='org.gtk.vfs.UDisks2VolumeMonitor' requested by ':1.27' (uid=4728 pid=10051 comm="/usr/lib64/tumbler-1/tumblerd ")
May 16 07:52:06 [automount] pidinfo requestor: pid:10079 comm:keepassxc tgid:10079 uid:4728 euid:4728 gid:4728 egid:4728
May 16 07:52:06 [automount] pidinfo parent: pid:1 comm:init tgid:1 uid:0 euid:0 gid:0 egid:0
May 16 07:52:06 [automount] attempting to mount entry /mnt/autofs/davfs/hidrive
May 16 07:52:06 [automount] mount(generic): calling mount -t davfs -o rw,uid=4728,gid=4728,dir_mode=0777,file_mode=0666 https://webdav.hidrive.ionos.com/ /mnt/autofs/davfs/hidrive
...
May 16 07:54:22 [automount] mounted /mnt/autofs/davfs/hidrive

I also tried adding a sleep 6 in my script but doesn't solve it. The mounting of davfs2 always takes a while, but the keepassxc dies before getting access to the mount. Usually, starting keepassxc manually without any autostart action at login, the delayed mounting is no issue and keepassxc waits for the DB file. But if my autostart script has run, I try to kill the running keepassxc which doesn't work. kill -9 works and removes the process. Starting another keepassxc does not open any gui or systray icon like usually when waiting for the mount, it's just frozen and can only be killed by -9.

KeePassXC - Version 2.7.1

Qt 5.15.3 Debugging mode is disabled.

Operating system: Gentoo/Linux CPU architecture: x86_64 Kernel: linux 5.17.8-gentoo-dist

Enabled extensions:

Cryptographic libraries:

Notes

I know using unreliable network mounts is always an issue, especially using fuse and webserver mounts like WebDAV. But centrally synchronizing my Keepass DB is essentially important. My earlier approach was to use a local file and synchronize via unison to the davfs2 mount like I'm doing with all other cloud documents. That works but is always tricky at conflicts as unison and no editor is capable to merge encrypted .kdbx files. I'm using the central DB from different Linux workstations and from Android using Keepass2Android. I noticed when using the WebDav instance of the file directly from all clients this works apparently well and also merges changes made in the background by detecting file modifications. It's just the initial start when waiting for the mount to finish that has issues with KeepassXC on Linux.

droidmonkey commented 2 years ago

But if my autostart script has run, I try to kill the running keepassxc which doesn't work. kill -9 works and removes the process.

It does not seem like keepassxc is dieing during the startup sequence in this case. The gui could be attached to another window or something crazy, we've seen this before. That's why you place the sleep before you start keepassxc.

If you close the database (ie, you see the welcome screen, press Ctrl+W) then exit, then allow it to autostart on next login, does the gui still fail to show up?

Roughly 2.5 minutes to mount the webdav is nuts, you may also be hitting some systemd timeouts for hung processes at startup.

Massimo-B commented 2 years ago

I'm not using systemd, but OpenRC. The keepassxc process has died because it doesn't exist anymore. Why davfs2 is taking so long is some question to discuss there: https://savannah.nongnu.org/support/?110645 I'm going to try autostarting keepassxc without opening any database...

Massimo-B commented 2 years ago

Yes, autostarting Keepassxc with disabled Tools->Settings->General->Basic Settings->[ ] "Load previously open databases on startup" works and makes it possible to open the Webdav file manually.

Massimo-B commented 2 years ago

Anyway, when waiting for a mount or having any IO issues on opening a file, the gui should still appear and eventually cancelling the open file after some timeout. Then we can discuss the timeout. But it's not starting any gui and the process is crashing sometimes.

droidmonkey commented 2 years ago

Can you reproduce with a local file that is opened on startup? I just checked the code, we do not do anything with files on startup. Literally just use the file name. The file is only touched when it is unlocked.

Massimo-B commented 2 years ago

I can't reproduce with a local file, and I can't reproduce with the WebDAV file if the davfs2 mount is already established. I also can't reproduce when starting KeepassXC manually because then it waits for the davfs2 mount to finish, even when being locked for more than 3 minutes. This is all working as expected.

Only the autostarting Keepassxc does not wait for the mount to finish. It triggers the autofs, but is not alive anymore when davfs2 comes back with the established mount.

droidmonkey commented 2 years ago

I don't think this is a keepassxc bug then