mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-01-06 16:40:16 +01:00
2005-08-17 Dan Williams <dcbw@redhat.com>
* gnome/applet/applet-dbus-info.c - (nmi_dbus_get_key_for_network): Grab new "new_key" parameter from the dbus message, which tells us to unconditionally ask the user for a new key. Otherwise, we pull the key from the keyring and return it. If we fail to get the key from the keyring, we ask the user for a new key. - (nmi_dbus_get_network_key): new function to grab the key for an essid from the keyring. - (nmi_dbus_get_network_properties): don't access the keyring here. Also, don't return any key in the dbus message. * src/NetworkManagerDbus.[ch] - (nm_dbus_get_user_key_for_network): Add "new_key" parameter to indicate that we unconditionally want a new key. This function is now also used to get keys from the info-daemon which are pre-stored, not just for asking the user for a new key. The "new_key" parameter indicates whether or not we wish to ask the user for a new key. - (nm_dbus_get_network_data_cb): we no longer get a key from the info-daemon in the return message, so use NULL instead. The key will be filled in at connect time by calling nm_dbus_get_user_key_for_network() * src/NetworkManagerDevice.c - (nm_device_wireless_configure): update for "new_key" param to nm_dbus_get_user_key_for_network(). We initially set new_key to FALSE to see if we have a stored key in the info-daemon, but if the connection is unsuccessful at this stage we request a new one git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@862 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
This commit is contained in:
parent
fa90b0567b
commit
7e7b8f001a
5 changed files with 124 additions and 40 deletions
32
ChangeLog
32
ChangeLog
|
|
@ -1,3 +1,35 @@
|
|||
2005-08-17 Dan Williams <dcbw@redhat.com>
|
||||
|
||||
* gnome/applet/applet-dbus-info.c
|
||||
- (nmi_dbus_get_key_for_network): Grab new "new_key" parameter
|
||||
from the dbus message, which tells us to unconditionally
|
||||
ask the user for a new key. Otherwise, we pull the key from
|
||||
the keyring and return it. If we fail to get the key from the
|
||||
keyring, we ask the user for a new key.
|
||||
- (nmi_dbus_get_network_key): new function to grab the key for
|
||||
an essid from the keyring.
|
||||
- (nmi_dbus_get_network_properties): don't access the keyring here.
|
||||
Also, don't return any key in the dbus message.
|
||||
|
||||
* src/NetworkManagerDbus.[ch]
|
||||
- (nm_dbus_get_user_key_for_network): Add "new_key" parameter to
|
||||
indicate that we unconditionally want a new key. This function
|
||||
is now also used to get keys from the info-daemon which are
|
||||
pre-stored, not just for asking the user for a new key. The
|
||||
"new_key" parameter indicates whether or not we wish to ask the
|
||||
user for a new key.
|
||||
- (nm_dbus_get_network_data_cb): we no longer get a key from the
|
||||
info-daemon in the return message, so use NULL instead. The
|
||||
key will be filled in at connect time by calling
|
||||
nm_dbus_get_user_key_for_network()
|
||||
|
||||
* src/NetworkManagerDevice.c
|
||||
- (nm_device_wireless_configure): update for "new_key" param to
|
||||
nm_dbus_get_user_key_for_network(). We initially set new_key
|
||||
to FALSE to see if we have a stored key in the info-daemon, but
|
||||
if the connection is unsuccessful at this stage we request a
|
||||
new one
|
||||
|
||||
2005-08-17 Dan Williams <dcbw@redhat.com>
|
||||
|
||||
* gnome/applet/icons/nm-no-connection.png
|
||||
|
|
|
|||
|
|
@ -39,6 +39,9 @@
|
|||
#include "nm-utils.h"
|
||||
|
||||
|
||||
static char *nmi_dbus_get_network_key (NMWirelessApplet *applet, WirelessNetwork *net);
|
||||
|
||||
|
||||
/*
|
||||
* nmi_network_type_valid
|
||||
*
|
||||
|
|
@ -62,21 +65,56 @@ static DBusMessage * nmi_dbus_get_key_for_network (NMWirelessApplet *applet, DBu
|
|||
char * dev_path = NULL;
|
||||
char * net_path = NULL;
|
||||
int attempt = 0;
|
||||
gboolean new_key = FALSE;
|
||||
gboolean success = FALSE;
|
||||
|
||||
if (dbus_message_get_args (message, NULL,
|
||||
DBUS_TYPE_OBJECT_PATH, &dev_path,
|
||||
DBUS_TYPE_OBJECT_PATH, &net_path,
|
||||
DBUS_TYPE_INT32, &attempt,
|
||||
DBUS_TYPE_BOOLEAN, &new_key,
|
||||
DBUS_TYPE_INVALID))
|
||||
{
|
||||
NetworkDevice *dev = NULL;
|
||||
WirelessNetwork *net = NULL;
|
||||
|
||||
g_mutex_lock (applet->data_mutex);
|
||||
if ((dev = nmwa_get_device_for_nm_path (applet->gui_device_list, dev_path)))
|
||||
if ((dev = nmwa_get_device_for_nm_path (applet->gui_device_list, dev_path))
|
||||
&& (net = network_device_get_wireless_network_by_nm_path (dev, net_path)))
|
||||
{
|
||||
if ((net = network_device_get_wireless_network_by_nm_path (dev, net_path)))
|
||||
/* Try to get the key from the keyring. If we fail, ask for a new key. */
|
||||
if (!new_key)
|
||||
{
|
||||
char *key;
|
||||
|
||||
if ((key = nmi_dbus_get_network_key (applet, net)))
|
||||
{
|
||||
char * gconf_key;
|
||||
char * escaped_network;
|
||||
const char * essid = wireless_network_get_essid (net);
|
||||
GConfValue * value;
|
||||
NMEncKeyType key_type = -1;
|
||||
|
||||
/* Grab key type from GConf since we need it for return message */
|
||||
escaped_network = gconf_escape_key (essid, strlen (essid));
|
||||
gconf_key = g_strdup_printf ("%s/%s/key_type", GCONF_PATH_WIRELESS_NETWORKS, escaped_network);
|
||||
g_free (escaped_network);
|
||||
if ((value = gconf_client_get (applet->gconf_client, gconf_key, NULL)))
|
||||
{
|
||||
key_type = gconf_value_get_int (value);
|
||||
gconf_value_free (value);
|
||||
}
|
||||
g_free (gconf_key);
|
||||
|
||||
nmi_dbus_return_user_key (applet->connection, message, key, key_type);
|
||||
g_free (key);
|
||||
success = TRUE;
|
||||
}
|
||||
else
|
||||
new_key = TRUE;
|
||||
}
|
||||
|
||||
if (new_key)
|
||||
success = nmi_passphrase_dialog_schedule_show (dev, net, message, applet);
|
||||
}
|
||||
g_mutex_unlock (applet->data_mutex);
|
||||
|
|
@ -280,6 +318,43 @@ static DBusMessage *nmi_dbus_get_networks (NMWirelessApplet *applet, DBusMessage
|
|||
}
|
||||
|
||||
|
||||
/*
|
||||
* nmi_dbus_get_network_key
|
||||
*
|
||||
* Grab the network's key from the keyring.
|
||||
*
|
||||
*/
|
||||
static char *nmi_dbus_get_network_key (NMWirelessApplet *applet, WirelessNetwork *net)
|
||||
{
|
||||
GnomeKeyringResult ret;
|
||||
GList * found_list = NULL;
|
||||
char * key = NULL;
|
||||
const char * essid;
|
||||
|
||||
g_return_val_if_fail (applet != NULL, NULL);
|
||||
g_return_val_if_fail (net != NULL, NULL);
|
||||
|
||||
essid = wireless_network_get_essid (net);
|
||||
g_return_val_if_fail (essid != NULL, NULL);
|
||||
|
||||
/* Get the essid key, if any, from the keyring */
|
||||
ret = gnome_keyring_find_itemsv_sync (GNOME_KEYRING_ITEM_GENERIC_SECRET,
|
||||
&found_list,
|
||||
"essid",
|
||||
GNOME_KEYRING_ATTRIBUTE_TYPE_STRING,
|
||||
essid,
|
||||
NULL);
|
||||
if (ret == GNOME_KEYRING_RESULT_OK)
|
||||
{
|
||||
GnomeKeyringFound *found = found_list->data;
|
||||
key = g_strdup (found->secret);
|
||||
gnome_keyring_found_list_free (found_list);
|
||||
}
|
||||
|
||||
return key;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* nmi_dbus_get_network_properties
|
||||
*
|
||||
|
|
@ -299,11 +374,8 @@ static DBusMessage *nmi_dbus_get_network_properties (NMWirelessApplet *applet, D
|
|||
char *essid = NULL;
|
||||
gint timestamp = -1;
|
||||
gint32 i;
|
||||
char *key = NULL;
|
||||
NMEncKeyType key_type = -1;
|
||||
gboolean trusted = FALSE;
|
||||
GList *found_list = NULL;
|
||||
GnomeKeyringResult ret;
|
||||
NMDeviceAuthMethod auth_method = NM_DEVICE_AUTH_METHOD_UNKNOWN;
|
||||
|
||||
g_return_val_if_fail (applet != NULL, NULL);
|
||||
|
|
@ -339,22 +411,6 @@ static DBusMessage *nmi_dbus_get_network_properties (NMWirelessApplet *applet, D
|
|||
}
|
||||
g_free (gconf_key);
|
||||
|
||||
/* Get the essid key, if any, from the keyring */
|
||||
ret = gnome_keyring_find_itemsv_sync (GNOME_KEYRING_ITEM_GENERIC_SECRET,
|
||||
&found_list,
|
||||
"essid",
|
||||
GNOME_KEYRING_ATTRIBUTE_TYPE_STRING,
|
||||
essid,
|
||||
NULL);
|
||||
if (ret == GNOME_KEYRING_RESULT_OK)
|
||||
{
|
||||
GnomeKeyringFound *found = found_list->data;
|
||||
key = g_strdup (found->secret);
|
||||
gnome_keyring_found_list_free (found_list);
|
||||
}
|
||||
else
|
||||
key = g_strdup ("");
|
||||
|
||||
gconf_key = g_strdup_printf ("%s/%s/key_type", GCONF_PATH_WIRELESS_NETWORKS, escaped_network);
|
||||
if ((value = gconf_client_get (applet->gconf_client, gconf_key, NULL)))
|
||||
{
|
||||
|
|
@ -417,7 +473,6 @@ static DBusMessage *nmi_dbus_get_network_properties (NMWirelessApplet *applet, D
|
|||
dbus_message_iter_append_basic (&iter, DBUS_TYPE_STRING, &essid);
|
||||
i = (gint32) timestamp;
|
||||
dbus_message_iter_append_basic (&iter, DBUS_TYPE_INT32, &i);
|
||||
dbus_message_iter_append_basic (&iter, DBUS_TYPE_STRING, &key);
|
||||
i = (gint32) key_type;
|
||||
dbus_message_iter_append_basic (&iter, DBUS_TYPE_INT32, &i);
|
||||
i = (gint32) auth_method;
|
||||
|
|
@ -449,10 +504,9 @@ static DBusMessage *nmi_dbus_get_network_properties (NMWirelessApplet *applet, D
|
|||
gconf_value_free (ap_addrs_value);
|
||||
|
||||
g_free (essid);
|
||||
g_free (key);
|
||||
|
||||
g_free (escaped_network);
|
||||
return (reply);
|
||||
|
||||
return reply;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -468,10 +468,10 @@ out:
|
|||
/*
|
||||
* nm_dbus_get_user_key_for_network
|
||||
*
|
||||
* Asks NetworkManagerInfo for a user-entered WEP key.
|
||||
* Asks the info-daemon for a user-entered WEP key.
|
||||
*
|
||||
*/
|
||||
void nm_dbus_get_user_key_for_network (DBusConnection *connection, NMActRequest *req)
|
||||
void nm_dbus_get_user_key_for_network (DBusConnection *connection, NMActRequest *req, const gboolean new_key)
|
||||
{
|
||||
DBusMessage * message;
|
||||
DBusPendingCall * pcall;
|
||||
|
|
@ -509,6 +509,7 @@ void nm_dbus_get_user_key_for_network (DBusConnection *connection, NMActRequest
|
|||
dbus_message_append_args (message, DBUS_TYPE_OBJECT_PATH, &dev_path,
|
||||
DBUS_TYPE_OBJECT_PATH, &net_path,
|
||||
DBUS_TYPE_INT32, &attempt,
|
||||
DBUS_TYPE_BOOLEAN, &new_key,
|
||||
DBUS_TYPE_INVALID);
|
||||
if (dbus_connection_send_with_reply (connection, message, &pcall, INT_MAX) && pcall)
|
||||
{
|
||||
|
|
@ -631,7 +632,7 @@ void nm_dbus_update_wireless_scan_method (DBusConnection *connection, NMData *da
|
|||
* Tell NetworkManagerInfo the updated info of the AP
|
||||
*
|
||||
*/
|
||||
gboolean nm_dbus_update_network_info (DBusConnection *connection, NMAccessPoint *ap, gboolean user_requested)
|
||||
gboolean nm_dbus_update_network_info (DBusConnection *connection, NMAccessPoint *ap, const gboolean user_requested)
|
||||
{
|
||||
DBusMessage * message;
|
||||
gboolean success = FALSE;
|
||||
|
|
@ -802,7 +803,6 @@ static void nm_dbus_get_network_data_cb (DBusPendingCall *pcall, void *user_data
|
|||
dbus_error_init (&error);
|
||||
if (dbus_message_get_args (reply, &error, DBUS_TYPE_STRING, &essid,
|
||||
DBUS_TYPE_INT32, ×tamp_secs,
|
||||
DBUS_TYPE_STRING, &key,
|
||||
DBUS_TYPE_INT32, &key_type,
|
||||
DBUS_TYPE_INT32, &auth_method,
|
||||
DBUS_TYPE_BOOLEAN, &trusted,
|
||||
|
|
@ -826,13 +826,11 @@ static void nm_dbus_get_network_data_cb (DBusPendingCall *pcall, void *user_data
|
|||
g_free (timestamp);
|
||||
|
||||
nm_ap_set_trusted (ap, trusted);
|
||||
|
||||
if (key && strlen (key))
|
||||
nm_ap_set_enc_key_source (ap, key, key_type);
|
||||
else
|
||||
nm_ap_set_enc_key_source (ap, NULL, NM_ENC_TYPE_UNKNOWN);
|
||||
nm_ap_set_auth_method (ap, auth_method);
|
||||
|
||||
/* We get the actual key when we try to connect, use NULL for now. */
|
||||
nm_ap_set_enc_key_source (ap, NULL, key_type);
|
||||
|
||||
for (i = 0; i < num_addresses; i++)
|
||||
if (strlen (addresses[i]) >= 11)
|
||||
addr_list = g_slist_append (addr_list, g_strdup (addresses[i]));
|
||||
|
|
|
|||
|
|
@ -66,7 +66,7 @@ void nm_dbus_signal_state_change (DBusConnection *connection, NMData *data);
|
|||
|
||||
void nm_dbus_signal_wireless_network_change (DBusConnection *connection, NMDevice *dev, NMAccessPoint *ap, NMNetworkStatus status, gint8 strength);
|
||||
|
||||
void nm_dbus_get_user_key_for_network (DBusConnection *connection, NMActRequest *req);
|
||||
void nm_dbus_get_user_key_for_network (DBusConnection *connection, NMActRequest *req, const gboolean new_key);
|
||||
|
||||
void nm_dbus_cancel_get_user_key_for_network (DBusConnection *connection, NMActRequest *req);
|
||||
|
||||
|
|
@ -76,7 +76,7 @@ NMAccessPoint *nm_dbus_get_network_object (DBusConnection *connection, NMNetwo
|
|||
|
||||
gboolean nm_dbus_add_network_address (DBusConnection *connection, NMNetworkType type, const char *network, struct ether_addr *addr);
|
||||
|
||||
gboolean nm_dbus_update_network_info (DBusConnection *connection, NMAccessPoint *ap, gboolean user_requested);
|
||||
gboolean nm_dbus_update_network_info (DBusConnection *connection, NMAccessPoint *ap, const gboolean user_requested);
|
||||
|
||||
void nm_dbus_update_allowed_networks (DBusConnection *connection, NMAccessPointList *list, NMData *data);
|
||||
|
||||
|
|
|
|||
|
|
@ -2313,7 +2313,7 @@ static gboolean nm_dwwfl_test (int tries, nm_completion_args args)
|
|||
}
|
||||
|
||||
/* If we're told to cancel, return that we're finished.
|
||||
* If we've the frequency has been stable for more than the required
|
||||
* If the card's frequency has been stable for more than the required
|
||||
* interval, return that we're finished.
|
||||
* Otherwise, we're not finished. */
|
||||
if (nm_device_activation_should_cancel (dev) || (*assoc_count >= required))
|
||||
|
|
@ -2441,7 +2441,7 @@ static void nm_device_wireless_configure (NMActRequest *req)
|
|||
|
||||
if (ap_need_key (dev, ap))
|
||||
{
|
||||
nm_dbus_get_user_key_for_network (data->dbus_connection, req);
|
||||
nm_dbus_get_user_key_for_network (data->dbus_connection, req, FALSE);
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -2475,7 +2475,7 @@ static void nm_device_wireless_configure (NMActRequest *req)
|
|||
/* Didn't work in Shared Key either. */
|
||||
nm_debug ("Activation (%s/wireless): no hardware link to '%s' in Shared Key mode, need correct key?",
|
||||
nm_device_get_iface (dev), nm_ap_get_essid (ap) ? nm_ap_get_essid (ap) : "(none)");
|
||||
nm_dbus_get_user_key_for_network (data->dbus_connection, req);
|
||||
nm_dbus_get_user_key_for_network (data->dbus_connection, req, TRUE);
|
||||
break;
|
||||
}
|
||||
else
|
||||
|
|
@ -2873,7 +2873,7 @@ static gboolean nm_device_activate_stage4_ip_config_timeout (NMActRequest *req)
|
|||
/* Shared Key mode failed, we must have bad WEP key */
|
||||
nm_debug ("Activation (%s/wireless): could not get IP configuration info for '%s' in Shared Key mode, asking for new key.",
|
||||
nm_device_get_iface (dev), nm_ap_get_essid (ap) ? nm_ap_get_essid (ap) : "(none)");
|
||||
nm_dbus_get_user_key_for_network (data->dbus_connection, req);
|
||||
nm_dbus_get_user_key_for_network (data->dbus_connection, req, TRUE);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue