From b287a702b70c3dcdab2b6db5c01369f3ccdb36ca Mon Sep 17 00:00:00 2001 From: Thomas Lamprecht Date: Mon, 28 Nov 2022 17:03:39 +0100 Subject: [PATCH] d/postinst: try to fixup installations with wrong .datastore.lck owner Must be a rather ancient installation in that case as we create new lockfiles with backup:backup since a while. Note that this wasn't all to relevant until recently when we fixed a TOCTOU for maintenance mode check by locking on datastore create, which happens in the unpriv. proxy daemon too, e.g., for the datastore status call. Signed-off-by: Thomas Lamprecht --- debian/postinst | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/debian/postinst b/debian/postinst index 3a53e686..489cf6ac 100644 --- a/debian/postinst +++ b/debian/postinst @@ -48,6 +48,16 @@ case "$1" in true fi + if dpkg --compare-versions "$2" 'lt' '2.3.1~'; then + lock_user="$(stat --format '%U' /etc/proxmox-backup/.datastore.lck)" + if [ "${lock_user}" != "backup" ]; then + echo "updating /etc/proxmox-backup/.datastore.lck from wrong user '${lock_user}' to 'backup'" + chown backup:backup /etc/proxmox-backup/.datastore.lck \ + || printf "Failed to fix datastore.lck user, please retry manually with:\n\n\t%s\n\n" \ + "chown backup:backup /etc/proxmox-backup/.datastore.lck" + fi + fi + if dpkg --compare-versions "$2" 'lt' '2.1.3~' && test -e /etc/proxmox-backup/sync.cfg; then prev_job=""