[ Add new files; missing from previous commit. ]

2006-02-25  Robert Love  <rml@novell.com>

	Add WPA Enterprise support:
	* gnome/applet/Makefile.am: Build the files nm-gconf-wso-wpa-eap.c and
	  nm-gconf-wso-wpa-eap.h.
	* gnome/applet/nm-gconf-wso-wpa-eap.c,
	  gnome/applet/nm-gconf-wso-wpa-eap.h:  Add WPA Enterprise Gconf
	  serialization and deserialization.
	* gnome/applet/nm-gconf-wso-wpa-psk.c, gnome/applet/nm-gconf-wso.c,
	  gnome/applet/wireless-security-option.c, gnome/applet/wso-wpa-psk.c,
	  gnome/applet/wso-wpa-psk.h: Clean up, support new defines.
	* gnome/applet/wireless-applet.glade: Add UI for configurating security
	  settings related to WPA Enterprise.
	* gnome/applet/wireless-security-manager.c: Invoke wso_wpa_eap_new() to
	  instantiate WPA Enterprise wireless-security-option.
	* gnome/applet/wso-wpa-eap.c, gnome/applet/wso-wpa-eap.h: New files.
	  Implement WPA Enterprise wireless-security-option object.
	* include/NetworkManager.h: Add new NM_AUTH_TYPE_* and NM_EAP_METHOD_*
	  defines.  Cleanup.
	* libnm-util/cipher-wpa-psk-hex.c,
	  libnm-util/cipher-wpa-psk-passphrase.c: Cleanup.
	* libnm-util/dbus-helpers.c, libnm-util/dbus-helpers.h: Add
	  nmu_security_serialize_wpa_eap() to serialize input to DBUS method,
	  nmu_security_serialize_wpa_eap_with_cipher() to serialize input
	  including the cipher to DBUS method, and
	  nmu_security_deserialize_wpa_eap() to deserialize from DBUS return
	  to output.
	* src/Makefile.am: Build the files nm-ap-security-wpa-eap.c and
	  nm-ap-security-wpa-eap.h
	* src/NetworkManagerAP.c: Add NM_AUTH_TYPE_WPA_EAP to
	  NM_802_11_CAP_KEY_MGMT_802_1X cipher to capability mapping.
	* src/nm-ap-security-wpa-eap.c, src/nm-ap-security-wpa-eap.h: New
	  files.  Implement NMAPSecurityWPA_EAP object.
	* src/nm-ap-security-wpa-psk.c: Cleanup.
	* src/nm-ap-security.c: Support NM_AUTH_TYPE_EAP cipher and instantiate
	  an NMAPSecurityWPA_EAP object via the method
	  nm_ap_security_wpa_eap_new_deserialize().
	* src/nm-dbus-nm.c: Cleanup.
	* test/nm-tool.c: Display "Enterprise" for wireless networks providing
	  WPA Enterprise support.


git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@1494 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
This commit is contained in:
Robert Love 2006-02-26 02:24:46 +00:00 committed by Robert Love
parent 7301a244b2
commit eaca24a5be
6 changed files with 1087 additions and 0 deletions

View file

@ -0,0 +1,319 @@
/* NetworkManager -- Network link manager
*
* Dan Williams <dcbw@redhat.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
* (C) Copyright 2005 Red Hat, Inc.
* (C) Copyright 2006 Novell, Inc.
*/
#include <glib.h>
#include <glib/gi18n.h>
#include <dbus/dbus.h>
#include <iwlib.h>
#include "applet.h"
#include "nm-gconf-wso.h"
#include "nm-gconf-wso-wpa-eap.h"
#include "nm-gconf-wso-private.h"
#include "dbus-helpers.h"
#include "gconf-helpers.h"
#define WPA_EAP_PREFIX "wpa_eap_"
#define NM_GCONF_WSO_WPA_EAP_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_GCONF_WSO_WPA_EAP, NMGConfWSOWPA_EAPPrivate))
struct _NMGConfWSOWPA_EAPPrivate
{
int eap_method;
int wpa_version;
int key_mgmt;
const char * identity;
const char * passwd;
const char * anon_identity;
const char * private_key_passwd;
const char * private_key_file;
const char * client_cert_file;
const char * ca_cert_file;
};
NMGConfWSOWPA_EAP *
nm_gconf_wso_wpa_eap_new_deserialize_dbus (DBusMessageIter *iter, int we_cipher)
{
NMGConfWSOWPA_EAP * security = NULL;
char * identity = NULL;
char * passwd = NULL;
char * anon_identity = NULL;
char * private_key_passwd = NULL;
char * private_key_file = NULL;
char * client_cert_file = NULL;
char * ca_cert_file = NULL;
int wpa_version;
int eap_method;
g_return_val_if_fail (we_cipher == NM_AUTH_TYPE_WPA_EAP, NULL);
g_return_val_if_fail (iter != NULL, NULL);
if (!nmu_security_deserialize_wpa_eap (iter, &eap_method, &identity, &passwd, &anon_identity, &private_key_passwd,
&private_key_file, &client_cert_file, &ca_cert_file, &wpa_version))
goto out;
/* Success, build up our security object */
security = g_object_new (NM_TYPE_GCONF_WSO_WPA_EAP, NULL);
nm_gconf_wso_set_we_cipher (NM_GCONF_WSO (security), we_cipher);
nm_gconf_wso_set_key (NM_GCONF_WSO (security), "FIXME", 5); /* FIXME: What to do about Enterprise keys? */
security->priv->wpa_version = wpa_version;
security->priv->eap_method = eap_method;
security->priv->key_mgmt = IW_AUTH_KEY_MGMT_802_1X;
security->priv->identity = g_strdup (identity);
security->priv->passwd = g_strdup (passwd);
security->priv->anon_identity = g_strdup (anon_identity);
security->priv->private_key_passwd = g_strdup (private_key_passwd);
security->priv->private_key_file = g_strdup (private_key_file);
security->priv->client_cert_file = g_strdup (client_cert_file);
security->priv->ca_cert_file = g_strdup (ca_cert_file);
/* FIXME: Need to free passwd, key_file, and cert_file ? */
out:
return security;
}
NMGConfWSOWPA_EAP *
nm_gconf_wso_wpa_eap_new_deserialize_gconf (GConfClient *client, const char *network, int we_cipher)
{
NMGConfWSOWPA_EAP * security = NULL;
char * identity = NULL;
char * passwd = NULL;
char * anon_identity = NULL;
char * private_key_passwd = NULL;
char * private_key_file = NULL;
char * client_cert_file = NULL;
char * ca_cert_file = NULL;
int wpa_version;
int eap_method;
int key_mgmt;
g_return_val_if_fail (client != NULL, NULL);
g_return_val_if_fail (network != NULL, NULL);
g_return_val_if_fail ((we_cipher == NM_AUTH_TYPE_WPA_EAP), NULL);
if (!nm_gconf_get_int_helper (client,
GCONF_PATH_WIRELESS_NETWORKS,
WPA_EAP_PREFIX"eap_method",
network,
&eap_method))
goto out;
if (!nm_gconf_get_int_helper (client,
GCONF_PATH_WIRELESS_NETWORKS,
WPA_EAP_PREFIX"wpa_version",
network,
&wpa_version))
goto out;
if (!nm_gconf_get_int_helper (client,
GCONF_PATH_WIRELESS_NETWORKS,
WPA_EAP_PREFIX"key_mgt",
network,
&key_mgmt))
if (!nm_gconf_get_string_helper (client,
GCONF_PATH_WIRELESS_NETWORKS,
WPA_EAP_PREFIX"identity",
network,
&identity))
goto out;
if (!nm_gconf_get_string_helper (client,
GCONF_PATH_WIRELESS_NETWORKS,
WPA_EAP_PREFIX"passwd",
network,
&passwd))
goto out;
if (!nm_gconf_get_string_helper (client,
GCONF_PATH_WIRELESS_NETWORKS,
WPA_EAP_PREFIX"anon_identity",
network,
&anon_identity))
goto out;
if (!nm_gconf_get_string_helper (client,
GCONF_PATH_WIRELESS_NETWORKS,
WPA_EAP_PREFIX"private_key_passwd",
network,
&private_key_passwd))
goto out;
if (!nm_gconf_get_string_helper (client,
GCONF_PATH_WIRELESS_NETWORKS,
WPA_EAP_PREFIX"private_key_file",
network,
&private_key_file))
goto out;
if (!nm_gconf_get_string_helper (client,
GCONF_PATH_WIRELESS_NETWORKS,
WPA_EAP_PREFIX"client_cert_file",
network,
&client_cert_file))
goto out;
if (!nm_gconf_get_string_helper (client,
GCONF_PATH_WIRELESS_NETWORKS,
WPA_EAP_PREFIX"ca_cert_file",
network,
&ca_cert_file))
goto out;
/* Success, build up our security object */
security = g_object_new (NM_TYPE_GCONF_WSO_WPA_EAP, NULL);
nm_gconf_wso_set_we_cipher (NM_GCONF_WSO (security), we_cipher);
security->priv->wpa_version = wpa_version;
security->priv->eap_method = eap_method;
security->priv->key_mgmt = IW_AUTH_KEY_MGMT_802_1X;
security->priv->identity = g_strdup (identity);
security->priv->passwd = g_strdup (passwd);
security->priv->anon_identity = g_strdup (anon_identity);
security->priv->private_key_passwd = g_strdup (private_key_passwd);
security->priv->private_key_file = g_strdup (private_key_file);
security->priv->client_cert_file = g_strdup (client_cert_file);
security->priv->ca_cert_file = g_strdup (ca_cert_file);
/* FIXME: Need to free key_file and cert_file ? */
out:
return security;
}
static gboolean
real_serialize_dbus (NMGConfWSO *instance, DBusMessageIter *iter)
{
NMGConfWSOWPA_EAP * self = NM_GCONF_WSO_WPA_EAP (instance);
if (!nmu_security_serialize_wpa_eap (iter,
self->priv->eap_method,
self->priv->identity,
self->priv->passwd,
self->priv->anon_identity,
self->priv->private_key_passwd,
self->priv->private_key_file,
self->priv->client_cert_file,
self->priv->ca_cert_file,
self->priv->wpa_version))
return FALSE;
return TRUE;
}
static gboolean
real_serialize_gconf (NMGConfWSO *instance, GConfClient *client, const char *network)
{
NMGConfWSOWPA_EAP * self = NM_GCONF_WSO_WPA_EAP (instance);
char * key;
key = g_strdup_printf ("%s/%s/%seap_method", GCONF_PATH_WIRELESS_NETWORKS, network, WPA_EAP_PREFIX);
gconf_client_set_int (client, key, self->priv->eap_method, NULL);
g_free (key);
key = g_strdup_printf ("%s/%s/%swpa_version", GCONF_PATH_WIRELESS_NETWORKS, network, WPA_EAP_PREFIX);
gconf_client_set_int (client, key, self->priv->wpa_version, NULL);
g_free (key);
key = g_strdup_printf ("%s/%s/%skey_mgt", GCONF_PATH_WIRELESS_NETWORKS, network, WPA_EAP_PREFIX);
gconf_client_set_int (client, key, self->priv->key_mgmt, NULL);
g_free (key);
key = g_strdup_printf ("%s/%s/%sidentity", GCONF_PATH_WIRELESS_NETWORKS, network, WPA_EAP_PREFIX);
gconf_client_set_string (client, key, self->priv->identity, NULL);
g_free (key);
key = g_strdup_printf ("%s/%s/%spasswd", GCONF_PATH_WIRELESS_NETWORKS, network, WPA_EAP_PREFIX);
gconf_client_set_string (client, key, self->priv->passwd, NULL);
g_free (key);
key = g_strdup_printf ("%s/%s/%sanon_identity", GCONF_PATH_WIRELESS_NETWORKS, network, WPA_EAP_PREFIX);
gconf_client_set_string (client, key, self->priv->anon_identity, NULL);
g_free (key);
key = g_strdup_printf ("%s/%s/%sprivate_key_passwd", GCONF_PATH_WIRELESS_NETWORKS, network, WPA_EAP_PREFIX);
gconf_client_set_string (client, key, self->priv->private_key_passwd, NULL);
g_free (key);
key = g_strdup_printf ("%s/%s/%sprivate_key_file", GCONF_PATH_WIRELESS_NETWORKS, network, WPA_EAP_PREFIX);
gconf_client_set_string (client, key, self->priv->private_key_file, NULL);
g_free (key);
key = g_strdup_printf ("%s/%s/%sclient_cert_file", GCONF_PATH_WIRELESS_NETWORKS, network, WPA_EAP_PREFIX);
gconf_client_set_string (client, key, self->priv->client_cert_file, NULL);
g_free (key);
key = g_strdup_printf ("%s/%s/%sca_cert_file", GCONF_PATH_WIRELESS_NETWORKS, network, WPA_EAP_PREFIX);
gconf_client_set_string (client, key, self->priv->ca_cert_file, NULL);
g_free (key);
return TRUE;
}
static void
nm_gconf_wso_wpa_eap_init (NMGConfWSOWPA_EAP *self)
{
self->priv = NM_GCONF_WSO_WPA_EAP_GET_PRIVATE (self);
self->priv->wpa_version = IW_AUTH_WPA_VERSION_WPA;
self->priv->key_mgmt = IW_AUTH_KEY_MGMT_802_1X;
}
static void
nm_gconf_wso_wpa_eap_class_init (NMGConfWSOWPA_EAPClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
NMGConfWSOClass *par_class = NM_GCONF_WSO_CLASS (klass);
par_class->serialize_dbus_func = real_serialize_dbus;
par_class->serialize_gconf_func = real_serialize_gconf;
g_type_class_add_private (object_class, sizeof (NMGConfWSOWPA_EAPPrivate));
}
GType
nm_gconf_wso_wpa_eap_get_type (void)
{
static GType type = 0;
if (type == 0) {
static const GTypeInfo info = {
sizeof (NMGConfWSOWPA_EAPClass),
NULL, /* base_init */
NULL, /* base_finalize */
(GClassInitFunc) nm_gconf_wso_wpa_eap_class_init,
NULL, /* class_finalize */
NULL, /* class_data */
sizeof (NMGConfWSOWPA_EAP),
0, /* n_preallocs */
(GInstanceInitFunc) nm_gconf_wso_wpa_eap_init,
NULL /* value_table */
};
type = g_type_register_static (NM_TYPE_GCONF_WSO,
"NMGConfWSOWPA_EAP",
&info, 0);
}
return type;
}

View file

@ -0,0 +1,62 @@
/* NetworkManager -- Network link manager
*
* Dan Williams <dcbw@redhat.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
* (C) Copyright 2005 Red Hat, Inc.
* (C) Copyright 2006 Novell, Inc.
*/
#ifndef NM_GCONF_WSO_WPA_EAP_H
#define NM_GCONF_WSO_WPA_EAP_H
#include <glib-object.h>
#include <dbus/dbus.h>
#include <gconf/gconf-client.h>
#include "nm-gconf-wso-wpa-eap.h"
#define NM_TYPE_GCONF_WSO_WPA_EAP (nm_gconf_wso_wpa_eap_get_type ())
#define NM_GCONF_WSO_WPA_EAP(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_GCONF_WSO_WPA_EAP, NMGConfWSOWPA_EAP))
#define NM_GCONF_WSO_WPA_EAP_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), NM_TYPE_GCONF_WSO_WPA_EAP, NMGConfWSOWPA_EAPClass))
#define NM_IS_GCONF_WSO_WPA_EAP(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NM_TYPE_GCONF_WSO_WPA_EAP))
#define NM_IS_GCONF_WSO_WPA_EAP_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NM_TYPE_GCONF_WSO_WPA_EAP))
#define NM_GCONF_WSO_WPA_EAP_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_GCONF_WSO_WPA_EAP, NMGConfWSOWPA_EAPClass))
typedef struct _NMGConfWSOWPA_EAP NMGConfWSOWPA_EAP;
typedef struct _NMGConfWSOWPA_EAPClass NMGConfWSOWPA_EAPClass;
typedef struct _NMGConfWSOWPA_EAPPrivate NMGConfWSOWPA_EAPPrivate;
struct _NMGConfWSOWPA_EAP
{
NMGConfWSO parent;
/*< private >*/
NMGConfWSOWPA_EAPPrivate *priv;
};
struct _NMGConfWSOWPA_EAPClass
{
NMGConfWSOClass parent;
};
GType nm_gconf_wso_wpa_eap_get_type (void);
NMGConfWSOWPA_EAP * nm_gconf_wso_wpa_eap_new_deserialize_dbus (DBusMessageIter *iter, int we_cipher);
NMGConfWSOWPA_EAP * nm_gconf_wso_wpa_eap_new_deserialize_gconf (GConfClient *client, const char *network, int we_cipher);
#endif /* NM_GCONF_WSO_WPA_EAP_H */

252
gnome/applet/wso-wpa-eap.c Normal file
View file

@ -0,0 +1,252 @@
/* NetworkManager Wireless Applet -- Display wireless access points and allow user control
*
* Dan Williams <dcbw@redhat.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
* (C) Copyright 2005 Red Hat, Inc.
* (C) Copyright 2006 Novell, Inc.
*/
#include <glib.h>
#include <glib/gi18n.h>
#include <gtk/gtk.h>
#include <glade/glade.h>
#include <dbus/dbus.h>
#include <iwlib.h>
#include "wireless-security-option.h"
#include "wso-wpa-eap.h"
#include "wso-private.h"
#include "cipher.h"
#include "dbus-helpers.h"
#include "NetworkManager.h"
#define WPA_EAP_NAME_COL 0
#define WPA_EAP_VALUE_COL 1
struct OptData
{
int eap_method;
const char * identity;
const char * passwd;
const char * anon_identity;
const char * private_key_passwd;
const char * private_key_file;
const char * client_cert_file;
const char * ca_cert_file;
gboolean wpa2;
};
static void
data_free_func (WirelessSecurityOption *opt)
{
g_return_if_fail (opt != NULL);
g_return_if_fail (opt->data != NULL);
/* FIXME: Need to free the internal char*'s */
memset (opt->data, 0, sizeof (opt->data));
g_free (opt->data);
}
static GtkWidget *
widget_create_func (WirelessSecurityOption *opt,
GtkSignalFunc validate_cb,
gpointer user_data)
{
GtkWidget * entry;
GtkWidget * widget;
g_return_val_if_fail (opt != NULL, NULL);
g_return_val_if_fail (opt->data != NULL, NULL);
g_return_val_if_fail (validate_cb != NULL, NULL);
widget = wso_widget_helper (opt);
/* FIXME: Add other UI elements */
entry = glade_xml_get_widget (opt->uixml, "wpa_eap_private_key_passwd_entry");
g_signal_connect (G_OBJECT (entry), "changed", validate_cb, user_data);
entry = glade_xml_get_widget (opt->uixml, "wpa_eap_private_key_file_chooser_button");
g_signal_connect (G_OBJECT (entry), "selection-changed", validate_cb, user_data);
entry = glade_xml_get_widget (opt->uixml, "wpa_eap_ca_cert_file_chooser_button");
g_signal_connect (G_OBJECT (entry), "selection-changed", validate_cb, user_data);
return widget;
}
static gboolean
validate_input_func (WirelessSecurityOption *opt,
const char *ssid,
IEEE_802_11_Cipher **out_cipher)
{
//GtkWidget * entry;
//GtkWidget * filechooser;
//const char * input;
g_return_val_if_fail (opt != NULL, FALSE);
/* FIXME: Add other UI elements */
#if 0
entry = glade_xml_get_widget (opt->uixml, "wpa_eap_private_key_passwd_entry");
input = gtk_entry_get_text (GTK_ENTRY (entry));
if (!input || strlen (input) < 1)
return FALSE;
filechooser = glade_xml_get_widget (opt->uixml, "wpa_eap_private_key_file_chooser_button");
input = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (filechooser));
if (!input)
return FALSE;
filechooser = glade_xml_get_widget (opt->uixml, "wpa_eap_ca_cert_file_chooser_button");
input = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (filechooser));
if (!input)
return FALSE;
#endif
return TRUE;
}
static gboolean
append_dbus_params_func (WirelessSecurityOption *opt,
const char *ssid,
DBusMessage *message)
{
GtkWidget * entry;
GtkTreeModel * model;
GtkTreeIter tree_iter;
DBusMessageIter dbus_iter;
g_return_val_if_fail (opt != NULL, FALSE);
g_return_val_if_fail (opt->data != NULL, FALSE);
entry = glade_xml_get_widget (opt->uixml, "wpa_eap_eap_method_combo");
model = gtk_combo_box_get_model (GTK_COMBO_BOX (entry));
gtk_combo_box_get_active_iter (GTK_COMBO_BOX (entry), &tree_iter);
gtk_tree_model_get (model, &tree_iter, WPA_EAP_VALUE_COL, &opt->data->eap_method, -1);
entry = glade_xml_get_widget (opt->uixml, "wpa_eap_identity_entry");
opt->data->identity = gtk_entry_get_text (GTK_ENTRY (entry)) ? : "";
entry = glade_xml_get_widget (opt->uixml, "wpa_eap_passwd_entry");
opt->data->passwd = gtk_entry_get_text (GTK_ENTRY (entry)) ? : "";
entry = glade_xml_get_widget (opt->uixml, "wpa_eap_anon_identity_entry");
opt->data->anon_identity = gtk_entry_get_text (GTK_ENTRY (entry)) ? : "";
entry = glade_xml_get_widget (opt->uixml, "wpa_eap_client_cert_file_chooser_button");
opt->data->client_cert_file = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (entry)) ? : "";
entry = glade_xml_get_widget (opt->uixml, "wpa_eap_ca_cert_file_chooser_button");
opt->data->ca_cert_file = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (entry)) ? : "";
entry = glade_xml_get_widget (opt->uixml, "wpa_eap_private_key_file_chooser_button");
opt->data->private_key_file = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (entry)) ? : "";
entry = glade_xml_get_widget (opt->uixml, "wpa_eap_private_key_passwd_entry");
opt->data->private_key_passwd = gtk_entry_get_text (GTK_ENTRY (entry)) ? : "";
dbus_message_iter_init_append (message, &dbus_iter);
nmu_security_serialize_wpa_eap_with_cipher (&dbus_iter,
opt->data->eap_method,
opt->data->identity,
opt->data->passwd,
opt->data->anon_identity,
opt->data->private_key_passwd,
opt->data->private_key_file,
opt->data->client_cert_file,
opt->data->ca_cert_file,
opt->data->wpa2 ? IW_AUTH_WPA_VERSION_WPA2 : IW_AUTH_WPA_VERSION_WPA);
return TRUE;
}
WirelessSecurityOption *
wso_wpa_eap_new (const char *glade_file,
int capabilities,
gboolean wpa2)
{
WirelessSecurityOption * opt = NULL;
OptData * data = NULL;
GtkWidget * eap_method_combo;
GtkListStore * model;
GtkTreeIter iter;
GtkCellRenderer * renderer;
struct {
const char * name;
int value;
} *list, eap_method_list[] = {
{ _("PEAP"), NM_EAP_METHOD_PEAP },
{ _("TLS"), NM_EAP_METHOD_TLS },
{ _("TTLS"), NM_EAP_METHOD_TTLS },
{ NULL, 0 }
};
g_return_val_if_fail (glade_file != NULL, NULL);
opt = g_malloc0 (sizeof (WirelessSecurityOption));
if (wpa2)
opt->name = g_strdup (_("WPA2 Enterprise"));
else
opt->name = g_strdup (_("WPA Enterprise"));
opt->widget_name = "wpa_eap_notebook";
opt->data_free_func = data_free_func;
opt->validate_input_func = validate_input_func;
opt->widget_create_func = widget_create_func;
opt->append_dbus_params_func = append_dbus_params_func;
if (!(opt->uixml = glade_xml_new (glade_file, opt->widget_name, NULL)))
{
wso_free (opt);
return NULL;
}
eap_method_combo = glade_xml_get_widget (opt->uixml, "wpa_eap_eap_method_combo");
model = gtk_list_store_new (2, G_TYPE_STRING, G_TYPE_INT);
list = eap_method_list;
while (list->name)
{
gtk_list_store_append (model, &iter);
gtk_list_store_set (model, &iter, WPA_EAP_NAME_COL, list->name, WPA_EAP_VALUE_COL, list->value, -1);
list++;
}
gtk_combo_box_set_model (GTK_COMBO_BOX (eap_method_combo), GTK_TREE_MODEL (model));
gtk_tree_model_get_iter_first (GTK_TREE_MODEL (model), &iter);
gtk_combo_box_set_active_iter (GTK_COMBO_BOX (eap_method_combo), &iter);
renderer = gtk_cell_renderer_text_new ();
/* FIXME: Why do we need this here but not in the same place in wso-wpa-psk.c ? */
gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (eap_method_combo), renderer, TRUE);
gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (eap_method_combo), renderer, "text", 0, NULL);
/* Option-specific data */
opt->data = data = g_malloc0 (sizeof (OptData));
data->wpa2 = wpa2;
data->eap_method = NM_EAP_METHOD_TLS;
return opt;
}

View file

@ -0,0 +1,28 @@
/* NetworkManager Wireless Applet -- Display wireless access points and allow user control
*
* Dan Williams <dcbw@redhat.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
* (C) Copyright 2005 Red Hat, Inc.
* (C) Copyright 2006 Novell, Inc.
*/
#ifndef WSO_WPA_EAP_H
#define WSO_WPA_EAP_H
WirelessSecurityOption * wso_wpa_eap_new (const char *glade_file, int capabilities, gboolean wpa2);
#endif /* WSO_WPA_EAP_H */

View file

@ -0,0 +1,364 @@
/* NetworkManager -- Network link manager
*
* Dan Williams <dcbw@redhat.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
* (C) Copyright 2005 Red Hat, Inc.
* (C) Copyright 2006 Novell, Inc.
*/
#include <glib.h>
#include <glib/gi18n.h>
#include <dbus/dbus.h>
#include <iwlib.h>
#include "nm-ap-security.h"
#include "nm-ap-security-wpa-eap.h"
#include "nm-ap-security-private.h"
#include "dbus-helpers.h"
#include "nm-device-802-11-wireless.h"
#include "NetworkManagerUtils.h"
#define NM_AP_SECURITY_WPA_EAP_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_AP_SECURITY_WPA_EAP, NMAPSecurityWPA_EAPPrivate))
struct _NMAPSecurityWPA_EAPPrivate
{
int eap_method;
int wpa_version;
int key_mgmt;
char * identity;
char * passwd;
char * anon_identity;
char * private_key_passwd;
char * private_key_file;
char * client_cert_file;
char * ca_cert_file;
};
NMAPSecurityWPA_EAP *
nm_ap_security_wpa_eap_new_deserialize (DBusMessageIter *iter)
{
NMAPSecurityWPA_EAP * security = NULL;
int eap_method;
int wpa_version;
char * identity = NULL;
char * passwd = NULL;
char * anon_identity = NULL;
char * private_key_passwd = NULL;
char * private_key_file = NULL;
char * client_cert_file = NULL;
char * ca_cert_file = NULL;
g_return_val_if_fail (iter != NULL, NULL);
if (!nmu_security_deserialize_wpa_eap (iter, &eap_method, &identity, &passwd, &anon_identity,
&private_key_passwd, &private_key_file, &client_cert_file,
&ca_cert_file, &wpa_version))
goto out;
/* Success, build up our security object */
security = g_object_new (NM_TYPE_AP_SECURITY_WPA_EAP, NULL);
nm_ap_security_set_we_cipher (NM_AP_SECURITY (security), NM_AUTH_TYPE_WPA_EAP);
nm_ap_security_set_key (NM_AP_SECURITY (security), "FIXME", 5); /* FIXME: what do we do for Enterprise? */
security->priv->eap_method = eap_method;
security->priv->wpa_version = wpa_version;
security->priv->key_mgmt = IW_AUTH_KEY_MGMT_802_1X;
security->priv->identity = g_strdup (identity);
security->priv->passwd = g_strdup (passwd);
security->priv->anon_identity = g_strdup (anon_identity);
security->priv->private_key_passwd = g_strdup (private_key_passwd);
security->priv->private_key_file = g_strdup (private_key_file);
security->priv->client_cert_file = g_strdup (client_cert_file);
security->priv->ca_cert_file = g_strdup (ca_cert_file);
security->priv->wpa_version = wpa_version;
/* FIXME: free passwd, cert_file, and key_file ? */
if (wpa_version == IW_AUTH_WPA_VERSION_WPA2)
nm_ap_security_set_description (NM_AP_SECURITY (security), _("WPA2 Enterprise"));
else
nm_ap_security_set_description (NM_AP_SECURITY (security), _("WPA Enterprise"));
out:
return security;
}
NMAPSecurityWPA_EAP *
nm_ap_security_wpa_eap_new_from_ap (NMAccessPoint *ap)
{
NMAPSecurityWPA_EAP * security = NULL;
guint32 caps;
g_return_val_if_fail (ap != NULL, NULL);
security = g_object_new (NM_TYPE_AP_SECURITY_WPA_EAP, NULL);
nm_ap_security_set_we_cipher (NM_AP_SECURITY (security), NM_AUTH_TYPE_WPA_EAP);
caps = nm_ap_get_capabilities (ap);
if (caps & NM_802_11_CAP_PROTO_WPA2)
{
security->priv->wpa_version = IW_AUTH_WPA_VERSION_WPA2;
nm_ap_security_set_description (NM_AP_SECURITY (security), _("WPA2 Enterprise"));
}
else
{
security->priv->wpa_version = IW_AUTH_WPA_VERSION_WPA;
nm_ap_security_set_description (NM_AP_SECURITY (security), _("WPA Enterprise"));
}
return security;
}
static int
real_serialize (NMAPSecurity *instance, DBusMessageIter *iter)
{
NMAPSecurityWPA_EAP * self = NM_AP_SECURITY_WPA_EAP (instance);
if (!nmu_security_serialize_wpa_eap (iter,
self->priv->eap_method,
self->priv->identity,
self->priv->passwd,
self->priv->anon_identity,
self->priv->private_key_passwd,
self->priv->private_key_file,
self->priv->client_cert_file,
self->priv->ca_cert_file,
self->priv->wpa_version))
return -1;
return 0;
}
static const char *
get_eap_method (int eap_method)
{
switch (eap_method)
{
case NM_EAP_METHOD_PEAP:
return "PEAP";
case NM_EAP_METHOD_TLS:
return "TLS";
case NM_EAP_METHOD_TTLS:
return "TTLS";
default:
g_warning ("Unmatched eap_method=%d!", eap_method);
return "TLS";
}
}
static gboolean
real_write_supplicant_config (NMAPSecurity *instance,
struct wpa_ctrl *ctrl,
int nwid,
gboolean user_created)
{
NMAPSecurityWPA_EAP * self = NM_AP_SECURITY_WPA_EAP (instance);
gboolean success = FALSE;
char * msg;
const char * identity = self->priv->identity;
const char * anon_identity = self->priv->anon_identity;
const char * passwd = self->priv->passwd;
const char * private_key_passwd = self->priv->private_key_passwd;
const char * private_key_file = self->priv->private_key_file;
const char * ca_cert_file = self->priv->ca_cert_file;
const char * client_cert_file = self->priv->client_cert_file;
int wpa_version = self->priv->wpa_version;
int cipher = nm_ap_security_get_we_cipher (instance);
int key_mgmt = self->priv->key_mgmt;
int eap_method = self->priv->eap_method;
g_return_val_if_fail (cipher == NM_AUTH_TYPE_WPA_EAP, FALSE);
g_return_val_if_fail (key_mgmt == IW_AUTH_KEY_MGMT_802_1X, FALSE);
g_return_val_if_fail (wpa_version == IW_AUTH_WPA_VERSION_WPA
|| wpa_version == IW_AUTH_WPA_VERSION_WPA2, FALSE);
g_return_val_if_fail (eap_method == NM_EAP_METHOD_MD5
|| eap_method == NM_EAP_METHOD_MSCHAP
|| eap_method == NM_EAP_METHOD_OTP
|| eap_method == NM_EAP_METHOD_GTC
|| eap_method == NM_EAP_METHOD_PEAP
|| eap_method == NM_EAP_METHOD_TLS
|| eap_method == NM_EAP_METHOD_TTLS, FALSE);
/* WPA-EAP network setup */
if (self->priv->wpa_version == IW_AUTH_WPA_VERSION_WPA)
{
if (!nm_utils_supplicant_request_with_check (ctrl, "OK", __func__, NULL, "SET_NETWORK %i proto WPA", nwid))
goto out;
}
else
{
if (!nm_utils_supplicant_request_with_check (ctrl, "OK", __func__, NULL, "SET_NETWORK %i proto WPA2", nwid))
goto out;
}
if (!nm_utils_supplicant_request_with_check (ctrl, "OK", __func__, NULL, "SET_NETWORK %i key_mgmt WPA-EAP", nwid))
goto out;
if (!nm_utils_supplicant_request_with_check (ctrl, "OK", __func__, NULL, "SET_NETWORK %i eap %s", nwid, get_eap_method (eap_method)))
goto out;
if (identity && strlen (identity) > 0)
if (!nm_utils_supplicant_request_with_check (ctrl, "OK", __func__, NULL, "SET_NETWORK %i identity \"%s\"", nwid, identity))
goto out;
if (passwd && strlen (passwd) > 0)
if (!nm_utils_supplicant_request_with_check (ctrl, "OK", __func__, NULL, "SET_NETWORK %i password \"%s\"", nwid, passwd))
goto out;
if (anon_identity && strlen (anon_identity) > 0)
if (!nm_utils_supplicant_request_with_check (ctrl, "OK", __func__, NULL, "SET_NETWORK %i anonymous_identity \"%s\"", nwid, anon_identity))
goto out;
if (private_key_file && private_key_passwd && strlen (private_key_file) > 0 && strlen (private_key_passwd) > 0)
{
if (!nm_utils_supplicant_request_with_check (ctrl, "OK", __func__, NULL, "SET_NETWORK %i private_key \"%s\"", nwid, private_key_file))
goto out;
msg = g_strdup_printf ("SET_NETWORK %i private_key_passwd <key>", nwid);
if (!nm_utils_supplicant_request_with_check (ctrl, "OK", __func__, msg, "SET_NETWORK %i private_key_passwd \"%s\"", nwid, private_key_passwd))
{
g_free (msg);
goto out;
}
g_free (msg);
}
if (client_cert_file && strlen (client_cert_file) > 0)
if (!nm_utils_supplicant_request_with_check (ctrl, "OK", __func__, NULL, "SET_NETWORK %i client_cert \"%s\"", nwid, client_cert_file))
goto out;
if (ca_cert_file && strlen (ca_cert_file) > 0)
if (!nm_utils_supplicant_request_with_check (ctrl, "OK", __func__, NULL, "SET_NETWORK %i ca_cert \"%s\"", nwid, ca_cert_file))
goto out;
#if 0 /* Right now we always let wpa_supplicant sort out the pairwise and group cipher */
/*
* FIXME: Technically, the pairwise cipher does not need to be the same as
* the group cipher. Fixing this requires changes in the UI.
*/
if (cipher == IW_AUTH_CIPHER_TKIP)
pairwise_cipher = group_cipher = "TKIP";
else if (cipher == IW_AUTH_CIPHER_CCMP)
pairwise_cipher = group_cipher = "CCMP";
else if (cipher == IW_AUTH_CIPHER_NONE)
pairwise_cipher = group_cipher = "NONE";
/* Ad-Hoc requires pairwise cipher of NONE */
if (user_created)
pairwise_cipher = "NONE";
/* If user selected "Automatic", we let wpa_supplicant sort it out */
if (cipher != NM_AUTH_TYPE_WPA_PSK_AUTO)
{
if (!nm_utils_supplicant_request_with_check (ctrl, "OK", __func__, NULL,
"SET_NETWORK %i pairwise %s", nwid, pairwise_cipher))
goto out;
if (!nm_utils_supplicant_request_with_check (ctrl, "OK", __func__, NULL,
"SET_NETWORK %i group %s", nwid, group_cipher))
goto out;
}
#endif
success = TRUE;
out:
return success;
}
static NMAPSecurity *
real_copy_constructor (NMAPSecurity *instance)
{
NMAPSecurityWPA_EAP * dst = g_object_new (NM_TYPE_AP_SECURITY_WPA_EAP, NULL);
NMAPSecurityWPA_EAP * self = NM_AP_SECURITY_WPA_EAP (instance);
dst->priv->eap_method = self->priv->eap_method;
dst->priv->wpa_version = self->priv->wpa_version;
dst->priv->key_mgmt = self->priv->key_mgmt;
dst->priv->identity = self->priv->identity;
dst->priv->passwd = self->priv->passwd;
dst->priv->anon_identity = self->priv->anon_identity;
dst->priv->private_key_passwd = self->priv->private_key_passwd;
dst->priv->private_key_file = self->priv->private_key_file;
dst->priv->client_cert_file = self->priv->client_cert_file;
dst->priv->ca_cert_file = self->priv->ca_cert_file;
nm_ap_security_copy_properties (NM_AP_SECURITY (self), NM_AP_SECURITY (dst));
return NM_AP_SECURITY (dst);
}
static void
nm_ap_security_wpa_eap_init (NMAPSecurityWPA_EAP * self)
{
self->priv = NM_AP_SECURITY_WPA_EAP_GET_PRIVATE (self);
self->priv->eap_method = NM_EAP_METHOD_TLS;
self->priv->wpa_version = IW_AUTH_WPA_VERSION_WPA;
self->priv->key_mgmt = IW_AUTH_KEY_MGMT_802_1X;
self->priv->identity = NULL;
self->priv->passwd = NULL;
self->priv->anon_identity = NULL;
self->priv->private_key_passwd = NULL;
self->priv->private_key_file = NULL;
self->priv->client_cert_file = NULL;
self->priv->ca_cert_file = NULL;
}
static void
nm_ap_security_wpa_eap_class_init (NMAPSecurityWPA_EAPClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
NMAPSecurityClass *par_class = NM_AP_SECURITY_CLASS (klass);
par_class->copy_constructor_func = real_copy_constructor;
par_class->serialize_func = real_serialize;
par_class->write_supplicant_config_func = real_write_supplicant_config;
g_type_class_add_private (object_class, sizeof (NMAPSecurityWPA_EAPPrivate));
}
GType
nm_ap_security_wpa_eap_get_type (void)
{
static GType type = 0;
if (type == 0) {
static const GTypeInfo info = {
sizeof (NMAPSecurityWPA_EAPClass),
NULL, /* base_init */
NULL, /* base_finalize */
(GClassInitFunc) nm_ap_security_wpa_eap_class_init,
NULL, /* class_finalize */
NULL, /* class_data */
sizeof (NMAPSecurityWPA_EAP),
0, /* n_preallocs */
(GInstanceInitFunc) nm_ap_security_wpa_eap_init,
NULL /* value_table */
};
type = g_type_register_static (NM_TYPE_AP_SECURITY,
"NMAPSecurityWPA_EAP",
&info, 0);
}
return type;
}

View file

@ -0,0 +1,62 @@
/* NetworkManager -- Network link manager
*
* Dan Williams <dcbw@redhat.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
* (C) Copyright 2005 Red Hat, Inc.
* (C) Copyright 2006 Novell, Inc.
*/
#ifndef NM_AP_SECURITY_WPA_EAP_H
#define NM_AP_SECURITY_WPA_EAP_H
#include <glib-object.h>
#include <dbus/dbus.h>
#include "nm-ap-security.h"
#define NM_TYPE_AP_SECURITY_WPA_EAP (nm_ap_security_wpa_eap_get_type ())
#define NM_AP_SECURITY_WPA_EAP(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_AP_SECURITY_WPA_EAP, NMAPSecurityWPA_EAP))
#define NM_AP_SECURITY_WPA_EAP_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), NM_TYPE_AP_SECURITY_WPA_EAP, NMAPSecurityWPA_EAPClass))
#define NM_IS_AP_SECURITY_WPA_EAP(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NM_TYPE_AP_SECURITY_WPA_EAP))
#define NM_IS_AP_SECURITY_WPA_EAP_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NM_TYPE_AP_SECURITY_WPA_EAP))
#define NM_AP_SECURITY_WPA_EAP_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_AP_SECURITY_WPA_EAP, NMAPSecurityWPA_EAPClass))
typedef struct _NMAPSecurityWPA_EAP NMAPSecurityWPA_EAP;
typedef struct _NMAPSecurityWPA_EAPClass NMAPSecurityWPA_EAPClass;
typedef struct _NMAPSecurityWPA_EAPPrivate NMAPSecurityWPA_EAPPrivate;
struct _NMAPSecurityWPA_EAP
{
NMAPSecurity parent;
/*< private >*/
NMAPSecurityWPA_EAPPrivate *priv;
};
struct _NMAPSecurityWPA_EAPClass
{
NMAPSecurityClass parent;
};
GType nm_ap_security_wpa_eap_get_type (void);
NMAPSecurityWPA_EAP * nm_ap_security_wpa_eap_new_deserialize (DBusMessageIter *iter);
struct NMAccessPoint;
NMAPSecurityWPA_EAP * nm_ap_security_wpa_eap_new_from_ap (struct NMAccessPoint *ap);
#endif /* NM_AP_SECURITY_WPA_EAP_H */