Advanced menu libvirt wiring: use SUDO_USER fallback like session prereqs

usermod used $USER directly; under sudo $USER can be root. All other
user-scoped calls already use ${SUDO_USER:-$USER} — aligned. No hardcoded
usernames anywhere in the repo (verified by grep; only the dotfiles repo
URL, which is overridable via DOTFILES_REPO).
This commit is contained in:
Pathfinder
2026-10-27 15:19:08 +01:00
parent e99c60a073
commit c552b30112
+3 -2
View File
@@ -541,9 +541,10 @@ install_category_pkgs() {
[[ "$item" == *libvirt* || "$item" == *virt-manager* || "$item" == *virt-install* ]] && wants_libvirt=true [[ "$item" == *libvirt* || "$item" == *virt-manager* || "$item" == *virt-install* ]] && wants_libvirt=true
done done
if $wants_libvirt; then if $wants_libvirt; then
info "Enabling libvirtd and adding $USER to the libvirt group..." local real_user="${SUDO_USER:-$USER}"
info "Enabling libvirtd and adding $real_user to the libvirt group..."
sudo systemctl enable --now libvirtd 2>/dev/null || true sudo systemctl enable --now libvirtd 2>/dev/null || true
sudo usermod -aG libvirt "$USER" || true sudo usermod -aG libvirt "$real_user" || true
warn "libvirt group membership applies after re-login." warn "libvirt group membership applies after re-login."
fi fi
;; ;;