Skip to content

Approving the helper (Service Management)

App Auto-Patch installs a root LaunchDaemon (the “root helper”) that runs Installomator with elevated privileges. Out of the box macOS requires the end user to approve that daemon once via System Settings › General › Login Items & Extensions. On a managed Mac that prompt can be removed entirely with a com.apple.servicemanagement configuration profile. This doc covers the correct rule values for App Auto-Patch 4.x.

Use RuleType=Label for App Auto-Patch’s helper. The recommended rule is:

<dict>
<key>RuleType</key>
<string>Label</string>
<key>RuleValue</key>
<string>xyz.techitout.appAutoPatch.roothelper</string>
</dict>

From build 130 the sample profile also has a Label rule for each of App Auto-Patch’s LaunchAgents, xyz.techitout.appAutoPatch.login and xyz.techitout.appAutoPatch.agent, so a user can’t switch them off. It no longer has the RuleType=TeamIdentifier rule for 6GBSVT64FS. See App Auto-Patch’s LaunchAgents below.

The Service Management Rules array matches against attributes that BTM (Background Task Management) stores on each launch item. For an SMAppService-registered daemon — which is how AAP installs its root helper — BTM stores the launchd plist’s Label as the daemon’s BTM Identifier. RuleType=Label matches against that field directly, so it reliably auto-approves the daemon. RuleType=BundleIdentifier, by contrast, matches against BTM’s Assoc. Bundle IDs field. SMAppService-registered daemons do not have that field — only curated legacy daemon items (installed via .pkg into /Library/LaunchDaemons and /Library/PrivilegedHelperTools) do. As a result, BundleIdentifier rules don’t reliably match against AAP’s helper regardless of what RuleValue you give them. This mis-match was the actual cause of issue #6 and issue #11. You can verify the daemon’s BTM record yourself with:

Terminal window
sudo sfltool dumpbtm | grep -B 2 -A 15 roothelper

On a Mac whose profile approves the helper, you’ll see something like:

Name: AppAutoPatchRootHelper
Team Identifier: 6GBSVT64FS
Type: daemon (0x10)
Flags: [ managed ] (0x8)
Disposition: [enabled, allowed, notified] (0xb)
Identifier: 16.xyz.techitout.appAutoPatch.roothelper
URL: Contents/Library/LaunchDaemons/xyz.techitout.appAutoPatch.roothelper.plist
Executable Path: Contents/MacOS/AppAutoPatchRootHelper
Parent Identifier: 2.xyz.techitout.appAutoPatch

Identifier is the launchd Label with BTM’s type number in front (16 for a daemon). The Label rule’s value is the label without that number. Flags: [ managed ] means a profile rule covers the daemon. There’s no Assoc. Bundle IDs line, which is why BundleIdentifier rules can’t match.

  • Helper LaunchDaemon Label / bundle id: xyz.techitout.appAutoPatch.roothelper
  • Parent app bundle id: xyz.techitout.appAutoPatch
  • Team identifier: 6GBSVT64FS

Apple’s Service Management framework supports five rule types (reference). In order of preference for App Auto-Patch:

  1. Label — exact match against a launch item’s BTM Identifier, which is set from the launchd plist’s Label key. This is the only rule type that reliably matches an SMAppService-registered daemon, and it matches a LaunchAgent the same way. Recommended: the sample has one for the helper and one for each LaunchAgent.
  2. TeamIdentifier — matches anything signed by the AAP development team (6GBSVT64FS), the helper and both LaunchAgents included, and anything else that team signs. Before build 130 the sample had this rule. System Settings showed it as a managed item named after the signing developer, Robert Schroeder, which users didn’t recognize as App Auto-Patch, so the sample uses a Label rule for each LaunchAgent instead. If you add one, RuleValue must be the Team ID that signed the installed app; see Which Team ID in MDM-AppManagement.md.
  3. BundleIdentifier / BundleIdentifierPrefix — these match against BTM’s Assoc. Bundle IDs field, which is not populated for SMAppService-registered daemons. Don’t use these for AAP. They were the source of the original incorrect recommendation in this file (issues #6 and #11).
  4. LabelPrefix — prefix-match against a launch item’s BTM Identifier. xyz.techitout.appAutoPatch. would match the helper and both LaunchAgents in one rule, and any later launch item with that prefix. The sample names each one with Label instead.

Two LaunchAgents can start the app at login, and the helper’s Label rule matches neither:

  • ~/Library/LaunchAgents/xyz.techitout.appAutoPatch.login.plist, which the app writes for each user when OpenAtLogin or KeepAlive is on.
  • /Library/LaunchAgents/xyz.techitout.appAutoPatch.agent.plist, which an organization deploys (MDM-LaunchAgent.md).

Without a rule they still run, but a user can switch them off under Allow in the Background. The sample’s Label rules for them lock them on.

System Settings lists a LaunchAgent under the app its plist names in AssociatedBundleIdentifiers. From build 130 both plists name xyz.techitout.appAutoPatch, so the agents are listed under App Auto-Patch. A plist without that key is listed under the name on the app’s signature, Robert Schroeder, and the rule locks that entry. The app rewrites its own plist on the first launch after updating to build 130. An organization’s plist needs the key added and redeployed.

A complete, ready-to-sign sample lives next to this doc:

<!-- Match the helper daemon by its launchd Label -->
<dict>
<key>Comment</key>
<string>App Auto-Patch root helper (daemon, by launchd Label)</string>
<key>RuleType</key>
<string>Label</string>
<key>RuleValue</key>
<string>xyz.techitout.appAutoPatch.roothelper</string>
</dict>
<!-- Lock on the LaunchAgents that start the app at login -->
<dict>
<key>Comment</key>
<string>App Auto-Patch login agent (Open at Login and Keep Running)</string>
<key>RuleType</key>
<string>Label</string>
<key>RuleValue</key>
<string>xyz.techitout.appAutoPatch.login</string>
</dict>
<dict>
<key>Comment</key>
<string>App Auto-Patch organization LaunchAgent (MDM-LaunchAgent.md)</string>
<key>RuleType</key>
<string>Label</string>
<key>RuleValue</key>
<string>xyz.techitout.appAutoPatch.agent</string>
</dict>

A profile made from the sample before build 130 keeps its TeamIdentifier rule and has no LaunchAgent rules until you change it and redeploy it.

  1. Push the profile.
  2. Install (or reinstall) App Auto-Patch.
  3. Launch App Auto-Patch.
  4. Open System Settings › General › Login Items & Extensions and confirm the AAP entry shows up under Allow in the Background and is toggled on with a managed by your organization badge — i.e. the user can’t disable it.
  5. Confirm the AAP first-run wizard skips step 1 (“Approve the root helper”) because the helper status is already enabled. On the command line, sudo sfltool dumpbtm | grep -B 2 -A 15 roothelper shows the AAP daemon’s BTM record. After a successful match Flags should read [ managed ], Disposition should include enabled and allowed, and Generation should be greater than 0. With OpenAtLogin or KeepAlive on, sudo sfltool dumpbtm | grep -B 4 -A 15 appAutoPatch.login shows the login agent’s record the same way, with xyz.techitout.appAutoPatch among its associated bundle IDs. System Settings should have no separate Robert Schroeder entry. To check which rules a Mac has, run system_profiler SPConfigurationProfileDataType (no sudo needed) and look for com.apple.servicemanagement payloads. Don’t rely on /Library/Managed Preferences/com.apple.servicemanagement.plist: when several profiles have login items payloads, that file holds only one of them.

Daemon was registered before the profile arrived

Section titled “Daemon was registered before the profile arrived”

If the daemon was already in BTM (registered by a previous AAP install) before the profile was pushed, the rule may not retroactively apply on some macOS versions. Recovery is straightforward:

  1. In App Auto-Patch, click Settings › About › Reset Helper. It unregisters the daemon with SMAppService, which removes its BTM record, and registers it again. uninstall.sh can’t do this: SMAppService.unregister() only works from inside the running app, so the script leaves the BTM record behind. If the app can’t run, sudo sfltool resetbtm clears the records instead, for every app’s background items, and needs a restart.
  2. Run sudo "/Applications/App Auto-Patch.app/Contents/Resources/uninstall.sh" to remove the daemon and App Auto-Patch’s files.
  3. Reboot.
  4. Confirm the profile is still installed (profiles list).
  5. Reinstall AAP.
  6. Re-check sudo sfltool dumpbtm | grep -B 2 -A 15 roothelper — the daemon should come up auto-approved on first registration.

Helper waiting for approval after an upgrade

Section titled “Helper waiting for approval after an upgrade”

When the helper’s binary changes, App Auto-Patch unregisters and re-registers it, as SMAppService requires. On one managed Mac the re-registered helper ran until the next restart and then waited for approval, although Login Items listed App Auto-Patch under Managed Background Apps (App-Auto-Patch#335). A standard user can’t allow it, so the helper stays down until an administrator does.

  1. Generate a diagnostic bundle (Settings › About › Generate Diagnostic Bundle). From build 116, metadata.txt has a Managed login items section that lists the com.apple.servicemanagement rules of every installed profile, says whether each one covers the helper, and ends with a verdict. The rules are also in prefs/servicemanagement-profiles.plist.
  2. If no rule covers the helper, add the Label rule above. A BundleIdentifier rule for xyz.techitout.appAutoPatch can make App Auto-Patch appear under Managed Background Apps without covering the daemon.
  3. If a rule does cover it, run sudo sfltool dumpbtm | grep -B 2 -A 15 roothelper and check that the daemon’s Flags include managed and its Disposition includes enabled and allowed. To get the helper running now, an administrator can turn App Auto-Patch on under Login Items & Extensions. Please attach the dumpbtm section to an issue.
  • macOS 13 (Ventura) or later. The com.apple.servicemanagement payload was introduced in macOS Ventura and AAP 4 targets macOS 14+ anyway.
  • The profile must be deployed by a user-approved MDM. Apple does not permit manual installation of this payload type.
  • The payload only manages launch items the system already knows about. AAP must have been installed (and its daemon registered) at least once before BTM has the daemon in its database. Practically: ship the AAP installer and the profile to the same Mac in either order, but make sure both eventually arrive.
  • Multiple com.apple.servicemanagement payloads are allowed on a single Mac, so you can keep an existing profile that approves other daemons and add an additional one for AAP.