2005-12-16 Dan Williams <dcbw@redhat.com>

* nm_device_set_enc_key -> nm_device_set_wep_enc_key

	* Fix up NM -> NMI get-user-key dbus calls in NM (applet
		bits still to be done)


git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@1202 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
This commit is contained in:
Dan Williams 2005-12-16 15:44:12 +00:00
parent b822a5cdc2
commit 9594bca7e6
6 changed files with 43 additions and 63 deletions

View file

@ -1,3 +1,10 @@
2005-12-16 Dan Williams <dcbw@redhat.com>
* nm_device_set_enc_key -> nm_device_set_wep_enc_key
* Fix up NM -> NMI get-user-key dbus calls in NM (applet
bits still to be done)
2005-12-16 Dan Williams <dcbw@redhat.com>
* Finally move info-daemon related stuff out of

View file

@ -1459,15 +1459,13 @@ void nm_device_get_ap_address (NMDevice *dev, struct ether_addr *addr)
/*
* nm_device_set_enc_key
* nm_device_set_wep_enc_key
*
* If a device is wireless, set the encryption key that it should use.
*
* key: encryption key to use, or NULL or "" to disable encryption.
* NOTE that at this time, the key must be the raw HEX key, not
* a passphrase.
*/
void nm_device_set_enc_key (NMDevice *dev, const char *key, int auth_method)
void nm_device_set_wep_enc_key (NMDevice *dev, const char *key, int auth_method)
{
NMSock * sk;
struct iwreq wreq;
@ -1542,12 +1540,12 @@ void nm_device_set_enc_key (NMDevice *dev, const char *key, int auth_method)
if (iw_set_ext (nm_dev_sock_get_fd (sk), nm_device_get_iface (dev), SIOCSIWENCODE, &wreq) == -1)
{
if (errno != ENODEV)
nm_warning ("nm_device_set_enc_key(): error setting key for device %s. errno = %d", nm_device_get_iface (dev), errno);
nm_warning ("nm_device_set_wep_enc_key(): error setting key for device %s. errno = %d", nm_device_get_iface (dev), errno);
}
}
nm_dev_sock_close (sk);
} else nm_warning ("nm_device_set_enc_key(): could not get wireless control socket.");
} else nm_warning ("nm_device_set_wep_enc_key(): could not get wireless control socket.");
}
@ -2868,7 +2866,7 @@ static gboolean nm_device_activate_stage4_ip_config_get (NMActRequest *req)
if (nm_device_is_802_11_wireless (dev))
{
nm_device_set_essid (dev, "");
nm_device_set_enc_key (dev, NULL, 0);
nm_device_set_wep_enc_key (dev, NULL, 0);
}
if (!nm_device_is_up (dev))
@ -3321,7 +3319,7 @@ gboolean nm_device_deactivate (NMDevice *dev)
if (nm_device_is_802_11_wireless (dev))
{
nm_device_set_essid (dev, "");
nm_device_set_enc_key (dev, NULL, 0);
nm_device_set_wep_enc_key (dev, NULL, 0);
nm_device_set_mode (dev, IW_MODE_INFRA);
nm_wireless_set_scan_interval (dev->app_data, dev, NM_WIRELESS_SCAN_INTERVAL_ACTIVE);
}
@ -3332,46 +3330,6 @@ gboolean nm_device_deactivate (NMDevice *dev)
}
/*
* nm_device_set_user_key_for_network
*
* Called upon receipt of a NetworkManagerInfo reply with a
* user-supplied key.
*
*/
void nm_device_set_user_key_for_network (NMActRequest *req, const char *key, const NMEncKeyType enc_type)
{
NMData * data;
NMDevice * dev;
NMAccessPoint * ap;
const char * cancel_message = "***canceled***";
g_return_if_fail (key != NULL);
data = nm_act_request_get_data (req);
g_assert (data);
dev = nm_act_request_get_dev (req);
g_assert (dev);
ap = nm_act_request_get_ap (req);
g_assert (ap);
/* If the user canceled, mark the ap as invalid */
if (strncmp (key, cancel_message, strlen (cancel_message)) == 0)
{
nm_ap_list_append_ap (data->invalid_ap_list, ap);
nm_device_deactivate (dev);
nm_policy_schedule_device_change_check (data);
}
else
{
/* nm_ap_set_security (ap, security) */
nm_device_activate_schedule_stage1_device_prepare (req);
}
}
/*
* nm_device_ap_list_add_ap
*

View file

@ -100,8 +100,7 @@ NMAccessPoint *nm_device_get_best_ap (NMDevice *dev);
void nm_device_set_wireless_scan_interval (NMDevice *dev, NMWirelessScanInterval interval);
/* There is no function to get the WEP key since that's a slight security risk */
void nm_device_set_enc_key (NMDevice *dev, const char *key, int auth_method);
void nm_device_set_wep_enc_key (NMDevice *dev, const char *key, int auth_method);
NMActRequest * nm_device_get_act_request (NMDevice *dev);
gboolean nm_device_activation_start (NMActRequest *req);
@ -115,8 +114,6 @@ gboolean nm_device_deactivate (NMDevice *dev);
NMAccessPoint *nm_device_wireless_get_activation_ap (NMDevice *dev, const char *essid, NMAPSecurity *security);
void nm_device_set_user_key_for_network (NMActRequest *req, const char *key, const NMEncKeyType enc_type);
void nm_device_bring_up (NMDevice *dev);
void nm_device_bring_down (NMDevice *dev);
gboolean nm_device_is_up (NMDevice *dev);

View file

@ -92,7 +92,7 @@ real_device_setup (NMAPSecurity *instance, NMDevice * dev)
{
NMAPSecurityWEP * self = NM_AP_SECURITY_WEP (instance);
nm_device_set_enc_key (dev, nm_ap_security_get_key (instance),
nm_device_set_wep_enc_key (dev, nm_ap_security_get_key (instance),
self->priv->auth_algorithm);
return 0;
}

View file

@ -163,7 +163,7 @@ static int
real_device_setup (NMAPSecurity *self, NMDevice * dev)
{
/* unencrypted */
nm_device_set_enc_key (dev, NULL, 0);
nm_device_set_wep_enc_key (dev, NULL, 0);
return 0;
}

View file

@ -37,12 +37,12 @@
*/
static void nm_dbus_get_user_key_for_network_cb (DBusPendingCall *pcall, NMActRequest *req)
{
DBusMessage * reply;
DBusMessage * reply = NULL;
NMData * data;
NMDevice * dev;
NMAccessPoint * ap;
char * passphrase = NULL;
NMEncKeyType key_type = -1;
NMAPSecurity * security;
DBusMessageIter iter;
g_return_if_fail (pcall != NULL);
g_return_if_fail (req != NULL);
@ -66,25 +66,43 @@ static void nm_dbus_get_user_key_for_network_cb (DBusPendingCall *pcall, NMActRe
if (!(reply = dbus_pending_call_steal_reply (pcall)))
goto out;
if (dbus_message_get_type (reply) == DBUS_MESSAGE_TYPE_ERROR)
if (message_is_error (reply))
{
DBusError err;
dbus_error_init (&err);
dbus_set_error_from_message (&err, reply);
/* Check for cancelled error */
if (strcmp (err.name, "CanceledError") != 0)
nm_warning ("nm_dbus_get_user_key_for_network_cb(): dbus returned an error.\n (%s) %s\n", err.name, err.message);
dbus_error_free (&err);
dbus_message_unref (reply);
/* 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.
*/
nm_ap_list_append_ap (data->invalid_ap_list, ap);
nm_device_deactivate (dev);
nm_policy_schedule_device_change_check (data);
goto out;
}
else
dbus_message_iter_init (reply, &iter);
if ((security = nm_ap_security_new_deserialize (&iter)))
{
if (dbus_message_get_args (reply, NULL, DBUS_TYPE_STRING, &passphrase, DBUS_TYPE_INT32, &key_type, DBUS_TYPE_INVALID))
nm_device_set_user_key_for_network (req, passphrase, key_type);
nm_act_request_set_user_key_pending_call (req, NULL);
nm_ap_set_security (ap, security);
nm_device_activation_start (req);
}
dbus_message_unref (reply);
nm_act_request_set_user_key_pending_call (req, NULL);
out:
if (reply)
dbus_message_unref (reply);
nm_act_request_unref (req);
dbus_pending_call_unref (pcall);
}