diff options
author | Jack Thomasson <jkt@moonlitsw.com> | 2019-04-25 17:37:13 +0300 |
---|---|---|
committer | Jonathan White <support@dmapps.us> | 2019-04-25 17:37:13 +0300 |
commit | 1cbd395d71c0adceb8880091cbe27b38c86a9b82 (patch) | |
tree | 6b79ea9a8492b9bead457ee5505a44768de5613b /utils/keepassxc-kdewallet | |
parent | ba4d68c76e5247c6e011487ef45efcfa93c83861 (diff) |
multiple database with --pw-stdin (#2916)
* Updated utilities to unlock KDBX with OS password manager on macOS and Linux
* Use a static stream on stdin for --pw-stdin otherwise buffer loss eliminates subsequent passwords
* Update INSTALL requirements
Diffstat (limited to 'utils/keepassxc-kdewallet')
-rwxr-xr-x | utils/keepassxc-kdewallet | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/utils/keepassxc-kdewallet b/utils/keepassxc-kdewallet new file mode 100755 index 000000000..90a3eb73d --- /dev/null +++ b/utils/keepassxc-kdewallet @@ -0,0 +1,38 @@ +#!/usr/bin/env bash +# fetch KeePass database passwords from kdewallet + +### change the path to suit your installation or set KDBX_SEARCH before calling ### +: ${KDBX_SEARCH:=~/.KeePass/*.kdbx} + +PROG="${0##*/}" +KEEPASSXC=$(which -a keepassxc | sed -e "\\,$0,d" -e 'q') + +function daemon_main { + # open kdewallet + handle=$(qdbus org.kde.kwalletd5 /modules/kwalletd5 org.kde.KWallet.open kdewallet 0 "$PROG") + while [[ true != $(qdbus org.kde.kwalletd5 /modules/kwalletd5 org.kde.KWallet.isOpen kdewallet) ]]; do + sleep 1 + done + + declare -A DBs + for DBPATH in $(ls -r $KDBX_SEARCH); do + DBs[$(realpath $DBPATH)]=$(qdbus org.kde.kwalletd5 /modules/kwalletd5 org.kde.KWallet.readPassword "$handle" "Passwords" "${DBPATH##*/}" "$PROG") + done + + # launch real keepassxc + IFS=$'\n\n\n' + "$KEEPASSXC" --pw-stdin "${!DBs[@]}" <<<"${DBs[*]}" & + + # done with kdewallet + qdbus org.kde.kwalletd5 /modules/kwalletd5 org.kde.KWallet.close "$handle" "false" "$PROG" +} + +if [[ '-d' = "$1" ]]; then + exec >&~/tmp/$PROG.log + set -vx + daemon_main +else + cd / + daemon_main </dev/null >&/dev/null & + disown +fi |