diff --git a/vpn-daemons/pptp/ChangeLog b/vpn-daemons/pptp/ChangeLog index c85066e5d..5baa51a26 100644 --- a/vpn-daemons/pptp/ChangeLog +++ b/vpn-daemons/pptp/ChangeLog @@ -1,3 +1,21 @@ +2008-10-12 Dan Williams + + Patch from Bin Li , 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 * properties/nm-pptp-dialog.glade diff --git a/vpn-daemons/pptp/Makefile.am b/vpn-daemons/pptp/Makefile.am index df8e8f57b..685686f3e 100644 --- a/vpn-daemons/pptp/Makefile.am +++ b/vpn-daemons/pptp/Makefile.am @@ -1,7 +1,7 @@ AUTOMAKE_OPTIONS = foreign if WITH_GNOME -SUBDIRS = src auth-dialog properties po +SUBDIRS = src common-gnome auth-dialog properties po else SUBDIRS = src endif diff --git a/vpn-daemons/pptp/auth-dialog/Makefile.am b/vpn-daemons/pptp/auth-dialog/Makefile.am index 1afa647b9..28aaf7f69 100644 --- a/vpn-daemons/pptp/auth-dialog/Makefile.am +++ b/vpn-daemons/pptp/auth-dialog/Makefile.am @@ -28,7 +28,7 @@ nm_pptp_auth_dialog_SOURCES = \ nm_pptp_auth_dialog_LDADD = \ $(GTK_LIBS) \ $(LIBGNOMEUI_LIBS) \ - $(GNOMEKEYRING_LIBS) \ + $(top_builddir)/common-gnome/libnm-pptp-common-gnome.la \ $(NULL) CLEANFILES = *~ diff --git a/vpn-daemons/pptp/auth-dialog/main.c b/vpn-daemons/pptp/auth-dialog/main.c index 5cd1062c4..53d101987 100644 --- a/vpn-daemons/pptp/auth-dialog/main.c +++ b/vpn-daemons/pptp/auth-dialog/main.c @@ -28,95 +28,17 @@ #include #include #include -#include #include -#include "../src/nm-pptp-service.h" +#include "src/nm-pptp-service.h" +#include "common-gnome/keyring-helpers.h" #include "gnome-two-password-dialog.h" #define KEYRING_UUID_TAG "connection-uuid" #define KEYRING_SN_TAG "setting-name" #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 get_secrets (const char *vpn_uuid, 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); - *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) return TRUE; @@ -167,19 +89,28 @@ get_secrets (const char *vpn_uuid, gtk_widget_show (GTK_WIDGET (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); switch (gnome_two_password_dialog_get_remember (dialog)) { case GNOME_TWO_PASSWORD_DIALOG_REMEMBER_SESSION: - save_vpn_password (vpn_uuid, vpn_name, vpn_service, "session", "password", *password); - break; + keyring = "session"; + /* Fall through */ case GNOME_TWO_PASSWORD_DIALOG_REMEMBER_FOREVER: - save_vpn_password (vpn_uuid, vpn_name, vpn_service, NULL, "password", *password); + save = TRUE; break; default: 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)); diff --git a/vpn-daemons/pptp/common-gnome/Makefile.am b/vpn-daemons/pptp/common-gnome/Makefile.am new file mode 100644 index 000000000..4a5d6c7a2 --- /dev/null +++ b/vpn-daemons/pptp/common-gnome/Makefile.am @@ -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) + diff --git a/vpn-daemons/pptp/common-gnome/keyring-helpers.c b/vpn-daemons/pptp/common-gnome/keyring-helpers.c new file mode 100644 index 000000000..cfb10ef32 --- /dev/null +++ b/vpn-daemons/pptp/common-gnome/keyring-helpers.c @@ -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 + * + * 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 +#include + +#include + +#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; +} + diff --git a/vpn-daemons/pptp/common-gnome/keyring-helpers.h b/vpn-daemons/pptp/common-gnome/keyring-helpers.h new file mode 100644 index 000000000..76040a3f5 --- /dev/null +++ b/vpn-daemons/pptp/common-gnome/keyring-helpers.h @@ -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 + * + * 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 +#include +#include + +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 */ + diff --git a/vpn-daemons/pptp/configure.in b/vpn-daemons/pptp/configure.in index 2794893a8..85719e448 100644 --- a/vpn-daemons/pptp/configure.in +++ b/vpn-daemons/pptp/configure.in @@ -134,6 +134,7 @@ fi AC_OUTPUT([ Makefile src/Makefile +common-gnome/Makefile auth-dialog/Makefile properties/Makefile po/Makefile.in diff --git a/vpn-daemons/pptp/properties/Makefile.am b/vpn-daemons/pptp/properties/Makefile.am index 3cf7472fe..ec20add98 100644 --- a/vpn-daemons/pptp/properties/Makefile.am +++ b/vpn-daemons/pptp/properties/Makefile.am @@ -17,7 +17,8 @@ libnm_pptp_properties_la_CFLAGS = \ $(GTK_CFLAGS) \ $(GCONF_CFLAGS) \ $(LIBGNOMEUI_CFLAGS) \ - $(NM_UTILS_CFLAGS) \ + $(GNOMEKEYRING_CFLAGS) \ + $(NM_UTILS_CFLAGS) \ -DICONDIR=\""$(datadir)/pixmaps"\" \ -DGLADEDIR=\""$(gladedir)"\" \ -DG_DISABLE_DEPRECATED \ @@ -31,6 +32,7 @@ libnm_pptp_properties_la_LIBADD = \ $(GTK_LIBS) \ $(GCONF_LIBS) \ $(LIBGNOMEUI_LIBS) \ + $(top_builddir)/common-gnome/libnm-pptp-common-gnome.la \ $(NM_UTILS_LIBS) libnm_pptp_properties_la_LDFLAGS = \ diff --git a/vpn-daemons/pptp/properties/nm-pptp-dialog.glade b/vpn-daemons/pptp/properties/nm-pptp-dialog.glade index fb6355a45..59e184e8d 100644 --- a/vpn-daemons/pptp/properties/nm-pptp-dialog.glade +++ b/vpn-daemons/pptp/properties/nm-pptp-dialog.glade @@ -1,6 +1,6 @@ - + window1 @@ -35,6 +35,17 @@ 2 12 6 + + + True + True + + + 1 + 2 + + + True @@ -48,17 +59,6 @@ - - - True - True - - - 1 - 2 - - - @@ -94,18 +94,23 @@ True - 2 + 4 2 12 6 - + + + + True - 0 - User name: + True - GTK_SHRINK | GTK_FILL + 1 + 2 + 3 + 4 @@ -116,16 +121,33 @@ NT Domain: - 1 - 2 + 3 + 4 GTK_SHRINK | GTK_FILL - + True True + Show password + 0 + True + + + 1 + 2 + 2 + 3 + + + + + + True + True + False 1 @@ -135,6 +157,19 @@ + + + True + 0 + Password: + + + 1 + 2 + GTK_SHRINK | GTK_FILL + + + True @@ -146,6 +181,17 @@ + + + True + 0 + User name: + + + GTK_SHRINK | GTK_FILL + + + diff --git a/vpn-daemons/pptp/properties/nm-pptp.c b/vpn-daemons/pptp/properties/nm-pptp.c index 31df47811..63cb81ee5 100644 --- a/vpn-daemons/pptp/properties/nm-pptp.c +++ b/vpn-daemons/pptp/properties/nm-pptp.c @@ -41,7 +41,8 @@ #include #include -#include "../src/nm-pptp-service.h" +#include "src/nm-pptp-service.h" +#include "common-gnome/keyring-helpers.h" #include "nm-pptp.h" #include "import-export.h" #include "advanced-dialog.h" @@ -51,6 +52,8 @@ #define PPTP_PLUGIN_SERVICE NM_DBUS_SERVICE_PPTP +typedef void (*ChangedCallback) (GtkWidget *widget, gpointer user_data); + /************** plugin 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[] = { /* Unknown error. */ 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. */ ENUM_ENTRY (PPTP_PLUGIN_UI_ERROR_INVALID_PROPERTY, "InvalidProperty"), /* 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); } +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 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"); 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; } @@ -327,6 +419,40 @@ done: 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 * 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 */ iface_class->get_widget = get_widget; 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 * @@ -562,6 +712,7 @@ pptp_plugin_ui_interface_init (NMVpnPluginUiInterface *iface_class) iface_class->import = import; iface_class->export = export; iface_class->get_suggested_name = get_suggested_name; + iface_class->delete_connection = delete_connection; } diff --git a/vpn-daemons/pptp/properties/nm-pptp.h b/vpn-daemons/pptp/properties/nm-pptp.h index 5877f06f3..49b4a4a76 100644 --- a/vpn-daemons/pptp/properties/nm-pptp.h +++ b/vpn-daemons/pptp/properties/nm-pptp.h @@ -28,6 +28,7 @@ typedef enum { PPTP_PLUGIN_UI_ERROR_UNKNOWN = 0, + PPTP_PLUGIN_UI_ERROR_INVALID_CONNECTION, PPTP_PLUGIN_UI_ERROR_INVALID_PROPERTY, PPTP_PLUGIN_UI_ERROR_MISSING_PROPERTY, PPTP_PLUGIN_UI_ERROR_FILE_NOT_READABLE,