NetworkManager r4097 - in trunk/vpn-daemons/openvpn: . auth-dialog common-gnome properties



Author: dcbw
Date: Wed Sep 24 19:03:07 2008
New Revision: 4097
URL: http://svn.gnome.org/viewvc/NetworkManager?rev=4097&view=rev

Log:
2008-09-24  Dan Williams  <dcbw redhat com>

	* common-gnome/*
	  auth-dialog/Makefile.am
	  properties/Makefile.am
		- Add the keyring helpers that Tambet forgot in the last commit :)



Added:
   trunk/vpn-daemons/openvpn/common-gnome/
   trunk/vpn-daemons/openvpn/common-gnome/Makefile.am
   trunk/vpn-daemons/openvpn/common-gnome/keyring-helpers.c
   trunk/vpn-daemons/openvpn/common-gnome/keyring-helpers.h
Modified:
   trunk/vpn-daemons/openvpn/ChangeLog
   trunk/vpn-daemons/openvpn/auth-dialog/Makefile.am
   trunk/vpn-daemons/openvpn/properties/Makefile.am

Modified: trunk/vpn-daemons/openvpn/auth-dialog/Makefile.am
==============================================================================
--- trunk/vpn-daemons/openvpn/auth-dialog/Makefile.am	(original)
+++ trunk/vpn-daemons/openvpn/auth-dialog/Makefile.am	Wed Sep 24 19:03:07 2008
@@ -5,6 +5,8 @@
 	$(GTK_CFLAGS)				\
 	$(LIBGNOMEUI_CFLAGS)			\
 	$(NETWORK_MANAGER_CFLAGS)		\
+	$(GNOMEKEYRING_CFLAGS) \
+	-I$(top_srcdir)/
 	-DICONDIR=\""$(datadir)/pixmaps"\"	\
 	-DGLADEDIR=\""$(gladedir)"\"		\
 	-DBINDIR=\""$(bindir)"\"		\

Added: trunk/vpn-daemons/openvpn/common-gnome/Makefile.am
==============================================================================
--- (empty file)
+++ trunk/vpn-daemons/openvpn/common-gnome/Makefile.am	Wed Sep 24 19:03:07 2008
@@ -0,0 +1,15 @@
+lib_LTLIBRARIES=libnm-openvpn-common-gnome.la
+
+libnm_openvpn_common_gnome_la_CPPFLAGS = \
+	$(NETWORK_MANAGER_CFLAGS) \
+	$(GNOMEKEYRING_CFLAGS) \
+	-DG_DISABLE_DEPRECATED
+
+libnm_openvpn_common_gnome_la_SOURCES= \
+	keyring-helpers.c \
+	keyring-helpers.h
+
+libnm_openvpn_common_gnome_la_LIBADD = \
+	$(NETWORK_MANAGER_LIBS) \
+	$(GNOMEKEYRING_LIBS)
+

Added: trunk/vpn-daemons/openvpn/common-gnome/keyring-helpers.c
==============================================================================
--- (empty file)
+++ trunk/vpn-daemons/openvpn/common-gnome/keyring-helpers.c	Wed Sep 24 19:03:07 2008
@@ -0,0 +1,156 @@
+/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
+/* NetworkManager Wireless Applet -- Display wireless access points and allow user control
+ *
+ * Dan Williams <dcbw redhat com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * (C) Copyright 2004 - 2008 Red Hat, Inc.
+ */
+
+#include <string.h>
+#include <gnome-keyring-memory.h>
+
+#include <nm-setting-vpn.h>
+
+#include "keyring-helpers.h"
+#include "../src/nm-openvpn-service.h"
+
+#define KEYRING_UUID_TAG "connection-uuid"
+#define KEYRING_SN_TAG "setting-name"
+#define KEYRING_SK_TAG "setting-key"
+
+char *
+keyring_helpers_lookup_secret (const char *vpn_uuid,
+							   const char *secret_name,
+							   gboolean *is_session)
+{
+	GList *found_list = NULL;
+	GnomeKeyringResult ret;
+	GnomeKeyringFound *found;
+	char *secret;
+
+	ret = gnome_keyring_find_itemsv_sync (GNOME_KEYRING_ITEM_GENERIC_SECRET,
+	                                      &found_list,
+	                                      KEYRING_UUID_TAG,
+	                                      GNOME_KEYRING_ATTRIBUTE_TYPE_STRING,
+	                                      vpn_uuid,
+	                                      KEYRING_SN_TAG,
+	                                      GNOME_KEYRING_ATTRIBUTE_TYPE_STRING,
+	                                      NM_SETTING_VPN_SETTING_NAME,
+	                                      KEYRING_SK_TAG,
+	                                      GNOME_KEYRING_ATTRIBUTE_TYPE_STRING,
+	                                      secret_name,
+	                                      NULL);
+	if ((ret != GNOME_KEYRING_RESULT_OK) || (g_list_length (found_list) == 0))
+		return NULL;
+
+	found = (GnomeKeyringFound *) found_list->data;
+
+	if (strcmp (found->keyring, "session") == 0)
+		*is_session = TRUE;
+	else
+		*is_session = FALSE;
+
+	secret = found->secret ? g_strdup (found->secret) : NULL;
+	gnome_keyring_found_list_free (found_list);
+
+	return secret;
+}
+
+GnomeKeyringResult
+keyring_helpers_save_secret (const char *vpn_uuid,
+                             const char *vpn_name,
+                             const char *keyring,
+                             const char *secret_name,
+                             const char *secret)
+{
+	char *display_name;
+	GnomeKeyringResult ret;
+	GnomeKeyringAttributeList *attrs = NULL;
+	guint32 id = 0;
+
+	display_name = g_strdup_printf ("VPN %s secret for %s/%s/" NM_SETTING_VPN_SETTING_NAME,
+	                                secret_name,
+	                                vpn_name,
+	                                NM_DBUS_SERVICE_OPENVPN);
+
+	attrs = gnome_keyring_attribute_list_new ();
+	gnome_keyring_attribute_list_append_string (attrs,
+	                                            KEYRING_UUID_TAG,
+	                                            vpn_uuid);
+	gnome_keyring_attribute_list_append_string (attrs,
+	                                            KEYRING_SN_TAG,
+	                                            NM_SETTING_VPN_SETTING_NAME);
+	gnome_keyring_attribute_list_append_string (attrs,
+	                                            KEYRING_SK_TAG,
+	                                            secret_name);
+
+	ret = gnome_keyring_item_create_sync (keyring,
+	                                      GNOME_KEYRING_ITEM_GENERIC_SECRET,
+	                                      display_name,
+	                                      attrs,
+	                                      secret,
+	                                      TRUE,
+	                                      &id);
+	gnome_keyring_attribute_list_free (attrs);
+	g_free (display_name);
+	return ret;
+}
+
+static void
+ignore_callback (GnomeKeyringResult result, gpointer data)
+{
+}
+
+gboolean
+keyring_helpers_delete_secret (const char *vpn_uuid,
+                               const char *secret_name)
+{
+	GList *found = NULL, *iter;
+	GnomeKeyringResult ret;
+
+	g_return_val_if_fail (vpn_uuid != NULL, FALSE);
+	g_return_val_if_fail (secret_name != NULL, FALSE);
+
+	ret = gnome_keyring_find_itemsv_sync (GNOME_KEYRING_ITEM_GENERIC_SECRET,
+	                                      &found,
+	                                      KEYRING_UUID_TAG,
+	                                      GNOME_KEYRING_ATTRIBUTE_TYPE_STRING,
+	                                      vpn_uuid,
+	                                      KEYRING_SN_TAG,
+	                                      GNOME_KEYRING_ATTRIBUTE_TYPE_STRING,
+	                                      NM_SETTING_VPN_SETTING_NAME,
+	                                      KEYRING_SK_TAG,
+	                                      GNOME_KEYRING_ATTRIBUTE_TYPE_STRING,
+	                                      secret_name,
+	                                      NULL);
+	if (ret != GNOME_KEYRING_RESULT_OK && ret != GNOME_KEYRING_RESULT_NO_MATCH)
+		return FALSE;
+	if (g_list_length (found) == 0)
+		return TRUE;
+
+	/* delete them all */
+	for (iter = found; iter; iter = g_list_next (iter)) {
+		GnomeKeyringFound *item = (GnomeKeyringFound *) iter->data;
+
+		gnome_keyring_item_delete (item->keyring, item->item_id,
+		                           ignore_callback, NULL, NULL);
+	}
+
+	gnome_keyring_found_list_free (found);
+	return TRUE;
+}
+

Added: trunk/vpn-daemons/openvpn/common-gnome/keyring-helpers.h
==============================================================================
--- (empty file)
+++ trunk/vpn-daemons/openvpn/common-gnome/keyring-helpers.h	Wed Sep 24 19:03:07 2008
@@ -0,0 +1,43 @@
+/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
+/* NetworkManager Wireless Applet -- Display wireless access points and allow user control
+ *
+ * Dan Williams <dcbw redhat com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * (C) Copyright 2004 - 2008 Red Hat, Inc.
+ */
+
+#ifndef KEYRING_HELPERS_H
+#define KEYRING_HELPERS_H
+
+#include <glib.h>
+#include <gnome-keyring.h>
+
+char *keyring_helpers_lookup_secret (const char *vpn_uuid,
+									 const char *secret_name,
+									 gboolean *is_session);
+
+GnomeKeyringResult keyring_helpers_save_secret (const char *vpn_uuid,
+                                                const char *vpn_name,
+                                                const char *keyring,
+                                                const char *secret_name,
+                                                const char *secret);
+
+gboolean keyring_helpers_delete_secret (const char *vpn_uuid,
+                                        const char *secret_name);
+
+#endif  /* KEYRING_HELPERS_H */
+

Modified: trunk/vpn-daemons/openvpn/properties/Makefile.am
==============================================================================
--- trunk/vpn-daemons/openvpn/properties/Makefile.am	(original)
+++ trunk/vpn-daemons/openvpn/properties/Makefile.am	Wed Sep 24 19:03:07 2008
@@ -18,6 +18,8 @@
         $(GCONF_CFLAGS)                                 \
         $(LIBGNOMEUI_CFLAGS)                            \
         $(NETWORK_MANAGER_CFLAGS)                       \
+        $(GNOMEKEYRING_CFLAGS)                          \
+        -I$(top_srcdir)/                                \
         -DICONDIR=\""$(datadir)/pixmaps"\"              \
         -DGLADEDIR=\""$(gladedir)"\"                    \
         -DG_DISABLE_DEPRECATED                          \
@@ -32,7 +34,7 @@
         $(GCONF_LIBS)                   \
         $(LIBGNOMEUI_LIBS)              \
         $(NETWORK_MANAGER_LIBS)         \
-	$(top_builddir)/common-gnome/libnm-openvpn-common-gnome.la
+        $(top_builddir)/common-gnome/libnm-openvpn-common-gnome.la
 
 libnm_openvpn_properties_la_LDFLAGS =   \
         -avoid-version



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]