Execute a script with root privileges before user login on macOS by configuring a Launch Daemon plist in /Library/LaunchDaemons.