What's the best way to run a script with root privileges whenever any user logs in? It should run in the background without prompting the user for a password.
2 Answers
Use a LoginHook.
sudo defaults write com.apple.loginwindow LoginHook /path/to/script
See here for more detail.
I still haven't found a way to do exactly this, but since the script I need to run is just a chmod command, it's sufficient to run it via a launchdaemon every 10 seconds instead.