My take on privileged helper, thanks to Erik's privileged helper tool example
Update: Erik's new privileged helper example is quite perfect, so I won't probably update this anymore.
- Create a project (for example, a normal Cocoa project, like PrivilegedTaskRunner in this example)
- Create a new command line target (PrivilegedTaskRunnerHelper)
- PrivilegedTaskRunner -> Copy helper (Build Phases)
- PrivilegedTaskRunner -> Compile sources (Build Phases)
Make sure that target name for helper tool is with full namespace (for example: com.suolapeikko.examples.PrivilegedRunnerHelper)
- Helper -> Build Settings -> Linking -> Other Linker Flags
-sectcreate
__TEXT
__info_plist
"$(SRCROOT)/PrivilegedTaskRunnerHelper/PrivilegedTaskRunnerHelper-Info.plist"
-sectcreate
__TEXT
__launchd_plist
"$(SRCROOT)/PrivilegedTaskRunnerHelper/PrivilegedTaskRunnerHelper-Launchd.plist"
- See PrivilegedTaskRunnerHelper-Info.plist and PrivilegedTaskRunnerHelper-Launchd.plist
- Anchor line with Certificate info needs to be created by Apple's tool called SMJobBlessUtil.py
SMJobBless creates lines to Info.plist and Helper-Info.plist:
./SMJobBlessUtil.py setreq PrivilegedTaskRunner.app PrivilegedTaskRunner/Info.plist PrivilegedTaskRunner/PrivilegedTaskRunnerHelper-Info.plist
SMJobBless contains requirements checker:
./SMJobBlessUtil.py check PrivilegedTaskRunner.app