NetworkManager r3927 - in trunk/vpn-daemons/pptp: . auth-dialog properties src
- From: dcbw svn gnome org
- To: svn-commits-list gnome org
- Subject: NetworkManager r3927 - in trunk/vpn-daemons/pptp: . auth-dialog properties src
- Date: Mon, 11 Aug 2008 17:17:47 +0000 (UTC)
Author: dcbw
Date: Mon Aug 11 17:17:47 2008
New Revision: 3927
URL: http://svn.gnome.org/viewvc/NetworkManager?rev=3927&view=rev
Log:
2008-08-11 Dan Williams <dcbw redhat com>
Update to match NM svn3924 vpn setting changes; verify options better;
return more informative errors on VPN launch failures.
Modified:
trunk/vpn-daemons/pptp/ChangeLog
trunk/vpn-daemons/pptp/auth-dialog/main.c
trunk/vpn-daemons/pptp/properties/advanced-dialog.c
trunk/vpn-daemons/pptp/properties/import-export.c
trunk/vpn-daemons/pptp/properties/nm-pptp.c
trunk/vpn-daemons/pptp/properties/nm-pptp.h
trunk/vpn-daemons/pptp/src/nm-pptp-service.c
Modified: trunk/vpn-daemons/pptp/auth-dialog/main.c
==============================================================================
--- trunk/vpn-daemons/pptp/auth-dialog/main.c (original)
+++ trunk/vpn-daemons/pptp/auth-dialog/main.c Mon Aug 11 17:17:47 2008
@@ -30,7 +30,6 @@
#include <gnome-keyring.h>
#include <nm-setting-vpn.h>
-#include <nm-setting-vpn-properties.h>
#include "../src/nm-pptp-service.h"
#include "gnome-two-password-dialog.h"
@@ -58,7 +57,7 @@
vpn_id,
KEYRING_SN_TAG,
GNOME_KEYRING_ATTRIBUTE_TYPE_STRING,
- NM_SETTING_VPN_PROPERTIES_SETTING_NAME,
+ NM_SETTING_VPN_SETTING_NAME,
KEYRING_SK_TAG,
GNOME_KEYRING_ATTRIBUTE_TYPE_STRING,
secret_name,
@@ -105,7 +104,7 @@
GnomeKeyringAttributeList *attrs = NULL;
guint32 id = 0;
- display_name = g_strdup_printf ("VPN %s secret for %s/%s/" NM_SETTING_VPN_PROPERTIES_SETTING_NAME,
+ display_name = g_strdup_printf ("VPN %s secret for %s/%s/" NM_SETTING_VPN_SETTING_NAME,
secret_name,
vpn_name,
vpn_service);
@@ -116,7 +115,7 @@
vpn_id);
gnome_keyring_attribute_list_append_string (attrs,
KEYRING_SN_TAG,
- NM_SETTING_VPN_PROPERTIES_SETTING_NAME);
+ NM_SETTING_VPN_SETTING_NAME);
gnome_keyring_attribute_list_append_string (attrs,
KEYRING_SK_TAG,
secret_name);
Modified: trunk/vpn-daemons/pptp/properties/advanced-dialog.c
==============================================================================
--- trunk/vpn-daemons/pptp/properties/advanced-dialog.c (original)
+++ trunk/vpn-daemons/pptp/properties/advanced-dialog.c Mon Aug 11 17:17:47 2008
@@ -29,6 +29,7 @@
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
+#include <errno.h>
#include <glib.h>
#include <glib/gi18n-lib.h>
@@ -36,7 +37,6 @@
#include <nm-connection.h>
#include <nm-setting-vpn.h>
-#include <nm-setting-vpn-properties.h>
#include "advanced-dialog.h"
#include "nm-pptp.h"
@@ -51,15 +51,6 @@
#define TAG_MSCHAP 2
#define TAG_MSCHAPV2 3
-static void
-nm_gvalue_destroy (gpointer data)
-{
- GValue *value = (GValue *) data;
-
- g_value_unset (value);
- g_slice_free (GValue, value);
-}
-
static const char *advanced_keys[] = {
NM_PPTP_KEY_REFUSE_EAP,
NM_PPTP_KEY_REFUSE_PAP,
@@ -82,30 +73,13 @@
copy_values (gpointer key, gpointer data, gpointer user_data)
{
GHashTable *hash = (GHashTable *) user_data;
- GValue *value = (GValue *) data;
const char **i;
for (i = &advanced_keys[0]; *i; i++) {
if (strcmp ((const char *) key, *i))
continue;
- if (G_VALUE_HOLDS_STRING (value)) {
- g_hash_table_insert (hash,
- g_strdup ((const char *) key),
- str_to_gvalue (g_value_get_string (value)));
- } else if (G_VALUE_HOLDS_INT (value)) {
- g_hash_table_insert (hash,
- g_strdup ((const char *) key),
- int_to_gvalue (g_value_get_int (value)));
- } else if (G_VALUE_HOLDS_UINT (value)) {
- g_hash_table_insert (hash,
- g_strdup ((const char *) key),
- uint_to_gvalue (g_value_get_uint (value)));
- } else if (G_VALUE_HOLDS_BOOLEAN (value)) {
- g_hash_table_insert (hash,
- g_strdup ((const char *) key),
- bool_to_gvalue (g_value_get_boolean (value)));
- }
+ g_hash_table_insert (hash, g_strdup ((const char *) key), g_strdup ((const char *) data));
}
}
@@ -114,13 +88,13 @@
GError **error)
{
GHashTable *hash;
- NMSettingVPNProperties *s_vpn_props;
+ NMSettingVPN *s_vpn;
- hash = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, nm_gvalue_destroy);
+ hash = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free);
- s_vpn_props = (NMSettingVPNProperties *) nm_connection_get_setting (connection, NM_TYPE_SETTING_VPN_PROPERTIES);
- if (s_vpn_props && s_vpn_props->data)
- g_hash_table_foreach (s_vpn_props->data, copy_values, hash);
+ s_vpn = (NMSettingVPN *) nm_connection_get_setting (connection, NM_TYPE_SETTING_VPN);
+ if (s_vpn && s_vpn->data)
+ g_hash_table_foreach (s_vpn->data, copy_values, hash);
return hash;
}
@@ -159,7 +133,7 @@
GtkListStore *store;
GtkTreeIter iter;
int active = -1;
- GValue *value;
+ const char *value;
g_return_if_fail (xml != NULL);
g_return_if_fail (hash != NULL);
@@ -177,7 +151,7 @@
gtk_list_store_set (store, &iter, 0, _("128-bit (most secure)"), -1);
if (active < 0) {
value = g_hash_table_lookup (hash, NM_PPTP_KEY_REQUIRE_MPPE_128);
- if (value && G_VALUE_HOLDS_BOOLEAN (value) && g_value_get_boolean (value))
+ if (value && !strcmp (value, "yes"))
active = SEC_INDEX_MPPE_128;
}
@@ -186,7 +160,7 @@
gtk_list_store_set (store, &iter, 0, _("40-bit (less secure)"), -1);
if (active < 0) {
value = g_hash_table_lookup (hash, NM_PPTP_KEY_REQUIRE_MPPE_40);
- if (value && G_VALUE_HOLDS_BOOLEAN (value) && g_value_get_boolean (value))
+ if (value && !strcmp (value, "yes"))
active = SEC_INDEX_MPPE_40;
}
@@ -225,7 +199,7 @@
GtkWidget *widget;
GtkListStore *store;
GtkTreeIter iter;
- GValue *value;
+ const char *value;
gboolean allowed;
gboolean use_mppe = FALSE;
GtkCellRendererToggle *check_renderer;
@@ -237,40 +211,40 @@
/* Check for MPPE */
value = g_hash_table_lookup (hash, NM_PPTP_KEY_REQUIRE_MPPE);
- if (value && G_VALUE_HOLDS_BOOLEAN (value) && g_value_get_boolean (value))
+ if (value && !strcmp (value, "yes"))
use_mppe = TRUE;
/* Or MPPE-128 */
value = g_hash_table_lookup (hash, NM_PPTP_KEY_REQUIRE_MPPE_128);
- if (value && G_VALUE_HOLDS_BOOLEAN (value) && g_value_get_boolean (value))
+ if (value && !strcmp (value, "yes"))
use_mppe = TRUE;
/* Or MPPE-40 */
value = g_hash_table_lookup (hash, NM_PPTP_KEY_REQUIRE_MPPE_40);
- if (value && G_VALUE_HOLDS_BOOLEAN (value) && g_value_get_boolean (value))
+ if (value && !strcmp (value, "yes"))
use_mppe = TRUE;
/* PAP */
value = g_hash_table_lookup (hash, NM_PPTP_KEY_REFUSE_PAP);
- allowed = (value && G_VALUE_HOLDS_BOOLEAN (value) && g_value_get_boolean (value)) ? FALSE : TRUE;
+ allowed = (value && !strcmp (value, "yes")) ? FALSE : TRUE;
gtk_list_store_append (store, &iter);
gtk_list_store_set (store, &iter, COL_NAME, _("PAP"), COL_VALUE, allowed, COL_TAG, TAG_PAP, -1);
/* CHAP */
value = g_hash_table_lookup (hash, NM_PPTP_KEY_REFUSE_CHAP);
- allowed = (value && G_VALUE_HOLDS_BOOLEAN (value) && g_value_get_boolean (value)) ? FALSE : TRUE;
+ allowed = (value && !strcmp (value, "yes")) ? FALSE : TRUE;
gtk_list_store_append (store, &iter);
gtk_list_store_set (store, &iter, COL_NAME, _("CHAP"), COL_VALUE, allowed, COL_TAG, TAG_CHAP, -1);
/* MSCHAP */
value = g_hash_table_lookup (hash, NM_PPTP_KEY_REFUSE_MSCHAP);
- allowed = (value && G_VALUE_HOLDS_BOOLEAN (value) && g_value_get_boolean (value)) ? FALSE : TRUE;
+ allowed = (value && !strcmp (value, "yes")) ? FALSE : TRUE;
gtk_list_store_append (store, &iter);
gtk_list_store_set (store, &iter, COL_NAME, _("MSCHAP"), COL_VALUE, allowed, COL_TAG, TAG_MSCHAP, -1);
/* PAP */
value = g_hash_table_lookup (hash, NM_PPTP_KEY_REFUSE_MSCHAPV2);
- allowed = (value && G_VALUE_HOLDS_BOOLEAN (value) && g_value_get_boolean (value)) ? FALSE : TRUE;
+ allowed = (value && !strcmp (value, "yes")) ? FALSE : TRUE;
gtk_list_store_append (store, &iter);
gtk_list_store_set (store, &iter, COL_NAME, _("MSCHAPv2"), COL_VALUE, allowed, COL_TAG, TAG_MSCHAPV2, -1);
@@ -306,7 +280,7 @@
GtkWidget *dialog = NULL;
char *glade_file = NULL;
GtkWidget *widget;
- GValue *value;
+ const char *value;
g_return_val_if_fail (hash != NULL, NULL);
@@ -332,47 +306,41 @@
g_signal_connect (G_OBJECT (widget), "toggled", G_CALLBACK (mppe_toggled_cb), xml);
value = g_hash_table_lookup (hash, NM_PPTP_KEY_REQUIRE_MPPE);
- if (value && G_VALUE_HOLDS_BOOLEAN (value)) {
- if (g_value_get_boolean (value))
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (widget), TRUE);
- }
+ if (value && !strcmp (value, "yes"))
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (widget), TRUE);
mppe_toggled_cb (widget, xml);
+ widget = glade_xml_get_widget (xml, "ppp_allow_stateful_mppe");
value = g_hash_table_lookup (hash, NM_PPTP_KEY_MPPE_STATEFUL);
- if (value && G_VALUE_HOLDS_BOOLEAN (value)) {
- widget = glade_xml_get_widget (xml, "ppp_allow_stateful_mppe");
- if (g_value_get_boolean (value))
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (widget), TRUE);
- }
+ if (value && !strcmp (value, "yes"))
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (widget), TRUE);
widget = glade_xml_get_widget (xml, "ppp_allow_bsdcomp");
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (widget), TRUE);
value = g_hash_table_lookup (hash, NM_PPTP_KEY_NOBSDCOMP);
- if (value && G_VALUE_HOLDS_BOOLEAN (value)) {
- if (g_value_get_boolean (value))
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (widget), FALSE);
- }
+ if (value && !strcmp (value, "yes"))
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (widget), FALSE);
widget = glade_xml_get_widget (xml, "ppp_allow_deflate");
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (widget), TRUE);
value = g_hash_table_lookup (hash, NM_PPTP_KEY_NODEFLATE);
- if (value && G_VALUE_HOLDS_BOOLEAN (value)) {
- if (g_value_get_boolean (value))
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (widget), FALSE);
- }
+ if (value && !strcmp (value, "yes"))
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (widget), FALSE);
widget = glade_xml_get_widget (xml, "ppp_usevj");
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (widget), TRUE);
value = g_hash_table_lookup (hash, NM_PPTP_KEY_NO_VJ_COMP);
- if (value && G_VALUE_HOLDS_BOOLEAN (value)) {
- if (g_value_get_boolean (value))
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (widget), FALSE);
- }
+ if (value && !strcmp (value, "yes"))
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (widget), FALSE);
+ widget = glade_xml_get_widget (xml, "ppp_send_echo_packets");
value = g_hash_table_lookup (hash, NM_PPTP_KEY_LCP_ECHO_INTERVAL);
- if (value && G_VALUE_HOLDS_UINT (value)) {
- widget = glade_xml_get_widget (xml, "ppp_send_echo_packets");
- if (g_value_get_uint (value))
+ if (value && strlen (value)) {
+ long int tmp_int;
+
+ errno = 0;
+ tmp_int = strtol (value, NULL, 10);
+ if (errno == 0 && tmp_int > 0)
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (widget), TRUE);
}
@@ -400,7 +368,7 @@
xml = g_object_get_data (G_OBJECT (dialog), "glade-xml");
g_return_val_if_fail (xml != NULL, NULL);
- hash = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, nm_gvalue_destroy);
+ hash = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free);
widget = glade_xml_get_widget (xml, "ppp_use_mppe");
if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget))) {
@@ -408,37 +376,37 @@
widget = glade_xml_get_widget (xml, "ppp_mppe_security_combo");
switch (gtk_combo_box_get_active (GTK_COMBO_BOX (widget))) {
case SEC_INDEX_MPPE_128:
- g_hash_table_insert (hash, g_strdup (NM_PPTP_KEY_REQUIRE_MPPE_128), bool_to_gvalue (TRUE));
+ g_hash_table_insert (hash, g_strdup (NM_PPTP_KEY_REQUIRE_MPPE_128), g_strdup ("yes"));
break;
case SEC_INDEX_MPPE_40:
- g_hash_table_insert (hash, g_strdup (NM_PPTP_KEY_REQUIRE_MPPE_40), bool_to_gvalue (TRUE));
+ g_hash_table_insert (hash, g_strdup (NM_PPTP_KEY_REQUIRE_MPPE_40), g_strdup ("yes"));
break;
default:
- g_hash_table_insert (hash, g_strdup (NM_PPTP_KEY_REQUIRE_MPPE), bool_to_gvalue (TRUE));
+ g_hash_table_insert (hash, g_strdup (NM_PPTP_KEY_REQUIRE_MPPE), g_strdup ("yes"));
break;
}
widget = glade_xml_get_widget (xml, "ppp_allow_stateful_mppe");
if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget)))
- g_hash_table_insert (hash, g_strdup (NM_PPTP_KEY_MPPE_STATEFUL), bool_to_gvalue (TRUE));
+ g_hash_table_insert (hash, g_strdup (NM_PPTP_KEY_MPPE_STATEFUL), g_strdup ("yes"));
}
widget = glade_xml_get_widget (xml, "ppp_allow_bsdcomp");
if (!gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget)))
- g_hash_table_insert (hash, g_strdup (NM_PPTP_KEY_NOBSDCOMP), bool_to_gvalue (TRUE));
+ g_hash_table_insert (hash, g_strdup (NM_PPTP_KEY_NOBSDCOMP), g_strdup ("yes"));
widget = glade_xml_get_widget (xml, "ppp_allow_deflate");
if (!gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget)))
- g_hash_table_insert (hash, g_strdup (NM_PPTP_KEY_NODEFLATE), bool_to_gvalue (TRUE));
+ g_hash_table_insert (hash, g_strdup (NM_PPTP_KEY_NODEFLATE), g_strdup ("yes"));
widget = glade_xml_get_widget (xml, "ppp_usevj");
if (!gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget)))
- g_hash_table_insert (hash, g_strdup (NM_PPTP_KEY_NO_VJ_COMP), bool_to_gvalue (TRUE));
+ g_hash_table_insert (hash, g_strdup (NM_PPTP_KEY_NO_VJ_COMP), g_strdup ("yes"));
widget = glade_xml_get_widget (xml, "ppp_send_echo_packets");
if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget))) {
- g_hash_table_insert (hash, g_strdup (NM_PPTP_KEY_LCP_ECHO_FAILURE), uint_to_gvalue (5));
- g_hash_table_insert (hash, g_strdup (NM_PPTP_KEY_LCP_ECHO_INTERVAL), uint_to_gvalue (30));
+ g_hash_table_insert (hash, g_strdup (NM_PPTP_KEY_LCP_ECHO_FAILURE), g_strdup_printf ("%d", 5));
+ g_hash_table_insert (hash, g_strdup (NM_PPTP_KEY_LCP_ECHO_INTERVAL), g_strdup_printf ("%d", 30));
}
widget = glade_xml_get_widget (xml, "ppp_auth_methods");
@@ -452,19 +420,19 @@
switch (tag) {
case TAG_PAP:
if (!allowed)
- g_hash_table_insert (hash, g_strdup (NM_PPTP_KEY_REFUSE_PAP), bool_to_gvalue (TRUE));
+ g_hash_table_insert (hash, g_strdup (NM_PPTP_KEY_REFUSE_PAP), g_strdup ("yes"));
break;
case TAG_CHAP:
if (!allowed)
- g_hash_table_insert (hash, g_strdup (NM_PPTP_KEY_REFUSE_CHAP), bool_to_gvalue (TRUE));
+ g_hash_table_insert (hash, g_strdup (NM_PPTP_KEY_REFUSE_CHAP), g_strdup ("yes"));
break;
case TAG_MSCHAP:
if (!allowed)
- g_hash_table_insert (hash, g_strdup (NM_PPTP_KEY_REFUSE_MSCHAP), bool_to_gvalue (TRUE));
+ g_hash_table_insert (hash, g_strdup (NM_PPTP_KEY_REFUSE_MSCHAP), g_strdup ("yes"));
break;
case TAG_MSCHAPV2:
if (!allowed)
- g_hash_table_insert (hash, g_strdup (NM_PPTP_KEY_REFUSE_MSCHAPV2), bool_to_gvalue (TRUE));
+ g_hash_table_insert (hash, g_strdup (NM_PPTP_KEY_REFUSE_MSCHAPV2), g_strdup ("yes"));
break;
default:
break;
Modified: trunk/vpn-daemons/pptp/properties/import-export.c
==============================================================================
--- trunk/vpn-daemons/pptp/properties/import-export.c (original)
+++ trunk/vpn-daemons/pptp/properties/import-export.c Mon Aug 11 17:17:47 2008
@@ -35,7 +35,6 @@
#include <glib/gi18n-lib.h>
#include <nm-setting-vpn.h>
-#include <nm-setting-vpn-properties.h>
#include <nm-setting-connection.h>
#include <nm-setting-ip4-config.h>
Modified: trunk/vpn-daemons/pptp/properties/nm-pptp.c
==============================================================================
--- trunk/vpn-daemons/pptp/properties/nm-pptp.c (original)
+++ trunk/vpn-daemons/pptp/properties/nm-pptp.c Mon Aug 11 17:17:47 2008
@@ -38,7 +38,6 @@
#include <nm-vpn-plugin-ui-interface.h>
#include <nm-setting-vpn.h>
-#include <nm-setting-vpn-properties.h>
#include <nm-setting-connection.h>
#include <nm-setting-ip4-config.h>
@@ -213,14 +212,14 @@
init_plugin_ui (PptpPluginUiWidget *self, NMConnection *connection, GError **error)
{
PptpPluginUiWidgetPrivate *priv = PPTP_PLUGIN_UI_WIDGET_GET_PRIVATE (self);
- NMSettingVPNProperties *s_vpn_props;
+ NMSettingVPN *s_vpn;
GtkWidget *widget;
GtkListStore *store;
GtkTreeIter iter;
int active = -1;
- GValue *value;
+ const char *value;
- s_vpn_props = (NMSettingVPNProperties *) nm_connection_get_setting (connection, NM_TYPE_SETTING_VPN_PROPERTIES);
+ s_vpn = (NMSettingVPN *) nm_connection_get_setting (connection, NM_TYPE_SETTING_VPN);
priv->group = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL);
@@ -228,10 +227,10 @@
if (!widget)
return FALSE;
gtk_size_group_add_widget (priv->group, widget);
- if (s_vpn_props) {
- value = g_hash_table_lookup (s_vpn_props->data, NM_PPTP_KEY_GATEWAY);
- if (value && G_VALUE_HOLDS_STRING (value))
- gtk_entry_set_text (GTK_ENTRY (widget), g_value_get_string (value));
+ if (s_vpn) {
+ value = g_hash_table_lookup (s_vpn->data, NM_PPTP_KEY_GATEWAY);
+ if (value && strlen (value))
+ gtk_entry_set_text (GTK_ENTRY (widget), value);
}
g_signal_connect (G_OBJECT (widget), "changed", G_CALLBACK (stuff_changed_cb), self);
@@ -239,10 +238,10 @@
if (!widget)
return FALSE;
gtk_size_group_add_widget (priv->group, widget);
- if (s_vpn_props) {
- value = g_hash_table_lookup (s_vpn_props->data, NM_PPTP_KEY_USER);
- if (value && G_VALUE_HOLDS_STRING (value))
- gtk_entry_set_text (GTK_ENTRY (widget), g_value_get_string (value));
+ if (s_vpn) {
+ value = g_hash_table_lookup (s_vpn->data, NM_PPTP_KEY_USER);
+ if (value && strlen (value))
+ gtk_entry_set_text (GTK_ENTRY (widget), value);
}
g_signal_connect (G_OBJECT (widget), "changed", G_CALLBACK (stuff_changed_cb), self);
@@ -250,10 +249,10 @@
if (!widget)
return FALSE;
gtk_size_group_add_widget (priv->group, widget);
- if (s_vpn_props) {
- value = g_hash_table_lookup (s_vpn_props->data, NM_PPTP_KEY_DOMAIN);
- if (value && G_VALUE_HOLDS_STRING (value))
- gtk_entry_set_text (GTK_ENTRY (widget), g_value_get_string (value));
+ if (s_vpn) {
+ value = g_hash_table_lookup (s_vpn->data, NM_PPTP_KEY_DOMAIN);
+ if (value && strlen (value))
+ gtk_entry_set_text (GTK_ENTRY (widget), value);
}
g_signal_connect (G_OBJECT (widget), "changed", G_CALLBACK (stuff_changed_cb), self);
@@ -272,76 +271,12 @@
return G_OBJECT (priv->widget);
}
-GValue *
-str_to_gvalue (const char *str)
-{
- GValue *value;
-
- value = g_slice_new0 (GValue);
- g_value_init (value, G_TYPE_STRING);
- g_value_set_string (value, str);
-
- return value;
-}
-
-GValue *
-bool_to_gvalue (gboolean b)
-{
- GValue *value;
-
- value = g_slice_new0 (GValue);
- g_value_init (value, G_TYPE_BOOLEAN);
- g_value_set_boolean (value, b);
-
- return value;
-}
-
-GValue *
-int_to_gvalue (gint i)
-{
- GValue *value;
-
- value = g_slice_new0 (GValue);
- g_value_init (value, G_TYPE_INT);
- g_value_set_int (value, i);
-
- return value;
-}
-
-GValue *
-uint_to_gvalue (guint32 u)
-{
- GValue *value;
-
- value = g_slice_new0 (GValue);
- g_value_init (value, G_TYPE_UINT);
- g_value_set_uint (value, u);
-
- return value;
-}
-
static void
hash_copy_advanced (gpointer key, gpointer data, gpointer user_data)
{
GHashTable *hash = (GHashTable *) user_data;
- GValue *value = (GValue *) data;
- if (G_VALUE_HOLDS_STRING (value)) {
- g_hash_table_insert (hash,
- g_strdup ((const char *) key),
- str_to_gvalue (g_value_get_string (value)));
- } else if (G_VALUE_HOLDS_INT (value)) {
- g_hash_table_insert (hash,
- g_strdup ((const char *) key),
- int_to_gvalue (g_value_get_int (value)));
- } else if (G_VALUE_HOLDS_BOOLEAN (value)) {
- g_hash_table_insert (hash,
- g_strdup ((const char *) key),
- bool_to_gvalue (g_value_get_boolean (value)));
- } else {
- g_warning ("%s: unhandled key '%s' of type '%s'",
- __func__, (const char *) key, G_VALUE_TYPE_NAME (value));
- }
+ g_hash_table_insert (hash, g_strdup ((const char *) key), g_strdup ((const char *) data));
}
static gboolean
@@ -352,9 +287,8 @@
PptpPluginUiWidget *self = PPTP_PLUGIN_UI_WIDGET (iface);
PptpPluginUiWidgetPrivate *priv = PPTP_PLUGIN_UI_WIDGET_GET_PRIVATE (self);
NMSettingVPN *s_vpn;
- NMSettingVPNProperties *s_vpn_props;
GtkWidget *widget;
- char *str;
+ const char *str;
GtkTreeModel *model;
GtkTreeIter iter;
gboolean valid = FALSE;
@@ -364,41 +298,29 @@
s_vpn = NM_SETTING_VPN (nm_setting_vpn_new ());
s_vpn->service_type = g_strdup (NM_DBUS_SERVICE_PPTP);
- nm_connection_add_setting (connection, NM_SETTING (s_vpn));
-
- s_vpn_props = NM_SETTING_VPN_PROPERTIES (nm_setting_vpn_properties_new ());
/* Gateway */
widget = glade_xml_get_widget (priv->xml, "gateway_entry");
- str = (char *) gtk_entry_get_text (GTK_ENTRY (widget));
- if (str && strlen (str)) {
- g_hash_table_insert (s_vpn_props->data,
- g_strdup (NM_PPTP_KEY_GATEWAY),
- str_to_gvalue (str));
- }
+ str = gtk_entry_get_text (GTK_ENTRY (widget));
+ if (str && strlen (str))
+ g_hash_table_insert (s_vpn->data, g_strdup (NM_PPTP_KEY_GATEWAY), g_strdup (str));
/* Username */
widget = glade_xml_get_widget (priv->xml, "user_entry");
- str = (char *) gtk_entry_get_text (GTK_ENTRY (widget));
- if (str && strlen (str)) {
- g_hash_table_insert (s_vpn_props->data,
- g_strdup (NM_PPTP_KEY_USER),
- str_to_gvalue (str));
- }
+ str = gtk_entry_get_text (GTK_ENTRY (widget));
+ if (str && strlen (str))
+ g_hash_table_insert (s_vpn->data, g_strdup (NM_PPTP_KEY_USER), g_strdup (str));
/* Domain */
widget = glade_xml_get_widget (priv->xml, "domain_entry");
- str = (char *) gtk_entry_get_text (GTK_ENTRY (widget));
- if (str && strlen (str)) {
- g_hash_table_insert (s_vpn_props->data,
- g_strdup (NM_PPTP_KEY_DOMAIN),
- str_to_gvalue (str));
- }
+ str = gtk_entry_get_text (GTK_ENTRY (widget));
+ if (str && strlen (str))
+ g_hash_table_insert (s_vpn->data, g_strdup (NM_PPTP_KEY_DOMAIN), g_strdup (str));
if (priv->advanced)
- g_hash_table_foreach (priv->advanced, hash_copy_advanced, s_vpn_props->data);
+ g_hash_table_foreach (priv->advanced, hash_copy_advanced, s_vpn->data);
- nm_connection_add_setting (connection, NM_SETTING (s_vpn_props));
+ nm_connection_add_setting (connection, NM_SETTING (s_vpn));
valid = TRUE;
done:
Modified: trunk/vpn-daemons/pptp/properties/nm-pptp.h
==============================================================================
--- trunk/vpn-daemons/pptp/properties/nm-pptp.h (original)
+++ trunk/vpn-daemons/pptp/properties/nm-pptp.h Mon Aug 11 17:17:47 2008
@@ -82,13 +82,5 @@
GType pptp_plugin_ui_widget_get_type (void);
-GValue *int_to_gvalue (gint i);
-
-GValue *uint_to_gvalue (guint32 u);
-
-GValue *bool_to_gvalue (gboolean b);
-
-GValue *str_to_gvalue (const char *str);
-
#endif /* _NM_PPTP_H_ */
Modified: trunk/vpn-daemons/pptp/src/nm-pptp-service.c
==============================================================================
--- trunk/vpn-daemons/pptp/src/nm-pptp-service.c (original)
+++ trunk/vpn-daemons/pptp/src/nm-pptp-service.c Mon Aug 11 17:17:47 2008
@@ -46,7 +46,6 @@
#include <linux/if_ppp.h>
#include <nm-setting-vpn.h>
-#include <nm-setting-vpn-properties.h>
#include <nm-utils.h>
#include "nm-pptp-service.h"
@@ -228,8 +227,6 @@
{
NMPptpPppServicePrivate *priv = NM_PPTP_PPP_SERVICE_GET_PRIVATE (self);
NMSettingVPN *s_vpn;
- NMSettingVPNProperties *s_vpn_props;
- GValue *value;
const char *username, *password;
g_return_val_if_fail (self != NULL, FALSE);
@@ -239,7 +236,7 @@
memset (priv->password, 0, sizeof (priv->password));
s_vpn = (NMSettingVPN *) nm_connection_get_setting (connection, NM_TYPE_SETTING_VPN);
- if (!s_vpn) {
+ if (!s_vpn || !s_vpn->data) {
g_set_error (error,
NM_VPN_PLUGIN_ERROR,
NM_VPN_PLUGIN_ERROR_CONNECTION_INVALID,
@@ -248,20 +245,9 @@
return FALSE;
}
- s_vpn_props = (NMSettingVPNProperties *) nm_connection_get_setting (connection, NM_TYPE_SETTING_VPN_PROPERTIES);
- if (!s_vpn_props || !s_vpn_props->data) {
- g_set_error (error,
- NM_VPN_PLUGIN_ERROR,
- NM_VPN_PLUGIN_ERROR_CONNECTION_INVALID,
- "%s",
- "Could not find secrets (connection invalid, no vpn-properties setting).");
- return FALSE;
- }
-
/* Username; try PPTP specific username first, then generic username */
- value = g_hash_table_lookup (s_vpn_props->data, NM_PPTP_KEY_USER);
- if (value && G_VALUE_HOLDS_STRING (value)) {
- username = g_value_get_string (value);
+ username = g_hash_table_lookup (s_vpn->data, NM_PPTP_KEY_USER);
+ if (username && strlen (username)) {
if (!username || !strlen (username)) {
g_set_error (error,
NM_VPN_PLUGIN_ERROR,
@@ -282,23 +268,13 @@
}
}
- value = g_hash_table_lookup (s_vpn_props->data, NM_PPTP_KEY_PASSWORD);
- if (!value || !G_VALUE_HOLDS_STRING (value)) {
- g_set_error (error,
- NM_VPN_PLUGIN_ERROR,
- NM_VPN_PLUGIN_ERROR_CONNECTION_INVALID,
- "%s",
- "Missing VPN password.");
- return FALSE;
- }
-
- password = g_value_get_string (value);
+ password = g_hash_table_lookup (s_vpn->data, NM_PPTP_KEY_PASSWORD);
if (!password || !strlen (password)) {
g_set_error (error,
NM_VPN_PLUGIN_ERROR,
NM_VPN_PLUGIN_ERROR_CONNECTION_INVALID,
"%s",
- "Invalid VPN password.");
+ "Missing or invalid VPN password.");
return FALSE;
}
@@ -407,9 +383,8 @@
};
static gboolean
-validate_gateway (GValue *value)
+validate_gateway (const char *gateway)
{
- const char *gateway = g_value_get_string (value);
const char *p = gateway;
if (!gateway || !strlen (gateway))
@@ -426,12 +401,12 @@
}
static void
-validate_one_property (gpointer key, gpointer val, gpointer user_data)
+validate_one_property (gpointer key, gpointer value, gpointer user_data)
{
- gboolean *failed = (gboolean *) user_data;
+ GError **error = (GError **) user_data;
int i;
- if (*failed)
+ if (*error)
return;
/* 'name' is the setting name; always allowed but unused */
@@ -440,47 +415,100 @@
for (i = 0; valid_properties[i].name; i++) {
ValidProperty prop = valid_properties[i];
+ long int tmp;
- if (!strcmp (prop.name, (char *) key) && prop.type == G_VALUE_TYPE ((GValue *) val)) {
- if (!strcmp (prop.name, NM_PPTP_KEY_GATEWAY)) {
- if (!validate_gateway ((GValue *) val))
- goto failed;
+ if (strcmp (prop.name, (char *) key))
+ continue;
+
+ switch (prop.type) {
+ case G_TYPE_STRING:
+ if ( !strcmp (prop.name, NM_PPTP_KEY_GATEWAY)
+ && !validate_gateway (value)) {
+ g_set_error (error,
+ NM_VPN_PLUGIN_ERROR,
+ NM_VPN_PLUGIN_ERROR_BAD_ARGUMENTS,
+ "invalid gateway '%s'",
+ (const char *) key);
+ return;
}
- /* Property is ok */
- return;
+ return; /* valid */
+ case G_TYPE_UINT:
+ errno = 0;
+ tmp = strtol ((char *) value, NULL, 10);
+ if (errno == 0)
+ return; /* valid */
+
+ g_set_error (error,
+ NM_VPN_PLUGIN_ERROR,
+ NM_VPN_PLUGIN_ERROR_BAD_ARGUMENTS,
+ "invalid integer property '%s'",
+ (const char *) key);
+ break;
+ case G_TYPE_BOOLEAN:
+ if (!strcmp ((char *) value, "yes") || !strcmp ((char *) value, "no"))
+ return; /* valid */
+
+ g_set_error (error,
+ NM_VPN_PLUGIN_ERROR,
+ NM_VPN_PLUGIN_ERROR_BAD_ARGUMENTS,
+ "invalid boolean property '%s' (not yes or no)",
+ (const char *) key);
+ break;
+ default:
+ g_set_error (error,
+ NM_VPN_PLUGIN_ERROR,
+ NM_VPN_PLUGIN_ERROR_BAD_ARGUMENTS,
+ "unhandled property '%s' type %d",
+ (const char *) key, prop.type);
+ break;
}
}
-failed:
/* Did not find the property from valid_properties or the type did not match */
- g_warning ("VPN property '%s' failed validation.", (char *) key);
- *failed = TRUE;
+ if (!valid_properties[i].name) {
+ g_set_error (error,
+ NM_VPN_PLUGIN_ERROR,
+ NM_VPN_PLUGIN_ERROR_BAD_ARGUMENTS,
+ "property '%s' invalid or not supported",
+ (const char *) key);
+ }
}
static gboolean
-nm_pptp_properties_validate (GHashTable *properties)
+nm_pptp_properties_validate (GHashTable *properties, GError **error)
{
- gboolean failed = FALSE;
int i;
- if (g_hash_table_size (properties) < 1)
- return failed;
+ if (g_hash_table_size (properties) < 1) {
+ g_set_error (error,
+ NM_VPN_PLUGIN_ERROR,
+ NM_VPN_PLUGIN_ERROR_BAD_ARGUMENTS,
+ "%s",
+ "No VPN configuration options.");
+ return FALSE;
+ }
- g_hash_table_foreach (properties, validate_one_property, &failed);
- if (failed)
+ g_hash_table_foreach (properties, validate_one_property, error);
+ if (*error)
return FALSE;
/* Ensure required properties exist */
for (i = 0; valid_properties[i].name; i++) {
ValidProperty prop = valid_properties[i];
- GValue *value;
+ const char *value;
if (!prop.required)
continue;
value = g_hash_table_lookup (properties, prop.name);
- if (!value || (G_VALUE_TYPE (value) != prop.type))
+ if (!value || !strlen (value)) {
+ g_set_error (error,
+ NM_VPN_PLUGIN_ERROR,
+ NM_VPN_PLUGIN_ERROR_BAD_ARGUMENTS,
+ "Missing required option '%s'.",
+ prop.name);
return FALSE;
+ }
}
return TRUE;
@@ -602,13 +630,11 @@
static GPtrArray *
construct_pppd_args (NMPptpPlugin *plugin,
NMSettingVPN *s_vpn,
- NMSettingVPNProperties *s_vpn_props,
const char *pppd,
GError **error)
{
GPtrArray *args = NULL;
- GValue *value;
- const char *pptp_binary;
+ const char *value, *pptp_binary;
char *ipparam, *tmp;
pptp_binary = nm_find_pptp ();
@@ -625,8 +651,8 @@
g_ptr_array_add (args, (gpointer) g_strdup (pppd));
/* PPTP options */
- value = g_hash_table_lookup (s_vpn_props->data, NM_PPTP_KEY_GATEWAY);
- if (!value || !G_VALUE_HOLDS_STRING (value)) {
+ value = g_hash_table_lookup (s_vpn->data, NM_PPTP_KEY_GATEWAY);
+ if (!value || !strlen (value)) {
g_set_error (error,
NM_VPN_PLUGIN_ERROR,
NM_VPN_PLUGIN_ERROR_CONNECTION_INVALID,
@@ -638,8 +664,7 @@
ipparam = g_strdup_printf ("nm-pptp-service-%d", getpid ());
g_ptr_array_add (args, (gpointer) g_strdup ("pty"));
- tmp = g_strdup_printf ("%s %s --nolaunchpppd --logstring %s",
- pptp_binary, g_value_get_string (value), ipparam);
+ tmp = g_strdup_printf ("%s %s --nolaunchpppd --logstring %s", pptp_binary, value, ipparam);
g_ptr_array_add (args, (gpointer) tmp);
/* PPP options */
@@ -651,66 +676,82 @@
g_ptr_array_add (args, (gpointer) g_strdup ("usepeerdns"));
g_ptr_array_add (args, (gpointer) g_strdup ("noipdefault"));
- value = g_hash_table_lookup (s_vpn_props->data, NM_PPTP_KEY_REFUSE_EAP);
- if (value && G_VALUE_HOLDS_BOOLEAN (value) && g_value_get_boolean (value))
+ value = g_hash_table_lookup (s_vpn->data, NM_PPTP_KEY_REFUSE_EAP);
+ if (value && !strcmp (value, "yes"))
g_ptr_array_add (args, (gpointer) g_strdup ("refuse-eap"));
- value = g_hash_table_lookup (s_vpn_props->data, NM_PPTP_KEY_REFUSE_PAP);
- if (value && G_VALUE_HOLDS_BOOLEAN (value) && g_value_get_boolean (value))
+ value = g_hash_table_lookup (s_vpn->data, NM_PPTP_KEY_REFUSE_PAP);
+ if (value && !strcmp (value, "yes"))
g_ptr_array_add (args, (gpointer) g_strdup ("refuse-pap"));
- value = g_hash_table_lookup (s_vpn_props->data, NM_PPTP_KEY_REFUSE_CHAP);
- if (value && G_VALUE_HOLDS_BOOLEAN (value) && g_value_get_boolean (value))
+ value = g_hash_table_lookup (s_vpn->data, NM_PPTP_KEY_REFUSE_CHAP);
+ if (value && !strcmp (value, "yes"))
g_ptr_array_add (args, (gpointer) g_strdup ("refuse-chap"));
- value = g_hash_table_lookup (s_vpn_props->data, NM_PPTP_KEY_REFUSE_MSCHAP);
- if (value && G_VALUE_HOLDS_BOOLEAN (value) && g_value_get_boolean (value))
+ value = g_hash_table_lookup (s_vpn->data, NM_PPTP_KEY_REFUSE_MSCHAP);
+ if (value && !strcmp (value, "yes"))
g_ptr_array_add (args, (gpointer) g_strdup ("refuse-mschap"));
- value = g_hash_table_lookup (s_vpn_props->data, NM_PPTP_KEY_REFUSE_MSCHAPV2);
- if (value && G_VALUE_HOLDS_BOOLEAN (value) && g_value_get_boolean (value))
+ value = g_hash_table_lookup (s_vpn->data, NM_PPTP_KEY_REFUSE_MSCHAPV2);
+ if (value && !strcmp (value, "yes"))
g_ptr_array_add (args, (gpointer) g_strdup ("refuse-mschap-v2"));
- value = g_hash_table_lookup (s_vpn_props->data, NM_PPTP_KEY_REQUIRE_MPPE);
- if (value && G_VALUE_HOLDS_BOOLEAN (value) && g_value_get_boolean (value))
+ value = g_hash_table_lookup (s_vpn->data, NM_PPTP_KEY_REQUIRE_MPPE);
+ if (value && !strcmp (value, "yes"))
g_ptr_array_add (args, (gpointer) g_strdup ("require-mppe"));
- value = g_hash_table_lookup (s_vpn_props->data, NM_PPTP_KEY_REQUIRE_MPPE_40);
- if (value && G_VALUE_HOLDS_BOOLEAN (value) && g_value_get_boolean (value))
+ value = g_hash_table_lookup (s_vpn->data, NM_PPTP_KEY_REQUIRE_MPPE_40);
+ if (value && !strcmp (value, "yes"))
g_ptr_array_add (args, (gpointer) g_strdup ("require-mppe-40"));
- value = g_hash_table_lookup (s_vpn_props->data, NM_PPTP_KEY_REQUIRE_MPPE_128);
- if (value && G_VALUE_HOLDS_BOOLEAN (value) && g_value_get_boolean (value))
+ value = g_hash_table_lookup (s_vpn->data, NM_PPTP_KEY_REQUIRE_MPPE_128);
+ if (value && !strcmp (value, "yes"))
g_ptr_array_add (args, (gpointer) g_strdup ("require-mppe-128"));
- value = g_hash_table_lookup (s_vpn_props->data, NM_PPTP_KEY_MPPE_STATEFUL);
- if (value && G_VALUE_HOLDS_BOOLEAN (value) && g_value_get_boolean (value))
+ value = g_hash_table_lookup (s_vpn->data, NM_PPTP_KEY_MPPE_STATEFUL);
+ if (value && !strcmp (value, "yes"))
g_ptr_array_add (args, (gpointer) g_strdup ("mppe-stateful"));
- value = g_hash_table_lookup (s_vpn_props->data, NM_PPTP_KEY_NOBSDCOMP);
- if (value && G_VALUE_HOLDS_BOOLEAN (value) && g_value_get_boolean (value))
+ value = g_hash_table_lookup (s_vpn->data, NM_PPTP_KEY_NOBSDCOMP);
+ if (value && !strcmp (value, "yes"))
g_ptr_array_add (args, (gpointer) g_strdup ("nobsdcomp"));
- value = g_hash_table_lookup (s_vpn_props->data, NM_PPTP_KEY_NODEFLATE);
- if (value && G_VALUE_HOLDS_BOOLEAN (value) && g_value_get_boolean (value))
+ value = g_hash_table_lookup (s_vpn->data, NM_PPTP_KEY_NODEFLATE);
+ if (value && !strcmp (value, "yes"))
g_ptr_array_add (args, (gpointer) g_strdup ("nodeflate"));
- value = g_hash_table_lookup (s_vpn_props->data, NM_PPTP_KEY_NO_VJ_COMP);
- if (value && G_VALUE_HOLDS_BOOLEAN (value) && g_value_get_boolean (value))
+ value = g_hash_table_lookup (s_vpn->data, NM_PPTP_KEY_NO_VJ_COMP);
+ if (value && !strcmp (value, "yes"))
g_ptr_array_add (args, (gpointer) g_strdup ("novj"));
- value = g_hash_table_lookup (s_vpn_props->data, NM_PPTP_KEY_LCP_ECHO_FAILURE);
- if (value && G_VALUE_HOLDS_UINT (value) && g_value_get_uint (value)) {
- g_ptr_array_add (args, (gpointer) g_strdup ("lcp-echo-failure"));
- tmp = g_strdup_printf ("%d", g_value_get_uint (value));
- g_ptr_array_add (args, (gpointer) tmp);
+ value = g_hash_table_lookup (s_vpn->data, NM_PPTP_KEY_LCP_ECHO_FAILURE);
+ if (value && strlen (value)) {
+ long int tmp_int;
+
+ /* Convert to integer and then back to string for security's sake
+ * because strtol ignores some leading and trailing characters.
+ */
+ errno = 0;
+ tmp_int = strtol (value, NULL, 10);
+ if (errno == 0) {
+ g_ptr_array_add (args, (gpointer) g_strdup ("lcp-echo-failure"));
+ g_ptr_array_add (args, (gpointer) g_strdup_printf ("%ld", tmp_int));
+ }
}
- value = g_hash_table_lookup (s_vpn_props->data, NM_PPTP_KEY_LCP_ECHO_INTERVAL);
- if (value && G_VALUE_HOLDS_UINT (value) && g_value_get_uint (value)) {
- g_ptr_array_add (args, (gpointer) g_strdup ("lcp-echo-interval"));
- tmp = g_strdup_printf ("%d", g_value_get_uint (value));
- g_ptr_array_add (args, (gpointer) tmp);
+ value = g_hash_table_lookup (s_vpn->data, NM_PPTP_KEY_LCP_ECHO_INTERVAL);
+ if (value && strlen (value)) {
+ long int tmp_int;
+
+ /* Convert to integer and then back to string for security's sake
+ * because strtol ignores some leading and trailing characters.
+ */
+ errno = 0;
+ tmp_int = strtol (value, NULL, 10);
+ if (errno == 0) {
+ g_ptr_array_add (args, (gpointer) g_strdup ("lcp-echo-interval"));
+ g_ptr_array_add (args, (gpointer) g_strdup_printf ("%ld", tmp_int));
+ }
}
g_ptr_array_add (args, (gpointer) g_strdup ("plugin"));
@@ -728,29 +769,30 @@
static gboolean
nm_pptp_start_pppd_binary (NMPptpPlugin *plugin,
NMSettingVPN *s_vpn,
- NMSettingVPNProperties *s_vpn_props)
+ GError **error)
{
NMPptpPluginPrivate *priv = NM_PPTP_PLUGIN_GET_PRIVATE (plugin);
GPid pid;
const char *pppd_binary;
GPtrArray *pppd_argv;
- GError *err = NULL;
pppd_binary = nm_find_pppd ();
if (!pppd_binary) {
- nm_info ("Could not find pppd binary.");
+ g_set_error (error,
+ NM_VPN_PLUGIN_ERROR,
+ NM_VPN_PLUGIN_ERROR_LAUNCH_FAILED,
+ "%s",
+ "Could not find the pppd binary.");
return FALSE;
}
- pppd_argv = construct_pppd_args (plugin, s_vpn, s_vpn_props, pppd_binary, &err);
+ pppd_argv = construct_pppd_args (plugin, s_vpn, pppd_binary, error);
if (!pppd_argv)
return FALSE;
if (!g_spawn_async (NULL, (char **) pppd_argv->pdata, NULL,
- G_SPAWN_DO_NOT_REAP_CHILD, NULL, NULL, &pid, &err)) {
+ G_SPAWN_DO_NOT_REAP_CHILD, NULL, NULL, &pid, error)) {
g_ptr_array_free (pppd_argv, TRUE);
- nm_warning ("pppd failed to start. error: '%s'", err->message);
- g_error_free (err);
return FALSE;
}
free_pppd_args (pppd_argv);
@@ -814,24 +856,15 @@
static gboolean
real_connect (NMVPNPlugin *plugin,
NMConnection *connection,
- GError **err)
+ GError **error)
{
NMPptpPluginPrivate *priv = NM_PPTP_PLUGIN_GET_PRIVATE (plugin);
NMSettingVPN *s_vpn;
- NMSettingVPNProperties *s_vpn_props;
-
- s_vpn_props = NM_SETTING_VPN_PROPERTIES (nm_connection_get_setting (connection, NM_TYPE_SETTING_VPN_PROPERTIES));
- if (!s_vpn_props || !nm_pptp_properties_validate (s_vpn_props->data)) {
- g_set_error (err,
- NM_VPN_PLUGIN_ERROR,
- NM_VPN_PLUGIN_ERROR_BAD_ARGUMENTS,
- "%s",
- "Invalid arguments.");
- return FALSE;
- }
s_vpn = NM_SETTING_VPN (nm_connection_get_setting (connection, NM_TYPE_SETTING_VPN));
g_assert (s_vpn);
+ if (!nm_pptp_properties_validate (s_vpn->data, error))
+ return FALSE;
/* Start our pppd plugin helper service */
if (priv->service)
@@ -839,7 +872,7 @@
priv->service = nm_pptp_ppp_service_new ();
if (!priv->service) {
- g_set_error (err,
+ g_set_error (error,
NM_VPN_PLUGIN_ERROR,
NM_VPN_PLUGIN_ERROR_LAUNCH_FAILED,
"%s",
@@ -853,17 +886,11 @@
/* Cache the username and password so we can relay the secrets to the pppd
* plugin when it asks for them.
*/
- if (!nm_pptp_ppp_service_cache_credentials (priv->service, connection, err))
+ if (!nm_pptp_ppp_service_cache_credentials (priv->service, connection, error))
return FALSE;
- if (!nm_pptp_start_pppd_binary (NM_PPTP_PLUGIN (plugin), s_vpn, s_vpn_props)) {
- g_set_error (err,
- NM_VPN_PLUGIN_ERROR,
- NM_VPN_PLUGIN_ERROR_LAUNCH_FAILED,
- "%s",
- "Could not start pppd binary.");
+ if (!nm_pptp_start_pppd_binary (NM_PPTP_PLUGIN (plugin), s_vpn, error))
return FALSE;
- }
return TRUE;
}
@@ -874,13 +901,13 @@
char **setting_name,
GError **error)
{
- NMSettingVPNProperties *s_vpn_props;
+ NMSettingVPN *s_vpn;
g_return_val_if_fail (NM_IS_VPN_PLUGIN (plugin), FALSE);
g_return_val_if_fail (NM_IS_CONNECTION (connection), FALSE);
- s_vpn_props = NM_SETTING_VPN_PROPERTIES (nm_connection_get_setting (connection, NM_TYPE_SETTING_VPN_PROPERTIES));
- if (!s_vpn_props) {
+ s_vpn = NM_SETTING_VPN (nm_connection_get_setting (connection, NM_TYPE_SETTING_VPN));
+ if (!s_vpn) {
g_set_error (error,
NM_VPN_PLUGIN_ERROR,
NM_VPN_PLUGIN_ERROR_CONNECTION_INVALID,
@@ -889,8 +916,8 @@
return FALSE;
}
- if (!g_hash_table_lookup (s_vpn_props->data, NM_PPTP_KEY_PASSWORD)) {
- *setting_name = NM_SETTING_VPN_PROPERTIES_SETTING_NAME;
+ if (!g_hash_table_lookup (s_vpn->data, NM_PPTP_KEY_PASSWORD)) {
+ *setting_name = NM_SETTING_VPN_SETTING_NAME;
return TRUE;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]