STATIC void
save_DUID_info(void)
{
    CFMutableDictionaryRef      duid_ia;
    CFDataRef			host_UUID;

    if (S_DUID == NULL) {
	return;
    }
    duid_ia = CFDictionaryCreateMutable(NULL, 0,
					&kCFTypeDictionaryKeyCallBacks,
					&kCFTypeDictionaryValueCallBacks);
    CFDictionarySetValue(duid_ia, kDUIDKey, S_DUID);
    if (S_IAIDList != NULL) {
	CFDictionarySetValue(duid_ia, kIAIDListKey, S_IAIDList);
    }
    host_UUID = HostUUIDGet();
    if (host_UUID != NULL) {
	CFDictionarySetValue(duid_ia, kHostUUIDKey, host_UUID);
    }
    if (my_CFPropertyListWriteFile(duid_ia, DUID_IA_FILE, 0644) < 0) {
	/*
	 * An ENOENT error is expected on a read-only filesystem.  All 
	 * other errors should be reported.
	 */
	if (errno != ENOENT) {
	    my_log(LOG_ERR,
		   "DHCPDUID: failed to write %s, %s", DUID_IA_FILE,
		   strerror(errno));
	}
    }
    CFRelease(duid_ia);
    return;
}
示例#2
0
文件: DHCPLease.c 项目: aosm/bootp
/* 
 * Function: DHCPLeaseListWrite
 *
 * Purpose:
 *   Write the last DHCP lease in the list for the given interface/client_id.
 *   We only save the last (current) lease.  See the comments for 
 *   DHCPLeaseListRead above for more information.
 */
void
DHCPLeaseListWrite(DHCPLeaseListRef list_p,
		   const char * ifname,
		   uint8_t cid_type, const void * cid, int cid_length)
{
    int			count;
    char		filename[PATH_MAX];
    CFDictionaryRef	lease_dict;
    DHCPLeaseRef	lease_p;
    
    if (DHCPLeaseListGetPath(ifname, cid_type, cid, cid_length,
			     filename, sizeof(filename)) == FALSE) {
	return;
    }
    DHCPLeaseListRemoveStaleLeases(list_p);
    count = dynarray_count(list_p);
    if (count == 0) {
	unlink(filename);
	return;
    }
    lease_p = dynarray_element(list_p, count - 1);
    lease_dict = DHCPLeaseCopyDictionary(lease_p);
    if (my_CFPropertyListWriteFile(lease_dict, filename, 0644) < 0) {
	/*
	 * An ENOENT error is expected on a read-only filesystem.  All 
	 * other errors should be reported.
	 */
	if (errno != ENOENT) {
	    my_log(LOG_ERR, "my_CFPropertyListWriteFile(%s) failed, %s", 
		   filename, strerror(errno));
	}
    }
    my_CFRelease(&lease_dict);
    return;
}
示例#3
0
文件: CGA.c 项目: carriercomm/osx-2
STATIC bool
CGAKeysWrite(CFDataRef priv, CFDataRef pub)
{
    CFDictionaryRef	dict;
    bool		success = TRUE;

    dict = cga_keys_dict_create(priv, pub);
    if (my_CFPropertyListWriteFile(dict, CGA_KEYS_FILE, 0600) < 0) {
	/*
	 * An ENOENT error is expected on a read-only filesystem.  All 
	 * other errors should be reported as LOG_NOTICE.
	 */
	my_log((errno == ENOENT) ? LOG_INFO : LOG_NOTICE,
	       "CGAParameters: failed to write %s, %s",
	       CGA_KEYS_FILE, strerror(errno));
	success = FALSE;
    }
    CFRelease(dict);
    return (success);
}
示例#4
0
文件: CGA.c 项目: carriercomm/osx-2
STATIC bool
CGAWrite(CFDataRef host_uuid, CFDictionaryRef global_modifier,
	 CFDictionaryRef linklocal_modifiers)
{
    CFDictionaryRef	dict;
    bool		success = TRUE;
    
    dict = cga_dict_create(host_uuid, global_modifier, linklocal_modifiers);
    if (my_CFPropertyListWriteFile(dict, CGA_FILE, 0644) < 0) {
	/*
	 * An ENOENT error is expected on a read-only filesystem.  All 
	 * other errors should be reported as LOG_NOTICE.
	 */
	my_log((errno == ENOENT) ? LOG_INFO : LOG_NOTICE,
	       "CGAParameters: failed to write %s, %s",
	       CGA_FILE, strerror(errno));
	success = FALSE;
    }
    CFRelease(dict);
    return (success);
}