// // Delete a NDAS device info. // // Return : false if No memory. // true if success. // bool NDASPreferencesDelete(UInt32 slotNumber) { CFStringRef strEntryKey = NULL; // Slot Number is the Key. strEntryKey = CFStringCreateWithFormat(NULL, NULL, CFSTR(KEY_SLOT_NUMBER_STRING), slotNumber); if(NULL == strEntryKey) { return false; } // Set Values. CFPreferencesSetValue( strEntryKey, NULL, NDAS_PREFERENCES_FILE_REGISTER, kCFPreferencesAnyUser, kCFPreferencesCurrentHost ); // Write out the preference data. CFPreferencesSynchronize( NDAS_PREFERENCES_FILE_REGISTER, kCFPreferencesAnyUser, kCFPreferencesCurrentHost ); // Clean up. if(strEntryKey) CFRelease(strEntryKey); return true; }
static kim_error kim_os_preferences_set_value (kim_preference_key in_key, CFPropertyListRef in_value) { kim_error err = KIM_NO_ERROR; CFStringRef key = NULL; /* in_value may be NULL if removing the key */ if (!err) { key = kim_os_preferences_cfstring_for_key (in_key); } if (!err && key) { kim_boolean homedir_ok = kim_library_allow_home_directory_access(); CFStringRef user = homedir_ok ? kCFPreferencesCurrentUser : kCFPreferencesAnyUser; CFStringRef host = homedir_ok ? kCFPreferencesAnyHost : kCFPreferencesCurrentHost; CFPreferencesSetValue (key, in_value, KIM_PREFERENCES_FILE, user, host); if (!CFPreferencesSynchronize (KIM_PREFERENCES_FILE, user, host)) { err = check_error (KIM_PREFERENCES_WRITE_ERR); } } return check_error (err); }
void QMacSettingsPrivate::sync() { for (int i = 0; i < numDomains; ++i) { for (int j = 0; j < numHostNames; ++j) { Boolean ok = CFPreferencesSynchronize(domains[i].applicationOrSuiteId, domains[i].userName, hostNames[j]); // only report failures for the primary file (the one we write to) if (!ok && i == 0 && hostNames[j] == hostName && status == QSettings::NoError) { #if 1 // work around what seems to be a bug in CFPreferences: // don't report an error if there are no preferences for the application QCFType<CFArrayRef> appIds = CFPreferencesCopyApplicationList(domains[i].userName, hostNames[j]); // iterate through all the applications and see if we're there CFIndex size = CFArrayGetCount(appIds); for (CFIndex k = 0; k < size; ++k) { const void *cfvalue = CFArrayGetValueAtIndex(appIds, k); if (CFGetTypeID(cfvalue) == CFStringGetTypeID()) { if (CFStringCompare(static_cast<CFStringRef>(cfvalue), domains[i].applicationOrSuiteId, kCFCompareCaseInsensitive) == kCFCompareEqualTo) { setStatus(QSettings::AccessError); break; } } } #else setStatus(QSettings::AccessError); #endif } } } }
void CACFPreferences::Synchronize(bool inCurrentUser, bool inCurrentHost, bool inForce) { if(inForce || ArePrefsOutOfDate(inCurrentUser, inCurrentHost)) { CFStringRef theUser = inCurrentUser ? kCFPreferencesCurrentUser : kCFPreferencesAnyUser; CFStringRef theHost = inCurrentHost ? kCFPreferencesCurrentHost : kCFPreferencesAnyHost; CFPreferencesSynchronize(kCFPreferencesAnyApplication, theUser, theHost); MarkPrefsClean(inCurrentUser, inCurrentHost); } }
STATIC void ProtoInfoChangedCheck(ProtoInfoRef proto_info) { if (prefs_did_change(&proto_info->generation)) { CFPreferencesSynchronize(proto_info->appID, kCFPreferencesCurrentUser, kCFPreferencesAnyHost); } return; }
CFArrayRef NDASPreferencesGetRegisteredSlotList() { // Read Last Value. CFPreferencesSynchronize( NDAS_PREFERENCES_FILE_REGISTER, kCFPreferencesAnyUser, kCFPreferencesCurrentHost ); return CFPreferencesCopyKeyList ( NDAS_PREFERENCES_FILE_REGISTER, kCFPreferencesAnyUser, kCFPreferencesCurrentHost ); }
static kim_error kim_os_selection_hints_set_selection_hints_array (CFArrayRef in_selection_hints_array) { kim_error err = KIM_NO_ERROR; if (!err && !in_selection_hints_array) { err = check_error (KIM_NULL_PARAMETER_ERR); } if (!err) { kim_boolean homedir_ok = kim_library_allow_home_directory_access(); CFStringRef user = homedir_ok ? kCFPreferencesCurrentUser : kCFPreferencesAnyUser; CFStringRef host = homedir_ok ? kCFPreferencesAnyHost : kCFPreferencesCurrentHost; CFPreferencesSetValue (KIM_SELECTION_HINTS_ARRAY, in_selection_hints_array, KIM_SELECTION_HINTS_FILE, user, host); if (!CFPreferencesSynchronize (KIM_SELECTION_HINTS_FILE, user, host)) { err = check_error (KIM_PREFERENCES_WRITE_ERR); } } return check_error (err); }
bool NDASPreferencesChangeNameOfRAIDDevice(PGUID raidID, CFStringRef name) { CFStringRef cfsKey = NULL; CFMutableDictionaryRef dictEntry = NULL; CFUUIDRef cfuGuid= NULL; if (name) { // Create Dict dictEntry = CFDictionaryCreateMutable (kCFAllocatorDefault, 0, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks); if (NULL == dictEntry) { return false; } CFDictionaryAddValue(dictEntry, CFSTR(KEY_NAME_STRING), name ); } // GUID is key. cfuGuid = CFUUIDCreateWithBytes(kCFAllocatorDefault, raidID->guid[0], raidID->guid[1], raidID->guid[2], raidID->guid[3], raidID->guid[4], raidID->guid[5], raidID->guid[6], raidID->guid[7], raidID->guid[8], raidID->guid[9], raidID->guid[10], raidID->guid[11], raidID->guid[12], raidID->guid[13], raidID->guid[14], raidID->guid[15]); if (NULL == cfuGuid) { return false; } cfsKey = CFUUIDCreateString ( kCFAllocatorDefault, cfuGuid ); if (NULL == cfsKey) { return false; } // Set Values. CFPreferencesSetValue( cfsKey, dictEntry, NDAS_PREFERENCES_FILE_RAID_INFORMATION, kCFPreferencesAnyUser, kCFPreferencesCurrentHost ); // Write out the preference data. CFPreferencesSynchronize( NDAS_PREFERENCES_FILE_RAID_INFORMATION, kCFPreferencesAnyUser, kCFPreferencesCurrentHost ); if (cfsKey) CFRelease(cfsKey); if (dictEntry) CFRelease(dictEntry); if (cfuGuid) CFRelease(cfuGuid); return true; }
bool NDASPreferencesChangeConfigurationOfLogicalDevice(UInt32 index, UInt32 configuration) { // Get Logical Device. NDASLogicalDeviceInformation NDASInfo = { 0 }; NDASInfo.index = index; if(NDASGetLogicalDeviceInformationByIndex(&NDASInfo)) { CFStringRef cfsKey = NULL; CFNumberRef cfnConfiguration = NULL; CFUUIDRef cfuGuid = NULL; switch(configuration) { case kNDASUnitConfigurationMountRW: case kNDASUnitConfigurationMountRO: { cfnConfiguration = CFNumberCreate (NULL, kCFNumberSInt32Type, &configuration); } break; case kNDASUnitConfigurationUnmount: { } break; } // GUID is key. cfuGuid = CFUUIDCreateWithBytes(kCFAllocatorDefault, NDASInfo.LowerUnitDeviceID.guid[0], NDASInfo.LowerUnitDeviceID.guid[1], NDASInfo.LowerUnitDeviceID.guid[2], NDASInfo.LowerUnitDeviceID.guid[3], NDASInfo.LowerUnitDeviceID.guid[4], NDASInfo.LowerUnitDeviceID.guid[5], NDASInfo.LowerUnitDeviceID.guid[6], NDASInfo.LowerUnitDeviceID.guid[7], NDASInfo.LowerUnitDeviceID.guid[8], NDASInfo.LowerUnitDeviceID.guid[9], NDASInfo.LowerUnitDeviceID.guid[10], NDASInfo.LowerUnitDeviceID.guid[11], NDASInfo.LowerUnitDeviceID.guid[12], NDASInfo.LowerUnitDeviceID.guid[13], NDASInfo.LowerUnitDeviceID.guid[14], NDASInfo.LowerUnitDeviceID.guid [15]); cfsKey = CFUUIDCreateString(kCFAllocatorDefault, cfuGuid); CFRelease(cfuGuid); // Set Values. CFPreferencesSetValue( cfsKey, cfnConfiguration, NDAS_PREFERENCES_FILE_CONFIGURATION, kCFPreferencesAnyUser, kCFPreferencesCurrentHost ); // Write out the preference data. CFPreferencesSynchronize( NDAS_PREFERENCES_FILE_CONFIGURATION, kCFPreferencesAnyUser, kCFPreferencesCurrentHost ); if (cfsKey) CFRelease(cfsKey); if (cfnConfiguration) CFRelease(cfnConfiguration); } else { return false; } return true; }
// // Query NDAS info by Slot number. // // Return : -1 if Bad parameters, No memory or bad Infos. // 0 if Not exist // 1 if success. // SInt32 NDASPreferencesQueryBySlotNumber(PNDASPreferencesParameter parameter) { CFStringRef strEntryKey = NULL; CFStringRef strIDKey[4] = { NULL }; CFStringRef strWriteKeyKey = NULL; CFStringRef strConfigurationKey = NULL; CFStringRef strNameKey = NULL; CFStringRef strIDValue[4] = { NULL }; CFStringRef strWriteKeyValue = NULL; CFNumberRef numberConfigurationValue = NULL; CFStringRef strNameValue = NULL; CFDictionaryRef dictEntry = NULL; int count; bool present; SInt32 result = -1; CFArrayRef cfaKeys = NULL; if(parameter == NULL || parameter->slotNumber == 0) { return -1; } // Read Last Value. CFPreferencesSynchronize( NDAS_PREFERENCES_FILE_REGISTER, kCFPreferencesAnyUser, kCFPreferencesCurrentHost ); // Slot Number is the Key. strEntryKey = CFStringCreateWithFormat(NULL, NULL, CFSTR(KEY_SLOT_NUMBER_STRING), parameter->slotNumber); if(NULL == strEntryKey) { return -1; } dictEntry = CFPreferencesCopyValue ( strEntryKey, NDAS_PREFERENCES_FILE_REGISTER, kCFPreferencesAnyUser, kCFPreferencesCurrentHost ); if(dictEntry == NULL) { result = 0; goto cleanup; } // // Check and Copy Values. // // Create Keys. for(count = 0; count < 4; count++) { strIDKey[count] = CFStringCreateWithFormat(NULL, NULL, CFSTR(KEY_ID_STRING), count); if(NULL == strIDKey[count]) { goto cleanup; } } strWriteKeyKey = CFStringCreateWithFormat(NULL, NULL, CFSTR(KEY_WRITEKEY_STRING)); strConfigurationKey = CFStringCreateWithFormat(NULL, NULL, CFSTR(KEY_CONFIGURATION_STRING)); if(NULL == strWriteKeyKey || NULL == strConfigurationKey) { goto cleanup; } // ID for(count = 0; count < 4; count++) { strIDValue[count] = NDASPreferencesGetIDorWriteKey(dictEntry, strIDKey[count]); if (NULL == strIDValue[count]) { result = -1; goto cleanup; } if(!CFStringGetCString(strIDValue[count], parameter->chID[count], 6, CFStringGetSystemEncoding())) { goto cleanup; } } // Write Key. strWriteKeyValue = NDASPreferencesGetIDorWriteKey(dictEntry, strWriteKeyKey); if (NULL == strWriteKeyValue) { // Write Key is Optional. memset(parameter->chWriteKey, 0, 6); } CFStringGetCString(strWriteKeyValue, parameter->chWriteKey, 6, CFStringGetSystemEncoding()); // Copy Name. strNameKey = CFStringCreateWithFormat(NULL, NULL, CFSTR(KEY_NAME_STRING), KEY_NAME_STRING); if(NULL == strNameKey) { goto cleanup; } present = CFDictionaryGetValueIfPresent( dictEntry, strNameKey, (const void**)&strNameValue ); if(!present || !strNameValue) { // Name is Optional. parameter->cfsName = NULL; } else { CFRetain(strNameValue); if(CFStringGetTypeID() == CFGetTypeID(strNameValue)) { parameter->cfsName = CFStringCreateCopy(kCFAllocatorDefault, strNameValue); } } // Configuration. present = CFDictionaryGetValueIfPresent( dictEntry, strConfigurationKey, (const void**)&numberConfigurationValue ); if(!present || !numberConfigurationValue) { // configuraton is Optional. parameter->configuration = kNDASUnitConfigurationUnmount; } else { CFRetain(numberConfigurationValue); // Convert CF Number to int CFNumberGetValue (numberConfigurationValue, kCFNumberSInt32Type, ¶meter->configuration); if(parameter->configuration > kNDASNumberOfUnitConfiguration) { parameter->configuration = kNDASUnitConfigurationUnmount; } } result = 1; cleanup: // clean up. if(strEntryKey) CFRelease(strEntryKey); if(dictEntry) CFRelease(dictEntry); if(strWriteKeyKey) CFRelease(strWriteKeyKey); if(strWriteKeyValue) CFRelease(strWriteKeyValue); if(strNameKey) CFRelease(strNameKey); if(strNameValue) CFRelease(strNameValue); if(strConfigurationKey) CFRelease(strConfigurationKey); if(numberConfigurationValue) CFRelease(numberConfigurationValue); for(count = 0; count < 4; count++) { if(strIDKey[count]) CFRelease(strIDKey[count]); if(strIDValue[count]) CFRelease(strIDValue[count]); } return result; }
// // Insert New NDAS device info. // // Return : false if Bad parameters or No memory. // true if success. // bool NDASPreferencesInsert(PNDASPreferencesParameter parameter) { CFStringRef strEntryKey = NULL; CFStringRef strIDKey[4] = { NULL }; CFStringRef strWriteKeyKey = NULL; CFStringRef strConfigurationKey = NULL; CFStringRef strIDValue[4] = { NULL }; CFStringRef strWriteKeyValue = NULL; CFNumberRef numberConfigurationValue = NULL; CFStringRef strNameKey = NULL; CFMutableDictionaryRef dictEntry = NULL; int count; bool result = false; if(parameter->slotNumber == 0) { return false; } // Create Dict dictEntry = CFDictionaryCreateMutable (kCFAllocatorDefault, 0, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks); if (NULL == dictEntry) { return false; } // Copy ID for(count = 0; count < 4; count++) { // Create Key. strIDKey[count] = CFStringCreateWithFormat(NULL, NULL, CFSTR(KEY_ID_STRING), count); // Create Value. strIDValue[count] = CFStringCreateWithFormat(NULL, NULL, CFSTR("%s"), parameter->chID[count]); if (NULL == strIDKey[count] || NULL == strIDValue[count]) { goto cleanup; } if (!NDASPreferencesSetIDorWriteKey(dictEntry, strIDKey[count], strIDValue[count])) { goto cleanup; } } // Copy WriteKey. strWriteKeyKey = CFStringCreateWithFormat(NULL, NULL, CFSTR(KEY_WRITEKEY_STRING)); strWriteKeyValue = CFStringCreateWithFormat(NULL, NULL, CFSTR("%s"), parameter->chWriteKey); if (NULL == strWriteKeyKey || NULL == strWriteKeyValue) { goto cleanup; } if(!NDASPreferencesSetIDorWriteKey(dictEntry, strWriteKeyKey, strWriteKeyValue)) { goto cleanup; } // Copy Name strNameKey = CFStringCreateWithFormat(NULL, NULL, CFSTR(KEY_NAME_STRING)); if (NULL == strNameKey) { goto cleanup; } //strNameValue = CFStringCreateWithFormat(NULL, NULL, CFSTR("%s"), parameter->Name); //strNameValue = CFStringCreateWithCharacters(kCFAllocatorDefault, (UniChar *)parameter->Name, MAX_NDAS_NAME_SIZE / 2); CFDictionaryAddValue(dictEntry, strNameKey, parameter->cfsName ); // Copy Configuration. strConfigurationKey = CFStringCreateWithFormat(NULL, NULL, CFSTR(KEY_CONFIGURATION_STRING)); numberConfigurationValue = CFNumberCreate (NULL, kCFNumberSInt32Type, ¶meter->configuration); if (NULL == strConfigurationKey || NULL == numberConfigurationValue) { goto cleanup; } CFDictionaryAddValue(dictEntry, strConfigurationKey, numberConfigurationValue); // Slot Number is the Key. strEntryKey = CFStringCreateWithFormat(NULL, NULL, CFSTR(KEY_SLOT_NUMBER_STRING), parameter->slotNumber); // Set Values. CFPreferencesSetValue( strEntryKey, dictEntry, NDAS_PREFERENCES_FILE_REGISTER, kCFPreferencesAnyUser, kCFPreferencesCurrentHost ); // Write out the preference data. CFPreferencesSynchronize( NDAS_PREFERENCES_FILE_REGISTER, kCFPreferencesAnyUser, kCFPreferencesCurrentHost ); result = true; cleanup: CFDictionaryRemoveAllValues(dictEntry); // Clean up. if(strEntryKey) CFRelease(strEntryKey); if(dictEntry) CFRelease(dictEntry); if(strWriteKeyKey) CFRelease(strWriteKeyKey); if(strWriteKeyValue) CFRelease(strWriteKeyValue); if(strConfigurationKey) CFRelease(strConfigurationKey); if(numberConfigurationValue) CFRelease(numberConfigurationValue); if(strNameKey) CFRelease(strNameKey); for(count = 0; count < 4; count++) { if(strIDKey[count]) CFRelease(strIDKey[count]); if(strIDValue[count]) CFRelease(strIDValue[count]); } return result; }
/* * Store the specified certificate (or, more likely, some platform-dependent * reference to it) as the specified principal's certificate. Passing * in NULL for the client_cert has the effect of deleting the relevant entry * in the cert storage. */ krb5_error_code krb5_pkinit_set_client_cert( const char *principal, /* full principal string */ krb5_pkinit_cert_t client_cert) { SecCertificateRef certRef = (SecCertificateRef)client_cert; OSStatus ortn; CSSM_DATA issuerSerial = {0, NULL}; CFDataRef cfIssuerSerial = NULL; CFDictionaryRef existDict = NULL; CFMutableDictionaryRef newDict = NULL; CFStringRef keyStr = NULL; krb5_error_code ourRtn = 0; if(certRef != NULL) { if(CFGetTypeID(certRef) != SecCertificateGetTypeID()) { return KRB5KRB_ERR_GENERIC; } /* Cook up DER-encoded issuer/serial number */ ortn = pkinit_get_cert_issuer_sn(certRef, &issuerSerial); if(ortn) { ourRtn = KRB5KRB_ERR_GENERIC; goto errOut; } } /* * Obtain the existing pref for kPkinitClientCertKey as a CFDictionary, or * cook up a new one. */ ortn = pkinit_get_pref_dict(&existDict); if(ortn == noErr) { /* dup to a mutable dictionary */ newDict = CFDictionaryCreateMutableCopy(NULL, 0, existDict); } else { if(certRef == NULL) { /* no existing entry, nothing to delete, we're done */ return 0; } newDict = CFDictionaryCreateMutable(NULL, 0, &kCFCopyStringDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks); } if(newDict == NULL) { ourRtn = ENOMEM; goto errOut; } /* issuer / serial number ==> that dictionary */ keyStr = CFStringCreateWithCString(NULL, principal, kCFStringEncodingASCII); if(certRef == NULL) { CFDictionaryRemoveValue(newDict, keyStr); } else { cfIssuerSerial = CFDataCreate(NULL, issuerSerial.Data, issuerSerial.Length); CFDictionarySetValue(newDict, keyStr, cfIssuerSerial); } /* dictionary ==> prefs */ CFPreferencesSetValue(CFSTR(kPkinitClientCertKey), newDict, CFSTR(kPkinitClientCertApp), kCFPreferencesCurrentUser, kCFPreferencesAnyHost); if(CFPreferencesSynchronize(CFSTR(kPkinitClientCertApp), kCFPreferencesCurrentUser, kCFPreferencesAnyHost)) { ourRtn = 0; } else { ourRtn = EACCES; /* any better ideas? */ } errOut: if(cfIssuerSerial) { CFRelease(cfIssuerSerial); } if(issuerSerial.Data) { free(issuerSerial.Data); } if(existDict) { CFRelease(existDict); } if(newDict) { CFRelease(newDict); } if(keyStr) { CFRelease(keyStr); } return ourRtn; }
static Boolean LoadSettingsForUser(CFStringRef username) { io_iterator_t iter = 0; io_registry_entry_t regEntry = 0; CFDictionaryRef newSettings = NULL; const char * name; Boolean success = TRUE; if(username != NULL) { name = CFStringGetCStringPtr(username, kCFStringEncodingMacRoman); write_log(LOG_NOTICE, "Loading settings for user '%s'.", name); CFPreferencesSynchronize(CFSTR(kDriverAppID), username, kCFPreferencesAnyHost); newSettings = CFPreferencesCopyValue(CFSTR(kCurrentParametersKey), CFSTR(kDriverAppID), username, kCFPreferencesAnyHost); if(newSettings == NULL) write_log(LOG_NOTICE, "No custom settings found."); } if(newSettings == NULL) { write_log(LOG_NOTICE, "Loading default settings."); CFPreferencesSynchronize(CFSTR(kDriverAppID), kCFPreferencesAnyUser, kCFPreferencesCurrentHost); newSettings = CFPreferencesCopyValue(CFSTR(kDefaultParametersKey), CFSTR(kDriverAppID), kCFPreferencesAnyUser, kCFPreferencesCurrentHost); if(newSettings == NULL) { write_log(LOG_ERR, "No default settings found."); success = FALSE; goto EXIT; } } if(IOServiceGetMatchingServices(kIOMasterPortDefault, IOServiceMatching(kIOHIDSystemClass), &iter) != KERN_SUCCESS) { iter = 0; write_log(LOG_ERR, "Error locating HIDSystem service!"); success = FALSE; goto EXIT; } regEntry = IOIteratorNext(iter); if(regEntry == 0) { write_log(LOG_ERR, "No HIDSystem service found!"); success = FALSE; goto EXIT; } if(IORegistryEntrySetCFProperty(regEntry, CFSTR(kiScroll2SettingsKey), newSettings) != KERN_SUCCESS) { write_log(LOG_ERR, "Error setting HIDSystem properties!"); success = FALSE; goto EXIT; } EXIT: if(newSettings != NULL) { CFRelease(newSettings); newSettings = NULL; } if(regEntry != 0) { IOObjectRelease(regEntry); regEntry = 0; } if(iter != 0) { IOObjectRelease(iter); iter = 0; } return success; }
OSErr SetScreenSaverSelection(passwd *pw, char *moduleName, char *modulePath, int type) { OSErr err = noErr; CFStringRef preferenceName = CFSTR("com.apple.screensaver"); CFStringRef mainKeyName = CFSTR("moduleDict"); CFDictionaryRef emptyData; CFMutableDictionaryRef newData; Boolean success; CFStringRef nameKey = CFStringCreateWithCString(NULL, "moduleName", kCFStringEncodingASCII); CFStringRef nameValue = CFStringCreateWithCString(NULL, moduleName, kCFStringEncodingASCII); CFStringRef pathKey = CFStringCreateWithCString(NULL, "path", kCFStringEncodingASCII); CFStringRef pathValue = CFStringCreateWithCString(NULL, modulePath, kCFStringEncodingASCII); CFStringRef typeKey = CFStringCreateWithCString(NULL, "type", kCFStringEncodingASCII); CFNumberRef typeValue = CFNumberCreate(NULL, kCFNumberIntType, &type); emptyData = CFDictionaryCreate(NULL, NULL, NULL, 0, NULL, NULL); if (emptyData == NULL) { fprintf(stderr, "Could not set screensaver for user %s\n", pw->pw_name); fflush(stderr); CFRelease(nameKey); CFRelease(nameValue); CFRelease(pathKey); CFRelease(pathValue); CFRelease(typeKey); CFRelease(typeValue); return(-1); } newData = CFDictionaryCreateMutableCopy(NULL,0, emptyData); if (newData == NULL) { fprintf(stderr, "Could not set screensaver for user %s\n", pw->pw_name); fflush(stderr); CFRelease(nameKey); CFRelease(nameValue); CFRelease(pathKey); CFRelease(pathValue); CFRelease(typeKey); CFRelease(typeValue); CFRelease(emptyData); return(-1); } CFDictionaryAddValue(newData, nameKey, nameValue); CFDictionaryAddValue(newData, pathKey, pathValue); CFDictionaryAddValue(newData, typeKey, typeValue); CFPreferencesSetValue(mainKeyName, newData, preferenceName, kCFPreferencesCurrentUser, kCFPreferencesCurrentHost); success = CFPreferencesSynchronize(preferenceName, kCFPreferencesCurrentUser, kCFPreferencesCurrentHost); if (!success) { fprintf(stderr, "Could not set screensaver for user %s\n", pw->pw_name); fflush(stderr); err = -1; } CFRelease(nameKey); CFRelease(nameValue); CFRelease(pathKey); CFRelease(pathValue); CFRelease(typeKey); CFRelease(typeValue); CFRelease(emptyData); CFRelease(newData); return err; }