Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is CFErrorDomainLaunchd error 2?

I can't find CFErrorDomainLaunchd in any of the headers. I used the find command to grep every header file in the 10.11 SDK.

I also tried google:

site:opensource.apple.com CFErrorDomainLaunchd

SMJobBless passes the error back when I try to install my helper app and its launchd plist.

I'm quite puzzled because that installation was working just fine yesterday. I hereby resolve to check my code in far more frequently than I presently do.

Boolean             success;
CFErrorRef          error;

success = SMJobBless(
    kSMDomainSystemLaunchd,
    CFSTR("com.frescologic.FL2000.Uninstaller.UninstallerHelper"),
    self->_authRef,
    &error );     <-- This is CFErrorDomainLaunchd error 2

I am eternally in your debt.

I'm developing - or trying to develop - an uninstaller for a driver. It will also uninstall a user space program as well as the LaunchAgent plist that OS X uses to start or stop that user space program.

like image 941
Mike Crawford Avatar asked Jan 24 '18 23:01

Mike Crawford


2 Answers

It generally means that the LaunchAgent can't be found. Make sure there's a Build Phase to copy the Helper with a destination of type "Wrapper" with a sub-path of Contents/Library/LaunchServices . Also make sure the Product Name matches the Bundle ID use supply in your plist file.

Eg:

<key>SMPrivilegedExecutables</key>
    <dict>
        <key>com.keenow.HelperTool</key>
        <string>anchor apple generic and identifier &quot;com.myapp.HelperTool&quot; and (certificate leaf[field.1.2.840.113635.100.6.1.9] /* exists */ or certificate 1[field.1.2.840.113635.100.6.2.6] /* exists */ and certificate leaf[field.1.2.840.113635.100.6.1.13] /* exists */ and certificate leaf[subject.OU] = &quot;YourTeamId&quot;)</string>
    </dict>
like image 135
Joel B Avatar answered Nov 16 '22 05:11

Joel B


This question is a bit old so I'm guessing you've resolved it but maybe this answer can help someone else.

It's not documented anywhere I can find but this error will occur if you try to (re)install the helper when it is already running on the target system.

To avoid this in my app (where I have to upgrade the helper as functionality changes) I first remove the existing helper with

Boolean SMJobRemove(CFStringRef domain, CFStringRef jobLabel, AuthorizationRef auth, Boolean wait, CFErrorRef *outError);

This method was deprecated in 10.10 and unfortunately it hasn't yet been replaced as far as I can tell. However it does work if updating an existing helper is required.

If this isn't required in your app then I suggest checking for a helper already installed or using a script to remove the helper between test runs.

like image 4
Gary M Avatar answered Nov 16 '22 05:11

Gary M