Knowledge Base

Preserving for the future: Shell scripts, AoC, and more

Keepass2 2.60 check update problem

I think I have found a novel bug in keepass2, and submitting a bug report in Debian is tricky when one doesn't use Debian.

The problem went away if I install keepass2=2.57-dfsg-4. I know the rest of the GNU+Linux world moved to keepassxc, but I like keepass2 interface, mostly because the password edit window is a separate window and there for I can move it around and still see the list of passwords.

The short explanation: starting in version 2.60, the application always removes an xml element "CheckForUpdateConfigured" when closing. This makes the application prompt again, after running again and opening a password file.

So my solution is to always enforce this entry, using this script in ~/bin/keepass2.

#!/bin/sh
# Startdate: 2026-03-16-2 15:46
# Purpose: fix keepass2 2.60 problem where it somehow removes this xml config element and therefore asks the user to
always check for updates.
update_xml_element() {
   # usage: parent="/toplevelobject" element="internalid" value="12341234" infile=./foo.xml _insert_xml_element
   _parent="${parent:-${1}}" ; _parent="${_parent%%/}"
   _element="${element:-${2}}"
   _value="${value:-${3}}"
   _infile="${infile:-${4}}"
   # example: xmlstarlet edit --update "/toplevelobject/internalid" --value "if-updated" --subnode "/toplevelobject[not(internalid)]" --type elem -n "internalid" --value "if-inserted"
   xmlstarlet edit --inplace --update "${_parent}/${_element}" --value "${_value}" --subnode "${_parent}[not(${_element})]" --type elem -n "${_element}" --value "${_value}" "${_infile}"
}
infile=~/.config/KeePass/KeePass.config.xml parent="/Configuration/Application/Start" element="CheckForUpdateConfigured" value="true" update_xml_element
infile=~/.config/KeePass/KeePass.config.xml parent="/Configuration/Application/Start" element="CheckForUpdate" value="false" update_xml_element
/usr/bin/keepass2 &
wait %1
infile=~/.config/KeePass/KeePass.config.xml parent="/Configuration/Application/Start" element="CheckForUpdateConfigured" value="true" update_xml_element
infile=~/.config/KeePass/KeePass.config.xml parent="/Configuration/Application/Start" element="CheckForUpdate" value="false" update_xml_element

Comments