PRIVATE_EXTERN AuthorizationExternalForm * EAPOLClientItemIDGetAuthorizationExternalForm(EAPOLClientItemIDRef itemID) { EAPOLClientConfigurationRef cfg; EAPOLClientProfileRef profile; profile = EAPOLClientItemIDGetProfile(itemID); if (profile == NULL) { return (NULL); } cfg = EAPOLClientProfileGetConfiguration(profile); if (cfg == NULL) { return (NULL); } return (EAPOLClientConfigurationGetAuthorizationExternalForm(cfg)); }
/* * Function: saveInterfaceEAPOLConfiguration * Purpose: * Save the SCNetworkInterface EAPOL information for System and LoginWindow * modes. * * Iterate over the changed SCNetworkInterfaceRef list cfg->sc_changed_if, * and for each interface, grab the EAPOL extended information from * cfg->sc_prefs. Then set the corresponding value in the new * freshly created SCPreferencesRef. * * All this done to avoid a writer getting Stale Object errors * when it has its own SCPreferencesRef object that it manipulates while * having an EAPOLClientConfigurationRef open. */ STATIC Boolean saveInterfaceEAPOLConfiguration(EAPOLClientConfigurationRef cfg, Boolean * changed_p) { AuthorizationExternalForm * auth_ext_p; int count; int i; SCPreferencesRef prefs = NULL; Boolean ret = FALSE; *changed_p = FALSE; if (cfg->sc_changed_if == NULL) { return (TRUE); } auth_ext_p = EAPOLClientConfigurationGetAuthorizationExternalForm(cfg); if (auth_ext_p != NULL) { AuthorizationRef auth; OSStatus status; status = AuthorizationCreateFromExternalForm(auth_ext_p, &auth); if (status != errAuthorizationSuccess) { EAPLOG(LOG_ERR, "EAPOLClientConfiguration: can't allocate Authorization, %d", (int)status); goto done; } prefs = SCPreferencesCreateWithAuthorization(NULL, kPrefsName, NULL, auth); AuthorizationFree(auth, kAuthorizationFlagDefaults); } else { prefs = SCPreferencesCreate(NULL, kPrefsName, NULL); } count = CFArrayGetCount(cfg->sc_changed_if); for (i = 0; i < count; i++) { CFDictionaryRef dict; CFStringRef if_name; SCNetworkInterfaceRef net_if; net_if = (SCNetworkInterfaceRef) CFArrayGetValueAtIndex(cfg->sc_changed_if, i); if_name = SCNetworkInterfaceGetBSDName(net_if); if (if_name == NULL) { /* should not happen */ EAPLOG(LOG_ERR, "EAPOLClientConfiguration: missing BSD name"); continue; } dict = SCNetworkInterfaceGetExtendedConfiguration(net_if, kEAPOL); /* find the same interface in the saving prefs */ if (set_eapol_configuration(prefs, if_name, dict) == FALSE) { continue; } } ret = SCPreferencesCommitChanges(prefs); if (ret == FALSE) { EAPLOG(LOG_NOTICE, "EAPOLClientConfigurationSave SCPreferencesCommitChanges" " failed %s", SCErrorString(SCError())); goto done; } SCPreferencesApplyChanges(prefs); *changed_p = TRUE; done: my_CFRelease(&cfg->sc_changed_if); my_CFRelease(&prefs); return (ret); }