fixed
This commit is contained in:
@@ -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 isn’t 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 ---
|
||||
|
||||
Reference in New Issue
Block a user