This commit is contained in:
klein panic
2025-02-10 13:34:02 -05:00
parent 3063b41206
commit 5fc271a8ab

View File

@@ -45,9 +45,14 @@ DAEMON_LOG_DIR="$(pwd)/chroot_daemon_logs"
# List of trivial commands to ignore in daemon logs (basename only)
IGNORE_LIST=(bash sh ls cat echo grep mount umount)
# Force the script to run as root while preserving the environment
if [ "$EUID" -ne 0 ]; then
exec sudo -E "$0" "$@"
# If running as root via sudo (SUDO_USER is set) but the environment isnt fully preserved,
# force a re-run with sudo -E. We use _ENV_PRESERVED as a marker to avoid an infinite loop.
if [ -n "$SUDO_USER" ] && [ -z "$_ENV_PRESERVED" ]; then
# Check for essential environment variables (you can add others if needed).
if [ -z "$DISPLAY" ] || [ -z "$XAUTHORITY" ]; then
export _ENV_PRESERVED=1
exec sudo -E "$0" "$@"
fi
fi
# --- Logging Functions ---