static void fill_connection (EAPMethod *parent, NMConnection *connection) { EAPMethodSimple *method = (EAPMethodSimple *) parent; NMSetting8021x *s_8021x; GtkWidget *widget; gboolean not_saved = FALSE; const char *eap = NULL; NMSettingSecretFlags flags = NM_SETTING_SECRET_FLAG_NONE; s_8021x = nm_connection_get_setting_802_1x (connection); g_assert (s_8021x); /* If this is the main EAP method, clear any existing methods because the * user-selected on will replace it. */ if (parent->phase2 == FALSE) nm_setting_802_1x_clear_eap_methods (s_8021x); switch (method->type) { case EAP_METHOD_SIMPLE_TYPE_PAP: eap = "pap"; break; case EAP_METHOD_SIMPLE_TYPE_MSCHAP: eap = "mschap"; break; case EAP_METHOD_SIMPLE_TYPE_MSCHAP_V2: eap = "mschapv2"; break; case EAP_METHOD_SIMPLE_TYPE_MD5: eap = "md5"; break; case EAP_METHOD_SIMPLE_TYPE_CHAP: eap = "chap"; break; case EAP_METHOD_SIMPLE_TYPE_GTC: eap = "gtc"; break; default: g_assert_not_reached (); break; } if (parent->phase2) g_object_set (s_8021x, NM_SETTING_802_1X_PHASE2_AUTH, eap, NULL); else nm_setting_802_1x_add_eap_method (s_8021x, eap); widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "eap_simple_username_entry")); g_assert (widget); g_object_set (s_8021x, NM_SETTING_802_1X_IDENTITY, gtk_entry_get_text (GTK_ENTRY (widget)), NULL); /* Save the password always ask setting */ widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "eap_password_always_ask")); g_assert (widget); not_saved = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget)); nm_setting_get_secret_flags (NM_SETTING (s_8021x), NM_SETTING_802_1X_PASSWORD, &flags, NULL); flags &= ~(NM_SETTING_SECRET_FLAG_NOT_SAVED); if (not_saved) flags |= NM_SETTING_SECRET_FLAG_NOT_SAVED; nm_setting_set_secret_flags (NM_SETTING (s_8021x), NM_SETTING_802_1X_PASSWORD, flags, NULL); /* Fill the connection's password if we're in the applet so that it'll get * back to NM. From the editor though, since the connection isn't going * back to NM in response to a GetSecrets() call, we don't save it if the * user checked "Always Ask". */ if (method->is_editor == FALSE || not_saved == FALSE) { widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "eap_simple_password_entry")); g_assert (widget); g_object_set (s_8021x, NM_SETTING_802_1X_PASSWORD, gtk_entry_get_text (GTK_ENTRY (widget)), NULL); } /* Default to agent-owned secrets for new connections */ if (method->new_connection && (not_saved == FALSE)) { g_object_set (s_8021x, NM_SETTING_802_1X_PASSWORD_FLAGS, NM_SETTING_SECRET_FLAG_AGENT_OWNED, NM_SETTING_802_1X_SYSTEM_CA_CERTS, TRUE, NULL); } }
static void fill_connection (EAPMethod *parent, NMConnection *connection, NMSettingSecretFlags prev_flags) { EAPMethodSimple *method = (EAPMethodSimple *) parent; NMSetting8021x *s_8021x; gboolean not_saved = FALSE; NMSettingSecretFlags flags = prev_flags; const EapType *eap_type; s_8021x = nm_connection_get_setting_802_1x (connection); g_assert (s_8021x); /* If this is the main EAP method, clear any existing methods because the * user-selected on will replace it. */ if (parent->phase2 == FALSE) nm_setting_802_1x_clear_eap_methods (s_8021x); eap_type = &eap_table[method->type]; if (parent->phase2) { /* If the outer EAP method (TLS, TTLS, PEAP, etc) allows inner/phase2 * EAP methods (which only TTLS allows) *and* the inner/phase2 method * supports being an inner EAP method, then set PHASE2_AUTHEAP. * Otherwise the inner/phase2 method goes into PHASE2_AUTH. */ if ((method->flags & EAP_METHOD_SIMPLE_FLAG_AUTHEAP_ALLOWED) && eap_type->autheap_allowed) { g_object_set (s_8021x, NM_SETTING_802_1X_PHASE2_AUTHEAP, eap_type->name, NULL); g_object_set (s_8021x, NM_SETTING_802_1X_PHASE2_AUTH, NULL, NULL); } else { g_object_set (s_8021x, NM_SETTING_802_1X_PHASE2_AUTH, eap_type->name, NULL); g_object_set (s_8021x, NM_SETTING_802_1X_PHASE2_AUTHEAP, NULL, NULL); } } else nm_setting_802_1x_add_eap_method (s_8021x, eap_type->name); g_object_set (s_8021x, NM_SETTING_802_1X_IDENTITY, gtk_entry_get_text (method->username_entry), NULL); /* Save the password always ask setting */ not_saved = gtk_toggle_button_get_active (method->always_ask); flags &= ~(NM_SETTING_SECRET_FLAG_NOT_SAVED); if (not_saved) flags |= NM_SETTING_SECRET_FLAG_NOT_SAVED; nm_setting_set_secret_flags (NM_SETTING (s_8021x), NM_SETTING_802_1X_PASSWORD, flags, NULL); /* Fill the connection's password if we're in the applet so that it'll get * back to NM. From the editor though, since the connection isn't going * back to NM in response to a GetSecrets() call, we don't save it if the * user checked "Always Ask". */ if (!(method->flags & EAP_METHOD_SIMPLE_FLAG_IS_EDITOR) || not_saved == FALSE) g_object_set (s_8021x, NM_SETTING_802_1X_PASSWORD, gtk_entry_get_text (method->password_entry), NULL); /* Update secret flags and popup when editing the connection */ if (!(method->flags & EAP_METHOD_SIMPLE_FLAG_SECRETS_ONLY)) { GtkWidget *passwd_entry = GTK_WIDGET (gtk_builder_get_object (parent->builder, "eap_simple_password_entry")); g_assert (passwd_entry); utils_update_password_storage (NM_SETTING (s_8021x), flags, passwd_entry, parent->password_flags_name); } }