[patch] first pass at gnome-keyring support, baby.
- From: Robert Love <rml novell com>
- To: networkmanager-list gnome org
- Subject: [patch] first pass at gnome-keyring support, baby.
- Date: Wed, 22 Jun 2005 22:02:22 -0400
Attached patch adds support for gnome-keyring to nm-applet and stores
the essid key encrypted in the keyring instead of cleartext in gconf.
It is a first pass, but it seems to work well [1].
One issue is it causes the gnome-keyring "decrypt your keyring" dialog
to pop up as soon as the applet loads (presuming that your keyring is
not already decrypted, of course). It seems as if the information
(including the keys) is read for each wireless network on startup?
Maybe we could change that, or defer reading the key until it is
absolutely needed. Or only read the key if the auth_method specifies
such.
Thoughts? Comments?
Robert Love
[1] Actually, it seems to work perfect. But I am having a lot of
problems with NetworkManager and encrypted essids (or maybe just
switching between lots of essids in general) and my airo wireless card.
Sometimes the daemon just starts sitting there. Sometimes it stops
scanning. In either case, it won't exit. Quick debugging shows it is
spinning on a mutex. Although I've also seen evidence it is waiting for
something from the card. It is confusing to the point of tears. I'll
debug it later. I should add that, ahem, Netapplet works fine with my
card. ;-)
Index: configure.in
===================================================================
RCS file: /cvs/gnome/NetworkManager/configure.in,v
retrieving revision 1.82
diff -u -u -r1.82 configure.in
--- configure.in 20 Jun 2005 17:16:51 -0000 1.82
+++ configure.in 23 Jun 2005 01:54:43 -0000
@@ -177,10 +177,6 @@
AC_SUBST(LIBGNOMEUI_CFLAGS) # is this even needed? it was typed incorrectly before
AC_SUBST(LIBGNOMEUI_LIBS)
-PKG_CHECK_MODULES(GNOMEKEYRING, gnome-keyring-1)
-AC_SUBST(GNOMEKEYRING_CFLAGS) # is this even needed? it was typed incorrectly before
-AC_SUBST(GNOMEKEYRING_LIBS)
-
AC_ARG_WITH(dbus-sys, AC_HELP_STRING([--with-dbus-sys=DIR], [where D-BUS system.d directory is]))
if ! test -z "$with_dbus_sys" ; then
Index: gnome/applet/Makefile.am
===================================================================
RCS file: /cvs/gnome/NetworkManager/gnome/applet/Makefile.am,v
retrieving revision 1.5
diff -u -u -r1.5 Makefile.am
--- gnome/applet/Makefile.am 16 Jun 2005 18:47:56 -0000 1.5
+++ gnome/applet/Makefile.am 23 Jun 2005 01:54:43 -0000
@@ -16,7 +16,7 @@
$(GCONF_CFLAGS) \
$(LIBGNOMEUI_CFLAGS) \
$(PANEL_APPLET_CFLAGS) \
- $(GNOMEKEYRING_CFLAGS) \
+ $(GNOME_KEYRING_CFLAGS) \
-DICONDIR=\""$(datadir)/pixmaps"\" \
-DGLADEDIR=\""$(gladedir)"\" \
-DBINDIR=\""$(bindir)"\" \
@@ -70,7 +70,7 @@
$(GTK_LIBS) \
$(GCONF_LIBS) \
$(LIBGNOMEUI_LIBS) \
- $(GNOMEKEYRING_LIBS) \
+ $(GNOME_KEYRING_LIBS) \
$(top_builddir)/utils/libnmutils.la \
$(NULL)
Index: gnome/applet/applet-dbus-info.c
===================================================================
RCS file: /cvs/gnome/NetworkManager/gnome/applet/applet-dbus-info.c,v
retrieving revision 1.8
diff -u -u -r1.8 applet-dbus-info.c
--- gnome/applet/applet-dbus-info.c 21 Jun 2005 15:07:00 -0000 1.8
+++ gnome/applet/applet-dbus-info.c 23 Jun 2005 01:54:43 -0000
@@ -29,6 +29,8 @@
#include <dbus/dbus.h>
#include <gtk/gtk.h>
#include <glade/glade.h>
+#include <gnome-keyring.h>
+
#include "NetworkManager.h"
#include "applet.h"
#include "applet-dbus.h"
@@ -293,13 +295,14 @@
DBusError error;
NMNetworkType type;
char *escaped_network;
-
char *essid = NULL;
gint timestamp = -1;
- gint32 i;
+ gint32 i;
char *key = NULL;
NMEncKeyType key_type = -1;
gboolean trusted = FALSE;
+ GList *found_list;
+ GnomeKeyringResult ret;
NMDeviceAuthMethod auth_method = NM_DEVICE_AUTH_METHOD_UNKNOWN;
g_return_val_if_fail (applet != NULL, NULL);
@@ -335,16 +338,21 @@
}
g_free (gconf_key);
- /* Grab user-key key for our access point from GConf */
- gconf_key = g_strdup_printf ("%s/%s/key", GCONF_PATH_WIRELESS_NETWORKS, escaped_network);
- if ((value = gconf_client_get (applet->gconf_client, gconf_key, NULL)))
- {
- key = g_strdup (gconf_value_get_string (value));
- gconf_value_free (value);
+ /* 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 ("");
- g_free (gconf_key);
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)))
Index: gnome/applet/applet.c
===================================================================
RCS file: /cvs/gnome/NetworkManager/gnome/applet/applet.c,v
retrieving revision 1.16
diff -u -u -r1.16 applet.c
--- gnome/applet/applet.c 21 Jun 2005 15:09:34 -0000 1.16
+++ gnome/applet/applet.c 23 Jun 2005 01:54:44 -0000
@@ -2323,24 +2323,23 @@
/* FIXME: force redraw */
}
-const gchar *style = " \
-style \"MenuBar\" \
-{ \
- GtkMenuBar::shadow_type = GTK_SHADOW_NONE \
- GtkMenuBar::internal-padding = 0 \
-} \
-style \"MenuItem\" \
-{ \
- xthickness=0 \
- ythickness=0 \
-} \
-class \"GtkMenuBar\" style \"MenuBar\"\
-widget \"*ToplevelMenu*\" style \"MenuItem\"\
-";
-
static void nmwa_icons_init (NMWirelessApplet *applet)
{
GtkIconTheme *icon_theme;
+ const gchar *style = " \
+ style \"MenuBar\" \
+ { \
+ GtkMenuBar::shadow_type = GTK_SHADOW_NONE \
+ GtkMenuBar::internal-padding = 0 \
+ } \
+ style \"MenuItem\" \
+ { \
+ xthickness=0 \
+ ythickness=0 \
+ } \
+ class \"GtkMenuBar\" style \"MenuBar\"\
+ widget \"*ToplevelMenu*\" style \"MenuItem\"\
+ ";
/* FIXME: Do we need to worry about other screens? */
gtk_rc_parse_string (style);
Index: gnome/applet/passphrase-dialog.c
===================================================================
RCS file: /cvs/gnome/NetworkManager/gnome/applet/passphrase-dialog.c,v
retrieving revision 1.5
diff -u -u -r1.5 passphrase-dialog.c
--- gnome/applet/passphrase-dialog.c 21 Jun 2005 15:07:00 -0000 1.5
+++ gnome/applet/passphrase-dialog.c 23 Jun 2005 01:54:44 -0000
@@ -27,6 +27,7 @@
#include <gtk/gtk.h>
#include <glade/glade.h>
#include <glib.h>
+#include <gnome-keyring.h>
#include <glib/gi18n.h>
#include <dbus/dbus.h>
#include <dbus/dbus-glib.h>
@@ -236,13 +237,39 @@
g_free (key);
if (gconf_entry)
{
+ GnomeKeyringAttributeList *attributes;
+ GnomeKeyringAttribute attr;
+ GnomeKeyringResult ret;
+ const char *essid, *name;
+ guint32 item_id;
+
+ essid = wireless_network_get_essid (net);
+ name = g_strdup_printf (_("Passphrase for wireless network %s"), essid);
+
+ attributes = gnome_keyring_attribute_list_new ();
+ attr.name = g_strdup ("essid");
+ attr.type = GNOME_KEYRING_ATTRIBUTE_TYPE_STRING;
+ attr.value.string = g_strdup (essid);
+ g_array_append_val (attributes, attr);
+
+ ret = gnome_keyring_item_create_sync (NULL,
+ GNOME_KEYRING_ITEM_GENERIC_SECRET,
+ name,
+ attributes,
+ passphrase,
+ TRUE,
+ &item_id);
+ if (ret != GNOME_KEYRING_RESULT_OK)
+ g_warning ("Error saving passphrase in keyring. Ret=%d", ret);
+ else
+ gnome_keyring_attribute_list_free (attributes);
+
gconf_entry_unref (gconf_entry);
- key = g_strdup_printf ("%s/%s/key", GCONF_PATH_WIRELESS_NETWORKS, escaped_network);
- gconf_client_set_string (applet->gconf_client, key, passphrase, NULL);
- g_free (key);
+
key = g_strdup_printf ("%s/%s/essid", GCONF_PATH_WIRELESS_NETWORKS, escaped_network);
- gconf_client_set_string (applet->gconf_client, key, wireless_network_get_essid (net), NULL);
+ gconf_client_set_string (applet->gconf_client, key, essid, NULL);
g_free (key);
+
key = g_strdup_printf ("%s/%s/key_type", GCONF_PATH_WIRELESS_NETWORKS, escaped_network);
gconf_client_set_int (applet->gconf_client, key, key_type_return, NULL);
g_free (key);
@@ -428,7 +455,7 @@
nmwa_schedule_warning_dialog (applet, _("The NetworkManager Applet could not find some required resources (the glade file was not found)."));
return NULL;
}
-
+
dialog = glade_xml_get_widget (dialog_xml, "passphrase_dialog");
gtk_widget_hide (dialog);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]