On Oct 3, 2011, at 12:22 PM, Quinn The Eskimo! wrote:In general I recommend that you avoid trying to check whether your helper tool is installed correctly by looking at the file system. Rather, do an IPC to the tool and, if it works, you know that everything is hunky dory. If you're concerned about version numbers, have an IPC request to ask the helper tool for its version. If that fails, or returns a low version, you then know that you need to go through the installation process.
Look at how I handle this in BetterAuthorizationSample. While it doesn't use SMJobBless (one day, one day...), the basic strategy is correct IMO.
<http://developer.apple.com/library/mac/samplecode/BetterAuthorizationSample/>
NSDictionary* installedHelperJobData = (NSDictionary*)SMJobCopyDictionary( kSMDomainSystemLaunchd, (CFStringRef)@"com.apple.bsd.SMJobBlessHelper" );NSString* installedPath = [[installedHelperJobData objectForKey:@"ProgramArguments"] objectAtIndex:0];NSURL* installedPathURL = [NSURL fileURLWithPath:installedPath];
SecStaticCodeCreateWithPath( (CFURLRef)installedPathURL, kSecCSDefaultFlags, &staticCodeRef );
What do you think about this solution? It certainly seems easier then doing an IPC to the tool when one is dealing with code that is signed…
I did write this code and it does seem to work…