2006-07-13 Dan Williams <dcbw@redhat.com>

Patch from Thiago Bauermann <thiago.bauermann@gmail.com>
	* gnome/applet/applet.glade
	  gnome/applet/Makefile.am
	  gnome/applet/nm-gconf-wso.c
	  gnome/applet/nm-gconf-wso-leap.c
	  gnome/applet/nm-gconf-wso-leap.h
	  gnome/applet/wireless-security-manager.c
	  gnome/applet/wso-leap.c
	  gnome/applet/wso-leap.h
	  include/NetworkManager.h
	  libnm-util/dbus-helpers.c
	  libnm-util/dbus-helpers.h
	  src/Makefile.am
	  src/NetworkManagerAP.c
	  src/nm-ap-security.c
	  src/nm-ap-security-leap.c
	  src/nm-ap-security-leap.h
		- Add LEAP authentication support


git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@1881 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
This commit is contained in:
Dan Williams 2006-07-13 17:03:31 +00:00
parent e51cecf34b
commit 3c10e4401f
17 changed files with 906 additions and 3 deletions

View file

@ -1,3 +1,24 @@
2006-07-13 Dan Williams <dcbw@redhat.com>
Patch from Thiago Bauermann <thiago.bauermann@gmail.com>
* gnome/applet/applet.glade
gnome/applet/Makefile.am
gnome/applet/nm-gconf-wso.c
gnome/applet/nm-gconf-wso-leap.c
gnome/applet/nm-gconf-wso-leap.h
gnome/applet/wireless-security-manager.c
gnome/applet/wso-leap.c
gnome/applet/wso-leap.h
include/NetworkManager.h
libnm-util/dbus-helpers.c
libnm-util/dbus-helpers.h
src/Makefile.am
src/NetworkManagerAP.c
src/nm-ap-security.c
src/nm-ap-security-leap.c
src/nm-ap-security-leap.h
- Add LEAP authentication support
2006-07-13 Dan Williams <dcbw@redhat.com>
Patch from Timothée Lecomte <timothee.lecomte@ens.fr>

View file

@ -82,6 +82,8 @@ nm_applet_SOURCES = \
wso-wpa-eap.h \
wso-wpa-psk.c \
wso-wpa-psk.h \
wso-leap.c \
wso-leap.h \
nm-gconf-wso.c \
nm-gconf-wso.h \
nm-gconf-wso-private.h \
@ -91,6 +93,8 @@ nm_applet_SOURCES = \
nm-gconf-wso-wpa-eap.h \
nm-gconf-wso-wpa-psk.c \
nm-gconf-wso-wpa-psk.h \
nm-gconf-wso-leap.c \
nm-gconf-wso-leap.h \
gconf-helpers.c \
gconf-helpers.h \
$(NULL)

View file

@ -2012,7 +2012,7 @@ Shared Key</property>
<widget class="GtkTable" id="table5">
<property name="border_width">6</property>
<property name="visible">True</property>
<property name="n_rows">2</property>
<property name="n_rows">3</property>
<property name="n_columns">2</property>
<property name="homogeneous">False</property>
<property name="row_spacing">6</property>
@ -2113,6 +2113,51 @@ Shared Key</property>
<property name="y_options"></property>
</packing>
</child>
<child>
<widget class="GtkLabel" id="leap_key_mgmt">
<property name="visible">True</property>
<property name="label" translatable="yes">Key management:</property>
<property name="use_underline">False</property>
<property name="use_markup">False</property>
<property name="justify">GTK_JUSTIFY_LEFT</property>
<property name="wrap">False</property>
<property name="selectable">False</property>
<property name="xalign">0</property>
<property name="yalign">0.5</property>
<property name="xpad">0</property>
<property name="ypad">0</property>
<property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
<property name="width_chars">-1</property>
<property name="single_line_mode">False</property>
<property name="angle">0</property>
</widget>
<packing>
<property name="left_attach">0</property>
<property name="right_attach">1</property>
<property name="top_attach">2</property>
<property name="bottom_attach">3</property>
<property name="x_options">fill</property>
<property name="y_options"></property>
</packing>
</child>
<child>
<widget class="GtkComboBox" id="leap_key_mgmt_combobox">
<property name="visible">True</property>
<property name="items" translatable="yes"></property>
<property name="add_tearoffs">False</property>
<property name="focus_on_click">True</property>
</widget>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="top_attach">2</property>
<property name="bottom_attach">3</property>
<property name="x_options">fill</property>
<property name="y_options">fill</property>
</packing>
</child>
</widget>
<packing>
<property name="tab_expand">False</property>

View file

@ -0,0 +1,178 @@
/* NetworkManager -- Network link manager
*
* 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 2006 Thiago Jung Bauermann <thiago.bauermann@gmail.com>
*/
/* This file is heavily based on nm-gconf-wso-wpa-eap.c */
#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-leap.h"
#include "nm-gconf-wso-private.h"
#include "dbus-helpers.h"
#include "gconf-helpers.h"
#define LEAP_PREFIX "leap_"
#define NM_GCONF_WSO_LEAP_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_GCONF_WSO_LEAP, NMGConfWSOLEAPPrivate))
struct _NMGConfWSOLEAPPrivate
{
const char * username;
const char * key_mgmt;
};
NMGConfWSOLEAP *
nm_gconf_wso_leap_new_deserialize_dbus (DBusMessageIter *iter, int we_cipher)
{
NMGConfWSOLEAP * security = NULL;
char * username = NULL;
char * password = NULL;
char * key_mgmt = NULL;
g_return_val_if_fail (we_cipher == NM_AUTH_TYPE_LEAP, NULL);
g_return_val_if_fail (iter != NULL, NULL);
if (!nmu_security_deserialize_leap (iter, &username, &password, &key_mgmt))
goto out;
/* Success, build up our security object */
security = g_object_new (NM_TYPE_GCONF_WSO_LEAP, NULL);
nm_gconf_wso_set_we_cipher (NM_GCONF_WSO (security), we_cipher);
if (password)
nm_gconf_wso_set_key (NM_GCONF_WSO (security), password, strlen(password));
if (username)
security->priv->username = g_strdup (username);
if (key_mgmt)
security->priv->key_mgmt = g_strdup (key_mgmt);
out:
return security;
}
NMGConfWSOLEAP *
nm_gconf_wso_leap_new_deserialize_gconf (GConfClient *client, const char *network, int we_cipher)
{
NMGConfWSOLEAP * security = NULL;
char * username = NULL;
char * key_mgmt = NULL;
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_LEAP), NULL);
nm_gconf_get_string_helper (client,
GCONF_PATH_WIRELESS_NETWORKS,
LEAP_PREFIX"username",
network,
&username);
nm_gconf_get_string_helper (client,
GCONF_PATH_WIRELESS_NETWORKS,
LEAP_PREFIX"key_mgmt",
network,
&key_mgmt);
/* Success, build up our security object */
security = g_object_new (NM_TYPE_GCONF_WSO_LEAP, NULL);
nm_gconf_wso_set_we_cipher (NM_GCONF_WSO (security), we_cipher);
security->priv->username = username;
security->priv->key_mgmt = key_mgmt;
return security;
}
static gboolean
real_serialize_dbus (NMGConfWSO *instance, DBusMessageIter *iter)
{
NMGConfWSOLEAP * self = NM_GCONF_WSO_LEAP (instance);
if (!nmu_security_serialize_leap (iter, self->priv->username,
nm_gconf_wso_get_key(instance), self->priv->key_mgmt))
return FALSE;
return TRUE;
}
static gboolean
real_serialize_gconf (NMGConfWSO *instance, GConfClient *client, const char *network)
{
NMGConfWSOLEAP * self = NM_GCONF_WSO_LEAP (instance);
char * key;
key = g_strdup_printf ("%s/%s/%susername", GCONF_PATH_WIRELESS_NETWORKS, network, LEAP_PREFIX);
gconf_client_set_string (client, key, self->priv->username, NULL);
g_free (key);
key = g_strdup_printf ("%s/%s/%skey_mgmt", GCONF_PATH_WIRELESS_NETWORKS, network, LEAP_PREFIX);
gconf_client_set_string (client, key, self->priv->key_mgmt, NULL);
g_free (key);
return TRUE;
}
static void
nm_gconf_wso_leap_init (NMGConfWSOLEAP *self)
{
self->priv = NM_GCONF_WSO_LEAP_GET_PRIVATE (self);
}
static void
nm_gconf_wso_leap_class_init (NMGConfWSOLEAPClass *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 (NMGConfWSOLEAPPrivate));
}
GType
nm_gconf_wso_leap_get_type (void)
{
static GType type = 0;
if (type == 0) {
static const GTypeInfo info = {
sizeof (NMGConfWSOLEAPClass),
NULL, /* base_init */
NULL, /* base_finalize */
(GClassInitFunc) nm_gconf_wso_leap_class_init,
NULL, /* class_finalize */
NULL, /* class_data */
sizeof (NMGConfWSOLEAP),
0, /* n_preallocs */
(GInstanceInitFunc) nm_gconf_wso_leap_init,
NULL /* value_table */
};
type = g_type_register_static (NM_TYPE_GCONF_WSO,
"NMGConfWSOLEAP",
&info, 0);
}
return type;
}

View file

@ -0,0 +1,60 @@
/* NetworkManager -- Network link manager
*
* 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 2006 Thiago Jung Bauermann <thiago.bauermann@gmail.com>
*/
/* This file is heavily based on nm-gconf-wso-wpa-eap.h */
#ifndef NM_GCONF_WSO_LEAP_H
#define NM_GCONF_WSO_LEAP_H
#include <glib-object.h>
#include <dbus/dbus.h>
#include <gconf/gconf-client.h>
#define NM_TYPE_GCONF_WSO_LEAP (nm_gconf_wso_leap_get_type ())
#define NM_GCONF_WSO_LEAP(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_GCONF_WSO_LEAP, NMGConfWSOLEAP))
#define NM_GCONF_WSO_LEAP_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), NM_TYPE_GCONF_WSO_LEAP, NMGConfWSOLEAPClass))
#define NM_IS_GCONF_WSO_LEAP(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NM_TYPE_GCONF_WSO_LEAP))
#define NM_IS_GCONF_WSO_LEAP_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NM_TYPE_GCONF_WSO_LEAP))
#define NM_GCONF_WSO_LEAP_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_GCONF_WSO_LEAP, NMGConfWSOLEAPClass))
typedef struct _NMGConfWSOLEAP NMGConfWSOLEAP;
typedef struct _NMGConfWSOLEAPClass NMGConfWSOLEAPClass;
typedef struct _NMGConfWSOLEAPPrivate NMGConfWSOLEAPPrivate;
struct _NMGConfWSOLEAP
{
NMGConfWSO parent;
/*< private >*/
NMGConfWSOLEAPPrivate *priv;
};
struct _NMGConfWSOLEAPClass
{
NMGConfWSOClass parent;
};
GType nm_gconf_wso_leap_get_type (void);
NMGConfWSOLEAP * nm_gconf_wso_leap_new_deserialize_dbus (DBusMessageIter *iter, int we_cipher);
NMGConfWSOLEAP * nm_gconf_wso_leap_new_deserialize_gconf (GConfClient *client, const char *network, int we_cipher);
#endif /* NM_GCONF_WSO_LEAP_H */

View file

@ -31,6 +31,7 @@
#include "nm-gconf-wso-wep.h"
#include "nm-gconf-wso-wpa-eap.h"
#include "nm-gconf-wso-wpa-psk.h"
#include "nm-gconf-wso-leap.h"
#include "gconf-helpers.h"
#include "wireless-security-option.h"
@ -95,6 +96,10 @@ nm_gconf_wso_new_deserialize_dbus (DBusMessageIter *iter)
security = NM_GCONF_WSO (nm_gconf_wso_wpa_eap_new_deserialize_dbus (iter, we_cipher));
break;
case NM_AUTH_TYPE_LEAP:
security = NM_GCONF_WSO (nm_gconf_wso_leap_new_deserialize_dbus (iter, we_cipher));
break;
default:
break;
}
@ -141,6 +146,10 @@ nm_gconf_wso_new_deserialize_gconf (GConfClient *client,
security = NM_GCONF_WSO (nm_gconf_wso_wpa_eap_new_deserialize_gconf (client, network, we_cipher));
break;
case NM_AUTH_TYPE_LEAP:
security = NM_GCONF_WSO (nm_gconf_wso_leap_new_deserialize_gconf (client, network, we_cipher));
break;
default:
break;
}
@ -187,6 +196,7 @@ nm_gconf_wso_set_we_cipher (NMGConfWSO *self,
g_return_if_fail (
(we_cipher == NM_AUTH_TYPE_WPA_PSK_AUTO)
|| (we_cipher == NM_AUTH_TYPE_WPA_EAP)
|| (we_cipher == NM_AUTH_TYPE_LEAP)
|| (we_cipher == IW_AUTH_CIPHER_NONE)
|| (we_cipher == IW_AUTH_CIPHER_WEP40)
|| (we_cipher == IW_AUTH_CIPHER_WEP104)

View file

@ -36,6 +36,7 @@
#include "wso-wep-passphrase.h"
#include "wso-wpa-eap.h"
#include "wso-wpa-psk.h"
#include "wso-leap.h"
struct WirelessSecurityManager
{
@ -116,6 +117,9 @@ gboolean wsm_set_capabilities (WirelessSecurityManager *wsm, guint32 capabilitie
}
}
if ((opt = wso_leap_new (wsm->glade_file, capabilities)))
wsm->options = g_slist_append (wsm->options, opt);
if (!wsm->options)
{
nm_warning ("capabilities='%x' and did not match any protocals, not even none!", capabilities);

169
gnome/applet/wso-leap.c Normal file
View file

@ -0,0 +1,169 @@
/* NetworkManager Wireless Applet -- Display wireless access points and allow user control
*
* 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 2006 Thiago Jung Bauermann <thiago.bauermann@gmail.com>
*/
/* This file is heavily based on wso-wpa-eap.c */
#include <glib.h>
#include <gtk/gtk.h>
#include <glade/glade.h>
#include <dbus/dbus.h>
#include <iwlib.h>
#include "wireless-security-option.h"
#include "wso-leap.h"
#include "wso-private.h"
#include "dbus-helpers.h"
#include "NetworkManager.h"
struct OptData
{
const char * username;
const char * passwd;
const char * key_mgmt;
};
static void
data_free_func (WirelessSecurityOption *opt)
{
g_return_if_fail (opt != NULL);
g_return_if_fail (opt->data != NULL);
if (opt->data->key_mgmt) {
g_free((char *) opt->data->key_mgmt);
}
memset (opt->data, 0, sizeof (opt->data));
g_free (opt->data);
}
static gboolean
append_dbus_params_func (WirelessSecurityOption *opt,
const char *ssid,
DBusMessage *message)
{
GtkWidget * entry;
GtkTreeModel * combo_model;
GtkTreeIter 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, "leap_username_entry");
opt->data->username = gtk_entry_get_text (GTK_ENTRY (entry));
entry = glade_xml_get_widget (opt->uixml, "leap_password_entry");
opt->data->passwd = gtk_entry_get_text (GTK_ENTRY (entry));
entry = glade_xml_get_widget (opt->uixml, "leap_key_mgmt_combobox");
combo_model = gtk_combo_box_get_model(GTK_COMBO_BOX(entry));
gtk_combo_box_get_active_iter(GTK_COMBO_BOX(entry), &iter);
gtk_tree_model_get(combo_model, &iter, 1, &opt->data->key_mgmt, -1);
dbus_message_iter_init_append (message, &dbus_iter);
nmu_security_serialize_leap_with_cipher (&dbus_iter,
opt->data->username,
opt->data->passwd,
opt->data->key_mgmt);
return TRUE;
}
static GtkWidget *
widget_create_func (WirelessSecurityOption *opt,
GtkSignalFunc validate_cb,
gpointer user_data)
{
GtkWidget * entry;
GtkWidget * widget;
GtkWidget * key_mgmt;
GtkListStore * list_store;
GtkTreeIter iter;
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);
entry = glade_xml_get_widget (opt->uixml, "leap_username_entry");
g_signal_connect (G_OBJECT (entry), "changed", validate_cb, user_data);
entry = glade_xml_get_widget (opt->uixml, "leap_password_entry");
g_signal_connect (G_OBJECT (entry), "changed", validate_cb, user_data);
/* set-up key_mgmt combo box */
key_mgmt = glade_xml_get_widget (opt->uixml, "leap_key_mgmt_combobox");
/* create tree model containing combo box items */
list_store = gtk_list_store_new(2, G_TYPE_STRING, G_TYPE_STRING);
gtk_list_store_append(list_store, &iter);
gtk_list_store_set(list_store, &iter, 0, "IEEE 802.1X", 1, "IEEE8021X", -1);
gtk_list_store_append(list_store, &iter);
gtk_list_store_set(list_store, &iter, 0, "WPA-EAP", 1, "WPA-EAP", -1);
gtk_combo_box_set_model(GTK_COMBO_BOX(key_mgmt), GTK_TREE_MODEL(list_store));
/* set default choice to be IEEE 802.1X */
gtk_combo_box_set_active(GTK_COMBO_BOX(key_mgmt), 0);
return widget;
}
static gboolean
validate_input_func (WirelessSecurityOption *opt,
const char *ssid,
IEEE_802_11_Cipher **out_cipher)
{
return TRUE;
}
WirelessSecurityOption *
wso_leap_new (const char *glade_file,
int capabilities)
{
WirelessSecurityOption * opt = NULL;
g_return_val_if_fail (glade_file != NULL, NULL);
opt = g_malloc0 (sizeof (WirelessSecurityOption));
opt->name = g_strdup("LEAP");
opt->widget_name = "leap_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;
}
/* Option-specific data */
opt->data = g_malloc0 (sizeof (OptData));
return opt;
}

27
gnome/applet/wso-leap.h Normal file
View file

@ -0,0 +1,27 @@
/* NetworkManager Wireless Applet -- Display wireless access points and allow user control
*
* 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 2006 Thiago Jung Bauermann <thiago.bauermann@gmail.com>
*/
/* This file is heavily based on wso-wpa-eap.h */
#ifndef WSO_LEAP_H
#define WSO_LEAP_H
WirelessSecurityOption * wso_leap_new (const char *glade_file, int capabilities);
#endif /* WSO_LEAP_H */

View file

@ -120,6 +120,7 @@ typedef enum NMDeviceType
#define NM_AUTH_TYPE_WPA_PSK_CCMP 0x00000008
#define NM_AUTH_TYPE_WEP104 0x00000010
#define NM_AUTH_TYPE_WPA_EAP 0x00000020
#define NM_AUTH_TYPE_LEAP 0x00000040
/*
* EAP Methods

View file

@ -474,6 +474,85 @@ nmu_security_deserialize_wpa_eap (DBusMessageIter *iter,
return TRUE;
}
dbus_bool_t
nmu_security_serialize_leap (DBusMessageIter *iter,
const char *username,
const char *passwd,
const char *key_mgmt)
{
const char *fake_username = "";
const char *fake_passwd = "";
g_return_val_if_fail (iter != NULL, FALSE);
g_return_val_if_fail (key_mgmt != NULL, FALSE);
/* Second arg: Username (STRING) */
dbus_message_iter_append_basic (iter, DBUS_TYPE_STRING, username? &username : &fake_username);
/* Third arg: Password (STRING) */
dbus_message_iter_append_basic (iter, DBUS_TYPE_STRING, passwd? &passwd : &fake_passwd);
/* Fourth arg: Key management (STRING) */
dbus_message_iter_append_basic (iter, DBUS_TYPE_STRING, &key_mgmt);
return TRUE;
}
dbus_bool_t
nmu_security_serialize_leap_with_cipher (DBusMessageIter *iter,
const char *username,
const char *passwd,
const char *key_mgmt)
{
g_return_val_if_fail (iter != NULL, FALSE);
/* First arg: WE Cipher (INT32) */
we_cipher_append_helper (iter, NM_AUTH_TYPE_LEAP);
return nmu_security_serialize_leap (iter, username, passwd, key_mgmt);
}
dbus_bool_t
nmu_security_deserialize_leap (DBusMessageIter *iter,
char **username,
char **passwd,
char **key_mgmt)
{
char * dbus_username;
char * dbus_password;
char * dbus_key_mgmt;
g_return_val_if_fail (iter != NULL, FALSE);
g_return_val_if_fail (username != NULL, FALSE);
g_return_val_if_fail (*username == NULL, FALSE);
g_return_val_if_fail (passwd != NULL, FALSE);
g_return_val_if_fail (*passwd == NULL, FALSE);
g_return_val_if_fail (key_mgmt != NULL, FALSE);
g_return_val_if_fail (*key_mgmt == NULL, FALSE);
/* Second arg: Username (STRING) */
g_return_val_if_fail (dbus_message_iter_get_arg_type (iter) == DBUS_TYPE_STRING, FALSE);
dbus_message_iter_get_basic (iter, &dbus_username);
g_return_val_if_fail (dbus_username != NULL, FALSE);
/* Third arg: Password (STRING) */
g_return_val_if_fail (dbus_message_iter_next (iter), FALSE);
g_return_val_if_fail (dbus_message_iter_get_arg_type (iter) == DBUS_TYPE_STRING, FALSE);
dbus_message_iter_get_basic (iter, &dbus_password);
g_return_val_if_fail (dbus_password != NULL, FALSE);
/* Fourth arg: Key Management (STRING) */
g_return_val_if_fail (dbus_message_iter_next (iter), FALSE);
g_return_val_if_fail (dbus_message_iter_get_arg_type (iter) == DBUS_TYPE_STRING, FALSE);
dbus_message_iter_get_basic (iter, &dbus_key_mgmt);
g_return_val_if_fail (dbus_key_mgmt != NULL, FALSE);
*username = strlen (dbus_username) > 0 ? dbus_username : NULL;
*passwd = strlen (dbus_password) > 0 ? dbus_password : NULL;
*key_mgmt = strlen (dbus_key_mgmt) > 0 ? dbus_key_mgmt : NULL;
return TRUE;
}
/*
* nmu_create_dbus_error_message

View file

@ -100,6 +100,20 @@ dbus_bool_t nmu_security_deserialize_wpa_eap (DBusMessageIter *iter,
char **client_cert_file,
char **ca_cert_file,
int *wpa_version);
dbus_bool_t nmu_security_serialize_leap (DBusMessageIter *iter,
const char *username,
const char *passwd,
const char *key_mgmt);
dbus_bool_t nmu_security_serialize_leap_with_cipher (DBusMessageIter *iter,
const char *username,
const char *passwd,
const char *key_mgmt);
dbus_bool_t nmu_security_deserialize_leap (DBusMessageIter *iter,
char **username,
char **passwd,
char **key_mgmt);
DBusMessage * nmu_create_dbus_error_message (DBusMessage *message,
const char *exception_namespace,

View file

@ -62,6 +62,8 @@ NetworkManager_SOURCES = \
nm-ap-security-wpa-eap.h \
nm-ap-security-wpa-psk.c \
nm-ap-security-wpa-psk.h \
nm-ap-security-leap.c \
nm-ap-security-leap.h \
nm-marshal-main.c \
kernel-types.h \
wpa.c \

View file

@ -600,7 +600,10 @@ static guint32 add_capabilities_from_cipher (guint32 caps, int cipher)
caps |= NM_802_11_CAP_KEY_MGMT_802_1X;
caps &= ~NM_802_11_CAP_PROTO_NONE;
}
if (cipher == NM_AUTH_TYPE_LEAP)
{
caps &= ~NM_802_11_CAP_PROTO_NONE;
}
return caps;
}

216
src/nm-ap-security-leap.c Normal file
View file

@ -0,0 +1,216 @@
/* NetworkManager -- Network link manager
*
* 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 2006 Thiago Jung Bauermann <thiago.bauermann@gmail.com>
*/
/* This file is heavily based on nm-ap-security-wpa-eap.c */
#include <glib.h>
#include <glib/gi18n.h>
#include <dbus/dbus.h>
#include <iwlib.h>
#include "nm-ap-security.h"
#include "nm-ap-security-leap.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_LEAP_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_AP_SECURITY_LEAP, NMAPSecurityLEAPPrivate))
struct _NMAPSecurityLEAPPrivate
{
char * username;
char * key_mgmt;
};
NMAPSecurityLEAP *
nm_ap_security_leap_new_deserialize (DBusMessageIter *iter)
{
NMAPSecurityLEAP * security = NULL;
char * username = NULL;
char * password = NULL;
char * key_mgmt = NULL;
g_return_val_if_fail (iter != NULL, NULL);
if (!nmu_security_deserialize_leap (iter, &username, &password, &key_mgmt))
goto out;
/* Success, build up our security object */
security = g_object_new (NM_TYPE_AP_SECURITY_LEAP, NULL);
nm_ap_security_set_we_cipher (NM_AP_SECURITY (security), NM_AUTH_TYPE_LEAP);
if (password)
nm_ap_security_set_key (NM_AP_SECURITY (security), password, strlen(password));
if (username)
security->priv->username = g_strdup (username);
if (key_mgmt)
security->priv->key_mgmt = g_strdup (key_mgmt);
nm_ap_security_set_description (NM_AP_SECURITY (security), _("LEAP"));
out:
return security;
}
NMAPSecurityLEAP *
nm_ap_security_leap_new_from_ap (NMAccessPoint *ap)
{
NMAPSecurityLEAP * security = NULL;
g_return_val_if_fail (ap != NULL, NULL);
security = g_object_new (NM_TYPE_AP_SECURITY_LEAP, NULL);
nm_ap_security_set_we_cipher (NM_AP_SECURITY (security), NM_AUTH_TYPE_LEAP);
nm_ap_security_set_description (NM_AP_SECURITY (security), _("LEAP"));
return security;
}
static int
real_serialize (NMAPSecurity *instance, DBusMessageIter *iter)
{
NMAPSecurityLEAP * self = NM_AP_SECURITY_LEAP (instance);
if (!nmu_security_serialize_leap (iter, self->priv->username,
nm_ap_security_get_key(instance), self->priv->key_mgmt))
return -1;
return 0;
}
static gboolean
real_write_supplicant_config (NMAPSecurity *instance,
struct wpa_ctrl *ctrl,
int nwid,
gboolean user_created)
{
NMAPSecurityLEAP * self = NM_AP_SECURITY_LEAP (instance);
gboolean success = FALSE;
char * msg;
const char * password = nm_ap_security_get_key(instance);
g_return_val_if_fail (nm_ap_security_get_we_cipher (instance) == NM_AUTH_TYPE_LEAP, FALSE);
if (!nm_utils_supplicant_request_with_check (ctrl, "OK", __func__, NULL, "SET_NETWORK %i proto WPA", nwid))
goto out;
if (!nm_utils_supplicant_request_with_check (ctrl, "OK", __func__, NULL, "SET_NETWORK %i key_mgmt %s",
nwid, self->priv->key_mgmt))
goto out;
if (!nm_utils_supplicant_request_with_check (ctrl, "OK", __func__, NULL, "SET_NETWORK %i eap LEAP", nwid))
goto out;
if (self->priv->username && strlen (self->priv->username) > 0)
if (!nm_utils_supplicant_request_with_check (ctrl, "OK", __func__, NULL, "SET_NETWORK %i identity \"%s\"",
nwid, self->priv->username))
goto out;
if (password && strlen (password) > 0)
{
msg = g_strdup_printf ("SET_NETWORK %i password <password>", nwid);
if (!nm_utils_supplicant_request_with_check (ctrl, "OK", __func__, msg, "SET_NETWORK %i password \"%s\"",
nwid, password))
{
g_free (msg);
goto out;
}
g_free (msg);
}
success = TRUE;
out:
return success;
}
static guint32
real_get_default_capabilities (NMAPSecurity *instance)
{
guint32 caps = NM_802_11_CAP_NONE;
caps |= NM_802_11_CAP_KEY_MGMT_802_1X;
return caps;
}
static NMAPSecurity *
real_copy_constructor (NMAPSecurity *instance)
{
NMAPSecurityLEAP * dst = g_object_new (NM_TYPE_AP_SECURITY_LEAP, NULL);
NMAPSecurityLEAP * self = NM_AP_SECURITY_LEAP (instance);
dst->priv->username = self->priv->username;
dst->priv->key_mgmt = self->priv->key_mgmt;
nm_ap_security_copy_properties (NM_AP_SECURITY (self), NM_AP_SECURITY (dst));
return NM_AP_SECURITY (dst);
}
static void
nm_ap_security_leap_init (NMAPSecurityLEAP * self)
{
self->priv = NM_AP_SECURITY_LEAP_GET_PRIVATE (self);
self->priv->username = NULL;
self->priv->key_mgmt = NULL;
}
static void
nm_ap_security_leap_class_init (NMAPSecurityLEAPClass *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;
par_class->get_default_capabilities_func = real_get_default_capabilities;
g_type_class_add_private (object_class, sizeof (NMAPSecurityLEAPPrivate));
}
GType
nm_ap_security_leap_get_type (void)
{
static GType type = 0;
if (type == 0) {
static const GTypeInfo info = {
sizeof (NMAPSecurityLEAPClass),
NULL, /* base_init */
NULL, /* base_finalize */
(GClassInitFunc) nm_ap_security_leap_class_init,
NULL, /* class_finalize */
NULL, /* class_data */
sizeof (NMAPSecurityLEAP),
0, /* n_preallocs */
(GInstanceInitFunc) nm_ap_security_leap_init,
NULL /* value_table */
};
type = g_type_register_static (NM_TYPE_AP_SECURITY,
"NMAPSecurityLEAP",
&info, 0);
}
return type;
}

61
src/nm-ap-security-leap.h Normal file
View file

@ -0,0 +1,61 @@
/* NetworkManager -- Network link manager
*
* 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 2006 Thiago Jung Bauermann <thiago.bauermann@gmail.com>
*/
/* This file is heavily based on nm-ap-security-wpa-eap.h */
#ifndef NM_AP_SECURITY_LEAP_H
#define NM_AP_SECURITY_LEAP_H
#include <glib-object.h>
#include <dbus/dbus.h>
#include "nm-ap-security.h"
#define NM_TYPE_AP_SECURITY_LEAP (nm_ap_security_leap_get_type ())
#define NM_AP_SECURITY_LEAP(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_AP_SECURITY_LEAP, NMAPSecurityLEAP))
#define NM_AP_SECURITY_LEAP_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), NM_TYPE_AP_SECURITY_LEAP, NMAPSecurityLEAPClass))
#define NM_IS_AP_SECURITY_LEAP(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NM_TYPE_AP_SECURITY_LEAP))
#define NM_IS_AP_SECURITY_LEAP_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NM_TYPE_AP_SECURITY_LEAP))
#define NM_AP_SECURITY_LEAP_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_AP_SECURITY_LEAP, NMAPSecurityLEAPClass))
typedef struct _NMAPSecurityLEAP NMAPSecurityLEAP;
typedef struct _NMAPSecurityLEAPClass NMAPSecurityLEAPClass;
typedef struct _NMAPSecurityLEAPPrivate NMAPSecurityLEAPPrivate;
struct _NMAPSecurityLEAP
{
NMAPSecurity parent;
/*< private >*/
NMAPSecurityLEAPPrivate *priv;
};
struct _NMAPSecurityLEAPClass
{
NMAPSecurityClass parent;
};
GType nm_ap_security_leap_get_type (void);
NMAPSecurityLEAP * nm_ap_security_leap_new_deserialize (DBusMessageIter *iter);
struct NMAccessPoint;
NMAPSecurityLEAP * nm_ap_security_leap_new_from_ap (struct NMAccessPoint *ap);
#endif /* NM_AP_SECURITY_LEAP_H */

View file

@ -29,6 +29,7 @@
#include "nm-ap-security-wep.h"
#include "nm-ap-security-wpa-psk.h"
#include "nm-ap-security-wpa-eap.h"
#include "nm-ap-security-leap.h"
#include "nm-device-802-11-wireless.h"
#include "wpa_ctrl.h"
#include "nm-utils.h"
@ -96,6 +97,10 @@ nm_ap_security_new_deserialize (DBusMessageIter *iter)
security = NM_AP_SECURITY (nm_ap_security_wpa_eap_new_deserialize (iter));
break;
case NM_AUTH_TYPE_LEAP:
security = NM_AP_SECURITY (nm_ap_security_leap_new_deserialize (iter));
break;
default:
nm_warning ("Unmatched cipher %d", we_cipher);
break;
@ -115,6 +120,7 @@ out:
#define WPA_EAP (NM_802_11_CAP_PROTO_WPA | NM_802_11_CAP_KEY_MGMT_802_1X)
#define WEP_WEP104 (NM_802_11_CAP_PROTO_WEP | NM_802_11_CAP_CIPHER_WEP104)
#define WEP_WEP40 (NM_802_11_CAP_PROTO_WEP | NM_802_11_CAP_CIPHER_WEP40)
#define LEAP (NM_802_11_CAP_KEY_MGMT_802_1X)
NMAPSecurity *
nm_ap_security_new_from_ap (NMAccessPoint *ap)
{
@ -135,6 +141,8 @@ nm_ap_security_new_from_ap (NMAccessPoint *ap)
security = NM_AP_SECURITY (nm_ap_security_wep_new_from_ap (ap, IW_AUTH_CIPHER_WEP104));
else if ((caps & WEP_WEP40) == WEP_WEP40)
security = NM_AP_SECURITY (nm_ap_security_wep_new_from_ap (ap, IW_AUTH_CIPHER_WEP40));
else if ((caps & LEAP) == LEAP)
security = NM_AP_SECURITY (nm_ap_security_leap_new_from_ap (ap));
else if (!nm_ap_get_encrypted (ap))
security = nm_ap_security_new (IW_AUTH_CIPHER_NONE);
@ -181,7 +189,8 @@ nm_ap_security_set_we_cipher (NMAPSecurity *self, int we_cipher)
|| (we_cipher == IW_AUTH_CIPHER_WEP104)
|| (we_cipher == IW_AUTH_CIPHER_TKIP)
|| (we_cipher == IW_AUTH_CIPHER_CCMP)
|| (we_cipher == NM_AUTH_TYPE_WPA_EAP));
|| (we_cipher == NM_AUTH_TYPE_WPA_EAP)
|| (we_cipher == NM_AUTH_TYPE_LEAP));
self->priv->we_cipher = we_cipher;
}