If anyone is interested, this (probably) turned out to be a mistake, and one was filed. rdar: // 10280469
The way the system works at the moment is that it will ask for the administrator password every time, regardless of whether the SMJobBless function should install the auxiliary tool or not. The error (probably) is that the administrator password request should not be executed if the auxiliary tool does not need to be installed (for example, it is already installed and has the same version as in the application bundle).
, , , , SMJobBless SMJobBless , , .
, (SMJobCopyDictionary ), , , , , .
() , , .
, . , , .
NSDictionary* installedHelperJobData;
installedHelperJobData = (NSDictionary*)SMJobCopyDictionary( kSMDomainSystemLaunchd, (CFStringRef)@"com.apple.bsd.SMJobBlessHelper" );
NSString* installedPath = [[installedHelperJobData objectForKey:@"ProgramArguments"] objectAtIndex:0];
NSURL* installedPathURL = [NSURL fileURLWithPath:installedPath];
NSDictionary* installedInfoPlist = (NSDictionary*)CFBundleCopyInfoDictionaryForURL( (CFURLRef)installedPathURL );
NSString* installedBundleVersion = [installedInfoPlist objectForKey:@"CFBundleVersion"];
NSInteger installedVersion = [installedBundleVersion integerValue];
NSLog( @"installedVersion: %ld", (long)installedVersion );
NSBundle* appBundle = [NSBundle mainBundle];
NSURL* appBundleURL = [appBundle bundleURL];
NSURL* currentHelperToolURL = [appBundleURL URLByAppendingPathComponent:@"Contents/Library/LaunchServices/com.apple.bsd.SMJobBlessHelper"];
NSDictionary* currentInfoPlist = (NSDictionary*)CFBundleCopyInfoDictionaryForURL( (CFURLRef)currentHelperToolURL );
NSString* currentBundleVersion = [currentInfoPlist objectForKey:@"CFBundleVersion"];
NSInteger currentVersion = [currentBundleVersion integerValue];
NSLog( @"currentVersion: %ld", (long)currentVersion );