I’ve a script, let’s name it on-event.sh, that is going to be run at particular occasions, corresponding to when a selected software launches or quits. The script itself will run as the present person (not root) since I will be utilizing BetterTouchTool to execute it.
Nonetheless, on-event.sh must someway set off the execution of one other script that should run as root, which I am going to name run-as-root.sh. run-as-root.sh will execute some instructions to load or unload particular third social gathering launch daemons (not my very own), therefore the necessity to run as root. Since it will all be taking place within the background, it must occur with out requiring person intervention, so it might’t use sudo or AppleScript’s with administrator privileges. Due to the apparent safety implications, I solely need it to be doable to execute run-as-root.sh as root and never any arbitrary script or terminal command.
How can I set it up so that is doable?
One possibility I am already conscious of is I might create a launch daemon that opens a socket, waits for a connection, after which executes run-as-root.sh, and have on-event.sh connect with that socket. However that is a extra heavy weight resolution than I am hoping for. Is there a better means to do that?
