For some reason, I can't seem to get a lock....was wondering if anyone else has been here before:
AuthorizationRef auth = nil; OSStatus authErr = noErr; AuthorizationFlags rootFlags = kAuthorizationFlagDefaults | kAuthorizationFlagExtendRights | kAuthorizationFlagInteractionAllowed | kAuthorizationFlagPreAuthorize; authErr = AuthorizationCreate(nil, kAuthorizationEmptyEnvironment, rootFlags, &auth); SCPreferencesRef prefs; //SCPreferencesRef prefsWithAuth; CFStringRef appName = CFSTR("com.test.testapp"); CFStringRef computerName = CFSTR("macbookpro2"); SCPreferencesLock(prefs, NO); if ( geteuid() != 0 ) { prefs = SCPreferencesCreateWithAuthorization(NULL, appName, NULL, auth); } else { prefs = SCPreferencesCreate(NULL, appName, NULL); } if (prefs == nil) NSLog(@"InterfaceConfig failure: SCPreferencesCreate failed"); SCPreferencesLock(prefs, NO); if (prefs && SCPreferencesLock(prefs, TRUE)) { //We got a write lock, that means we can do whatever //we want to /Library/Preferences/SystemConfiguration/preferences.plist NSLog(@"LOCK OBTAINED"); } else { NSLog(@"LOCK NOT OBTAINED"); } SCPreferencesSetComputerName(prefs, computerName, kCFStringEncodingUTF8); SCPreferencesCommitChanges(prefs); if(!SCPreferencesCommitChanges(prefs)) { NSLog(@"can't commit changes"); } SCPreferencesApplyChanges(prefs); if(!SCPreferencesApplyChanges(prefs)) { NSLog(@"can't apply changes"); } SCPreferencesUnlock(prefs); CFRelease(prefs); _______________________________________________ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com