mirror of
https://github.com/keepassxreboot/keepassxc.git
synced 2024-10-01 01:26:01 -04:00
1cbd395d71
* 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
39 lines
1.1 KiB
Bash
Executable File
39 lines
1.1 KiB
Bash
Executable File
#!/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
|