From 18fd95044ba559b43bfb136f28692da7e0454463 Mon Sep 17 00:00:00 2001 From: Ali Mirjamali Date: Sun, 30 Jun 2024 21:51:35 +0330 Subject: [PATCH] qubes-dom0-update: prevent concurrent execution fixes: https://github.com/QubesOS/qubes-issues/issues/6345 --- dom0-updates/qubes-dom0-update | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/dom0-updates/qubes-dom0-update b/dom0-updates/qubes-dom0-update index e23455e..4031f83 100755 --- a/dom0-updates/qubes-dom0-update +++ b/dom0-updates/qubes-dom0-update @@ -187,6 +187,15 @@ if [ "$ID" != 0 ] && [ -z "$GUI" ] && [ -z "$CHECK_ONLY" ] ; then exit 1 fi +LOCKFILE="/var/run/qubes/qubes-dom0-update.lock" +exec 9>"${LOCKFILE}" +[ "$ID" == 0 ] && chgrp qubes "${LOCKFILE}" && chmod g+w "${LOCKFILE}" +flock -n 9 +if [[ ${?} -ne 0 ]]; then + echo "Another instance of qubes-dom0-update is already running!" + exit 1 +fi + if [ "$GUI" == "1" ] && [ ${#PKGS[@]} -ne 0 ]; then echo "ERROR: GUI mode can be used only for updates" >&2 exit 1