コード例 #1
0
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
ファイル: CGA.c プロジェクト: carriercomm/osx-2
PRIVATE_EXTERN void
CGAPrepareSetForInterface(const char * ifname,
			  struct in6_cga_prepare * cga_prep)
{
    CFDictionaryRef	dict;
    CFStringRef		ifname_cf;
    CFDataRef		modifier = NULL;
    uint8_t		security_level;

    if (S_LinkLocalModifiers == NULL) {
	my_log_fl(LOG_NOTICE, "S_LinkLocalModifiers is NULL");
	return;
    }
    ifname_cf = CFStringCreateWithCString(NULL, ifname, kCFStringEncodingASCII);
    dict = CFDictionaryGetValue(S_LinkLocalModifiers, ifname_cf);
    if (isA_CFDictionary(dict) != NULL) {
	modifier = CGAModifierDictGetModifier(dict, &security_level);
    }
    if (modifier == NULL) {
	security_level = kCGASecurityLevelZero;
	modifier = my_CFDataCreateWithRandomBytes(IN6_CGA_MODIFIER_LENGTH);
	dict = CGAModifierDictCreate(modifier, security_level);
	    CFDictionarySetValue(S_LinkLocalModifiers, ifname_cf, dict);
	CFRelease(modifier);
	CGAWrite(HostUUIDGet(), S_GlobalModifier, S_LinkLocalModifiers);
    }
    CFRelease(ifname_cf);
    cga_prepare_set(cga_prep, modifier, security_level);
    return;
}
コード例 #3
0
STATIC bool
load_DUID_info(void)
{
    CFDataRef		duid;
    CFDictionaryRef	duid_ia;
    CFDataRef		host_uuid;
    CFArrayRef		ia_list;

    duid_ia = my_CFPropertyListCreateFromFile(DUID_IA_FILE);
    if (isA_CFDictionary(duid_ia) == NULL) {
	goto done;
    }
    duid = CFDictionaryGetValue(duid_ia, kDUIDKey);
    if (isA_CFData(duid) == NULL) {
	goto done;
    }
    ia_list = CFDictionaryGetValue(duid_ia, kIAIDListKey);
    ia_list = isA_CFArray(ia_list);
    if (ia_list != NULL) {
	int		count;
	int		i;

	count = CFArrayGetCount(ia_list);
	for (i = 0; i < count; i++) {
	    CFStringRef	name = CFArrayGetValueAtIndex(ia_list, i);
	    if (isA_CFString(name) == NULL) {
		/* invalid property */
		ia_list = NULL;
		break;
	    }
	}
    }
    host_uuid = CFDictionaryGetValue(duid_ia, kHostUUIDKey);
    if (isA_CFData(host_uuid) != NULL 
	&& CFDataGetLength(host_uuid) == sizeof(uuid_t)) {
	CFDataRef	our_UUID;

	our_UUID = HostUUIDGet();
	if (our_UUID != NULL && CFEqual(host_uuid, our_UUID) == FALSE) {
	    syslog(LOG_NOTICE,
		   "DHCPDUID: ignoring DUID - host UUID doesn't match");
	    goto done;
	}
    }
    S_DUID = CFRetain(duid);
    if (ia_list != NULL) {
	S_IAIDList = CFArrayCreateMutableCopy(NULL, 0, ia_list);
    }

 done:
    my_CFRelease(&duid_ia);
    return (S_DUID != NULL);
}
コード例 #4
0
ファイル: CGA.c プロジェクト: carriercomm/osx-2
PRIVATE_EXTERN void
CGAInit(void)
{
    CFDataRef		host_uuid;

    if (G_is_netboot || cga_is_enabled() == FALSE) {
	return;
    }
    host_uuid = HostUUIDGet();
    if (host_uuid == NULL) {
	my_log_fl(LOG_NOTICE, "Failed to get HostUUID");
	return;
    }
    if (CGAParametersLoad(host_uuid) == FALSE) {
	return;
    }
    return;
    
}