I am attempting to replace a helper tool. Most of the time if I increment the 
version (of my application and of the helper tool) then the new tool will be 
installed. Sometimes it won't be installed and I have to delete the old one 
manually. The problem seems to occur about every dozen versions or so, and once 
it happens the replacement will not occur even if I change the version numbers 
again.

https://developer.apple.com/reference/servicemanagement/1431078-smjobbless?language=objc
 
<https://developer.apple.com/reference/servicemanagement/1431078-smjobbless?language=objc>
 states "If the job is already installed, success is returned.” 

How does SMJobBless() determine that the job is already installed? What do I 
need to do, beyond creating an entirely new job name, to make it look different 
enough to replace?

Following is my code and console output (from macOS 10.12.2).

James Foster


CODE:

- (void)installHelperTool;
{
    OSStatus status = AuthorizationCreate(...);
    // handle errors
    
    NSLog(@"existing: %@", [self system:@"/usr/bin/otool -P "
        "/Library/PrivilegedHelperTools/com.GemTalk.GemStone.Helper | "
        "grep -A 1 VersionString | tail -1"]);
    NSLog(@"replacement: %@", [self system:@"/usr/bin/otool -P "
        
"GemStone.app/Contents/Library/LaunchServices/com.GemTalk.GemStone.Helper | "
          "grep -A 1 VersionString | tail -1"]);
    CFErrorRef cfError = nil;
    if (SMJobBless(kSMDomainSystemLaunchd, (__bridge 
CFStringRef)@kHelperIdentifier, authRef, &cfError)) {
        NSLog(@"SMJobBless(%s,...) returned true; attempting (%s).", 
kHelperIdentifier, kShortVersionString);
        NSLog(@"now found: %@", [self system:@"/usr/bin/otool -P "
                 "/Library/PrivilegedHelperTools/com.GemTalk.GemStone.Helper | "
                "grep -A 1 VersionString | tail -1"]);
    } else {
        AppError(@"Helper tool installation failed: %@", [(__bridge NSError*) 
cfError localizedDescription]);
    }
}


CONSOLE:

default 14:25:04.368568 -0800   authd   Succeeded authorizing right 
'com.apple.ServiceManagement.blesshelper' by client 
'/Users/jfoster/Library/Developer/Xcode/DerivedData/GemStone-akfvfyaoddyaavgbcxnrdhnovoal/Build/Products/Debug/GemStone.app'
 [5626] for authorization created by 
'/Users/jfoster/Library/Developer/Xcode/DerivedData/GemStone-akfvfyaoddyaavgbcxnrdhnovoal/Build/Products/Debug/GemStone.app'
 [5626] (13,0)
default 14:25:04.889238 -0800   kernel  AMFI: allowing exception handler for 
'GemStone' (5626) because the process is not restricted.
default 14:25:04.385444 -0800   GemStone        existing:       
<string>1.3.3.9</string>
default 14:25:04.900905 -0800   kernel  AMFI: allowing exception handler for 
'GemStone' (5626) because the process is not restricted.
default 14:25:04.397113 -0800   GemStone        replacement:    
<string>1.4.0</string>
default 14:25:04.398426 -0800   authd   Succeeded authorizing right 
'com.apple.ServiceManagement.blesshelper' by client '/usr/libexec/smd' [251] 
for authorization created by 
'/Users/jfoster/Library/Developer/Xcode/DerivedData/GemStone-akfvfyaoddyaavgbcxnrdhnovoal/Build/Products/Debug/GemStone.app'
 [5626] (3,0)
default 14:25:04.408694 -0800   GemStone        
SMJobBless(com.GemTalk.GemStone.Helper,...) returned true; attempting (1.4.0).
default 14:25:04.923798 -0800   kernel  AMFI: allowing exception handler for 
'GemStone' (5626) because the process is not restricted.
default 14:25:04.419988 -0800   GemStone        now found:      
<string>1.3.3.9</string>

_______________________________________________
launchd-dev mailing list
launchd-dev@lists.macosforge.org
https://lists.macosforge.org/mailman/listinfo/launchd-dev

Reply via email to