I'm trying to develop a GUI app on macOS that takes control of the screen so that user must perform certain actions before regaining control of the desktop. I don't want the user to be able to kill the process (for example via an "assassin" shell script that looks for the process and terminates it with kill
).
Based on this post it is not possible to create an unkillable process on macOS.
I'm wondering, however, if it's possible to run the GUI process in root (or with other escalated privileges) such that the logged in user cannot kill it. So it's killable, but you need privileges above what the logged in user has (assuming they are not root). I'm not worried about a root user being able to kill it.
Such an app would run in a managed context. I've played around with Service Background Tasks, but so far haven't found what I'm looking for.
I'm hoping someone (especially from Apple) might be able to tell me if this goal is even achievable with macOS Sequoia (and beyond).
You seem to be on a path that DTS can’t follow you down. For example, the “unlock event” you mentioned in most definitely an implementation detail, and hence not supported by DTS.
If macOS 15.* and onward simply do not allow a GUI to be launched by anyone other than the logged in user
That statement doesn’t make sense in the context of macOS’s layered architecture. GUI code is only supported in a GUI login context. Code running in a GUI login context is, by definition, run by that logged in user. If that code switches the user ID to root then it’s still in the same GUI login context, although now it has a mixed execution context.
I referenced TN2083 previously. I strongly recommend that you read it carefully, and specifically the Execution Contexts section. If you do stuff like attempt to open a window from a daemon, you will run into compatibility problems down the line.
I'm wondering if this could be accomplished in conjunction with an Endpoint Security agent.
It’s certainly true that as ES client can prevent signals being delivered to processes.
However, I’m not sure there’s a good way to achieve your high-level goal. Presenting a window ‘above’ all other windows on the system is challenging. At one point I investigated how the screen saver / unlock subsystem works [1] and the answer was that it uses a whole bunch of SPI.
If you decide to ship a product that relies on implementation details rather than API, I encourage you to file one or more enhancement requests for a supported API to achieve your goals.
Share and Enjoy
—
Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"
[1] While trying to work out how SFAuthorizationPluginView
is able to presents its UI above the screen saver but standard GUI authorisation plug-ins are no longer able to do this.