Skip to content

Commit

Permalink
qubes-dom0-update: prevent concurrent execution
Browse files Browse the repository at this point in the history
  • Loading branch information
alimirjamali committed Jul 5, 2024
1 parent f6b35ff commit 18fd950
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions dom0-updates/qubes-dom0-update
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 18fd950

Please sign in to comment.