diff --git a/ChangeLog b/ChangeLog index 09e4f0516..35d831b48 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,39 @@ +2004-10-08 Dan Williams + + * info-daemon/NetworkManagerInfo.[ch] + info-dameon/NetworkManagerInfoDbus.[ch] + info-daemon/NetworkManagerInfoPassphraseDialog.[ch] + - Preserve original label text in the passphrase dialog so that + it actually gets updated with the new network name the next + time around. Previously, we were overwriting it so you'd get + the wrong network name to enter a key for + - Add a "Key Type" combo to the passphrase dialog, user selects + encryption key type now, type is stored in GConf too + - Adjust NM<->NMI DBUS protocol to pass the key type back to NM too + + * src/NetworkManagerAP.[ch] + - Remove all the encyption method magic. It's now set by the user + and NetworkManager retrieves the type of encryption key from + NetworkManagerInfo + + * src/NetworkManagerAPList.[ch] + src/NetworkManagerDbus.[ch] + - Adjust to new way of setting encryption key and method + - Pull encryption method down from NMI along with key + + * src/NetworkManagerDevice.[ch] + - Removed encryption method fallback magic as the method is now + determined by the user. This greatly simplifies the connection + logic. + - More robust connection/link logic. Besides removing the encryption + method fallback magic, check whether or not the card is receiving + invalidly encrypted packets, which usually indicates that we have + a bad WEP key set. + - Don't blindly forge ahead when DHCP fails (still not completely fixed) + + * test/nminfotest.c + - Test out new "Key Type" stuff in the NMI passphrase dialog + 2004-10-07 Dan Williams * info-daemon/NetworkManagerInfo.conf diff --git a/info-daemon/NetworkManagerInfo.h b/info-daemon/NetworkManagerInfo.h index 72a55f6bb..a171945c5 100644 --- a/info-daemon/NetworkManagerInfo.h +++ b/info-daemon/NetworkManagerInfo.h @@ -35,6 +35,7 @@ struct NMIAppInfo { GladeXML *passphrase_dialog; + char *orig_label_text; DBusConnection *connection; GConfClient *gconf_client; @@ -46,8 +47,7 @@ struct NMIAppInfo /* GtkWidget *notification_icon; */ - GPid notification_icon_pid; - + GPid notification_icon_pid; }; typedef struct NMIAppInfo NMIAppInfo; diff --git a/info-daemon/NetworkManagerInfoDbus.c b/info-daemon/NetworkManagerInfoDbus.c index 1f8457bb7..8965903bf 100644 --- a/info-daemon/NetworkManagerInfoDbus.c +++ b/info-daemon/NetworkManagerInfoDbus.c @@ -114,7 +114,7 @@ static void nmi_dbus_get_key_for_network (NMIAppInfo *info, DBusMessage *message * */ void nmi_dbus_return_user_key (DBusConnection *connection, const char *device, - const char *network, const char *passphrase) + const char *network, const char *passphrase, const char *key_type_string) { DBusMessage *message; @@ -133,6 +133,7 @@ void nmi_dbus_return_user_key (DBusConnection *connection, const char *device, if (dbus_message_append_args (message, DBUS_TYPE_STRING, device, DBUS_TYPE_STRING, network, DBUS_TYPE_STRING, passphrase, + DBUS_TYPE_STRING, key_type_string, DBUS_TYPE_INVALID)) { if (!dbus_connection_send (connection, message, NULL)) @@ -371,7 +372,7 @@ static DBusMessage *nmi_dbus_get_network_essid (NMIAppInfo *info, DBusMessage *m /* * nmi_dbus_get_network_key * - * If the specified network exists, get its key from gconf + * If the specified network exists, get its key and key type from gconf * and pass it back as a dbus message. * */ @@ -380,7 +381,8 @@ static DBusMessage *nmi_dbus_get_network_key (NMIAppInfo *info, DBusMessage *mes DBusMessage *reply_message = NULL; gchar *key = NULL; char *network = NULL; - GConfValue *value; + GConfValue *key_value; + GConfValue *key_type_value; DBusError error; NMINetworkType type; char *escaped_network; @@ -401,19 +403,28 @@ static DBusMessage *nmi_dbus_get_network_key (NMIAppInfo *info, DBusMessage *mes /* Grab user-key key for our access point from GConf */ escaped_network = gnome_vfs_escape_string (network); key = g_strdup_printf ("%s/%s/key", NMI_GCONF_WIRELESS_NETWORKS_PATH, escaped_network); - g_free (escaped_network); - value = gconf_client_get (info->gconf_client, key, NULL); + key_value = gconf_client_get (info->gconf_client, key, NULL); g_free (key); + key = g_strdup_printf ("%s/%s/key_type", NMI_GCONF_WIRELESS_NETWORKS_PATH, escaped_network); + key_type_value = gconf_client_get (info->gconf_client, key, NULL); + g_free (key); + g_free (escaped_network); + /* We don't error out if no key was found in gconf, we return blank key */ reply_message = dbus_message_new_method_return (message); - if (value) + if (key_value && key_type_value) { - dbus_message_append_args (reply_message, DBUS_TYPE_STRING, gconf_value_get_string (value), DBUS_TYPE_INVALID); - gconf_value_free (value); + dbus_message_append_args (reply_message, DBUS_TYPE_STRING, gconf_value_get_string (key_value), + DBUS_TYPE_STRING, gconf_value_get_string (key_type_value), DBUS_TYPE_INVALID); } else - dbus_message_append_args (reply_message, DBUS_TYPE_STRING, "", DBUS_TYPE_INVALID); + dbus_message_append_args (reply_message, DBUS_TYPE_STRING, "", DBUS_TYPE_STRING, "", DBUS_TYPE_INVALID); + + if (key_value) + gconf_value_free (key_value); + if (key_type_value) + gconf_value_free (key_type_value); return (reply_message); } diff --git a/info-daemon/NetworkManagerInfoDbus.h b/info-daemon/NetworkManagerInfoDbus.h index 3c0206a29..d10eba060 100644 --- a/info-daemon/NetworkManagerInfoDbus.h +++ b/info-daemon/NetworkManagerInfoDbus.h @@ -45,7 +45,7 @@ const char * nmi_dbus_nm_get_network_essid (DBusConnection *connection, const gboolean nmi_dbus_nm_get_network_encrypted (DBusConnection *connection, const char *ap_path); void nmi_dbus_return_user_key (DBusConnection *connection, const char *device, - const char *network, const char *passphrase); + const char *network, const char *passphrase, const char *key_type_string); void nmi_dbus_signal_update_network (DBusConnection *connection, const char *network, NMINetworkType type); diff --git a/info-daemon/NetworkManagerInfoPassphraseDialog.c b/info-daemon/NetworkManagerInfoPassphraseDialog.c index 1ee349546..9a5449bcf 100644 --- a/info-daemon/NetworkManagerInfoPassphraseDialog.c +++ b/info-daemon/NetworkManagerInfoPassphraseDialog.c @@ -20,6 +20,8 @@ * (C) Copyright 2004 Red Hat, Inc. */ +#include +#include #include #include #include @@ -27,10 +29,22 @@ #include #include #include +#include + +#ifndef _ +#define _(x) dgettext (GETTEXT_PACKAGE, x) +#define N_(x) x +#endif #include "NetworkManagerInfoDbus.h" #include "NetworkManagerInfoPassphraseDialog.h" +enum NMIPassphraseDialogKeyTypes +{ + KEY_TYPE_128_BIT_PASSPHRASE = 0, + KEY_TYPE_128_BIT_RAW_HEX_KEY = 1 +}; + /* * nmi_passphrase_dialog_clear @@ -65,6 +79,36 @@ void nmi_passphrase_dialog_clear (GtkWidget *dialog, GtkWidget *entry) } +/* + * nmi_passphrase_dialog_key_type_combo_changed + * + * Change the text of the passphrase entry label to match the selected + * key type. + * + */ +void nmi_passphrase_dialog_key_type_combo_changed (GtkWidget *key_type_combo, gpointer user_data) +{ + GtkLabel *entry_label; + int combo_choice; + NMIAppInfo *info = (NMIAppInfo *)user_data; + + g_return_if_fail (info != NULL); + + entry_label = GTK_LABEL (glade_xml_get_widget (info->passphrase_dialog, "passphrase_entry_label")); + switch ((combo_choice = gtk_combo_box_get_active (GTK_COMBO_BOX (key_type_combo)))) + { + case KEY_TYPE_128_BIT_PASSPHRASE: + gtk_label_set_label (entry_label, _("Passphrase:")); + break; + case KEY_TYPE_128_BIT_RAW_HEX_KEY: + gtk_label_set_label (entry_label, _("Key:")); + break; + default: + break; + } +} + + /* * nmi_passphrase_dialog_ok_clicked * @@ -81,32 +125,54 @@ void nmi_passphrase_dialog_ok_clicked (GtkWidget *ok_button, gpointer user_data) if (GTK_WIDGET_TOPLEVEL (dialog)) { - GtkWidget *entry = glade_xml_get_widget (info->passphrase_dialog, "passphrase_entry"); - const char *passphrase = gtk_entry_get_text (GTK_ENTRY (entry)); + GtkEntry *entry = GTK_ENTRY (glade_xml_get_widget (info->passphrase_dialog, "passphrase_entry")); + GtkComboBox *key_type_combo = GTK_COMBO_BOX (glade_xml_get_widget (info->passphrase_dialog, "key_type_combo")); + int key_type = gtk_combo_box_get_active (key_type_combo); + const char *passphrase = gtk_entry_get_text (entry); const char *device = g_object_get_data (G_OBJECT (dialog), "device"); const char *network = g_object_get_data (G_OBJECT (dialog), "network"); - gchar *key = NULL; + char *key = NULL; + char *key_type_string = NULL; GConfEntry *gconf_entry; + char *escaped_network; + + switch (key_type) + { + case KEY_TYPE_128_BIT_PASSPHRASE: + key_type_string = "128-bit-passphrase"; + break; + case KEY_TYPE_128_BIT_RAW_HEX_KEY: + key_type_string = "128-bit-raw-hex-key"; + break; + default: + key_type_string = ""; + break; + } /* Tell NetworkManager about the key the user typed in */ - nmi_dbus_return_user_key (info->connection, device, network, passphrase); + nmi_dbus_return_user_key (info->connection, device, network, passphrase, key_type_string); /* Update GConf with the new user key */ - key = g_strdup_printf ("%s/%s", NMI_GCONF_WIRELESS_NETWORKS_PATH, network); + escaped_network = gnome_vfs_escape_string (network); + key = g_strdup_printf ("%s/%s", NMI_GCONF_WIRELESS_NETWORKS_PATH, escaped_network); gconf_entry = gconf_client_get_entry (info->gconf_client, key, NULL, TRUE, NULL); g_free (key); if (gconf_entry) { gconf_entry_unref (gconf_entry); - key = g_strdup_printf ("%s/%s/key", NMI_GCONF_WIRELESS_NETWORKS_PATH, network); + key = g_strdup_printf ("%s/%s/key", NMI_GCONF_WIRELESS_NETWORKS_PATH, escaped_network); gconf_client_set_string (info->gconf_client, key, passphrase, NULL); g_free (key); - key = g_strdup_printf ("%s/%s/essid", NMI_GCONF_WIRELESS_NETWORKS_PATH, network); + key = g_strdup_printf ("%s/%s/essid", NMI_GCONF_WIRELESS_NETWORKS_PATH, escaped_network); gconf_client_set_string (info->gconf_client, key, network, NULL); g_free (key); + key = g_strdup_printf ("%s/%s/key_type", NMI_GCONF_WIRELESS_NETWORKS_PATH, escaped_network); + gconf_client_set_string (info->gconf_client, key, key_type_string, NULL); + g_free (key); } + g_free (escaped_network); - nmi_passphrase_dialog_clear (dialog, entry); + nmi_passphrase_dialog_clear (dialog, GTK_WIDGET (entry)); } } @@ -130,7 +196,7 @@ void nmi_passphrase_dialog_cancel_clicked (GtkWidget *cancel_button, gpointer us const char *device = g_object_get_data (G_OBJECT (dialog), "device"); const char *network = g_object_get_data (G_OBJECT (dialog), "network"); - nmi_dbus_return_user_key (info->connection, device, network, "***canceled***"); + nmi_dbus_return_user_key (info->connection, device, network, "***canceled***", ""); nmi_passphrase_dialog_clear (dialog, glade_xml_get_widget (info->passphrase_dialog, "passphrase_entry")); } } @@ -145,8 +211,6 @@ void nmi_passphrase_dialog_cancel_clicked (GtkWidget *cancel_button, gpointer us void nmi_passphrase_dialog_show (const char *device, const char *network, NMIAppInfo *info) { GtkWidget *dialog; - GtkWidget *label; - const gchar *label_text; g_return_if_fail (info != NULL); g_return_if_fail (device != NULL); @@ -156,11 +220,11 @@ void nmi_passphrase_dialog_show (const char *device, const char *network, NMIApp nmi_passphrase_dialog_clear (dialog, glade_xml_get_widget (info->passphrase_dialog, "passphrase_entry")); /* Insert the Network name into the dialog text */ - label = glade_xml_get_widget (info->passphrase_dialog, "label1"); - label_text = gtk_label_get_label (GTK_LABEL (label)); - if (label_text) + if (info->orig_label_text) { - gchar *new_label_text = g_strdup_printf (label_text, network); + GtkWidget *label = glade_xml_get_widget (info->passphrase_dialog, "label1"); + char *new_label_text = g_strdup_printf (info->orig_label_text, network); + gtk_label_set_label (GTK_LABEL (label), new_label_text); } @@ -204,6 +268,8 @@ int nmi_passphrase_dialog_init (NMIAppInfo *info) GtkButton *ok_button; GtkButton *cancel_button; GtkEntry *entry; + GtkComboBox *key_type_combo; + GtkLabel *label; info->passphrase_dialog = glade_xml_new(GLADEDIR"/passphrase.glade", NULL, NULL); if (!info->passphrase_dialog) @@ -224,5 +290,16 @@ int nmi_passphrase_dialog_init (NMIAppInfo *info) entry = GTK_ENTRY (glade_xml_get_widget (info->passphrase_dialog, "passphrase_entry")); nmi_passphrase_dialog_clear (dialog, GTK_WIDGET (entry)); + key_type_combo = GTK_COMBO_BOX (glade_xml_get_widget (info->passphrase_dialog, "key_type_combo")); + gtk_combo_box_set_active (key_type_combo, 0); + g_signal_connect (G_OBJECT (key_type_combo), "changed", GTK_SIGNAL_FUNC (nmi_passphrase_dialog_key_type_combo_changed), info); + nmi_passphrase_dialog_key_type_combo_changed (GTK_WIDGET (key_type_combo), info); + + /* Save original label text to preserve the '%s' and other formatting that gets overwritten + * when the dialog is first shown. + */ + label = GTK_LABEL (glade_xml_get_widget (info->passphrase_dialog, "label1")); + info->orig_label_text = g_strdup (gtk_label_get_label (label)); + return (0); } diff --git a/info-daemon/passphrase.glade b/info-daemon/passphrase.glade index 23ca16e4f..e04fa81a1 100644 --- a/info-daemon/passphrase.glade +++ b/info-daemon/passphrase.glade @@ -99,7 +99,7 @@ True <span weight="bold" size="larger">Passphrase Required by Wireless Network</span> -A passphrase or WEP key is required to access the wireless network '%s'. +A passphrase or encryption key is required to access the wireless network '%s'. False True GTK_JUSTIFY_LEFT @@ -117,6 +117,57 @@ A passphrase or WEP key is required to access the wireless network '%s'. + + + True + False + 6 + + + + True + Key Type: + False + False + GTK_JUSTIFY_LEFT + False + False + 0.5 + 0.5 + 0 + 0 + + + 0 + False + False + + + + + + True + 128-bit Passphrase +128-bit Raw Hex Key + + + 0 + True + True + + + + + + + + + 0 + True + True + + + True @@ -124,7 +175,7 @@ A passphrase or WEP key is required to access the wireless network '%s'.6 - + True Passphrase: False diff --git a/src/NetworkManagerAP.c b/src/NetworkManagerAP.c index ed17a7fcb..4637af6ca 100644 --- a/src/NetworkManagerAP.c +++ b/src/NetworkManagerAP.c @@ -37,13 +37,12 @@ struct NMAccessPoint guint16 rate; gboolean encrypted; gboolean invalid; - NMAPEncMethod enc_method; - gboolean enc_method_good; gboolean matched; // used in ap list diffing gboolean trusted; /* Things from user prefs */ - gchar *enc_key; + char *enc_key; + NMAPEncMethod enc_method; GTimeVal timestamp; }; @@ -161,14 +160,14 @@ void nm_ap_set_timestamp (NMAccessPoint *ap, const GTimeVal *timestamp) * Get/set functions for essid * */ -gchar * nm_ap_get_essid (NMAccessPoint *ap) +char * nm_ap_get_essid (NMAccessPoint *ap) { g_return_val_if_fail (ap != NULL, NULL); return (ap->essid); } -void nm_ap_set_essid (NMAccessPoint *ap, gchar * essid) +void nm_ap_set_essid (NMAccessPoint *ap, char * essid) { g_return_if_fail (ap != NULL); @@ -183,14 +182,14 @@ void nm_ap_set_essid (NMAccessPoint *ap, gchar * essid) * Get/set functions for encryption key * */ -gchar * nm_ap_get_enc_key_source (NMAccessPoint *ap) +char * nm_ap_get_enc_key_source (NMAccessPoint *ap) { g_return_val_if_fail (ap != NULL, NULL); return (ap->enc_key); } -void nm_ap_set_enc_key_source (NMAccessPoint *ap, gchar * key) +void nm_ap_set_enc_key_source (NMAccessPoint *ap, char * key, NMAPEncMethod method) { g_return_if_fail (ap != NULL); @@ -198,25 +197,26 @@ void nm_ap_set_enc_key_source (NMAccessPoint *ap, gchar * key) g_free (ap->enc_key); ap->enc_key = g_strdup (key); + ap->enc_method = method; } -gchar *nm_ap_get_enc_key_hashed (NMAccessPoint *ap, NMAPEncMethod method) +char *nm_ap_get_enc_key_hashed (NMAccessPoint *ap) { - gchar *hashed = NULL; - char *source_key; + char *hashed = NULL; + char *source_key; g_return_val_if_fail (ap != NULL, NULL); source_key = nm_ap_get_enc_key_source (ap); - switch (method) + switch (ap->enc_method) { - case (NM_AP_ENC_METHOD_104_BIT_PASSPHRASE): + case (NM_AP_ENC_METHOD_128_BIT_PASSPHRASE): if (source_key) hashed = nm_wireless_128bit_key_from_passphrase (source_key); break; case (NM_AP_ENC_METHOD_40_BIT_PASSPHRASE): - case (NM_AP_ENC_METHOD_HEX_KEY): + case (NM_AP_ENC_METHOD_128_BIT_HEX_KEY): case (NM_AP_ENC_METHOD_UNKNOWN): if (source_key) hashed = g_strdup (source_key); @@ -375,49 +375,6 @@ void nm_ap_set_matched (NMAccessPoint *ap, gboolean matched) } -/* - * Get/set functions for encryption method - * Given some sort of passphrase/wep key from the user, we try it first - * as a 104-bit passphrase->key conversion, and fall back from there. These - * functions are meant to cache which fallback succeeds so we don't have to - * do it every time. - * - */ -NMAPEncMethod nm_ap_get_enc_method (NMAccessPoint *ap) -{ - g_return_val_if_fail (ap != NULL, TRUE); - - return (ap->enc_method); -} - -void nm_ap_set_enc_method (NMAccessPoint *ap, NMAPEncMethod enc_method) -{ - g_return_if_fail (ap != NULL); - - ap->enc_method = enc_method; - - /* By definition, if the encryption method is "unknown", it cannot be - * "firm" (that is, we know what method we need to use to talk to an ap) - */ - if (enc_method == NM_AP_ENC_METHOD_UNKNOWN) - ap->enc_method_good = FALSE; -} - -gboolean nm_ap_get_enc_method_good (NMAccessPoint *ap) -{ - g_return_val_if_fail (ap != NULL, FALSE); - - return (ap->enc_method_good); -} - -void nm_ap_set_enc_method_good (NMAccessPoint *ap, gboolean good) -{ - g_return_if_fail (ap != NULL); - - ap->enc_method_good = good; -} - - /* * Get/Set functions to indicate that an access point is * 'trusted' @@ -436,3 +393,15 @@ void nm_ap_set_trusted (NMAccessPoint *ap, gboolean trusted) ap->trusted = trusted; } + + +/* + * Return the encryption method the user specified for this access point. + * + */ +NMAPEncMethod nm_ap_get_enc_method (NMAccessPoint *ap) +{ + g_return_val_if_fail (ap != NULL, TRUE); + + return (ap->enc_method); +} diff --git a/src/NetworkManagerAP.h b/src/NetworkManagerAP.h index c80e908a9..5d9707194 100644 --- a/src/NetworkManagerAP.h +++ b/src/NetworkManagerAP.h @@ -31,9 +31,9 @@ typedef enum NMAPEncMethod { NM_AP_ENC_METHOD_UNKNOWN = 0, NM_AP_ENC_METHOD_NONE, - NM_AP_ENC_METHOD_HEX_KEY, + NM_AP_ENC_METHOD_128_BIT_HEX_KEY, NM_AP_ENC_METHOD_40_BIT_PASSPHRASE, - NM_AP_ENC_METHOD_104_BIT_PASSPHRASE + NM_AP_ENC_METHOD_128_BIT_PASSPHRASE /* Well, 104-bit really... */ } NMAPEncMethod; @@ -46,12 +46,12 @@ void nm_ap_ref (NMAccessPoint *ap); const GTimeVal * nm_ap_get_timestamp (NMAccessPoint *ap); void nm_ap_set_timestamp (NMAccessPoint *ap, const GTimeVal *timestamp); -gchar * nm_ap_get_essid (NMAccessPoint *ap); -void nm_ap_set_essid (NMAccessPoint *ap, gchar *essid); +char * nm_ap_get_essid (NMAccessPoint *ap); +void nm_ap_set_essid (NMAccessPoint *ap, char *essid); -gchar * nm_ap_get_enc_key_source (NMAccessPoint *ap); -gchar * nm_ap_get_enc_key_hashed (NMAccessPoint *ap, NMAPEncMethod method); -void nm_ap_set_enc_key_source (NMAccessPoint *ap, gchar *key); +char * nm_ap_get_enc_key_source (NMAccessPoint *ap); +char * nm_ap_get_enc_key_hashed (NMAccessPoint *ap); +void nm_ap_set_enc_key_source (NMAccessPoint *ap, char *key, NMAPEncMethod method); gboolean nm_ap_get_encrypted (NMAccessPoint *ap); void nm_ap_set_encrypted (NMAccessPoint *ap, gboolean encrypted); @@ -74,13 +74,9 @@ void nm_ap_set_invalid (NMAccessPoint *ap, gboolean invalid); gboolean nm_ap_get_matched (NMAccessPoint *ap); void nm_ap_set_matched (NMAccessPoint *ap, gboolean matched); -NMAPEncMethod nm_ap_get_enc_method (NMAccessPoint *ap); -void nm_ap_set_enc_method (NMAccessPoint *ap, NMAPEncMethod enc_method); - -gboolean nm_ap_get_enc_method_good(NMAccessPoint *ap); -void nm_ap_set_enc_method_good(NMAccessPoint *ap, gboolean good); - gboolean nm_ap_get_trusted (NMAccessPoint *ap); void nm_ap_set_trusted (NMAccessPoint *ap, gboolean trusted); +NMAPEncMethod nm_ap_get_enc_method (NMAccessPoint *ap); + #endif diff --git a/src/NetworkManagerAPList.c b/src/NetworkManagerAPList.c index b00bbca2b..032be1411 100644 --- a/src/NetworkManagerAPList.c +++ b/src/NetworkManagerAPList.c @@ -231,9 +231,10 @@ void nm_ap_list_update_network (NMAccessPointList *list, const char *network, NM /* Get the allowed access point's details from NetworkManagerInfo */ if ((essid = nm_dbus_get_network_essid (data->dbus_connection, list->type, network))) { - char *key = nm_dbus_get_network_key (data->dbus_connection, list->type, network); - GTimeVal *timestamp = nm_dbus_get_network_timestamp (data->dbus_connection, list->type, network); - gboolean trusted = nm_dbus_get_network_trusted (data->dbus_connection, list->type, network); + NMAPEncMethod enc_method; + char *key = nm_dbus_get_network_key (data->dbus_connection, list->type, network, &enc_method); + GTimeVal *timestamp = nm_dbus_get_network_timestamp (data->dbus_connection, list->type, network); + gboolean trusted = nm_dbus_get_network_trusted (data->dbus_connection, list->type, network); if (timestamp != NULL) { @@ -242,12 +243,12 @@ void nm_ap_list_update_network (NMAccessPointList *list, const char *network, NM nm_ap_list_append_ap (list, (ap = nm_ap_new ())); nm_ap_set_essid (ap, essid); - nm_ap_set_enc_key_source (ap, key); nm_ap_set_timestamp (ap, timestamp); nm_ap_set_trusted (ap, trusted); - g_free (timestamp); + nm_ap_set_enc_key_source (ap, key, enc_method); } + g_free (timestamp); g_free (essid); g_free (key); } @@ -327,7 +328,6 @@ void nm_ap_list_diff (NMData *data, NMDevice *dev, NMAccessPointList *old, NMAcc nm_ap_set_matched (old_ap, TRUE); nm_ap_set_matched (new_ap, TRUE); nm_ap_set_invalid (new_ap, nm_ap_get_invalid (old_ap)); - nm_ap_set_enc_method (new_ap, nm_ap_get_enc_method (old_ap)); } else nm_dbus_signal_wireless_network_change (data->dbus_connection, dev, old_ap, TRUE); diff --git a/src/NetworkManagerDbus.c b/src/NetworkManagerDbus.c index 434faaf1f..3c9bd9a58 100644 --- a/src/NetworkManagerDbus.c +++ b/src/NetworkManagerDbus.c @@ -63,6 +63,25 @@ static DBusMessage *nm_dbus_create_error_message (DBusMessage *message, const ch } +/* + * nm_dbus_get_enc_method_from_string + * + * Parse a string and return the encryption method it specifies. + * + */ +NMAPEncMethod nm_dbus_get_enc_method_from_string (const char *key_type) +{ + g_return_val_if_fail (key_type != NULL, NM_AP_ENC_METHOD_UNKNOWN); + + if (!strcmp (key_type, "128-bit-passphrase")) + return (NM_AP_ENC_METHOD_128_BIT_PASSPHRASE); + else if (!strcmp (key_type, "128-bit-raw-hex-key")) + return (NM_AP_ENC_METHOD_128_BIT_HEX_KEY); + + return (NM_AP_ENC_METHOD_UNKNOWN); +} + + /* * nm_dbus_get_object_path_from_device * @@ -521,7 +540,6 @@ void nm_dbus_get_user_key_for_network (DBusConnection *connection, NMDevice *dev DBUS_TYPE_STRING, nm_ap_get_essid (ap), DBUS_TYPE_INVALID); -fprintf( stderr, "getUserKey\n"); if (!dbus_connection_send (connection, message, NULL)) syslog (LOG_WARNING, "nm_dbus_get_user_key_for_network(): could not send dbus message"); @@ -542,6 +560,7 @@ static void nm_dbus_set_user_key_for_network (DBusConnection *connection, DBusMe char *device; char *network; char *passphrase; + char *key_type; g_return_if_fail (data != NULL); g_return_if_fail (connection != NULL); @@ -552,16 +571,21 @@ static void nm_dbus_set_user_key_for_network (DBusConnection *connection, DBusMe DBUS_TYPE_STRING, &device, DBUS_TYPE_STRING, &network, DBUS_TYPE_STRING, &passphrase, + DBUS_TYPE_STRING, &key_type, DBUS_TYPE_INVALID)) { NMDevice *dev; if ((dev = nm_get_device_by_iface (data, device))) - nm_device_set_user_key_for_network (dev, data->invalid_ap_list, network, passphrase); + { + NMAPEncMethod method = nm_dbus_get_enc_method_from_string (key_type); + nm_device_set_user_key_for_network (dev, data->invalid_ap_list, network, passphrase, method); + } dbus_free (device); dbus_free (network); dbus_free (passphrase); + dbus_free (key_type); } } @@ -653,18 +677,21 @@ char * nm_dbus_get_network_essid (DBusConnection *connection, NMNetworkType type /* * nm_dbus_get_network_key * - * Get a network's key from NetworkManagerInfo. + * Get a network's key and key type from NetworkManagerInfo. * * NOTE: caller MUST free returned value * */ -char * nm_dbus_get_network_key (DBusConnection *connection, NMNetworkType type, const char *network) +char * nm_dbus_get_network_key (DBusConnection *connection, NMNetworkType type, const char *network, NMAPEncMethod *enc_method) { DBusMessage *message; DBusError error; DBusMessage *reply; char *key = NULL; + g_return_val_if_fail (enc_method != NULL, NULL); + *enc_method = NM_AP_ENC_METHOD_UNKNOWN; + g_return_val_if_fail (connection != NULL, NULL); g_return_val_if_fail (network != NULL, NULL); g_return_val_if_fail (type != NETWORK_TYPE_UNKNOWN, NULL); @@ -684,25 +711,32 @@ char * nm_dbus_get_network_key (DBusConnection *connection, NMNetworkType type, /* Send message and get key back from NetworkManagerInfo */ dbus_error_init (&error); reply = dbus_connection_send_with_reply_and_block (connection, message, -1, &error); + dbus_message_unref (message); if (dbus_error_is_set (&error)) + { syslog (LOG_ERR, "nm_dbus_get_network_key(): %s raised %s", error.name, error.message); + dbus_error_free (&error); + } else if (!reply) syslog (LOG_NOTICE, "nm_dbus_get_network_key(): reply was NULL."); else { - char *dbus_string; + char *dbus_key; + char *dbus_key_type; dbus_error_init (&error); - if (dbus_message_get_args (reply, &error, DBUS_TYPE_STRING, &dbus_string, DBUS_TYPE_INVALID)) + if (dbus_message_get_args (reply, &error, DBUS_TYPE_STRING, &dbus_key, DBUS_TYPE_STRING, &dbus_key_type, DBUS_TYPE_INVALID)) { - key = (dbus_string == NULL ? NULL : strdup (dbus_string)); - dbus_free (dbus_string); + key = (dbus_key == NULL ? NULL : strdup (dbus_key)); + dbus_free (dbus_key); + *enc_method = nm_dbus_get_enc_method_from_string (dbus_key_type); + dbus_free (dbus_key_type); } - } + if (dbus_error_is_set (&error)) + dbus_error_free (&error); - dbus_message_unref (message); - if (reply) dbus_message_unref (reply); + } return (key); } @@ -1222,7 +1256,7 @@ static DBusHandlerResult nm_dbus_nm_message_handler (DBusConnection *connection, { if (data->active_device && nm_device_activating (data->active_device)) { - if (nm_device_now_scanning (data->active_device)) + if (nm_device_is_wireless (data->active_device) && nm_device_now_scanning (data->active_device)) dbus_message_append_args (reply_message, DBUS_TYPE_STRING, "scanning", DBUS_TYPE_INVALID); else dbus_message_append_args (reply_message, DBUS_TYPE_STRING, "connecting", DBUS_TYPE_INVALID); diff --git a/src/NetworkManagerDbus.h b/src/NetworkManagerDbus.h index b09e31b6e..80f1b2c0d 100644 --- a/src/NetworkManagerDbus.h +++ b/src/NetworkManagerDbus.h @@ -66,7 +66,7 @@ void nm_dbus_cancel_get_user_key_for_network (DBusConnection *connection); char * nm_dbus_get_network_essid (DBusConnection *connection, NMNetworkType type, const char *network); -char * nm_dbus_get_network_key (DBusConnection *connection, NMNetworkType type, const char *network); +char * nm_dbus_get_network_key (DBusConnection *connection, NMNetworkType type, const char *network, NMAPEncMethod *enc_method); GTimeVal * nm_dbus_get_network_timestamp (DBusConnection *connection, NMNetworkType type, const char *network); diff --git a/src/NetworkManagerDevice.c b/src/NetworkManagerDevice.c index 7b8ac50eb..a95fa7a1f 100644 --- a/src/NetworkManagerDevice.c +++ b/src/NetworkManagerDevice.c @@ -770,7 +770,7 @@ void nm_device_set_enc_key (NMDevice *dev, const char *key) keylen = iw_in_key_full(iwlib_socket, nm_device_get_iface (dev), safe_key, &parsed_key[0], &wreq.u.data.flags); if (keylen > 0) { - wreq.u.data.flags |= IW_ENCODE_OPEN; // FIXME: what about restricted/Shared Key? + wreq.u.data.flags |= IW_ENCODE_RESTRICTED; // FIXME: what about restricted/Shared Key? wreq.u.data.pointer = (caddr_t) &parsed_key; wreq.u.data.length = keylen; set_key = TRUE; @@ -1146,7 +1146,7 @@ gboolean nm_device_activation_begin (NMDevice *dev) * and other random things. * */ -gboolean nm_device_activation_should_cancel (NMDevice *dev) +static gboolean nm_device_activation_should_cancel (NMDevice *dev) { g_return_val_if_fail (dev != NULL, TRUE); @@ -1172,7 +1172,7 @@ gboolean nm_device_activation_should_cancel (NMDevice *dev) * FALSE on unsuccessful activation (ie no best AP) * */ -static gboolean nm_device_activate_wireless (NMDevice *dev) +static gboolean nm_device_activate_wireless (NMDevice *dev, guint *bad_crypt_packets) { NMAccessPoint *best_ap; gboolean success = FALSE; @@ -1180,6 +1180,7 @@ static gboolean nm_device_activate_wireless (NMDevice *dev) g_return_val_if_fail (dev != NULL, FALSE); g_return_val_if_fail (nm_device_is_wireless (dev), FALSE); + *bad_crypt_packets = 0; /* If there is a desired AP to connect to, use that essid and possible WEP key */ if ((best_ap = nm_device_get_best_ap (dev)) && nm_ap_get_essid (best_ap)) { @@ -1191,16 +1192,17 @@ static gboolean nm_device_activate_wireless (NMDevice *dev) nm_device_set_enc_key (dev, NULL); if (nm_ap_get_encrypted (best_ap) && nm_ap_get_enc_key_source (best_ap)) { - char *hashed_key = nm_ap_get_enc_key_hashed (best_ap, nm_ap_get_enc_method (best_ap)); + char *hashed_key = nm_ap_get_enc_key_hashed (best_ap); nm_device_set_enc_key (dev, hashed_key); g_free (hashed_key); } nm_device_set_essid (dev, nm_ap_get_essid (best_ap)); + *bad_crypt_packets = nm_device_get_bad_crypt_packets (dev); syslog (LOG_INFO, "nm_device_wireless_activate(%s) using essid '%s'", nm_device_get_iface (dev), nm_ap_get_essid (best_ap)); - /* Bring the device up and pause to allow card to associate*/ + /* Bring the device up and pause to allow card to associate */ nm_device_bring_up (dev); g_usleep (G_USEC_PER_SEC * 2); @@ -1217,7 +1219,6 @@ inline gboolean HAVE_LINK (NMDevice *dev, guint32 bad_crypt_packets) g_return_val_if_fail (dev != NULL, FALSE); g_return_val_if_fail (nm_device_is_wireless (dev), FALSE); -fprintf (stderr, "PACKETS: dev %d, previous %d\n", nm_device_get_bad_crypt_packets (dev), bad_crypt_packets); return (nm_device_get_link_active (dev) && (nm_device_get_bad_crypt_packets (dev) <= bad_crypt_packets)); } @@ -1240,12 +1241,12 @@ void nm_device_activate_wireless_wait_for_link (NMDevice *dev) if (!(best_ap = nm_device_get_best_ap (dev))) { nm_device_do_wireless_scan (dev); + nm_device_update_best_ap (dev); best_ap = nm_device_get_best_ap (dev); } /* Try activating the device with the key and access point we have already */ - bad_crypt_packets = nm_device_get_bad_crypt_packets (dev); - nm_device_activate_wireless (dev); + nm_device_activate_wireless (dev, &bad_crypt_packets); /* Wait until we have a link. Some things that might block us from * getting one: @@ -1273,64 +1274,27 @@ void nm_device_activate_wireless_wait_for_link (NMDevice *dev) * are using Open System authentication. Also, not all drivers return an invalid MAC address * when the card cannot communicate with the access point. */ - while (!HAVE_LINK (dev, bad_crypt_packets)) + while ( !HAVE_LINK (dev, bad_crypt_packets) + || (best_ap && (nm_ap_get_encrypted (best_ap) && !nm_ap_get_enc_key_source (best_ap)))) /* No link if best AP is encrypted but we don't have a key yet */ { if ((best_ap = nm_device_get_best_ap (dev))) { dev->options.wireless.now_scanning = FALSE; - fprintf( stderr, "is_enc (%d) && (!enc_source (%d) || !enc_method_good (%d)) && \n", - nm_ap_get_encrypted (best_ap), - !!nm_ap_get_enc_key_source (best_ap), - nm_ap_get_enc_method_good (best_ap)); - - /* Since we don't have a link yet, something is bad with the - * encryption key, try falling back to a different method of - * encryption or asking the user for a new key. + /* If we don't have a link yet, the encryption key is bad. Ask the user for a + * new one. */ - if ( nm_ap_get_encrypted (best_ap) - && (!nm_ap_get_enc_key_source (best_ap) || !nm_ap_get_enc_method_good (best_ap))) + if (nm_ap_get_encrypted (best_ap)) { - gboolean ask_for_key = TRUE; + dev->options.wireless.user_key_received = FALSE; + nm_dbus_get_user_key_for_network (dev->app_data->dbus_connection, dev, best_ap); - /* If we have a key, try all the key/passphrase generation methods - * before asking the user for a key. - */ - if (nm_ap_get_enc_key_source (best_ap) && !nm_ap_get_enc_method_good (best_ap)) - { - /* Try another method, since the one set in a previous iteration obviously didn't work */ - switch (nm_ap_get_enc_method (best_ap)) - { - case (NM_AP_ENC_METHOD_UNKNOWN): - nm_ap_set_enc_method (best_ap, NM_AP_ENC_METHOD_104_BIT_PASSPHRASE); - ask_for_key = FALSE; - break; - case (NM_AP_ENC_METHOD_104_BIT_PASSPHRASE): - nm_ap_set_enc_method (best_ap, NM_AP_ENC_METHOD_40_BIT_PASSPHRASE); - ask_for_key = FALSE; - break; - case (NM_AP_ENC_METHOD_40_BIT_PASSPHRASE): - nm_ap_set_enc_method (best_ap, NM_AP_ENC_METHOD_HEX_KEY); - ask_for_key = FALSE; - break; - default: - break; - } - } + /* Wait for the key to come back */ + syslog (LOG_DEBUG, "nm_device_activation_worker(%s): asking for user key.", nm_device_get_iface (dev)); + while (!dev->options.wireless.user_key_received && !dev->quit_activation) + g_usleep (G_USEC_PER_SEC / 2); - /* If all fallbacks for encryption method fail, ask the user for a new WEP key */ - if (ask_for_key) - { - dev->options.wireless.user_key_received = FALSE; - nm_dbus_get_user_key_for_network (dev->app_data->dbus_connection, dev, best_ap); - - /* Wait for the key to come back */ - syslog (LOG_DEBUG, "nm_device_activation_worker(%s): asking for user key.", nm_device_get_iface (dev)); - while (!dev->options.wireless.user_key_received && !dev->quit_activation) - g_usleep (G_USEC_PER_SEC / 2); - - syslog (LOG_DEBUG, "nm_device_activation_worker(%s): user key received.", nm_device_get_iface (dev)); - } + syslog (LOG_DEBUG, "nm_device_activation_worker(%s): user key received.", nm_device_get_iface (dev)); /* If we were told to quit activation, stop the thread and return */ if (nm_device_activation_should_cancel (dev)) @@ -1338,8 +1302,7 @@ void nm_device_activate_wireless_wait_for_link (NMDevice *dev) } /* Try activating again with up-to-date access point and keys */ - bad_crypt_packets = nm_device_get_bad_crypt_packets (dev); - nm_device_activate_wireless (dev); + nm_device_activate_wireless (dev, &bad_crypt_packets); } else { @@ -1353,7 +1316,6 @@ void nm_device_activate_wireless_wait_for_link (NMDevice *dev) break; } - dev->options.wireless.now_scanning = FALSE; } @@ -1365,13 +1327,17 @@ void nm_device_activate_wireless_wait_for_link (NMDevice *dev) * or manually setting up the IP address, gateway, and default route. * */ -void nm_device_activation_configure_ip (NMDevice *dev) +static gboolean nm_device_activation_configure_ip (NMDevice *dev) { - g_return_if_fail (dev != NULL); + gboolean success = FALSE; + + g_return_val_if_fail (dev != NULL, FALSE); if (nm_device_config_get_use_dhcp (dev)) { - if (!nm_system_device_run_dhcp (dev)) + if (nm_system_device_run_dhcp (dev)) + success = TRUE; + else { /* Interfaces cannot be down if they are the active interface, * otherwise we cannot use them for scanning or link detection. @@ -1391,7 +1357,10 @@ void nm_device_activation_configure_ip (NMDevice *dev) { /* Manually set up the device */ /* FIXME: implement */ + syslog (LOG_ERR, "NetworkManager does not currently support static IP addresses\n"); } + + return (success); } @@ -1425,9 +1394,6 @@ static gpointer nm_device_activation_worker (gpointer user_data) return (NULL); } - /* Since we've got a link, the encryption method must be good */ - nm_ap_set_enc_method_good (nm_device_get_best_ap (dev), TRUE); - syslog (LOG_DEBUG, "nm_device_activation_worker(%s): using ESSID '%s'", nm_device_get_iface (dev), nm_ap_get_essid (nm_device_get_best_ap (dev))); } @@ -1444,10 +1410,12 @@ static gpointer nm_device_activation_worker (gpointer user_data) /* If we don't have a "best" ap, don't try to get a DHCP address or restart the name service cache */ if (nm_device_is_wired (dev) || (nm_device_is_wireless (dev) && nm_device_get_best_ap (dev))) { + gboolean success; /* Save machine host name */ host_err = gethostname (&hostname[0], 100); - nm_device_activation_configure_ip (dev); + if (!(success = nm_device_activation_configure_ip (dev))) + syslog (LOG_DEBUG, "nm_device_activation_worker(%s): could not retrieve and assign IP information to device\n", nm_device_get_iface (dev)); /* Set the hostname back to what it was before so that X11 doesn't * puke when the hostname changes, and so users can actually launch stuff. @@ -1456,7 +1424,7 @@ static gpointer nm_device_activation_worker (gpointer user_data) sethostname (hostname, strlen (hostname)); /* If we were told to quit activation, stop the thread and return */ - if (nm_device_activation_should_cancel (dev)) + if (nm_device_activation_should_cancel (dev) || !success) { nm_device_unref (dev); return (NULL); @@ -1601,7 +1569,8 @@ gboolean nm_device_now_scanning (NMDevice *dev) * */ void nm_device_set_user_key_for_network (NMDevice *dev, NMAccessPointList *invalid_list, - unsigned char *network, unsigned char *key) + unsigned char *network, unsigned char *key, + NMAPEncMethod enc_method) { NMAccessPoint *best_ap; const char *cancel_message = "***canceled***"; @@ -1631,11 +1600,7 @@ void nm_device_set_user_key_for_network (NMDevice *dev, NMAccessPointList *inval * then set the new key on the access point. */ if (nm_null_safe_strcmp (network, nm_ap_get_essid (best_ap)) == 0) - { - nm_ap_set_enc_key_source (best_ap, key); - nm_ap_set_enc_method (best_ap, NM_AP_ENC_METHOD_UNKNOWN); - nm_ap_set_enc_method_good (best_ap, FALSE); - } + nm_ap_set_enc_key_source (best_ap, key, enc_method); } dev->options.wireless.user_key_received = TRUE; } @@ -1897,14 +1862,14 @@ void nm_device_update_best_ap (NMDevice *dev) trusted_latest_timestamp = *nm_ap_get_timestamp (tmp_ap); trusted_best_ap = ap; /* Merge access point data (mainly to get updated WEP key) */ - nm_ap_set_enc_key_source (trusted_best_ap, nm_ap_get_enc_key_source (tmp_ap)); + nm_ap_set_enc_key_source (trusted_best_ap, nm_ap_get_enc_key_source (tmp_ap), nm_ap_get_enc_method (tmp_ap)); } else if (!nm_ap_get_trusted (tmp_ap) && (curtime->tv_sec > untrusted_latest_timestamp.tv_sec)) { untrusted_latest_timestamp = *nm_ap_get_timestamp (tmp_ap); untrusted_best_ap = ap; /* Merge access point data (mainly to get updated WEP key) */ - nm_ap_set_enc_key_source (untrusted_best_ap, nm_ap_get_enc_key_source (tmp_ap)); + nm_ap_set_enc_key_source (untrusted_best_ap, nm_ap_get_enc_key_source (tmp_ap), nm_ap_get_enc_method (tmp_ap)); } } } @@ -1996,16 +1961,9 @@ static void nm_device_do_normal_scan (NMDevice *dev) nm_ap_set_essid (nm_ap, tmp_ap->b.essid); if (tmp_ap->b.has_key && (tmp_ap->b.key_flags & IW_ENCODE_DISABLED)) - { nm_ap_set_encrypted (nm_ap, FALSE); - nm_ap_set_enc_method (nm_ap, NM_AP_ENC_METHOD_NONE); - nm_ap_set_enc_method_good (nm_ap, TRUE); - } else - { nm_ap_set_encrypted (nm_ap, TRUE); - nm_ap_set_enc_method (nm_ap, NM_AP_ENC_METHOD_UNKNOWN); - } if (tmp_ap->has_ap_addr) nm_ap_set_address (nm_ap, (const struct ether_addr *)(tmp_ap->ap_addr.sa_data)); @@ -2019,9 +1977,8 @@ static void nm_device_do_normal_scan (NMDevice *dev) if ((list_ap = nm_ap_list_get_ap_by_essid (data->allowed_ap_list, nm_ap_get_essid (nm_ap)))) { nm_ap_set_timestamp (nm_ap, nm_ap_get_timestamp (list_ap)); - nm_ap_set_enc_key_source (nm_ap, nm_ap_get_enc_key_source (list_ap)); + nm_ap_set_enc_key_source (nm_ap, nm_ap_get_enc_key_source (list_ap), nm_ap_get_enc_method (list_ap)); } - /* Add the AP to the device's AP list */ nm_device_ap_list_add_ap (dev, nm_ap); } @@ -2084,7 +2041,11 @@ static void nm_device_do_pseudo_scan (NMDevice *dev) nm_device_set_essid (dev, nm_ap_get_essid (ap)); if (nm_ap_get_enc_key_source (ap)) - nm_device_set_enc_key (dev, nm_ap_get_enc_key_source (ap)); + { + char *hashed_key = nm_ap_get_enc_key_hashed (ap); + nm_device_set_enc_key (dev, hashed_key); + g_free (hashed_key); + } else nm_device_set_enc_key (dev, NULL); @@ -2155,15 +2116,9 @@ static void nm_device_fake_ap_list (NMDevice *dev) nm_ap_set_essid (nm_ap, fake_essids[i]); if (fake_enc[i]) - { nm_ap_set_encrypted (nm_ap, FALSE); - nm_ap_set_enc_method (nm_ap, NM_AP_ENC_METHOD_NONE); - } else - { nm_ap_set_encrypted (nm_ap, TRUE); - nm_ap_set_enc_method (nm_ap, NM_AP_ENC_METHOD_UNKNOWN); - } nm_ap_set_address (nm_ap, (const struct ether_addr *)(&fake_addrs[i])); nm_ap_set_strength (nm_ap, fake_qualities[i]); @@ -2173,7 +2128,7 @@ static void nm_device_fake_ap_list (NMDevice *dev) if ((list_ap = nm_ap_list_get_ap_by_essid (dev->app_data->allowed_ap_list, nm_ap_get_essid (nm_ap)))) { nm_ap_set_timestamp (nm_ap, nm_ap_get_timestamp (list_ap)); - nm_ap_set_enc_key_source (nm_ap, nm_ap_get_enc_key_source (list_ap)); + nm_ap_set_enc_key_source (nm_ap, nm_ap_get_enc_key_source (list_ap), nm_ap_get_enc_method (list_ap)); } /* Add the AP to the device's AP list */ diff --git a/src/NetworkManagerDevice.h b/src/NetworkManagerDevice.h index a8fb3982a..93626cb2d 100644 --- a/src/NetworkManagerDevice.h +++ b/src/NetworkManagerDevice.h @@ -88,7 +88,8 @@ gboolean nm_device_deactivate (NMDevice *dev, gboolean just_added); gboolean nm_device_now_scanning (NMDevice *dev); void nm_device_set_user_key_for_network (NMDevice *dev, struct NMAccessPointList *invalid_list, - unsigned char *network, unsigned char *key); + unsigned char *network, unsigned char *key, + NMAPEncMethod enc_method); void nm_device_bring_up (NMDevice *dev); void nm_device_bring_down (NMDevice *dev); diff --git a/test/nminfotest.c b/test/nminfotest.c index 20996b7a2..b034ba491 100644 --- a/test/nminfotest.c +++ b/test/nminfotest.c @@ -249,6 +249,7 @@ void set_user_key_for_network (DBusConnection *connection, DBusMessage *message, char *device; char *network; char *passphrase; + char *key_type_string; g_return_if_fail (connection != NULL); g_return_if_fail (message != NULL); @@ -258,13 +259,15 @@ void set_user_key_for_network (DBusConnection *connection, DBusMessage *message, DBUS_TYPE_STRING, &device, DBUS_TYPE_STRING, &network, DBUS_TYPE_STRING, &passphrase, + DBUS_TYPE_STRING, &key_type_string, DBUS_TYPE_INVALID)) { - fprintf( stderr, "Device was '%s'\nNetwork was '%s'\nPassphrase was '%s'\n", device, network, passphrase); + fprintf( stderr, "Device was '%s'\nNetwork was '%s'\nPassphrase was '%s'\nKey type was '%s'\n", device, network, passphrase, key_type_string); dbus_free (device); dbus_free (network); dbus_free (passphrase); + dbus_free (key_type_string); g_main_loop_quit (loop); }