mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-04-20 11:50:43 +02:00
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 :) git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@4097 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
This commit is contained in:
parent
ec7186d75f
commit
05f1b0a041
6 changed files with 226 additions and 1 deletions
|
|
@ -1,3 +1,10 @@
|
|||
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 :)
|
||||
|
||||
2008-09-24 Tambet Ingo <tambet@gmail.com>
|
||||
|
||||
* properties/nm-openvpn-dialog.glade: Add "show passwords" checkbox.
|
||||
|
|
|
|||
|
|
@ -5,6 +5,8 @@ nm_openvpn_auth_dialog_CPPFLAGS = \
|
|||
$(GTK_CFLAGS) \
|
||||
$(LIBGNOMEUI_CFLAGS) \
|
||||
$(NETWORK_MANAGER_CFLAGS) \
|
||||
$(GNOMEKEYRING_CFLAGS) \
|
||||
-I$(top_srcdir)/
|
||||
-DICONDIR=\""$(datadir)/pixmaps"\" \
|
||||
-DGLADEDIR=\""$(gladedir)"\" \
|
||||
-DBINDIR=\""$(bindir)"\" \
|
||||
|
|
|
|||
15
vpn-daemons/openvpn/common-gnome/Makefile.am
Normal file
15
vpn-daemons/openvpn/common-gnome/Makefile.am
Normal file
|
|
@ -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)
|
||||
|
||||
156
vpn-daemons/openvpn/common-gnome/keyring-helpers.c
Normal file
156
vpn-daemons/openvpn/common-gnome/keyring-helpers.c
Normal file
|
|
@ -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;
|
||||
}
|
||||
|
||||
43
vpn-daemons/openvpn/common-gnome/keyring-helpers.h
Normal file
43
vpn-daemons/openvpn/common-gnome/keyring-helpers.h
Normal file
|
|
@ -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 */
|
||||
|
||||
|
|
@ -18,6 +18,8 @@ libnm_openvpn_properties_la_CFLAGS = \
|
|||
$(GCONF_CFLAGS) \
|
||||
$(LIBGNOMEUI_CFLAGS) \
|
||||
$(NETWORK_MANAGER_CFLAGS) \
|
||||
$(GNOMEKEYRING_CFLAGS) \
|
||||
-I$(top_srcdir)/ \
|
||||
-DICONDIR=\""$(datadir)/pixmaps"\" \
|
||||
-DGLADEDIR=\""$(gladedir)"\" \
|
||||
-DG_DISABLE_DEPRECATED \
|
||||
|
|
@ -32,7 +34,7 @@ libnm_openvpn_properties_la_LIBADD = \
|
|||
$(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
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue