static gboolean validate (CEPage *page, NMConnection *connection, GError **error) { CEPageWirelessSecurity *self = CE_PAGE_WIRELESS_SECURITY (page); NMSettingWireless *s_wireless; WirelessSecurity *sec; gboolean valid = FALSE; s_wireless = NM_SETTING_WIRELESS (nm_connection_get_setting (connection, NM_TYPE_SETTING_WIRELESS)); g_assert (s_wireless); sec = wireless_security_combo_get_active (self); if (sec) { const GByteArray *ssid = nm_setting_wireless_get_ssid (s_wireless); if (ssid) { /* FIXME: get failed property and error out of wireless security objects */ valid = wireless_security_validate (sec, ssid); if (valid) wireless_security_fill_connection (sec, connection); else g_set_error (error, 0, 0, "Invalid wireless security"); } else g_set_error (error, 0, 0, "Missing SSID"); } else { /* No security, unencrypted */ g_object_set (s_wireless, NM_SETTING_WIRELESS_SEC, NULL, NULL); nm_connection_remove_setting (connection, NM_TYPE_SETTING_WIRELESS_SECURITY); nm_connection_remove_setting (connection, NM_TYPE_SETTING_802_1X); nm_gconf_clear_private_connection_values (connection); valid = TRUE; } return valid; }
static gboolean validate (CEPage *page, NMConnection *connection, GError **error) { CEPageWirelessSecurity *self = CE_PAGE_WIRELESS_SECURITY (page); NMSettingWireless *s_wireless; WirelessSecurity *sec; gboolean valid = FALSE; const char *mode; s_wireless = nm_connection_get_setting_wireless (connection); g_assert (s_wireless); /* Kernel Ad-Hoc WPA support is busted; it creates open networks. Disable * WPA when Ad-Hoc is selected. set_sensitive() will pick up self->adhoc * and do the right thing. */ mode = nm_setting_wireless_get_mode (s_wireless); if (g_strcmp0 (mode, NM_SETTING_WIRELESS_MODE_ADHOC) == 0) self->adhoc = TRUE; else self->adhoc = FALSE; sec = wireless_security_combo_get_active (self); if (sec) { const GByteArray *ssid = nm_setting_wireless_get_ssid (s_wireless); if (ssid) { /* FIXME: get failed property and error out of wireless security objects */ valid = wireless_security_validate (sec, ssid); if (valid) wireless_security_fill_connection (sec, connection); else g_set_error (error, NMA_ERROR, NMA_ERROR_GENERIC, "Invalid wireless security"); } else { g_set_error (error, NMA_ERROR, NMA_ERROR_GENERIC, "Missing SSID"); valid = FALSE; } if (self->adhoc) { if (!wireless_security_adhoc_compatible (sec)) { g_set_error (error, NMA_ERROR, NMA_ERROR_GENERIC, "Security not compatible with Ad-Hoc mode"); valid = FALSE; } } } else { /* No security, unencrypted */ g_object_set (s_wireless, NM_SETTING_WIRELESS_SEC, NULL, NULL); nm_connection_remove_setting (connection, NM_TYPE_SETTING_WIRELESS_SECURITY); nm_connection_remove_setting (connection, NM_TYPE_SETTING_802_1X); valid = TRUE; } return valid; }
static gboolean validate (CEPage *page, NMConnection *connection, GError **error) { NMSettingWireless *sw; NMSettingConnection *sc; WirelessSecurity *sec; gboolean valid = FALSE; const char *mode; sw = nm_connection_get_setting_wireless (connection); mode = nm_setting_wireless_get_mode (sw); if (g_strcmp0 (mode, NM_SETTING_WIRELESS_MODE_ADHOC) == 0) CE_PAGE_SECURITY (page)->adhoc = TRUE; else CE_PAGE_SECURITY (page)->adhoc = FALSE; sec = security_combo_get_active (CE_PAGE_SECURITY (page)); if (sec) { GBytes *ssid = nm_setting_wireless_get_ssid (sw); if (ssid) { /* FIXME: get failed property and error out of wifi security objects */ valid = wireless_security_validate (sec, error); if (valid) wireless_security_fill_connection (sec, connection); } else { g_set_error (error, NM_CONNECTION_ERROR, NM_CONNECTION_ERROR_MISSING_SETTING, "Missing SSID"); valid = FALSE; } if (CE_PAGE_SECURITY (page)->adhoc) { if (!wireless_security_adhoc_compatible (sec)) { g_set_error (error, NM_CONNECTION_ERROR, NM_CONNECTION_ERROR_INVALID_SETTING, "Security not compatible with Ad-Hoc mode"); valid = FALSE; } } wireless_security_unref (sec); } else { /* No security, unencrypted */ nm_connection_remove_setting (connection, NM_TYPE_SETTING_WIRELESS_SECURITY); nm_connection_remove_setting (connection, NM_TYPE_SETTING_802_1X); valid = TRUE; } sc = nm_connection_get_setting_connection (connection); firewall_ui_to_setting (sc, GTK_WIDGET (CE_PAGE_SECURITY (page)->firewall_combo)); return valid; }
static gboolean validate (CEPage *page, NMConnection *connection, GError **error) { NMSettingWireless *sw; WirelessSecurity *sec; gboolean valid = FALSE; const char *mode; sw = nm_connection_get_setting_wireless (connection); mode = nm_setting_wireless_get_mode (sw); if (g_strcmp0 (mode, NM_SETTING_WIRELESS_MODE_ADHOC) == 0) CE_PAGE_SECURITY (page)->adhoc = TRUE; else CE_PAGE_SECURITY (page)->adhoc = FALSE; sec = security_combo_get_active (CE_PAGE_SECURITY (page)); if (sec) { const GByteArray *ssid = nm_setting_wireless_get_ssid (sw); if (ssid) { /* FIXME: get failed property and error out of wifi security objects */ valid = wireless_security_validate (sec, ssid); if (valid) wireless_security_fill_connection (sec, connection); else g_set_error (error, NM_CONNECTION_ERROR, NM_CONNECTION_ERROR_UNKNOWN, "Invalid Wi-Fi security"); } else { g_set_error (error, NM_CONNECTION_ERROR, NM_CONNECTION_ERROR_UNKNOWN, "Missing SSID"); valid = FALSE; } if (CE_PAGE_SECURITY (page)->adhoc) { if (!wireless_security_adhoc_compatible (sec)) { g_set_error (error, NM_CONNECTION_ERROR, NM_CONNECTION_ERROR_UNKNOWN, "Security not compatible with Ad-Hoc mode"); valid = FALSE; } } wireless_security_unref (sec); } else { /* No security, unencrypted */ g_object_set (sw, NM_SETTING_WIRELESS_SEC, NULL, NULL); nm_connection_remove_setting (connection, NM_TYPE_SETTING_WIRELESS_SECURITY); nm_connection_remove_setting (connection, NM_TYPE_SETTING_802_1X); valid = TRUE; } return valid; }
NMConnection * nma_ethernet_dialog_get_connection (GtkWidget *dialog) { NMConnection *connection, *tmp_connection; WirelessSecurity *security; NMSetting *s_8021x, *s_con; g_return_val_if_fail (dialog != NULL, NULL); connection = g_object_get_data (G_OBJECT (dialog), "connection"); security = g_object_get_data (G_OBJECT (dialog), "security"); /* Here's a nice hack to work around the fact that ws_802_1x_fill_connection() * needs a wireless setting and a connection setting for various things. */ tmp_connection = nm_simple_connection_new (); /* Add the fake connection setting (mainly for the UUID for cert ignore checking) */ s_con = nm_connection_get_setting (connection, NM_TYPE_SETTING_CONNECTION); g_assert (s_con); nm_connection_add_setting (tmp_connection, NM_SETTING (g_object_ref (s_con))); /* And the fake wireless setting */ nm_connection_add_setting (tmp_connection, nm_setting_wireless_new ()); /* Fill up the 802.1x setting */ ws_802_1x_fill_connection (security, "wpa_eap_auth_combo", tmp_connection); /* Grab it and add it to our original connection */ s_8021x = nm_connection_get_setting (tmp_connection, NM_TYPE_SETTING_802_1X); nm_connection_add_setting (connection, NM_SETTING (g_object_ref (s_8021x))); /* Save new CA cert ignore values to GSettings */ eap_method_ca_cert_ignore_save (tmp_connection); /* Remove the 8021x setting to prevent the clearing of secrets when the * simple-connection is destroyed. */ nm_connection_remove_setting (tmp_connection, NM_TYPE_SETTING_802_1X); g_object_unref (tmp_connection); return connection; }
static gboolean ce_page_validate_v (CEPage *page, NMConnection *connection, GError **error) { CEPageDcb *self = CE_PAGE_DCB (page); CEPageDcbPrivate *priv = CE_PAGE_DCB_GET_PRIVATE (self); NMSettingDcb *s_dcb; if (!gtk_toggle_button_get_active (priv->enabled)) { nm_connection_remove_setting (connection, NM_TYPE_SETTING_DCB); return TRUE; } s_dcb = nm_connection_get_setting_dcb (connection); if (!s_dcb) { s_dcb = (NMSettingDcb *) nm_setting_dcb_new (); nm_connection_add_setting (connection, NM_SETTING (s_dcb)); } ui_to_setting (self, s_dcb); return nm_setting_verify (NM_SETTING (s_dcb), NULL, error); }
static void wireless_security_target_changed (GObject *object, GParamSpec *pspec, gpointer user_data) { NMEditorWirelessSecurityMethodBinding *binding = user_data; char *method; if (binding->updating) return; g_object_get (binding->target, binding->target_property, &method, NULL); binding->updating = TRUE; if (!strcmp (method, "none")) { if (!binding->s_wsec_in_use) return; binding->s_wsec_in_use = FALSE; nm_connection_remove_setting (binding->connection, NM_TYPE_SETTING_WIRELESS_SECURITY); binding->updating = FALSE; return; } if (!binding->s_wsec_in_use) { binding->s_wsec_in_use = TRUE; nm_connection_add_setting (binding->connection, NM_SETTING (binding->s_wsec)); } if (!strcmp (method, "wep-key")) { g_object_set (binding->s_wsec, NM_SETTING_WIRELESS_SECURITY_KEY_MGMT, "none", NM_SETTING_WIRELESS_SECURITY_AUTH_ALG, "open", NM_SETTING_WIRELESS_SECURITY_WEP_KEY_TYPE, NM_WEP_KEY_TYPE_KEY, NULL); } else if (!strcmp (method, "wep-passphrase")) { g_object_set (binding->s_wsec, NM_SETTING_WIRELESS_SECURITY_KEY_MGMT, "none", NM_SETTING_WIRELESS_SECURITY_AUTH_ALG, "open", NM_SETTING_WIRELESS_SECURITY_WEP_KEY_TYPE, NM_WEP_KEY_TYPE_PASSPHRASE, NULL); } else if (!strcmp (method, "leap")) { g_object_set (binding->s_wsec, NM_SETTING_WIRELESS_SECURITY_KEY_MGMT, "ieee8021x", NM_SETTING_WIRELESS_SECURITY_AUTH_ALG, "leap", NM_SETTING_WIRELESS_SECURITY_WEP_KEY_TYPE, NM_WEP_KEY_TYPE_UNKNOWN, NULL); } else if (!strcmp (method, "dynamic-wep")) { g_object_set (binding->s_wsec, NM_SETTING_WIRELESS_SECURITY_KEY_MGMT, "ieee8021x", NM_SETTING_WIRELESS_SECURITY_AUTH_ALG, "open", NM_SETTING_WIRELESS_SECURITY_WEP_KEY_TYPE, NM_WEP_KEY_TYPE_UNKNOWN, NULL); } else if (!strcmp (method, "wpa-personal")) { g_object_set (binding->s_wsec, NM_SETTING_WIRELESS_SECURITY_KEY_MGMT, "wpa-psk", NM_SETTING_WIRELESS_SECURITY_AUTH_ALG, NULL, NM_SETTING_WIRELESS_SECURITY_WEP_KEY_TYPE, NM_WEP_KEY_TYPE_UNKNOWN, NULL); } else if (!strcmp (method, "wpa-enterprise")) { g_object_set (binding->s_wsec, NM_SETTING_WIRELESS_SECURITY_KEY_MGMT, "wpa-eap", NM_SETTING_WIRELESS_SECURITY_AUTH_ALG, NULL, NM_SETTING_WIRELESS_SECURITY_WEP_KEY_TYPE, NM_WEP_KEY_TYPE_UNKNOWN, NULL); } else g_warn_if_reached (); binding->updating = FALSE; }
static void ui_to_setting (CEPageVlan *self) { CEPageVlanPrivate *priv = CE_PAGE_VLAN_GET_PRIVATE (self); NMConnection *connection = CE_PAGE (self)->connection; NMSettingConnection *s_con = nm_connection_get_setting_connection (connection); GByteArray *cloned_mac = NULL; VlanParent *parent = NULL; int parent_id, vid; const char *parent_iface = NULL, *parent_uuid = NULL; const char *slave_type; const char *iface; char *tmp_parent_iface = NULL; GType hwtype; gboolean mtu_set; int mtu; parent_id = gtk_combo_box_get_active (GTK_COMBO_BOX (priv->parent)); if (parent_id == -1) { parent_iface = gtk_entry_get_text (priv->parent_entry); tmp_parent_iface = g_strndup (parent_iface, strcspn (parent_iface, " ")); parent_iface = tmp_parent_iface; } else { parent = priv->parents[parent_id]; if (parent->connection) parent_uuid = nm_connection_get_uuid (parent->connection); if (parent->device) parent_iface = nm_device_get_iface (parent->device); } g_assert (parent_uuid != NULL || parent_iface != NULL); slave_type = nm_setting_connection_get_slave_type (s_con); if (parent_uuid) { /* Update NMSettingConnection:master if it's set, but don't * set it if it's not. */ if (!g_strcmp0 (slave_type, NM_SETTING_VLAN_SETTING_NAME)) { g_object_set (s_con, NM_SETTING_CONNECTION_MASTER, parent_uuid, NULL); } } else if (!g_strcmp0 (slave_type, NM_SETTING_VLAN_SETTING_NAME)) { g_object_set (s_con, NM_SETTING_CONNECTION_MASTER, NULL, NM_SETTING_CONNECTION_SLAVE_TYPE, NULL, NULL); } if (parent && NM_IS_DEVICE_ETHERNET (parent->device)) hwtype = NM_TYPE_SETTING_WIRED; else hwtype = G_TYPE_NONE; if (priv->s_hw && G_OBJECT_TYPE (priv->s_hw) != hwtype) { nm_connection_remove_setting (connection, G_OBJECT_TYPE (priv->s_hw)); priv->s_hw = NULL; } iface = gtk_entry_get_text (priv->name_entry); vid = gtk_spin_button_get_value_as_int (priv->id_entry); g_object_set (priv->setting, NM_SETTING_VLAN_PARENT, parent_uuid ? parent_uuid : parent_iface, NM_SETTING_VLAN_INTERFACE_NAME, iface, NM_SETTING_VLAN_ID, vid, NULL); if (hwtype != G_TYPE_NONE) { cloned_mac = ce_page_entry_to_mac (priv->cloned_mac, ARPHRD_ETHER, NULL); mtu_set = g_ascii_isdigit (*gtk_entry_get_text (GTK_ENTRY (priv->mtu))); mtu = gtk_spin_button_get_value_as_int (priv->mtu); if (cloned_mac || mtu_set) { if (!priv->s_hw) { priv->s_hw = g_object_new (hwtype, NULL); nm_connection_add_setting (connection, priv->s_hw); } g_object_set (priv->s_hw, NM_SETTING_WIRED_CLONED_MAC_ADDRESS, cloned_mac, NM_SETTING_WIRED_MTU, (guint32) mtu, NULL); if (cloned_mac) g_byte_array_free (cloned_mac, TRUE); } else if (priv->s_hw) { nm_connection_remove_setting (connection, G_OBJECT_TYPE (priv->s_hw)); priv->s_hw = NULL; } } g_free (tmp_parent_iface); }