launchd that runs a console app from authenticator

I have an authentication app (authApp) that runs on Mac. AuthApp lets you log in to the Mac. It runs in place of the default login screen. I have added a new button in authApp and I want that button to launch another app (let's call it newApp) when clicked. AuthApp is written in Objective-C and newApp in Swift. I am able to launch newApp from the login screen every time at logout with the help of launchd agents. But that is not what I want; I want it to open only when the button in AuthApp is clicked. This is my launchd plist

 `<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
        <key>Label</key>
        <string>com.example.apple-sample</string>
        <key>LimitLoadToSessionType</key>
        <string>LoginWindow</string>
        <key>KeepAlive</key>
        <true/>
        <key>ProgramArguments</key>
        <array>
        <string>/Library/PrivilegedHelperTools/newApp.app/Contents/MacOS/newApp</string>
        </array>
</dict>
</plist>`

The file is saved in /Library/LaunchAgents. newApp is in /Library/PrivilegedHelperTools. Is there a way to execute this launchd programmatically (Objective-C++/Swift) from the code so that newApp is launched? Please note this needs to be done before the user has logged in to the machine.

thanks in advance

It runs in place of the default login screen.

By what mechanism? As an authorisation plug-in that presents an SFAuthorizationPluginView subclass?

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

Yes as an Authorisation plugin

Authorisation plug-ins run in the pre-login environment which is quite strange. Running GUI apps directly from your plug-in is not supported [1]. You can use a pre-login agent but that presents two challenges:

  • IPC — The pre-login agent runs as a different user than the authorisation plug-in (root vs _securityagent).

  • General interface issues — It’s hard to coordinate the window in which your SFAuthorizationPluginView is hosted with any window being shown by the pre-login agent.

My recommendation here is that you open a DTS tech support incident so that I can help you one-on-one. Please reference this DevForums thread for context.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

[1] I also see folks trying to run a web view from their authorisation plug-in, and that’s something we support either.

Thanks @eskimo for the reply. Thanks for confirming that pre-login agents is the way to go. Right now the GUI app is showing up all the time at logout. How can I get it to work when only the button on the authorisation plugin is clicked? I tried WatchPaths and QueueDirectories, when the button is clicked I created a file in the WatchPath directory so the launchd launches the app only when there is a file in the directory(according to the definition of WatchPaths/QueuDirectories). But that did not help. The GUI app is showing up irrespective of the file being there or not in the WatchPath folder.

Hi,

I was able to get it working by using "WatchPaths". For watchPaths to work the file need to be existing already. When the button was clicked I wrote to a file and my App would be launched because the file was modified. But my app stands behind the authorisation plugin window. It comes in front once clicked. I am able to toggle between windows. But it would be nice if I could have my app displayed in front. Can this be done ?

Also the app is launched only when logged out. Is it possible to display the app even when locked and not only logged out?

My launchd plist now:

launchd that runs a console app from authenticator
 
 
Q