twpayne / chezmoi

Manage your dotfiles across multiple diverse machines, securely.
https://www.chezmoi.io/
MIT License
12.9k stars 478 forks source link

v2.44 fails to authenticate with keepassxc using key file #3474

Closed tleepa closed 8 months ago

tleepa commented 8 months ago

Describe the bug

A clear and concise description of what the bug is.

To reproduce

Have keepassxc configured to use a key file, e.g. (chezmoi data | jq '.chezmoi.config.keepassxc):

{
  "args": [
    "-k",
    "/path/to/file.key"
  ],
  "command": "keepassxc-cli",
  "database": {},
  "prompt": true
}

Run chezmoi diff

Expected behavior

After providing password to KeepassXC, chezmoi shows diff with no errors.

Output of command with the --verbose flag

❯ chezmoi diff --no-pager --verbose
chezmoi: template: dot_config/template_file.tmpl:3:29: executing "dot_config/template_file.tmpl" at <keepassxc "entry">: error calling keepassxc: /usr/bin/keepassxc-cli show /path/to/file.kdbx --quiet --show-protected 'entry': exit status 1

Output of chezmoi doctor

```console ❯ chezmoi doctor RESULT CHECK MESSAGE ok version v2.44.0, commit 9902245adf529f5617dd1606a08f53f1fb1e8fa9, built at 2024-01-10T13:14:57Z, built by goreleaser ok latest-version v2.44.0 ok os-arch linux/amd64 (Fedora Linux 39 (KDE Plasma)) ok uname Linux tltp 6.6.9-200.fc39.x86_64 #1 SMP PREEMPT_DYNAMIC Mon Jan 1 20:05:54 UTC 2024 x86_64 GNU/Linux ok go-version go1.21.6 (gc) ok executable /usr/bin/chezmoi ok upgrade-method sudo-upgrade-package ok config-file ~/.config/chezmoi/chezmoi.toml, last modified 2023-10-27T08:39:45+02:00 warning source-dir ~/.local/share/chezmoi is a git working tree (dirty) ok suspicious-entries no suspicious entries warning working-tree ~/.local/share/chezmoi is a git working tree (dirty) ok dest-dir ~ is a directory ok umask 022 ok cd-command found /bin/zsh ok cd-args /bin/zsh info diff-command not set ok edit-command found /usr/bin/vim ok edit-args /usr/bin/vim ok git-command found /usr/bin/git, version 2.43.0 ok merge-command found /usr/bin/vimdiff ok shell-command found /bin/zsh ok shell-args /bin/zsh info age-command age not found in $PATH ok gpg-command found /usr/bin/gpg, version 2.4.3 info pinentry-command not set info 1password-command op not found in $PATH info bitwarden-command bw not found in $PATH info bitwarden-secrets-command bws not found in $PATH info dashlane-command dcli not found in $PATH info doppler-command doppler not found in $PATH info gopass-command gopass not found in $PATH ok keepassxc-command found /usr/bin/keepassxc-cli, version 2.7.6 ok keepassxc-db /path/to/file.kdbx is a file info keeper-command keeper not found in $PATH info lastpass-command lpass not found in $PATH info pass-command pass not found in $PATH info passhole-command ph not found in $PATH info rbw-command rbw not found in $PATH ok vault-command found /usr/bin/vault, version 1.15.4 info vlt-command vlt not found in $PATH info secret-command not set ```

Additional context

Using --debug gives the culprit:

❯ chezmoi diff --no-pager --debug
2024-01-12T12:52:11+01:00 ERR Output error="exit status 1" args=["keepassxc-cli","show","/path/to/file.kdbx","--quiet","--show-protected","entry"] duration=30.927591ms exitCode=1 output= path=/usr/bin/keepassxc-cli size=0 systemTime=7.986 userTime=22.548
chezmoi: template: dot_config/template_file.tmpl:3:29: executing "dot_config/template_file.tmpl" at <keepassxc "entry">: error calling keepassxc: /usr/bin/keepassxc-cli show /path/to/file.kdbx --quiet --show-protected 'entry': exit status 1

compared to the older version (v.2.43.0):

❯ chezmoi diff --no-pager --debug
2024-01-12T12:53:12+01:00 INF Output args=["keepassxc-cli","show","--quiet","--show-protected","-k","/path/to/file.key","/path/to/file.kdbx","entry"] duration=115.468203ms output="Title: entry\nUserName: REDACTED\nPasswor..." path=/usr/bin/keepassxc-cli size=196

one can notice that the new version does not use -k /path/to/file.key arguments.

twpayne commented 8 months ago

Thanks for reporting this. This was an oversight that was missed in #3443 and is fixed with #3476.