2008-10-12 Dan Williams <dcbw@redhat.com>
Patch from Bin Li <libin.charles@gmail.com>, based on patches by Tambet (openvpn) and Dan (vpnc) * common-gnome/* - Copy over common keyring functions * auth-dialog/Makefile.am auth-dialog/main.c - Use common keyring functions * properties/Makefile.am properties/nm-pptp-dialog.glade properties/nm-pptp.c properties/nm-pptp.h - Add a 'password' entry and read/write the password when appropriate git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@4175 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
This commit is contained in:
@@ -1,3 +1,21 @@
|
|||||||
|
2008-10-12 Dan Williams <dcbw@redhat.com>
|
||||||
|
|
||||||
|
Patch from Bin Li <libin.charles@gmail.com>, based on patches by Tambet
|
||||||
|
(openvpn) and Dan (vpnc)
|
||||||
|
|
||||||
|
* common-gnome/*
|
||||||
|
- Copy over common keyring functions
|
||||||
|
|
||||||
|
* auth-dialog/Makefile.am
|
||||||
|
auth-dialog/main.c
|
||||||
|
- Use common keyring functions
|
||||||
|
|
||||||
|
* properties/Makefile.am
|
||||||
|
properties/nm-pptp-dialog.glade
|
||||||
|
properties/nm-pptp.c
|
||||||
|
properties/nm-pptp.h
|
||||||
|
- Add a 'password' entry and read/write the password when appropriate
|
||||||
|
|
||||||
2008-09-29 Dan Williams <dcbw@redhat.com>
|
2008-09-29 Dan Williams <dcbw@redhat.com>
|
||||||
|
|
||||||
* properties/nm-pptp-dialog.glade
|
* properties/nm-pptp-dialog.glade
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
AUTOMAKE_OPTIONS = foreign
|
AUTOMAKE_OPTIONS = foreign
|
||||||
|
|
||||||
if WITH_GNOME
|
if WITH_GNOME
|
||||||
SUBDIRS = src auth-dialog properties po
|
SUBDIRS = src common-gnome auth-dialog properties po
|
||||||
else
|
else
|
||||||
SUBDIRS = src
|
SUBDIRS = src
|
||||||
endif
|
endif
|
||||||
|
@@ -28,7 +28,7 @@ nm_pptp_auth_dialog_SOURCES = \
|
|||||||
nm_pptp_auth_dialog_LDADD = \
|
nm_pptp_auth_dialog_LDADD = \
|
||||||
$(GTK_LIBS) \
|
$(GTK_LIBS) \
|
||||||
$(LIBGNOMEUI_LIBS) \
|
$(LIBGNOMEUI_LIBS) \
|
||||||
$(GNOMEKEYRING_LIBS) \
|
$(top_builddir)/common-gnome/libnm-pptp-common-gnome.la \
|
||||||
$(NULL)
|
$(NULL)
|
||||||
|
|
||||||
CLEANFILES = *~
|
CLEANFILES = *~
|
||||||
|
@@ -28,95 +28,17 @@
|
|||||||
#include <glib/gi18n.h>
|
#include <glib/gi18n.h>
|
||||||
#include <gtk/gtk.h>
|
#include <gtk/gtk.h>
|
||||||
#include <libgnomeui/libgnomeui.h>
|
#include <libgnomeui/libgnomeui.h>
|
||||||
#include <gnome-keyring.h>
|
|
||||||
|
|
||||||
#include <nm-setting-vpn.h>
|
#include <nm-setting-vpn.h>
|
||||||
|
|
||||||
#include "../src/nm-pptp-service.h"
|
#include "src/nm-pptp-service.h"
|
||||||
|
#include "common-gnome/keyring-helpers.h"
|
||||||
#include "gnome-two-password-dialog.h"
|
#include "gnome-two-password-dialog.h"
|
||||||
|
|
||||||
#define KEYRING_UUID_TAG "connection-uuid"
|
#define KEYRING_UUID_TAG "connection-uuid"
|
||||||
#define KEYRING_SN_TAG "setting-name"
|
#define KEYRING_SN_TAG "setting-name"
|
||||||
#define KEYRING_SK_TAG "setting-key"
|
#define KEYRING_SK_TAG "setting-key"
|
||||||
|
|
||||||
static char *
|
|
||||||
find_one_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;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
save_vpn_password (const char *vpn_uuid,
|
|
||||||
const char *vpn_name,
|
|
||||||
const char *vpn_service,
|
|
||||||
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,
|
|
||||||
vpn_service);
|
|
||||||
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
get_secrets (const char *vpn_uuid,
|
get_secrets (const char *vpn_uuid,
|
||||||
const char *vpn_name,
|
const char *vpn_name,
|
||||||
@@ -133,7 +55,7 @@ get_secrets (const char *vpn_uuid,
|
|||||||
g_return_val_if_fail (password != NULL, FALSE);
|
g_return_val_if_fail (password != NULL, FALSE);
|
||||||
g_return_val_if_fail (*password == NULL, FALSE);
|
g_return_val_if_fail (*password == NULL, FALSE);
|
||||||
|
|
||||||
*password = find_one_secret (vpn_uuid, "password", &is_session);
|
*password = keyring_helpers_lookup_secret (vpn_uuid, NM_PPTP_KEY_PASSWORD, &is_session);
|
||||||
if (!retry && *password)
|
if (!retry && *password)
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
|
||||||
@@ -167,19 +89,28 @@ get_secrets (const char *vpn_uuid,
|
|||||||
gtk_widget_show (GTK_WIDGET (dialog));
|
gtk_widget_show (GTK_WIDGET (dialog));
|
||||||
|
|
||||||
if (gnome_two_password_dialog_run_and_block (dialog)) {
|
if (gnome_two_password_dialog_run_and_block (dialog)) {
|
||||||
|
const char *keyring = NULL;
|
||||||
|
gboolean save = FALSE;
|
||||||
|
|
||||||
*password = gnome_two_password_dialog_get_password (dialog);
|
*password = gnome_two_password_dialog_get_password (dialog);
|
||||||
|
|
||||||
switch (gnome_two_password_dialog_get_remember (dialog)) {
|
switch (gnome_two_password_dialog_get_remember (dialog)) {
|
||||||
case GNOME_TWO_PASSWORD_DIALOG_REMEMBER_SESSION:
|
case GNOME_TWO_PASSWORD_DIALOG_REMEMBER_SESSION:
|
||||||
save_vpn_password (vpn_uuid, vpn_name, vpn_service, "session", "password", *password);
|
keyring = "session";
|
||||||
break;
|
/* Fall through */
|
||||||
case GNOME_TWO_PASSWORD_DIALOG_REMEMBER_FOREVER:
|
case GNOME_TWO_PASSWORD_DIALOG_REMEMBER_FOREVER:
|
||||||
save_vpn_password (vpn_uuid, vpn_name, vpn_service, NULL, "password", *password);
|
save = TRUE;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (save) {
|
||||||
|
if (*password) {
|
||||||
|
keyring_helpers_save_secret (vpn_uuid, vpn_name, keyring,
|
||||||
|
NM_PPTP_KEY_PASSWORD, *password);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
gtk_widget_hide (GTK_WIDGET (dialog));
|
gtk_widget_hide (GTK_WIDGET (dialog));
|
||||||
|
17
vpn-daemons/pptp/common-gnome/Makefile.am
Normal file
17
vpn-daemons/pptp/common-gnome/Makefile.am
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
lib_LTLIBRARIES=libnm-pptp-common-gnome.la
|
||||||
|
|
||||||
|
libnm_pptp_common_gnome_la_CPPFLAGS = \
|
||||||
|
$(NM_UTILS_CFLAGS) \
|
||||||
|
$(GLIB_CFLAGS) \
|
||||||
|
$(GNOMEKEYRING_CFLAGS) \
|
||||||
|
-DG_DISABLE_DEPRECATED
|
||||||
|
|
||||||
|
libnm_pptp_common_gnome_la_SOURCES= \
|
||||||
|
keyring-helpers.c \
|
||||||
|
keyring-helpers.h
|
||||||
|
|
||||||
|
libnm_pptp_common_gnome_la_LIBADD = \
|
||||||
|
$(NM_UTILS_LIBS) \
|
||||||
|
$(GLIB_LIBS) \
|
||||||
|
$(GNOMEKEYRING_LIBS)
|
||||||
|
|
158
vpn-daemons/pptp/common-gnome/keyring-helpers.c
Normal file
158
vpn-daemons/pptp/common-gnome/keyring-helpers.c
Normal file
@@ -0,0 +1,158 @@
|
|||||||
|
/* -*- 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-pptp-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 (is_session) {
|
||||||
|
if (strcmp (found->keyring, "session") == 0)
|
||||||
|
*is_session = TRUE;
|
||||||
|
else
|
||||||
|
*is_session = FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
secret = found->secret ? gnome_keyring_memory_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_PPTP);
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
47
vpn-daemons/pptp/common-gnome/keyring-helpers.h
Normal file
47
vpn-daemons/pptp/common-gnome/keyring-helpers.h
Normal file
@@ -0,0 +1,47 @@
|
|||||||
|
/* -*- 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>
|
||||||
|
#include <gnome-keyring-memory.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 */
|
||||||
|
|
@@ -134,6 +134,7 @@ fi
|
|||||||
AC_OUTPUT([
|
AC_OUTPUT([
|
||||||
Makefile
|
Makefile
|
||||||
src/Makefile
|
src/Makefile
|
||||||
|
common-gnome/Makefile
|
||||||
auth-dialog/Makefile
|
auth-dialog/Makefile
|
||||||
properties/Makefile
|
properties/Makefile
|
||||||
po/Makefile.in
|
po/Makefile.in
|
||||||
|
@@ -17,7 +17,8 @@ libnm_pptp_properties_la_CFLAGS = \
|
|||||||
$(GTK_CFLAGS) \
|
$(GTK_CFLAGS) \
|
||||||
$(GCONF_CFLAGS) \
|
$(GCONF_CFLAGS) \
|
||||||
$(LIBGNOMEUI_CFLAGS) \
|
$(LIBGNOMEUI_CFLAGS) \
|
||||||
$(NM_UTILS_CFLAGS) \
|
$(GNOMEKEYRING_CFLAGS) \
|
||||||
|
$(NM_UTILS_CFLAGS) \
|
||||||
-DICONDIR=\""$(datadir)/pixmaps"\" \
|
-DICONDIR=\""$(datadir)/pixmaps"\" \
|
||||||
-DGLADEDIR=\""$(gladedir)"\" \
|
-DGLADEDIR=\""$(gladedir)"\" \
|
||||||
-DG_DISABLE_DEPRECATED \
|
-DG_DISABLE_DEPRECATED \
|
||||||
@@ -31,6 +32,7 @@ libnm_pptp_properties_la_LIBADD = \
|
|||||||
$(GTK_LIBS) \
|
$(GTK_LIBS) \
|
||||||
$(GCONF_LIBS) \
|
$(GCONF_LIBS) \
|
||||||
$(LIBGNOMEUI_LIBS) \
|
$(LIBGNOMEUI_LIBS) \
|
||||||
|
$(top_builddir)/common-gnome/libnm-pptp-common-gnome.la \
|
||||||
$(NM_UTILS_LIBS)
|
$(NM_UTILS_LIBS)
|
||||||
|
|
||||||
libnm_pptp_properties_la_LDFLAGS = \
|
libnm_pptp_properties_la_LDFLAGS = \
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||||
<!DOCTYPE glade-interface SYSTEM "glade-2.0.dtd">
|
<!DOCTYPE glade-interface SYSTEM "glade-2.0.dtd">
|
||||||
<!--Generated with glade3 3.4.4 on Tue Aug 12 07:11:36 2008 -->
|
<!--Generated with glade3 3.4.4 on Sun Oct 12 10:59:11 2008 -->
|
||||||
<glade-interface>
|
<glade-interface>
|
||||||
<widget class="GtkWindow" id="pptp-widget">
|
<widget class="GtkWindow" id="pptp-widget">
|
||||||
<property name="title" translatable="yes">window1</property>
|
<property name="title" translatable="yes">window1</property>
|
||||||
@@ -35,6 +35,17 @@
|
|||||||
<property name="n_columns">2</property>
|
<property name="n_columns">2</property>
|
||||||
<property name="column_spacing">12</property>
|
<property name="column_spacing">12</property>
|
||||||
<property name="row_spacing">6</property>
|
<property name="row_spacing">6</property>
|
||||||
|
<child>
|
||||||
|
<widget class="GtkEntry" id="gateway_entry">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="can_focus">True</property>
|
||||||
|
</widget>
|
||||||
|
<packing>
|
||||||
|
<property name="left_attach">1</property>
|
||||||
|
<property name="right_attach">2</property>
|
||||||
|
<property name="y_options"></property>
|
||||||
|
</packing>
|
||||||
|
</child>
|
||||||
<child>
|
<child>
|
||||||
<widget class="GtkLabel" id="label23">
|
<widget class="GtkLabel" id="label23">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
@@ -48,17 +59,6 @@
|
|||||||
<property name="y_options"></property>
|
<property name="y_options"></property>
|
||||||
</packing>
|
</packing>
|
||||||
</child>
|
</child>
|
||||||
<child>
|
|
||||||
<widget class="GtkEntry" id="gateway_entry">
|
|
||||||
<property name="visible">True</property>
|
|
||||||
<property name="can_focus">True</property>
|
|
||||||
</widget>
|
|
||||||
<packing>
|
|
||||||
<property name="left_attach">1</property>
|
|
||||||
<property name="right_attach">2</property>
|
|
||||||
<property name="y_options"></property>
|
|
||||||
</packing>
|
|
||||||
</child>
|
|
||||||
</widget>
|
</widget>
|
||||||
</child>
|
</child>
|
||||||
</widget>
|
</widget>
|
||||||
@@ -94,18 +94,23 @@
|
|||||||
<child>
|
<child>
|
||||||
<widget class="GtkTable" id="table3">
|
<widget class="GtkTable" id="table3">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="n_rows">2</property>
|
<property name="n_rows">4</property>
|
||||||
<property name="n_columns">2</property>
|
<property name="n_columns">2</property>
|
||||||
<property name="column_spacing">12</property>
|
<property name="column_spacing">12</property>
|
||||||
<property name="row_spacing">6</property>
|
<property name="row_spacing">6</property>
|
||||||
<child>
|
<child>
|
||||||
<widget class="GtkLabel" id="label26">
|
<placeholder/>
|
||||||
|
</child>
|
||||||
|
<child>
|
||||||
|
<widget class="GtkEntry" id="domain_entry">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="xalign">0</property>
|
<property name="can_focus">True</property>
|
||||||
<property name="label" translatable="yes">User name:</property>
|
|
||||||
</widget>
|
</widget>
|
||||||
<packing>
|
<packing>
|
||||||
<property name="x_options">GTK_SHRINK | GTK_FILL</property>
|
<property name="left_attach">1</property>
|
||||||
|
<property name="right_attach">2</property>
|
||||||
|
<property name="top_attach">3</property>
|
||||||
|
<property name="bottom_attach">4</property>
|
||||||
<property name="y_options"></property>
|
<property name="y_options"></property>
|
||||||
</packing>
|
</packing>
|
||||||
</child>
|
</child>
|
||||||
@@ -116,16 +121,33 @@
|
|||||||
<property name="label" translatable="yes">NT Domain:</property>
|
<property name="label" translatable="yes">NT Domain:</property>
|
||||||
</widget>
|
</widget>
|
||||||
<packing>
|
<packing>
|
||||||
<property name="top_attach">1</property>
|
<property name="top_attach">3</property>
|
||||||
<property name="bottom_attach">2</property>
|
<property name="bottom_attach">4</property>
|
||||||
<property name="x_options">GTK_SHRINK | GTK_FILL</property>
|
<property name="x_options">GTK_SHRINK | GTK_FILL</property>
|
||||||
<property name="y_options"></property>
|
<property name="y_options"></property>
|
||||||
</packing>
|
</packing>
|
||||||
</child>
|
</child>
|
||||||
<child>
|
<child>
|
||||||
<widget class="GtkEntry" id="domain_entry">
|
<widget class="GtkCheckButton" id="show_passwords_checkbutton">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="can_focus">True</property>
|
<property name="can_focus">True</property>
|
||||||
|
<property name="label" translatable="yes">Show password</property>
|
||||||
|
<property name="response_id">0</property>
|
||||||
|
<property name="draw_indicator">True</property>
|
||||||
|
</widget>
|
||||||
|
<packing>
|
||||||
|
<property name="left_attach">1</property>
|
||||||
|
<property name="right_attach">2</property>
|
||||||
|
<property name="top_attach">2</property>
|
||||||
|
<property name="bottom_attach">3</property>
|
||||||
|
<property name="y_options"></property>
|
||||||
|
</packing>
|
||||||
|
</child>
|
||||||
|
<child>
|
||||||
|
<widget class="GtkEntry" id="user_password_entry">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="can_focus">True</property>
|
||||||
|
<property name="visibility">False</property>
|
||||||
</widget>
|
</widget>
|
||||||
<packing>
|
<packing>
|
||||||
<property name="left_attach">1</property>
|
<property name="left_attach">1</property>
|
||||||
@@ -135,6 +157,19 @@
|
|||||||
<property name="y_options"></property>
|
<property name="y_options"></property>
|
||||||
</packing>
|
</packing>
|
||||||
</child>
|
</child>
|
||||||
|
<child>
|
||||||
|
<widget class="GtkLabel" id="label2">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="xalign">0</property>
|
||||||
|
<property name="label" translatable="yes">Password:</property>
|
||||||
|
</widget>
|
||||||
|
<packing>
|
||||||
|
<property name="top_attach">1</property>
|
||||||
|
<property name="bottom_attach">2</property>
|
||||||
|
<property name="x_options">GTK_SHRINK | GTK_FILL</property>
|
||||||
|
<property name="y_options"></property>
|
||||||
|
</packing>
|
||||||
|
</child>
|
||||||
<child>
|
<child>
|
||||||
<widget class="GtkEntry" id="user_entry">
|
<widget class="GtkEntry" id="user_entry">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
@@ -146,6 +181,17 @@
|
|||||||
<property name="y_options"></property>
|
<property name="y_options"></property>
|
||||||
</packing>
|
</packing>
|
||||||
</child>
|
</child>
|
||||||
|
<child>
|
||||||
|
<widget class="GtkLabel" id="label26">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="xalign">0</property>
|
||||||
|
<property name="label" translatable="yes">User name:</property>
|
||||||
|
</widget>
|
||||||
|
<packing>
|
||||||
|
<property name="x_options">GTK_SHRINK | GTK_FILL</property>
|
||||||
|
<property name="y_options"></property>
|
||||||
|
</packing>
|
||||||
|
</child>
|
||||||
</widget>
|
</widget>
|
||||||
</child>
|
</child>
|
||||||
</widget>
|
</widget>
|
||||||
|
@@ -41,7 +41,8 @@
|
|||||||
#include <nm-setting-connection.h>
|
#include <nm-setting-connection.h>
|
||||||
#include <nm-setting-ip4-config.h>
|
#include <nm-setting-ip4-config.h>
|
||||||
|
|
||||||
#include "../src/nm-pptp-service.h"
|
#include "src/nm-pptp-service.h"
|
||||||
|
#include "common-gnome/keyring-helpers.h"
|
||||||
#include "nm-pptp.h"
|
#include "nm-pptp.h"
|
||||||
#include "import-export.h"
|
#include "import-export.h"
|
||||||
#include "advanced-dialog.h"
|
#include "advanced-dialog.h"
|
||||||
@@ -51,6 +52,8 @@
|
|||||||
#define PPTP_PLUGIN_SERVICE NM_DBUS_SERVICE_PPTP
|
#define PPTP_PLUGIN_SERVICE NM_DBUS_SERVICE_PPTP
|
||||||
|
|
||||||
|
|
||||||
|
typedef void (*ChangedCallback) (GtkWidget *widget, gpointer user_data);
|
||||||
|
|
||||||
/************** plugin class **************/
|
/************** plugin class **************/
|
||||||
|
|
||||||
static void pptp_plugin_ui_interface_init (NMVpnPluginUiInterface *iface_class);
|
static void pptp_plugin_ui_interface_init (NMVpnPluginUiInterface *iface_class);
|
||||||
@@ -102,6 +105,8 @@ pptp_plugin_ui_error_get_type (void)
|
|||||||
static const GEnumValue values[] = {
|
static const GEnumValue values[] = {
|
||||||
/* Unknown error. */
|
/* Unknown error. */
|
||||||
ENUM_ENTRY (PPTP_PLUGIN_UI_ERROR_UNKNOWN, "UnknownError"),
|
ENUM_ENTRY (PPTP_PLUGIN_UI_ERROR_UNKNOWN, "UnknownError"),
|
||||||
|
/* The connection was missing invalid. */
|
||||||
|
ENUM_ENTRY (PPTP_PLUGIN_UI_ERROR_INVALID_CONNECTION, "InvalidConnection"),
|
||||||
/* The specified property was invalid. */
|
/* The specified property was invalid. */
|
||||||
ENUM_ENTRY (PPTP_PLUGIN_UI_ERROR_INVALID_PROPERTY, "InvalidProperty"),
|
ENUM_ENTRY (PPTP_PLUGIN_UI_ERROR_INVALID_PROPERTY, "InvalidProperty"),
|
||||||
/* The specified property was missing and is required. */
|
/* The specified property was missing and is required. */
|
||||||
@@ -208,6 +213,85 @@ advanced_button_clicked_cb (GtkWidget *button, gpointer user_data)
|
|||||||
gtk_widget_show_all (dialog);
|
gtk_widget_show_all (dialog);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
show_toggled_cb (GtkCheckButton *button, PptpPluginUiWidget *self)
|
||||||
|
{
|
||||||
|
PptpPluginUiWidgetPrivate *priv = PPTP_PLUGIN_UI_WIDGET_GET_PRIVATE (self);
|
||||||
|
GtkWidget *widget;
|
||||||
|
gboolean visible;
|
||||||
|
|
||||||
|
visible = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (button));
|
||||||
|
|
||||||
|
widget = glade_xml_get_widget (priv->xml, "user_password_entry");
|
||||||
|
g_assert (widget);
|
||||||
|
gtk_entry_set_visibility (GTK_ENTRY (widget), visible);
|
||||||
|
}
|
||||||
|
|
||||||
|
static GtkWidget *
|
||||||
|
fill_password (GladeXML *xml,
|
||||||
|
const char *widget_name,
|
||||||
|
NMConnection *connection,
|
||||||
|
const char *password_type)
|
||||||
|
{
|
||||||
|
GtkWidget *widget = NULL;
|
||||||
|
gchar *password = NULL;
|
||||||
|
|
||||||
|
widget = glade_xml_get_widget (xml, widget_name);
|
||||||
|
g_assert (widget);
|
||||||
|
|
||||||
|
if (!connection)
|
||||||
|
return widget;
|
||||||
|
|
||||||
|
password = NULL;
|
||||||
|
|
||||||
|
if (nm_connection_get_scope (connection) == NM_CONNECTION_SCOPE_SYSTEM) {
|
||||||
|
NMSettingVPN *s_vpn;
|
||||||
|
|
||||||
|
s_vpn = (NMSettingVPN *) nm_connection_get_setting (connection, NM_TYPE_SETTING_VPN);
|
||||||
|
if (s_vpn) {
|
||||||
|
const gchar *tmp = NULL;
|
||||||
|
|
||||||
|
tmp = g_hash_table_lookup (s_vpn->secrets, password_type);
|
||||||
|
if (tmp)
|
||||||
|
password = gnome_keyring_memory_strdup (tmp);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
NMSettingConnection *s_con = NULL;
|
||||||
|
gboolean unused;
|
||||||
|
|
||||||
|
s_con = NM_SETTING_CONNECTION (nm_connection_get_setting (connection, NM_TYPE_SETTING_CONNECTION));
|
||||||
|
|
||||||
|
password = keyring_helpers_lookup_secret (s_con->uuid,
|
||||||
|
password_type,
|
||||||
|
&unused);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (password) {
|
||||||
|
gtk_entry_set_text (GTK_ENTRY (widget), password);
|
||||||
|
gnome_keyring_memory_free (password);
|
||||||
|
}
|
||||||
|
|
||||||
|
return widget;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
fill_vpn_passwords (GladeXML *xml,
|
||||||
|
GtkSizeGroup *group,
|
||||||
|
NMConnection *connection,
|
||||||
|
ChangedCallback changed_cb,
|
||||||
|
gpointer user_data)
|
||||||
|
{
|
||||||
|
GtkWidget *w = NULL;
|
||||||
|
|
||||||
|
w = fill_password (xml, "user_password_entry", connection, NM_PPTP_KEY_PASSWORD);
|
||||||
|
if (w) {
|
||||||
|
gtk_size_group_add_widget (group, w);
|
||||||
|
g_signal_connect (w, "changed", G_CALLBACK (changed_cb), user_data);
|
||||||
|
} else {
|
||||||
|
nm_error ("No user_password_entry in glade file!");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
init_plugin_ui (PptpPluginUiWidget *self, NMConnection *connection, GError **error)
|
init_plugin_ui (PptpPluginUiWidget *self, NMConnection *connection, GError **error)
|
||||||
{
|
{
|
||||||
@@ -259,6 +343,14 @@ init_plugin_ui (PptpPluginUiWidget *self, NMConnection *connection, GError **err
|
|||||||
widget = glade_xml_get_widget (priv->xml, "advanced_button");
|
widget = glade_xml_get_widget (priv->xml, "advanced_button");
|
||||||
g_signal_connect (G_OBJECT (widget), "clicked", G_CALLBACK (advanced_button_clicked_cb), self);
|
g_signal_connect (G_OBJECT (widget), "clicked", G_CALLBACK (advanced_button_clicked_cb), self);
|
||||||
|
|
||||||
|
widget = glade_xml_get_widget (priv->xml, "show_passwords_checkbutton");
|
||||||
|
g_return_val_if_fail (widget != NULL, FALSE);
|
||||||
|
g_signal_connect (G_OBJECT (widget), "toggled",
|
||||||
|
(GCallback) show_toggled_cb,
|
||||||
|
self);
|
||||||
|
|
||||||
|
fill_vpn_passwords (priv->xml, priv->group, connection, stuff_changed_cb, self);
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -327,6 +419,40 @@ done:
|
|||||||
return valid;
|
return valid;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static gboolean
|
||||||
|
save_secrets (NMVpnPluginUiWidgetInterface *iface,
|
||||||
|
NMConnection *connection,
|
||||||
|
GError **error)
|
||||||
|
{
|
||||||
|
PptpPluginUiWidget *self = PPTP_PLUGIN_UI_WIDGET (iface);
|
||||||
|
PptpPluginUiWidgetPrivate *priv = PPTP_PLUGIN_UI_WIDGET_GET_PRIVATE (self);
|
||||||
|
GnomeKeyringResult ret;
|
||||||
|
NMSettingConnection *s_con;
|
||||||
|
GtkWidget *widget;
|
||||||
|
const char *str;
|
||||||
|
|
||||||
|
s_con = (NMSettingConnection *) nm_connection_get_setting (connection, NM_TYPE_SETTING_CONNECTION);
|
||||||
|
if (!s_con) {
|
||||||
|
g_set_error (error,
|
||||||
|
PPTP_PLUGIN_UI_ERROR,
|
||||||
|
PPTP_PLUGIN_UI_ERROR_INVALID_CONNECTION,
|
||||||
|
"missing 'connection' setting");
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
widget = glade_xml_get_widget (priv->xml, "user_password_entry");
|
||||||
|
g_assert (widget);
|
||||||
|
str = gtk_entry_get_text (GTK_ENTRY (widget));
|
||||||
|
if (str && strlen (str)) {
|
||||||
|
ret = keyring_helpers_save_secret (s_con->uuid, s_con->id, NULL, NM_PPTP_KEY_PASSWORD, str);
|
||||||
|
if (ret != GNOME_KEYRING_RESULT_OK)
|
||||||
|
g_warning ("%s: failed to save user password to keyring.", __func__);
|
||||||
|
} else
|
||||||
|
keyring_helpers_delete_secret (s_con->uuid, NM_PPTP_KEY_PASSWORD);
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
static NMVpnPluginUiWidgetInterface *
|
static NMVpnPluginUiWidgetInterface *
|
||||||
nm_vpn_plugin_ui_widget_interface_new (NMConnection *connection, GError **error)
|
nm_vpn_plugin_ui_widget_interface_new (NMConnection *connection, GError **error)
|
||||||
{
|
{
|
||||||
@@ -425,6 +551,30 @@ pptp_plugin_ui_widget_interface_init (NMVpnPluginUiWidgetInterface *iface_class)
|
|||||||
/* interface implementation */
|
/* interface implementation */
|
||||||
iface_class->get_widget = get_widget;
|
iface_class->get_widget = get_widget;
|
||||||
iface_class->update_connection = update_connection;
|
iface_class->update_connection = update_connection;
|
||||||
|
iface_class->save_secrets = save_secrets;
|
||||||
|
}
|
||||||
|
|
||||||
|
static gboolean
|
||||||
|
delete_connection (NMVpnPluginUiInterface *iface,
|
||||||
|
NMConnection *connection,
|
||||||
|
GError **error)
|
||||||
|
{
|
||||||
|
NMSettingConnection *s_con = NULL;
|
||||||
|
|
||||||
|
/* Remove any secrets in the keyring associated with this connection's UUID */
|
||||||
|
s_con = (NMSettingConnection *) nm_connection_get_setting (connection,
|
||||||
|
NM_TYPE_SETTING_CONNECTION);
|
||||||
|
if (!s_con) {
|
||||||
|
g_set_error (error,
|
||||||
|
PPTP_PLUGIN_UI_ERROR,
|
||||||
|
PPTP_PLUGIN_UI_ERROR_INVALID_CONNECTION,
|
||||||
|
"missing 'connection' setting");
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
keyring_helpers_delete_secret (s_con->uuid, NM_PPTP_KEY_PASSWORD);
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static NMConnection *
|
static NMConnection *
|
||||||
@@ -562,6 +712,7 @@ pptp_plugin_ui_interface_init (NMVpnPluginUiInterface *iface_class)
|
|||||||
iface_class->import = import;
|
iface_class->import = import;
|
||||||
iface_class->export = export;
|
iface_class->export = export;
|
||||||
iface_class->get_suggested_name = get_suggested_name;
|
iface_class->get_suggested_name = get_suggested_name;
|
||||||
|
iface_class->delete_connection = delete_connection;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@@ -28,6 +28,7 @@
|
|||||||
typedef enum
|
typedef enum
|
||||||
{
|
{
|
||||||
PPTP_PLUGIN_UI_ERROR_UNKNOWN = 0,
|
PPTP_PLUGIN_UI_ERROR_UNKNOWN = 0,
|
||||||
|
PPTP_PLUGIN_UI_ERROR_INVALID_CONNECTION,
|
||||||
PPTP_PLUGIN_UI_ERROR_INVALID_PROPERTY,
|
PPTP_PLUGIN_UI_ERROR_INVALID_PROPERTY,
|
||||||
PPTP_PLUGIN_UI_ERROR_MISSING_PROPERTY,
|
PPTP_PLUGIN_UI_ERROR_MISSING_PROPERTY,
|
||||||
PPTP_PLUGIN_UI_ERROR_FILE_NOT_READABLE,
|
PPTP_PLUGIN_UI_ERROR_FILE_NOT_READABLE,
|
||||||
|
Reference in New Issue
Block a user