keepassxreboot / keepassxc

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

Handle database on inaccessible NFS share gracefully #9125

Open sburris0 opened 1 year ago

sburris0 commented 1 year ago

Overview

When a keepass db is on an inaccessible NFS share, it hangs rather than handling the error gracefully.

Steps to Reproduce

Setup:

  1. Set up an NFS share with your DB on it
  2. Mount the share from another machine
  3. Start keepassxc, unlock DB (so it saves DB location)
  4. Close keepassxc

    Actual reproduction:

  5. Make the NFS share inaccessible (e.g. disable wireless, unplug ethernet, etc)
  6. Start keepassxc
  7. Observe that it hangs/is a black screen

Expected Behavior

Upon starting keepassxc with an inaccessible DB file, I expect:

Ideally, an inaccessible DB should not impair the function of keepassxc. "Display an error and exit" is a bad strategy because the user may have other DBs that work.

Actual Behavior

Keepassxc starts and the window is entirely black. After a few minutes, I am asked if I want to Force Quit the application.

Context

My use case is storing a DB on my NAS, mounting the NFS share from my workstation, and using keepass from there.

$ keepassxc --debug-info # can't start GUI right now
Warning: Ignoring XDG_SESSION_TYPE=wayland on Gnome. Use QT_QPA_PLATFORM=wayland to run on Wayland anyway.
KeePassXC - Version 2.7.4

Qt 5.15.8
Debugging mode is disabled.

Operating system: NixOS 23.05 (Stoat)
CPU architecture: x86_64
Kernel: linux 6.0.11

Enabled extensions:
- Auto-Type
- Browser Integration
- SSH Agent
- KeeShare
- YubiKey
- Secret Service Integration

Cryptographic libraries:
- Botan 2.19.3

Operating System: Linux (Nixos) Desktop Env: Gnome Windowing System: Wayland

droidmonkey commented 1 year ago

I can never reproduce this problem on Windows or Ubuntu. It is either a poor interaction with Qt and your desktop env, or it's the desktop env itself not properly reporting inaccessible file.

sburris0 commented 1 year ago

I wonder if it's GVFS-related. I noticed that stat <db file> doesn't error as expected but also hangs

droidmonkey commented 1 year ago

Right so it isn't really on us. Although we should enforce a time out somehow. Unfortunately qt doesn't have that built into their file api. Really GVFS needs to properly handle this situation.

sburris0 commented 2 months ago

I've just run into this again. This time running sway wm rather than GNOME. ps output:

spencer   327274  0.1  0.2 1476992 42564 ?       Sl   16:42   0:00 foot
spencer   327275  0.0  0.0   9384  5888 pts/4    Ss   16:42   0:00  \_ /run/current-system/sw/bin/bash
spencer   329684  2.1  0.0  10312  6912 pts/4    S    16:51   0:00      \_ bash --rcfile /tmp/nix-shell-329684-0/rc
spencer   332724  0.2  0.5 674592 89576 pts/4    DLl+ 16:51   0:00          \_ keepassxc

I don't think there is GVFS in the picture here:

[spencer@nixos:~]$ systemctl cat mnt-nas.mount
# /run/systemd/generator/mnt-nas.mount
# Automatically generated by systemd-fstab-generator

[Unit]
Documentation=man:fstab(5) man:systemd-fstab-generator(8)
SourcePath=/etc/fstab
Before=remote-fs.target

[Mount]
What=192.168.2.32:/tank/data
Where=/mnt/nas
Type=nfs

I do have local copies of my DB, but I can't get keepassxc to start to access them. It would be nice to have some sort of failsafe, like a CLI flag that tries to access ONLY databases passed as an argument, or one that ignores the cache