Mac OSX : How to protect daemon process from stopping by root/admin

daemonslaunchdmacSecurity

I've a security daemon which performs many security related tasks. Daemon plist is part of /Library/LaunchDaemon/com.xyz.securityservice.plist also KeepAlive flag is 1.

The daemon I've currently can be stopped using this command – sudo launchctl unload /Library/LaunchDaemon/com.xyz.securityservice.plist

I wanted to restrict security daemon from unloading by this command.

I do not want anyone to unload/stop this daemon. One can stop security daemon only if he has security password(not system password) or if we send some private notification to daemon to stop itself. Daemon will observe this private notification.

Please suggest any pointer on this.

Best Answer

I'm not a developer or a guru in all of the available keys with launch daemons, but that is kind of a tall order as by design, root can do anything. I'm thinking you would basically be creating a security "virus" that would have a helper mechanism reload the daemon if it gets unloaded.