Add sbin paths for hypervisor tool detection on non-root users
All checks were successful
Build-Publish / build (linux/amd64) (push) Successful in 4s
Build-Publish / build (linux/arm64) (push) Successful in 11s
Build-Publish / create-manifest (push) Successful in 2s
Build-Publish / publish-template (push) Successful in 8s

This commit is contained in:
j
2026-03-08 14:03:22 +13:00
parent 9fbc19183c
commit d675d282b6
2 changed files with 13 additions and 1 deletions

View File

@@ -206,9 +206,18 @@ fi
SUDOERS_FILE="/etc/sudoers.d/infmap"
SUDO_CMDS=""
# Detect which hypervisor tools are present
# Detect which hypervisor tools are present (check common sbin paths too)
for cmd in pct qm lxc virsh; do
cmd_path=$(command -v "$cmd" 2>/dev/null)
# Also check sbin paths not always in PATH
if [ -z "$cmd_path" ]; then
for p in /usr/sbin/$cmd /usr/local/sbin/$cmd /sbin/$cmd; do
if [ -x "$p" ]; then
cmd_path="$p"
break
fi
done
fi
if [ -n "$cmd_path" ]; then
SUDO_CMDS="${SUDO_CMDS}${USERNAME} ALL=(root) NOPASSWD: ${cmd_path}\n"
fi