2005-08-18 Dan Williams <dcbw@redhat.com>
* gnome/applet/applet-dbus-info.c - (nmi_dbus_create_error_message): new function - (nmi_dbus_get_key_for_network): correctly use dbus error creation functions. Also don't check for both device _and_ network before asking for a user's key, because we may not have gotten all our networks back from NM quite yet (due to the dbus pending calls coming in later). Fixes a hang in NM/nm-applet. * src/NetworkManagerDbus.c - (nm_dbus_get_user_key_for_network_cb): handle error conditions in a slightly more sane manner, even though we are still broken for certain other error conditions. - (nm_dbus_get_user_key_for_network): need to pass the network's essid to the info-daemon too * src/NetworkManagerDevice.c - Fix some debug messages to be info messages instead git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@875 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
This commit is contained in:
26
ChangeLog
26
ChangeLog
@@ -1,8 +1,28 @@
|
||||
2005-08-18 Dan Williams <dcbw@redhat.com>
|
||||
|
||||
* gnome/applet/main.c
|
||||
- Add new "--no-session" parameter that disables applet
|
||||
session management, ie for testing
|
||||
* gnome/applet/applet-dbus-info.c
|
||||
- (nmi_dbus_create_error_message): new function
|
||||
- (nmi_dbus_get_key_for_network): correctly use dbus error creation
|
||||
functions. Also don't check for both device _and_ network before
|
||||
asking for a user's key, because we may not have gotten all our
|
||||
networks back from NM quite yet (due to the dbus pending calls
|
||||
coming in later). Fixes a hang in NM/nm-applet.
|
||||
|
||||
* src/NetworkManagerDbus.c
|
||||
- (nm_dbus_get_user_key_for_network_cb): handle error conditions in a
|
||||
slightly more sane manner, even though we are still broken for
|
||||
certain other error conditions.
|
||||
- (nm_dbus_get_user_key_for_network): need to pass the network's essid
|
||||
to the info-daemon too
|
||||
|
||||
* src/NetworkManagerDevice.c
|
||||
- Fix some debug messages to be info messages instead
|
||||
|
||||
2005-08-18 Dan Williams <dcbw@redhat.com>
|
||||
|
||||
* gnome/applet/main.c
|
||||
- Add new "--no-session" parameter that disables applet
|
||||
session management, ie for testing
|
||||
|
||||
2005-08-18 Christopher Aillon <caillon@redhat.com>
|
||||
|
||||
|
@@ -39,9 +39,6 @@
|
||||
#include "nm-utils.h"
|
||||
|
||||
|
||||
static char *nmi_dbus_get_network_key (NMWirelessApplet *applet, WirelessNetwork *net);
|
||||
|
||||
|
||||
/*
|
||||
* nmi_network_type_valid
|
||||
*
|
||||
@@ -54,6 +51,65 @@ static inline gboolean nmi_network_type_valid (NMNetworkType type)
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* nmi_dbus_create_error_message
|
||||
*
|
||||
* Make a DBus error message
|
||||
*
|
||||
*/
|
||||
DBusMessage *nmi_dbus_create_error_message (DBusMessage *message, const char *exception_namespace,
|
||||
const char *exception, const char *format, ...)
|
||||
{
|
||||
char * exception_text;
|
||||
DBusMessage * reply_message;
|
||||
va_list args;
|
||||
char error_text[512];
|
||||
|
||||
va_start (args, format);
|
||||
vsnprintf (error_text, 512, format, args);
|
||||
va_end (args);
|
||||
|
||||
exception_text = g_strdup_printf ("%s.%s", exception_namespace, exception);
|
||||
reply_message = dbus_message_new_error (message, exception_text, error_text);
|
||||
g_free (exception_text);
|
||||
|
||||
return (reply_message);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* nmi_dbus_get_network_key
|
||||
*
|
||||
* Grab the network's key from the keyring.
|
||||
*
|
||||
*/
|
||||
static char *nmi_dbus_get_network_key (NMWirelessApplet *applet, const char *essid)
|
||||
{
|
||||
GnomeKeyringResult ret;
|
||||
GList * found_list = NULL;
|
||||
char * key = NULL;
|
||||
|
||||
g_return_val_if_fail (applet != NULL, NULL);
|
||||
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_key_for_network
|
||||
*
|
||||
@@ -62,36 +118,36 @@ static inline gboolean nmi_network_type_valid (NMNetworkType type)
|
||||
*/
|
||||
static DBusMessage * nmi_dbus_get_key_for_network (NMWirelessApplet *applet, DBusMessage *message)
|
||||
{
|
||||
char * dev_path = NULL;
|
||||
char * net_path = NULL;
|
||||
int attempt = 0;
|
||||
gboolean new_key = FALSE;
|
||||
gboolean success = FALSE;
|
||||
char * dev_path = NULL;
|
||||
char * net_path = NULL;
|
||||
char * essid = 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_STRING, &essid,
|
||||
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))
|
||||
&& (net = network_device_get_wireless_network_by_nm_path (dev, net_path)))
|
||||
if ((dev = nmwa_get_device_for_nm_path (applet->dbus_device_list, dev_path)))
|
||||
{
|
||||
WirelessNetwork *net = NULL;
|
||||
|
||||
/* 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)))
|
||||
if ((key = nmi_dbus_get_network_key (applet, essid)))
|
||||
{
|
||||
char * gconf_key;
|
||||
char * escaped_network;
|
||||
const char * essid = wireless_network_get_essid (net);
|
||||
GConfValue * value;
|
||||
NMEncKeyType key_type = -1;
|
||||
|
||||
@@ -114,14 +170,16 @@ static DBusMessage * nmi_dbus_get_key_for_network (NMWirelessApplet *applet, DBu
|
||||
new_key = TRUE;
|
||||
}
|
||||
|
||||
if (new_key)
|
||||
/* We only ask the user for a new key when we know about the network from NM,
|
||||
* since throwing up a dialog with a random essid from somewhere is a security issue.
|
||||
*/
|
||||
if (new_key && (net = network_device_get_wireless_network_by_nm_path (dev, net_path)))
|
||||
success = nmi_passphrase_dialog_schedule_show (dev, net, message, applet);
|
||||
}
|
||||
g_mutex_unlock (applet->data_mutex);
|
||||
}
|
||||
|
||||
if (!success)
|
||||
return dbus_message_new_error (message, "GetKeyError", "Could not get user key for network.");
|
||||
return nmi_dbus_create_error_message (message, NMI_DBUS_INTERFACE, "GetKeyError", "Could not get user key for network.");
|
||||
|
||||
return NULL;
|
||||
}
|
||||
@@ -318,43 +376,6 @@ 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
|
||||
*
|
||||
|
@@ -448,7 +448,15 @@ static void nm_dbus_get_user_key_for_network_cb (DBusPendingCall *pcall, NMActRe
|
||||
|
||||
if (dbus_message_get_type (reply) == DBUS_MESSAGE_TYPE_ERROR)
|
||||
{
|
||||
/* FIXME: stop activation for this device if the dialog couldn't show */
|
||||
/* FIXME: since we're not marking the device as invalid, its a fair bet
|
||||
* that NM will just try to reactivate the device again, and may fail
|
||||
* to get the user key in exactly the same way, which ends up right back
|
||||
* here... ad nauseum. Figure out how to deal with a failure here.
|
||||
*/
|
||||
if (nm_device_is_activating (dev))
|
||||
nm_device_activation_cancel (dev);
|
||||
nm_policy_schedule_device_change_check (data);
|
||||
|
||||
dbus_message_unref (reply);
|
||||
goto out;
|
||||
}
|
||||
@@ -481,6 +489,7 @@ void nm_dbus_get_user_key_for_network (DBusConnection *connection, NMActRequest
|
||||
gint32 attempt = 1;
|
||||
char * dev_path;
|
||||
char * net_path;
|
||||
char * essid;
|
||||
|
||||
g_return_if_fail (connection != NULL);
|
||||
g_return_if_fail (req != NULL);
|
||||
@@ -494,7 +503,8 @@ void nm_dbus_get_user_key_for_network (DBusConnection *connection, NMActRequest
|
||||
ap = nm_act_request_get_ap (req);
|
||||
g_assert (ap);
|
||||
|
||||
nm_info ("Activation (%s) New wireless user key requested for network '%s'.", nm_device_get_iface (dev), nm_ap_get_essid (ap));
|
||||
essid = nm_ap_get_essid (ap);
|
||||
nm_info ("Activation (%s) New wireless user key requested for network '%s'.", nm_device_get_iface (dev), essid);
|
||||
|
||||
if (!(message = dbus_message_new_method_call (NMI_DBUS_SERVICE, NMI_DBUS_PATH, NMI_DBUS_INTERFACE, "getKeyForNetwork")))
|
||||
{
|
||||
@@ -508,6 +518,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_STRING, &essid,
|
||||
DBUS_TYPE_INT32, &attempt,
|
||||
DBUS_TYPE_BOOLEAN, &new_key,
|
||||
DBUS_TYPE_INVALID);
|
||||
@@ -524,6 +535,11 @@ void nm_dbus_get_user_key_for_network (DBusConnection *connection, NMActRequest
|
||||
g_free (net_path);
|
||||
g_free (dev_path);
|
||||
|
||||
/* FIXME: figure out how to deal with a failure here, otherwise
|
||||
* we just hang in the activation process and nothing happens
|
||||
* until the user cancels stuff.
|
||||
*/
|
||||
|
||||
dbus_message_unref (message);
|
||||
}
|
||||
|
||||
|
@@ -3130,7 +3130,7 @@ void nm_device_activation_cancel (NMDevice *dev)
|
||||
NMActRequest * req = nm_device_get_act_request (dev);
|
||||
gboolean clear_act_request = FALSE;
|
||||
|
||||
nm_debug ("Activation (%s/wireless): cancelling...", nm_device_get_iface (dev));
|
||||
nm_info ("Activation (%s): cancelling...", nm_device_get_iface (dev));
|
||||
dev->quit_activation = TRUE;
|
||||
|
||||
/* If the device is waiting for DHCP or a user key, force its current request to stop. */
|
||||
@@ -3157,7 +3157,7 @@ void nm_device_activation_cancel (NMDevice *dev)
|
||||
*/
|
||||
args[0] = dev;
|
||||
nm_wait_for_completion (NM_COMPLETION_TRIES_INFINITY, G_USEC_PER_SEC / 20, nm_ac_test, NULL, args);
|
||||
nm_debug ("Activation (%s/wireless): cancelled.", nm_device_get_iface(dev));
|
||||
nm_info ("Activation (%s): cancelled.", nm_device_get_iface(dev));
|
||||
nm_schedule_state_change_signal_broadcast (dev->app_data);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user