Skip to content
How to create an privileged Helper Tool under macOS, with Lazarus Pascal, to get root acces in your application.
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
SMJobBlessTest
LICENSE
Lazarus-Pascal-MacOS-SMJobBless.zip
README.md

README.md

macOS-SMJobBless-Lazarus-Pascal

How to create an privileged Helper Tool under macOS, with Lazarus Pascal, to get root acces in your application.

A full description and a ton of related information can be found on my homepage:

English: MacOS - SMJobBless: Elevated Privileges in Lazarus Pascal

Dutch: MacOS - SMJobBless: Elevated Privileges met Lazarus Pascal

SmJoBBless and Elevated Privileges Helper Tool Example

Purpose:

Simple example on how to create a Privileged Helper Tool using Lazarus Pascal, so your application can get root access by using such a Helper Tool.

Requirement:

A valid Apple Developer ID in order to sign the app bundle and the Helper Tool.

Tested and created with:

Lazarus 2.1.0 r60620M FPC 3.0.4 x86_64-darwin-cocoa (alpha) from SVN.

Before you start

I've uploaded a ZIP file that holds all files. Not the way GitHub should work, I know. Unfortunately, the project1.app structure seems to get lost when uploading empty directories, and we need those directories for things to work. I recommend downloading the zip file, and extracting that instead of cloning all files.

  1. Replace "XXXXXXXXXX" with your Developer ID in these files:
SMJobBlessTest/project1.app/Contents/Info.plist
SMJobBlessTest/Helper/SMJobBlessHelper-Info.plist
  1. Replace "John Doe (XXXXXXXXXX)" with your Developer name and ID in this file:
SMJobBlessTest/prepareproject1.sh
  1. Open the Helper Tool project com.tweaking4all.SMJobBlessHelper.lpi in Lazarus and compile it with "Build".

  2. Open the Main Application project project1.lpi in Lazarus and compile it with "Build".

  3. in Terminal, go to the "SMJobBlessTest" directory and run "./prepareproject.sh"

    Optionally verify with

./SMJobBlessUtil.py check project1.app
  1. Open Console (Applications/Utilities) and set the filter to "SMJOBBLESS"

  2. Run project1.app (or project1) from the "SMJobBlessTest" directory.

  • "Initialize" will initialze and optionally install the Helper Tool
  • "Start Complicated" will start a process that keeps putting timestamps in the log
  • "Is Active?" will show if it's active or not
  • "Abort Complicated" will stop the time stamping
  • "Last Error" will just show a dummy message
  • "Get Version" will show the current Helper Version
  • "Quit Helper" will terminate the Helper tool

Clean up:

Remove Helper Tool

(Caution: this may not be the appropriate method)

sudo rm /Library/PrivilegedHelperTools/com.tweaking4all.SMJobBlessHelper

Kill running Helper Tool

(Caution: this may not be the appropriate method)

ps -ax | grep com.tweaking4all
sudo kill -9 <PID>

Where <PID> is the PID from the "ps" line that had "com.tweaking4all.SMJobBlessHelper" in it.

You can’t perform that action at this time.