Hello community,
here is the log from the commit of package NetworkManager-vpnc
checked in at Fri Nov 7 16:03:32 CET 2008.
--------
--- NetworkManager-vpnc/NetworkManager-vpnc.changes 2008-10-28 07:48:14.000000000 +0100
+++ /mounts/work_src_done/STABLE/NetworkManager-vpnc/NetworkManager-vpnc.changes 2008-11-03 14:11:04.000000000 +0100
@@ -1,0 +2,7 @@
+Mon Nov 3 14:56:06 EET 2008 - tambet@suse.de
+
+- Use the accessors provided by NM instead of poking the private
+ structures directly for settings. (a.k.a make it built with the
+ latest NetworkManager again.)
+
+-------------------------------------------------------------------
calling whatdependson for head-i586
Old:
----
NetworkManager-vpnc-0.7.0.r4209.tar.bz2
New:
----
NetworkManager-vpnc-0.7.0.r4274.tar.bz2
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Other differences:
------------------
++++++ NetworkManager-vpnc.spec ++++++
--- /var/tmp/diff_new_pack.C30453/_old 2008-11-07 16:03:23.000000000 +0100
+++ /var/tmp/diff_new_pack.C30453/_new 2008-11-07 16:03:23.000000000 +0100
@@ -1,5 +1,5 @@
#
-# spec file for package NetworkManager-vpnc (Version 0.7.0.r4209)
+# spec file for package NetworkManager-vpnc (Version 0.7.0.r4274)
#
# Copyright (c) 2008 SUSE LINUX Products GmbH, Nuernberg, Germany.
#
@@ -24,8 +24,8 @@
BuildRequires: pulseaudio-esound-compat
ExcludeArch: s390 s390x
Summary: NetworkManager VPN Support for vpnc
-Version: 0.7.0.r4209
-Release: 2
+Version: 0.7.0.r4274
+Release: 1
License: GPL v2 or later
Group: Productivity/Networking/System
Url: http://people.redhat.com/dcbw/NetworkManager/
@@ -35,7 +35,7 @@
Patch1: nm-vpnc-properties.patch
BuildRoot: %{_tmppath}/%{name}-%{version}-build
Requires: vpnc %{name}-frontend
-Requires: NetworkManager >= 0.7.0.r4060
+Requires: NetworkManager >= 0.7.0.r4274
Requires: gnome-keyring
%description
@@ -84,7 +84,6 @@
%find_lang %{name}
# No headers, no development files:
rm $RPM_BUILD_ROOT%{_libdir}/NetworkManager/*.la
-#rm $RPM_BUILD_ROOT%{_libdir}/libnm*.la
# FIXME: There is no MIME type definition for application/x-openvpn-settings in %{_datadir}/mime/packages.
# Without it, MIME icon has no effect.
mkdir -p $RPM_BUILD_ROOT%{_datadir}/icons/hicolor/48x48/mimetypes
@@ -119,6 +118,10 @@
%{_libexecdir}/nm-vpnc-auth-dialog
%changelog
+* Mon Nov 03 2008 tambet@suse.de
+- Use the accessors provided by NM instead of poking the private
+ structures directly for settings. (a.k.a make it built with the
+ latest NetworkManager again.)
* Tue Oct 28 2008 bili@suse.de
- Fixing couldn't find auth-dialog cause wrong path(#429667).
* Sat Oct 25 2008 bili@suse.de
@@ -169,7 +172,7 @@
configure macros and po/Makefile.in.in
* Fri Jun 16 2006 rml@suse.de
- Update translations (Novell bug #169096)
-* Fri Jun 16 2006 gekker@suse.de
+* Thu Jun 15 2006 gekker@suse.de
- Update package to install all existing translations (#179731)
* Mon Jun 05 2006 rml@suse.de
- Update translations (Novell bug #169096)
@@ -216,5 +219,5 @@
- Update to CVS snapshot 20051004.
* Tue Sep 06 2005 rml@suse.de
- Fix crasher bug #114803
-* Wed Jul 27 2005 gekker@suse.de
+* Tue Jul 26 2005 gekker@suse.de
- Initial import into autobuild version 0.2cvs20050722
++++++ NetworkManager-vpnc-0.7.0.r4209.tar.bz2 -> NetworkManager-vpnc-0.7.0.r4274.tar.bz2 ++++++
++++ 61667 lines of diff (skipped)
++++ retrying with extended exclude list
diff -urN --exclude=CVS --exclude=.cvsignore --exclude=.svn --exclude=.svnignore --exclude Makefile.in --exclude configure --exclude config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 --exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh old/NetworkManager-vpnc-0.7.0/ChangeLog new/NetworkManager-vpnc-0.7.0/ChangeLog
--- old/NetworkManager-vpnc-0.7.0/ChangeLog 2008-10-16 12:01:07.000000000 +0200
+++ new/NetworkManager-vpnc-0.7.0/ChangeLog 2008-11-07 12:03:23.000000000 +0100
@@ -1,3 +1,18 @@
+2008-11-03 Dan Williams
+
+ Patch from Carlos Martín Nieto (and me) (bgo #547582)
+
+ * properties/nm-vpnc.c
+ - (import, fill_vpn_passwords): import passwords too
+ - (decrypt_cisco_key, child_stdout_data_cb, decrypt_child_finished_cb):
+ call out to cisco-decrypt if present to de-obfuscate the group
+ password
+
+2008-10-26 Dan Williams
+
+ * properties/nm-vpnc.c
+ - Update for setting accessor changes
+
2008-10-09 Dan Williams
* properties/nm-vpnc.c
diff -urN --exclude=CVS --exclude=.cvsignore --exclude=.svn --exclude=.svnignore --exclude Makefile.in --exclude configure --exclude config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 --exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh old/NetworkManager-vpnc-0.7.0/config.h.in new/NetworkManager-vpnc-0.7.0/config.h.in
--- old/NetworkManager-vpnc-0.7.0/config.h.in 2008-10-24 16:53:48.000000000 +0200
+++ new/NetworkManager-vpnc-0.7.0/config.h.in 2008-10-28 14:16:52.000000000 +0100
@@ -75,6 +75,10 @@
/* Define to 1 if you have the header file. */
#undef HAVE_UNISTD_H
+/* Define to the sub-directory in which libtool stores uninstalled libraries.
+ */
+#undef LT_OBJDIR
+
/* Define to 1 if your C compiler doesn't accept -c and -o together. */
#undef NO_MINUS_C_MINUS_O
diff -urN --exclude=CVS --exclude=.cvsignore --exclude=.svn --exclude=.svnignore --exclude Makefile.in --exclude configure --exclude config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 --exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh old/NetworkManager-vpnc-0.7.0/po/Makefile.in.in new/NetworkManager-vpnc-0.7.0/po/Makefile.in.in
--- old/NetworkManager-vpnc-0.7.0/po/Makefile.in.in 2008-10-24 16:53:43.000000000 +0200
+++ new/NetworkManager-vpnc-0.7.0/po/Makefile.in.in 2008-10-28 14:16:45.000000000 +0100
@@ -54,16 +54,16 @@
ALL_LINGUAS = @ALL_LINGUAS@
-PO_LINGUAS=$(shell if test -r $(srcdir)/LINGUAS; then grep -v "^\#" $(srcdir)/LINGUAS; fi)
+PO_LINGUAS=$(shell if test -r $(srcdir)/LINGUAS; then grep -v "^\#" $(srcdir)/LINGUAS; else echo "$(ALL_LINGUAS)"; fi)
USER_LINGUAS=$(shell if test -n "$(LINGUAS)"; then LLINGUAS="$(LINGUAS)"; ALINGUAS="$(ALL_LINGUAS)"; for lang in $$LLINGUAS; do if test -n "`grep ^$$lang$$ $(srcdir)/LINGUAS 2>/dev/null`" -o -n "`echo $$ALINGUAS|tr ' ' '\n'|grep ^$$lang$$`"; then printf "$$lang "; fi; done; fi)
USE_LINGUAS=$(shell if test -n "$(USER_LINGUAS)" -o -n "$(LINGUAS)"; then LLINGUAS="$(USER_LINGUAS)"; else if test -n "$(PO_LINGUAS)"; then LLINGUAS="$(PO_LINGUAS)"; else LLINGUAS="$(ALL_LINGUAS)"; fi; fi; for lang in $$LLINGUAS; do printf "$$lang "; done)
-POFILES=$(shell LINGUAS="$(USE_LINGUAS)"; for lang in $$LINGUAS; do printf "$$lang.po "; done)
+POFILES=$(shell LINGUAS="$(PO_LINGUAS)"; for lang in $$LINGUAS; do printf "$$lang.po "; done)
-DISTFILES = ChangeLog Makefile.in.in POTFILES.in $(POFILES)
-EXTRA_DISTFILES = POTFILES.skip Makevars LINGUAS
+DISTFILES = Makefile.in.in POTFILES.in $(POFILES)
+EXTRA_DISTFILES = ChangeLog POTFILES.skip Makevars LINGUAS
POTFILES = \
# This comment gets stripped out
diff -urN --exclude=CVS --exclude=.cvsignore --exclude=.svn --exclude=.svnignore --exclude Makefile.in --exclude configure --exclude config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 --exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh old/NetworkManager-vpnc-0.7.0/properties/nm-vpnc.c new/NetworkManager-vpnc-0.7.0/properties/nm-vpnc.c
--- old/NetworkManager-vpnc-0.7.0/properties/nm-vpnc.c 2008-10-16 12:01:06.000000000 +0200
+++ new/NetworkManager-vpnc-0.7.0/properties/nm-vpnc.c 2008-11-07 12:03:23.000000000 +0100
@@ -1,6 +1,6 @@
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
/***************************************************************************
- * CVSID: $Id: nm-vpnc.c 4159 2008-10-09 13:59:13Z dcbw $
+ * CVSID: $Id$
*
* nm-vpnc.c : GNOME UI dialogs for configuring vpnc VPN connections
*
@@ -174,20 +174,30 @@
NMSettingVPN *s_vpn;
const char *tmp;
+ s_vpn = (NMSettingVPN *) nm_connection_get_setting (connection, NM_TYPE_SETTING_VPN);
+
if (nm_connection_get_scope (connection) == NM_CONNECTION_SCOPE_SYSTEM) {
- s_vpn = (NMSettingVPN *) nm_connection_get_setting (connection, NM_TYPE_SETTING_VPN);
if (s_vpn) {
- tmp = g_hash_table_lookup (s_vpn->secrets, NM_VPNC_KEY_XAUTH_PASSWORD);
+ tmp = nm_setting_vpn_get_secret (s_vpn, NM_VPNC_KEY_XAUTH_PASSWORD);
if (tmp)
password = gnome_keyring_memory_strdup (tmp);
- tmp = g_hash_table_lookup (s_vpn->secrets, NM_VPNC_KEY_SECRET);
+ tmp = nm_setting_vpn_get_secret (s_vpn, NM_VPNC_KEY_SECRET);
if (tmp)
group_password = gnome_keyring_memory_strdup (tmp);
}
} else {
s_con = NM_SETTING_CONNECTION (nm_connection_get_setting (connection, NM_TYPE_SETTING_CONNECTION));
- keyring_helpers_lookup_secrets (s_con->uuid, &password, &group_password, NULL);
+ keyring_helpers_lookup_secrets (nm_setting_connection_get_uuid (s_con),
+ &password, &group_password, NULL);
+
+ /* If they weren't in the keyring, maybe they are already in the conneciton
+ * (from import, perhaps).
+ */
+ if (!password)
+ password = gnome_keyring_memory_strdup (nm_setting_vpn_get_secret (s_vpn, NM_VPNC_KEY_XAUTH_PASSWORD));
+ if (!group_password)
+ group_password = gnome_keyring_memory_strdup (nm_setting_vpn_get_secret (s_vpn, NM_VPNC_KEY_SECRET));
}
}
@@ -244,7 +254,7 @@
GtkWidget *widget;
GtkListStore *store;
GtkTreeIter iter;
- char *value;
+ const char *value;
int active = -1;
const char *natt_mode = NULL;
@@ -256,7 +266,7 @@
g_return_val_if_fail (widget != NULL, FALSE);
gtk_size_group_add_widget (priv->group, GTK_WIDGET (widget));
if (s_vpn) {
- value = g_hash_table_lookup (s_vpn->data, NM_VPNC_KEY_GATEWAY);
+ value = nm_setting_vpn_get_data_item (s_vpn, NM_VPNC_KEY_GATEWAY);
if (value && strlen (value))
gtk_entry_set_text (GTK_ENTRY (widget), value);
}
@@ -266,7 +276,7 @@
g_return_val_if_fail (widget != NULL, FALSE);
gtk_size_group_add_widget (priv->group, GTK_WIDGET (widget));
if (s_vpn) {
- value = g_hash_table_lookup (s_vpn->data, NM_VPNC_KEY_ID);
+ value = nm_setting_vpn_get_data_item (s_vpn, NM_VPNC_KEY_ID);
if (value && strlen (value))
gtk_entry_set_text (GTK_ENTRY (widget), value);
}
@@ -284,7 +294,7 @@
gtk_list_store_append (store, &iter);
gtk_list_store_set (store, &iter, 0, _("Weak (use with caution)"), -1);
if (s_vpn && (active < 0)) {
- value = g_hash_table_lookup (s_vpn->data, NM_VPNC_KEY_SINGLE_DES);
+ value = nm_setting_vpn_get_data_item (s_vpn, NM_VPNC_KEY_SINGLE_DES);
if (value && !strcmp (value, "yes"))
active = 1;
}
@@ -292,7 +302,7 @@
gtk_list_store_append (store, &iter);
gtk_list_store_set (store, &iter, 0, _("None (completely insecure)"), -1);
if (s_vpn && (active < 0)) {
- value = g_hash_table_lookup (s_vpn->data, NM_VPNC_KEY_NO_ENCRYPTION);
+ value = nm_setting_vpn_get_data_item (s_vpn, NM_VPNC_KEY_NO_ENCRYPTION);
if (value && !strcmp (value, "yes"))
active = 2;
}
@@ -306,7 +316,7 @@
g_return_val_if_fail (widget != NULL, FALSE);
gtk_size_group_add_widget (priv->group, GTK_WIDGET (widget));
if (s_vpn) {
- value = g_hash_table_lookup (s_vpn->data, NM_VPNC_KEY_XAUTH_USER);
+ value = nm_setting_vpn_get_data_item (s_vpn, NM_VPNC_KEY_XAUTH_USER);
if (value && strlen (value))
gtk_entry_set_text (GTK_ENTRY (widget), value);
}
@@ -316,7 +326,7 @@
g_return_val_if_fail (widget != NULL, FALSE);
gtk_size_group_add_widget (priv->group, GTK_WIDGET (widget));
if (s_vpn) {
- value = g_hash_table_lookup (s_vpn->data, NM_VPNC_KEY_DOMAIN);
+ value = nm_setting_vpn_get_data_item (s_vpn, NM_VPNC_KEY_DOMAIN);
if (value && strlen (value))
gtk_entry_set_text (GTK_ENTRY (widget), value);
}
@@ -325,7 +335,7 @@
active = -1;
store = gtk_list_store_new (2, G_TYPE_STRING, G_TYPE_STRING);
if (s_vpn)
- natt_mode = g_hash_table_lookup (s_vpn->data, NM_VPNC_KEY_NAT_TRAVERSAL_MODE);
+ natt_mode = nm_setting_vpn_get_data_item (s_vpn, NM_VPNC_KEY_NAT_TRAVERSAL_MODE);
gtk_list_store_append (store, &iter);
gtk_list_store_set (store, &iter, 0, _("NAT-T (default)"), 1, NM_VPNC_NATT_MODE_NATT, -1);
@@ -359,7 +369,7 @@
widget = glade_xml_get_widget (priv->xml, "disable_dpd_checkbutton");
g_return_val_if_fail (widget != NULL, FALSE);
if (s_vpn) {
- value = g_hash_table_lookup (s_vpn->data, NM_VPNC_KEY_DPD_IDLE_TIMEOUT);
+ value = nm_setting_vpn_get_data_item (s_vpn, NM_VPNC_KEY_DPD_IDLE_TIMEOUT);
if (value) {
long int tmp;
@@ -411,53 +421,37 @@
return FALSE;
s_vpn = NM_SETTING_VPN (nm_setting_vpn_new ());
- s_vpn->service_type = g_strdup (NM_DBUS_SERVICE_VPNC);
+ g_object_set (s_vpn, NM_SETTING_VPN_SERVICE_TYPE, NM_DBUS_SERVICE_VPNC, NULL);
/* 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->data,
- g_strdup (NM_VPNC_KEY_GATEWAY),
- g_strdup (str));
- }
+ if (str && strlen (str))
+ nm_setting_vpn_add_data_item (s_vpn, NM_VPNC_KEY_GATEWAY, str);
/* Group name */
widget = glade_xml_get_widget (priv->xml, "group_entry");
str = (char *) gtk_entry_get_text (GTK_ENTRY (widget));
- if (str && strlen (str)) {
- g_hash_table_insert (s_vpn->data,
- g_strdup (NM_VPNC_KEY_ID),
- g_strdup (str));
- }
+ if (str && strlen (str))
+ nm_setting_vpn_add_data_item (s_vpn, NM_VPNC_KEY_ID, str);
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->data,
- g_strdup (NM_VPNC_KEY_XAUTH_USER),
- g_strdup (str));
- }
+ if (str && strlen (str))
+ nm_setting_vpn_add_data_item (s_vpn, NM_VPNC_KEY_XAUTH_USER, str);
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->data,
- g_strdup (NM_VPNC_KEY_DOMAIN),
- g_strdup (str));
- }
+ if (str && strlen (str))
+ nm_setting_vpn_add_data_item (s_vpn, NM_VPNC_KEY_DOMAIN, str);
widget = glade_xml_get_widget (priv->xml, "encryption_combo");
switch (gtk_combo_box_get_active (GTK_COMBO_BOX (widget))) {
case ENC_TYPE_WEAK:
- g_hash_table_insert (s_vpn->data,
- g_strdup (NM_VPNC_KEY_SINGLE_DES),
- g_strdup ("yes"));
+ nm_setting_vpn_add_data_item (s_vpn, NM_VPNC_KEY_SINGLE_DES, "yes");
break;
case ENC_TYPE_NONE:
- g_hash_table_insert (s_vpn->data,
- g_strdup (NM_VPNC_KEY_NO_ENCRYPTION),
- g_strdup ("yes"));
+ nm_setting_vpn_add_data_item (s_vpn, NM_VPNC_KEY_NO_ENCRYPTION, "yes");
break;
case ENC_TYPE_SECURE:
default:
@@ -470,29 +464,22 @@
const char *mode;
gtk_tree_model_get (model, &iter, 1, &mode, -1);
- g_hash_table_insert (s_vpn->data,
- g_strdup (NM_VPNC_KEY_NAT_TRAVERSAL_MODE),
- g_strdup (mode));
- } else {
- g_hash_table_insert (s_vpn->data,
- g_strdup (NM_VPNC_KEY_NAT_TRAVERSAL_MODE),
- g_strdup (NM_VPNC_NATT_MODE_NATT));
- }
+ nm_setting_vpn_add_data_item (s_vpn, NM_VPNC_KEY_NAT_TRAVERSAL_MODE, mode);
+ } else
+ nm_setting_vpn_add_data_item (s_vpn, NM_VPNC_KEY_NAT_TRAVERSAL_MODE, NM_VPNC_NATT_MODE_NATT);
widget = glade_xml_get_widget (priv->xml, "disable_dpd_checkbutton");
if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget))) {
- g_hash_table_insert (s_vpn->data,
- g_strdup (NM_VPNC_KEY_DPD_IDLE_TIMEOUT),
- g_strdup ("0"));
+ nm_setting_vpn_add_data_item (s_vpn, NM_VPNC_KEY_DPD_IDLE_TIMEOUT, "0");
} else {
/* If DPD was disabled and now the user wishes to enable it, just
* don't pass the DPD_IDLE_TIMEOUT option to vpnc and thus use the
* default DPD idle time. Otherwise keep the original DPD idle timeout.
*/
if (priv->orig_dpd_timeout >= 10) {
- g_hash_table_insert (s_vpn->data,
- g_strdup (NM_VPNC_KEY_DPD_IDLE_TIMEOUT),
- g_strdup_printf ("%d", priv->orig_dpd_timeout));
+ char *tmp = g_strdup_printf ("%d", priv->orig_dpd_timeout);
+ nm_setting_vpn_add_data_item (s_vpn, NM_VPNC_KEY_DPD_IDLE_TIMEOUT, tmp);
+ g_free (tmp);
}
}
@@ -503,20 +490,14 @@
/* User password */
widget = glade_xml_get_widget (priv->xml, "user_password_entry");
str = (char *) gtk_entry_get_text (GTK_ENTRY (widget));
- if (str && strlen (str)) {
- g_hash_table_insert (s_vpn->secrets,
- g_strdup (NM_VPNC_KEY_XAUTH_PASSWORD),
- g_strdup (str));
- }
+ if (str && strlen (str))
+ nm_setting_vpn_add_secret (s_vpn, NM_VPNC_KEY_XAUTH_PASSWORD, str);
/* Group password */
widget = glade_xml_get_widget (priv->xml, "group_password_entry");
str = (char *) gtk_entry_get_text (GTK_ENTRY (widget));
- if (str && strlen (str)) {
- g_hash_table_insert (s_vpn->secrets,
- g_strdup (NM_VPNC_KEY_SECRET),
- g_strdup (str));
- }
+ if (str && strlen (str))
+ nm_setting_vpn_add_secret (s_vpn, NM_VPNC_KEY_SECRET, str);
}
nm_connection_add_setting (connection, NM_SETTING (s_vpn));
@@ -533,7 +514,7 @@
GnomeKeyringResult ret;
NMSettingConnection *s_con;
GtkWidget *widget;
- const char *str;
+ const char *str, *id, *uuid;
s_con = (NMSettingConnection *) nm_connection_get_setting (connection, NM_TYPE_SETTING_CONNECTION);
if (!s_con) {
@@ -544,25 +525,28 @@
return FALSE;
}
+ id = nm_setting_connection_get_id (s_con);
+ uuid = nm_setting_connection_get_uuid (s_con);
+
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, VPNC_USER_PASSWORD, str);
+ ret = keyring_helpers_save_secret (uuid, id, NULL, VPNC_USER_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, VPNC_USER_PASSWORD);
+ keyring_helpers_delete_secret (uuid, VPNC_USER_PASSWORD);
widget = glade_xml_get_widget (priv->xml, "group_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, VPNC_GROUP_PASSWORD, str);
+ ret = keyring_helpers_save_secret (uuid, id, NULL, VPNC_GROUP_PASSWORD, str);
if (ret != GNOME_KEYRING_RESULT_OK)
g_warning ("%s: failed to save group password to keyring.", __func__);
} else
- keyring_helpers_delete_secret (s_con->uuid, VPNC_GROUP_PASSWORD);
+ keyring_helpers_delete_secret (uuid, VPNC_GROUP_PASSWORD);
return TRUE;
}
@@ -654,10 +638,9 @@
iface_class->save_secrets = save_secrets;
}
-static GSList *
-get_routes (const char *routelist)
+static void
+add_routes (NMSettingIP4Config *s_ip4, const char *routelist)
{
- GSList *routes = NULL;
char **substrs;
unsigned int i;
@@ -684,13 +667,12 @@
/* don't pass the prefix to inet_pton() */
*p = '\0';
if (inet_pton (AF_INET, str_route, &tmp) > 0) {
- NMSettingIP4Route *route;
+ NMIP4Route *route = nm_ip4_route_new ();
- route = g_new0 (NMSettingIP4Route, 1);
- route->address = tmp.s_addr;
- route->prefix = (guint32) prefix;
+ nm_ip4_route_set_dest (route, tmp.s_addr);
+ nm_ip4_route_set_prefix (route, (guint32) prefix);
- routes = g_slist_append (routes, route);
+ nm_setting_ip4_config_add_route (s_ip4, route);
} else
g_warning ("Ignoring invalid route '%s'", str_route);
@@ -699,7 +681,111 @@
}
g_strfreev (substrs);
- return routes;
+}
+
+static void
+decrypt_child_finished_cb (GPid pid, gint status, gpointer userdata)
+{
+ int *child_status = (gint *) userdata;
+
+ *child_status = status;
+}
+
+static gboolean
+child_stdout_data_cb (GIOChannel *source, GIOCondition condition, gpointer userdata)
+{
+ char *str;
+ char **output = (char **) userdata;
+
+ if (*output || !(condition & (G_IO_IN | G_IO_ERR)))
+ return TRUE;
+
+ if (g_io_channel_read_line (source, &str, NULL, NULL, NULL) == G_IO_STATUS_NORMAL) {
+ int len;
+
+ len = strlen (str);
+ if (len > 0) {
+ /* remove terminating newline */
+ *output = g_strchomp (str);
+ } else
+ g_free (str);
+ }
+ return TRUE;
+}
+
+static char *
+decrypt_cisco_key (const char* enc_key)
+{
+ int child_stdout, child_status;
+ GPid child_pid;
+ guint32 ioid;
+ char *key = NULL;
+ GIOChannel *channel;
+ const char **decrypt_path;
+ GError *error = NULL;
+
+ const char *decrypt_possible_paths[] = {
+ "/usr/lib/vpnc/cisco-decrypt",
+ "/usr/bin/cisco-decrypt",
+ NULL
+ };
+
+ const char *argv[] = {
+ NULL, /* The path we figure out later. */
+ enc_key, /* The key in encrypted form */
+ NULL
+ };
+
+ /* Find the binary. */
+ decrypt_path = decrypt_possible_paths;
+ while (*decrypt_path != NULL){
+ if (g_file_test (*decrypt_path, G_FILE_TEST_EXISTS))
+ break;
+ ++decrypt_path;
+ }
+
+ if (*decrypt_path == NULL){
+ g_warning ("Couldn't find cisco-decrypt.\n");
+ return NULL;
+ }
+
+ /* Now that we know where it is, we call the decrypter. */
+ argv[0] = *decrypt_path;
+ child_status = -1;
+
+ if (!g_spawn_async_with_pipes ("/", /* working directory */
+ (gchar **) argv, /* argv */
+ NULL , /* envp */
+ G_SPAWN_DO_NOT_REAP_CHILD, /* flags */
+ NULL, /* child setup */
+ NULL, /* user data */
+ &child_pid, /* child pid */
+ NULL, /* child stdin */
+ &child_stdout, /* child stdout */
+ NULL, /* child stderr */
+ &error)) { /* error */
+ /* The child did not spawn */
+ g_warning ("Error processing password: %s", error ? error->message : "(none)");
+ if (error)
+ g_error_free (error);
+ return NULL;
+ }
+
+ g_child_watch_add (child_pid, decrypt_child_finished_cb, (gpointer) &child_status);
+
+ /* Grab child output and wait for it to exit */
+ channel = g_io_channel_unix_new (child_stdout);
+ g_io_channel_set_encoding (channel, NULL, NULL);
+ ioid = g_io_add_watch (channel, G_IO_IN | G_IO_ERR, child_stdout_data_cb, &key);
+
+ while (child_status == -1) /* Wait until the child has finished. */
+ g_main_context_iteration (NULL, TRUE);
+
+ g_source_remove (ioid);
+ g_io_channel_shutdown (channel, TRUE, NULL);
+ g_io_channel_unref (channel);
+
+ return key;
}
static NMConnection *
@@ -711,9 +797,6 @@
GHashTable *pcf;
const char *buf;
gboolean have_value;
- NMConnectionScope scope = NM_CONNECTION_SCOPE_USER;
-
- g_debug ("Enter import function now...");
pcf = pcf_file_load (path);
if (!pcf) {
@@ -725,14 +808,14 @@
connection = nm_connection_new ();
s_con = NM_SETTING_CONNECTION (nm_setting_connection_new ());
nm_connection_add_setting (connection, NM_SETTING (s_con));
- nm_connection_set_scope (connection, scope);
s_vpn = NM_SETTING_VPN (nm_setting_vpn_new ());
- s_vpn->service_type = g_strdup (VPNC_PLUGIN_SERVICE);
+ g_object_set (s_vpn, NM_SETTING_VPN_SERVICE_TYPE, NM_DBUS_SERVICE_VPNC, NULL);
+ nm_connection_add_setting (connection, NM_SETTING (s_vpn));
/* Connection name */
if ((buf = pcf_file_lookup_value (pcf, "main", "Description")))
- s_con->id = g_strdup (buf);
+ g_object_set (s_con, NM_SETTING_CONNECTION_ID, buf, NULL);
else {
g_set_error (error, 0, 0, "does not look like a %s VPN connection (parse failed)",
VPNC_PLUGIN_NAME);
@@ -742,7 +825,7 @@
/* Gateway */
if ((buf = pcf_file_lookup_value (pcf, "main", "Host")))
- g_hash_table_insert (s_vpn->data, g_strdup (NM_VPNC_KEY_GATEWAY), g_strdup (buf));
+ nm_setting_vpn_add_data_item (s_vpn, NM_VPNC_KEY_GATEWAY, buf);
else {
g_set_error (error, 0, 0, "does not look like a %s VPN connection (no Host)",
VPNC_PLUGIN_NAME);
@@ -752,7 +835,7 @@
/* Group name */
if ((buf = pcf_file_lookup_value (pcf, "main", "GroupName")))
- g_hash_table_insert (s_vpn->data, g_strdup (NM_VPNC_KEY_ID), g_strdup (buf));
+ nm_setting_vpn_add_data_item (s_vpn, NM_VPNC_KEY_ID, buf);
else {
g_set_error (error, 0, 0, "does not look like a %s VPN connection (no GroupName)",
VPNC_PLUGIN_NAME);
@@ -765,23 +848,48 @@
buf = pcf_file_lookup_value (pcf, "main", "UserName");
have_value = buf == NULL ? FALSE : strlen (buf) > 0;
if (have_value)
- g_hash_table_insert (s_vpn->data, g_strdup (NM_VPNC_KEY_XAUTH_USER), g_strdup (buf));
+ nm_setting_vpn_add_data_item (s_vpn, NM_VPNC_KEY_XAUTH_USER, buf);
+
+ buf = pcf_file_lookup_value (pcf, "main", "UserPassword");
+ have_value = buf == NULL ? FALSE : strlen (buf) > 0;
+ if (have_value)
+ nm_setting_vpn_add_secret (s_vpn, NM_VPNC_KEY_XAUTH_PASSWORD, buf);
+
+ buf = pcf_file_lookup_value (pcf, "main", "GroupPwd");
+ have_value = buf == NULL ? FALSE : strlen (buf) > 0;
+ if (have_value)
+ nm_setting_vpn_add_secret (s_vpn, NM_VPNC_KEY_SECRET, buf);
+ else {
+ /* Handle encrypted passwords */
+ buf = pcf_file_lookup_value (pcf, "main", "enc_GroupPwd");
+ have_value = buf == NULL ? FALSE : strlen (buf) > 0;
+ if (have_value) {
+ char *decrypted;
+
+ decrypted = decrypt_cisco_key (buf);
+ if (decrypted) {
+ nm_setting_vpn_add_secret (s_vpn, NM_VPNC_KEY_SECRET, decrypted);
+ memset (decrypted, 0, strlen (decrypted));
+ g_free (decrypted);
+ }
+ }
+ }
buf = pcf_file_lookup_value (pcf, "main", "NTDomain");
have_value = buf == NULL ? FALSE : strlen (buf) > 0;
if (have_value)
- g_hash_table_insert (s_vpn->data, g_strdup (NM_VPNC_KEY_DOMAIN), g_strdup (buf));
+ nm_setting_vpn_add_data_item (s_vpn, NM_VPNC_KEY_DOMAIN, buf);
buf = pcf_file_lookup_value (pcf, "main", "SingleDES");
have_value = (buf == NULL ? FALSE : strcmp (buf, "0") != 0);
if (have_value)
- g_hash_table_insert (s_vpn->data, g_strdup (NM_VPNC_KEY_SINGLE_DES), g_strdup ("yes"));
+ nm_setting_vpn_add_data_item (s_vpn, NM_VPNC_KEY_SINGLE_DES, "yes");
/* Default is enabled, only disabled if explicit EnableNat=0 exists */
buf = pcf_file_lookup_value (pcf, "main", "EnableNat");
have_value = (buf ? strncmp (buf, "0", 1) == 0 : FALSE);
if (have_value)
- g_hash_table_insert (s_vpn->data, g_strdup (NM_VPNC_KEY_NAT_TRAVERSAL_MODE), g_strdup (NM_VPNC_NATT_MODE_NATT));
+ nm_setting_vpn_add_data_item (s_vpn, NM_VPNC_KEY_NAT_TRAVERSAL_MODE, NM_VPNC_NATT_MODE_NATT);
if ((buf = pcf_file_lookup_value (pcf, "main", "PeerTimeout"))) {
long int val;
@@ -789,9 +897,9 @@
errno = 0;
val = strtol (buf, NULL, 10);
if ((errno == 0) && ((val == 0) || ((val >= 10) && (val <= 86400)))) {
- g_hash_table_insert (s_vpn->data,
- g_strdup (NM_VPNC_KEY_DPD_IDLE_TIMEOUT),
- g_strdup_printf ("%d", (gint) val));
+ char *tmp = g_strdup_printf ("%d", (gint) val);
+ nm_setting_vpn_add_data_item (s_vpn, NM_VPNC_KEY_DPD_IDLE_TIMEOUT, tmp);
+ g_free (tmp);
}
}
@@ -802,7 +910,7 @@
s_ip4 = NM_SETTING_IP4_CONFIG (nm_setting_ip4_config_new ());
nm_connection_add_setting (connection, NM_SETTING (s_ip4));
- s_ip4->routes = get_routes (buf);
+ add_routes (s_ip4, buf);
}
if ((buf = pcf_file_lookup_value (pcf, "main", "TunnelingMode"))) {
@@ -826,8 +934,6 @@
g_hash_table_destroy (pcf);
- nm_connection_add_setting (connection, NM_SETTING (s_vpn));
-
return connection;
}
@@ -856,10 +962,6 @@
s_ip4 = (NMSettingIP4Config *) nm_connection_get_setting (connection, NM_TYPE_SETTING_IP4_CONFIG);
s_vpn = (NMSettingVPN *) nm_connection_get_setting (connection, NM_TYPE_SETTING_VPN);
- if (!s_vpn || !s_vpn->data) {
- g_set_error (error, 0, 0, "connection was incomplete");
- return FALSE;
- }
f = fopen (path, "w");
if (!f) {
@@ -867,7 +969,7 @@
return FALSE;
}
- value = g_hash_table_lookup (s_vpn->data, NM_VPNC_KEY_GATEWAY);
+ value = nm_setting_vpn_get_data_item (s_vpn, NM_VPNC_KEY_GATEWAY);
if (value && strlen (value))
gateway = value;
else {
@@ -875,7 +977,7 @@
goto done;
}
- value = g_hash_table_lookup (s_vpn->data, NM_VPNC_KEY_ID);
+ value = nm_setting_vpn_get_data_item (s_vpn, NM_VPNC_KEY_ID);
if (value && strlen (value))
groupname = value;
else {
@@ -883,41 +985,41 @@
goto done;
}
- value = g_hash_table_lookup (s_vpn->data, NM_VPNC_KEY_XAUTH_USER);
+ value = nm_setting_vpn_get_data_item (s_vpn, NM_VPNC_KEY_XAUTH_USER);
if (value && strlen (value))
username = value;
- value = g_hash_table_lookup (s_vpn->data, NM_VPNC_KEY_DOMAIN);
+ value = nm_setting_vpn_get_data_item (s_vpn, NM_VPNC_KEY_DOMAIN);
if (value && strlen (value))
domain = value;
- value = g_hash_table_lookup (s_vpn->data, NM_VPNC_KEY_SINGLE_DES);
+ value = nm_setting_vpn_get_data_item (s_vpn, NM_VPNC_KEY_SINGLE_DES);
if (value && !strcmp (value, "yes"))
singledes = TRUE;
- value = g_hash_table_lookup (s_vpn->data, NM_VPNC_KEY_NAT_TRAVERSAL_MODE);
+ value = nm_setting_vpn_get_data_item (s_vpn, NM_VPNC_KEY_NAT_TRAVERSAL_MODE);
if (value && strlen (value) && strcmp (value, NM_VPNC_NATT_MODE_NONE))
enablenat = TRUE;
- value = g_hash_table_lookup (s_vpn->data, NM_VPNC_KEY_DPD_IDLE_TIMEOUT);
+ value = nm_setting_vpn_get_data_item (s_vpn, NM_VPNC_KEY_DPD_IDLE_TIMEOUT);
if (value && strlen (value))
peertimeout = value;
routes = g_string_new ("");
- if (s_ip4 && s_ip4->routes) {
- GSList *iter;
+ if (s_ip4 && nm_setting_ip4_config_get_num_routes (s_ip4)) {
+ int i;
- for (iter = s_ip4->routes; iter; iter = g_slist_next (iter)) {
- NMSettingIP4Route *route = (NMSettingIP4Route *) iter->data;
+ for (i = 0; i < nm_setting_ip4_config_get_num_routes (s_ip4); i++) {
+ NMIP4Route *route = nm_setting_ip4_config_get_route (s_ip4, i);
char str_addr[INET_ADDRSTRLEN + 1];
struct in_addr num_addr;
if (routes->len)
g_string_append_c (routes, ' ');
- num_addr.s_addr = route->address;
+ num_addr.s_addr = nm_ip4_route_get_dest (route);
if (inet_ntop (AF_INET, &num_addr, &str_addr[0], INET_ADDRSTRLEN + 1))
- g_string_append_printf (routes, "%s/%d", str_addr, route->prefix);
+ g_string_append_printf (routes, "%s/%d", str_addr, nm_ip4_route_get_prefix (route));
}
}
@@ -960,7 +1062,7 @@
"SingleDES=%s\n"
"SPPhonebook=\n"
"%s",
- /* Description */ s_con->id,
+ /* Description */ nm_setting_connection_get_id (s_con),
/* Host */ gateway,
/* GroupName */ groupname,
/* Username */ username != NULL ? username : "",
@@ -983,14 +1085,17 @@
get_suggested_name (NMVpnPluginUiInterface *iface, NMConnection *connection)
{
NMSettingConnection *s_con;
+ const char *id;
g_return_val_if_fail (connection != NULL, NULL);
s_con = NM_SETTING_CONNECTION (nm_connection_get_setting (connection, NM_TYPE_SETTING_CONNECTION));
g_return_val_if_fail (s_con != NULL, NULL);
- g_return_val_if_fail (s_con->id != NULL, NULL);
- return g_strdup_printf ("%s.pcf", s_con->id);
+ id = nm_setting_connection_get_id (s_con);
+ g_return_val_if_fail (id != NULL, NULL);
+
+ return g_strdup_printf ("%s.pcf", id);
}
static guint32
@@ -1005,6 +1110,7 @@
GError **error)
{
NMSettingConnection *s_con;
+ const char *id, *uuid;
/* Remove any secrets in the keyring associated with this connection's UUID */
s_con = (NMSettingConnection *) nm_connection_get_setting (connection, NM_TYPE_SETTING_CONNECTION);
@@ -1016,11 +1122,14 @@
return FALSE;
}
- if (!keyring_helpers_delete_secret (s_con->uuid, VPNC_USER_PASSWORD))
- g_message ("%s: couldn't delete user password for '%s'", __func__, s_con->id);
+ id = nm_setting_connection_get_id (s_con);
+ uuid = nm_setting_connection_get_uuid (s_con);
+
+ if (!keyring_helpers_delete_secret (uuid, VPNC_USER_PASSWORD))
+ g_message ("%s: couldn't delete user password for '%s'", __func__, id);
- if (!keyring_helpers_delete_secret (s_con->uuid, VPNC_GROUP_PASSWORD))
- g_message ("%s: couldn't delete group password for '%s'", __func__, s_con->id);
+ if (!keyring_helpers_delete_secret (uuid, VPNC_GROUP_PASSWORD))
+ g_message ("%s: couldn't delete group password for '%s'", __func__, id);
return TRUE;
}
diff -urN --exclude=CVS --exclude=.cvsignore --exclude=.svn --exclude=.svnignore --exclude Makefile.in --exclude configure --exclude config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 --exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh old/NetworkManager-vpnc-0.7.0/src/nm-vpnc-service.c new/NetworkManager-vpnc-0.7.0/src/nm-vpnc-service.c
--- old/NetworkManager-vpnc-0.7.0/src/nm-vpnc-service.c 2008-09-16 04:53:41.000000000 +0200
+++ new/NetworkManager-vpnc-0.7.0/src/nm-vpnc-service.c 2008-10-29 10:26:27.000000000 +0100
@@ -45,9 +45,7 @@
static ValidProperty valid_properties[] = {
{ NM_VPNC_KEY_GATEWAY, G_TYPE_STRING, 0, 0 },
{ NM_VPNC_KEY_ID, G_TYPE_STRING, 0, 0 },
- { NM_VPNC_KEY_SECRET, G_TYPE_STRING, 0, 0 },
{ NM_VPNC_KEY_XAUTH_USER, G_TYPE_STRING, 0, 0 },
- { NM_VPNC_KEY_XAUTH_PASSWORD, G_TYPE_STRING, 0, 0 },
{ NM_VPNC_KEY_DOMAIN, G_TYPE_STRING, 0, 0 },
{ NM_VPNC_KEY_DHGROUP, G_TYPE_STRING, 0, 0 },
{ NM_VPNC_KEY_PERFECT_FORWARD, G_TYPE_STRING, 0, 0 },
@@ -62,24 +60,38 @@
{ NULL, G_TYPE_NONE, 0, 0 }
};
+static ValidProperty valid_secrets[] = {
+ { NM_VPNC_KEY_SECRET, G_TYPE_STRING, 0, 0 },
+ { NM_VPNC_KEY_XAUTH_PASSWORD, G_TYPE_STRING, 0, 0 },
+ { NULL, G_TYPE_NONE, 0, 0 }
+};
+
+typedef struct ValidateInfo {
+ ValidProperty *table;
+ GError **error;
+ gboolean have_items;
+} ValidateInfo;
+
static void
-validate_one_property (gpointer key, gpointer value, gpointer user_data)
+validate_one_property (const char *key, const char *value, gpointer user_data)
{
- GError **error = (GError **) user_data;
+ ValidateInfo *info = (ValidateInfo *) user_data;
int i;
- if (*error)
+ if (*(info->error))
return;
+ info->have_items = TRUE;
+
/* 'name' is the setting name; always allowed but unused */
- if (!strcmp ((char *) key, NM_SETTING_NAME))
+ if (!strcmp (key, NM_SETTING_NAME))
return;
- for (i = 0; valid_properties[i].name; i++) {
- ValidProperty prop = valid_properties[i];
+ for (i = 0; info->table[i].name; i++) {
+ ValidProperty prop = info->table[i];
long int tmp;
- if (strcmp (prop.name, (char *) key))
+ if (strcmp (prop.name, key))
continue;
switch (prop.type) {
@@ -87,50 +99,53 @@
return; /* valid */
case G_TYPE_INT:
errno = 0;
- tmp = strtol ((char *) value, NULL, 10);
+ tmp = strtol (value, NULL, 10);
if (errno == 0 && tmp >= prop.int_min && tmp <= prop.int_max)
return; /* valid */
- g_set_error (error,
+ g_set_error (info->error,
NM_VPN_PLUGIN_ERROR,
NM_VPN_PLUGIN_ERROR_BAD_ARGUMENTS,
"invalid integer property '%s' or out of range [%d -> %d]",
- (const char *) key, prop.int_min, prop.int_max);
+ key, prop.int_min, prop.int_max);
break;
case G_TYPE_BOOLEAN:
- if (!strcmp ((char *) value, "yes") || !strcmp ((char *) value, "no"))
+ if (!strcmp (value, "yes") || !strcmp (value, "no"))
return; /* valid */
- g_set_error (error,
+ g_set_error (info->error,
NM_VPN_PLUGIN_ERROR,
NM_VPN_PLUGIN_ERROR_BAD_ARGUMENTS,
"invalid boolean property '%s' (not yes or no)",
- (const char *) key);
+ key);
break;
default:
- g_set_error (error,
+ g_set_error (info->error,
NM_VPN_PLUGIN_ERROR,
NM_VPN_PLUGIN_ERROR_BAD_ARGUMENTS,
"unhandled property '%s' type %s",
- (const char *) key, g_type_name (prop.type));
+ key, g_type_name (prop.type));
break;
}
}
/* Did not find the property from valid_properties or the type did not match */
- if (!valid_properties[i].name) {
- g_set_error (error,
+ if (!info->table[i].name) {
+ g_set_error (info->error,
NM_VPN_PLUGIN_ERROR,
NM_VPN_PLUGIN_ERROR_BAD_ARGUMENTS,
"property '%s' invalid or not supported",
- (const char *) key);
+ key);
}
}
static gboolean
-nm_vpnc_properties_validate (GHashTable *properties, GError **error)
+nm_vpnc_properties_validate (NMSettingVPN *s_vpn, GError **error)
{
- if (g_hash_table_size (properties) < 1) {
+ ValidateInfo info = { &valid_properties[0], error, FALSE };
+
+ nm_setting_vpn_foreach_data_item (s_vpn, validate_one_property, &info);
+ if (!info.have_items) {
g_set_error (error,
NM_VPN_PLUGIN_ERROR,
NM_VPN_PLUGIN_ERROR_BAD_ARGUMENTS,
@@ -139,7 +154,23 @@
return FALSE;
}
- g_hash_table_foreach (properties, validate_one_property, error);
+ return *error ? FALSE : TRUE;
+}
+
+static gboolean
+nm_vpnc_secrets_validate (NMSettingVPN *s_vpn, GError **error)
+{
+ ValidateInfo info = { &valid_secrets[0], error, FALSE };
+
+ nm_setting_vpn_foreach_secret (s_vpn, validate_one_property, &info);
+ if (!info.have_items) {
+ g_set_error (error,
+ NM_VPN_PLUGIN_ERROR,
+ NM_VPN_PLUGIN_ERROR_BAD_ARGUMENTS,
+ "%s",
+ "No VPN secrets!");
+ return FALSE;
+ }
return *error ? FALSE : TRUE;
}
@@ -257,7 +288,7 @@
} WriteConfigInfo;
static void
-write_one_property (gpointer key, gpointer value, gpointer user_data)
+write_one_property (const char *key, const char *value, gpointer user_data)
{
WriteConfigInfo *info = (WriteConfigInfo *) user_data;
GType type = G_TYPE_INVALID;
@@ -271,8 +302,19 @@
ValidProperty prop = valid_properties[i];
if (!strcmp (prop.name, (char *) key)) {
- /* Property is ok */
- type = prop.type;
+ /* Property is ok */
+ type = prop.type;
+ break;
+ }
+ }
+
+ /* Try the valid secrets table */
+ for (i = 0; type == G_TYPE_INVALID && valid_secrets[i].name; i++) {
+ ValidProperty prop = valid_secrets[i];
+
+ if (!strcmp (prop.name, (char *) key)) {
+ /* Property is ok */
+ type = prop.type;
break;
}
}
@@ -319,14 +361,15 @@
static gboolean
nm_vpnc_config_write (gint vpnc_fd,
- const char *default_user_name,
- GHashTable *properties,
- GHashTable *secrets,
+ NMSettingVPN *s_vpn,
GError **error)
{
WriteConfigInfo *info;
- const char *props_user_name;
+ const char *props_username;
const char *props_natt_mode;
+ const char *default_username;
+
+ default_username = nm_setting_vpn_get_user_name (s_vpn);
write_config_option (vpnc_fd, "Script " NM_VPNC_HELPER_PATH "\n");
@@ -335,17 +378,17 @@
NM_VPNC_UDP_ENCAPSULATION_PORT);
/* Fill username if it's not present */
- props_user_name = g_hash_table_lookup (properties, NM_VPNC_KEY_XAUTH_USER);
- if ( default_user_name
- && strlen (default_user_name)
- && (!props_user_name || !strlen (props_user_name))) {
+ props_username = nm_setting_vpn_get_data_item (s_vpn, NM_VPNC_KEY_XAUTH_USER);
+ if ( default_username
+ && strlen (default_username)
+ && (!props_username || !strlen (props_username))) {
write_config_option (vpnc_fd,
NM_VPNC_KEY_XAUTH_USER " %s\n",
- default_user_name);
+ default_username);
}
/* Use NAT-T by default */
- props_natt_mode = g_hash_table_lookup (properties, NM_VPNC_KEY_NAT_TRAVERSAL_MODE);
+ props_natt_mode = nm_setting_vpn_get_data_item (s_vpn, NM_VPNC_KEY_NAT_TRAVERSAL_MODE);
if (!props_natt_mode || !strlen (props_natt_mode)) {
write_config_option (vpnc_fd,
NM_VPNC_KEY_NAT_TRAVERSAL_MODE " %s\n",
@@ -354,8 +397,8 @@
info = g_malloc0 (sizeof (WriteConfigInfo));
info->fd = vpnc_fd;
- g_hash_table_foreach (properties, write_one_property, info);
- g_hash_table_foreach (secrets, write_one_property, info);
+ nm_setting_vpn_foreach_data_item (s_vpn, write_one_property, info);
+ nm_setting_vpn_foreach_secret (s_vpn, write_one_property, info);
*error = info->error;
g_free (info);
@@ -373,16 +416,17 @@
s_vpn = NM_SETTING_VPN (nm_connection_get_setting (connection, NM_TYPE_SETTING_VPN));
g_assert (s_vpn);
- if (!nm_vpnc_properties_validate (s_vpn->data, error))
+
+ if (!nm_vpnc_properties_validate (s_vpn, error))
goto out;
- if (!nm_vpnc_properties_validate (s_vpn->secrets, error))
+ if (!nm_vpnc_secrets_validate (s_vpn, error))
goto out;
vpnc_fd = nm_vpnc_start_vpnc_binary (NM_VPNC_PLUGIN (plugin), error);
if (vpnc_fd < 0)
goto out;
- if (!nm_vpnc_config_write (vpnc_fd, s_vpn->user_name, s_vpn->data, s_vpn->secrets, error))
+ if (!nm_vpnc_config_write (vpnc_fd, s_vpn, error))
goto out;
success = TRUE;
@@ -416,11 +460,11 @@
// FIXME: there are some configurations where both passwords are not
// required. Make sure they work somehow.
- if (!g_hash_table_lookup (s_vpn->secrets, NM_VPNC_KEY_SECRET)) {
+ if (!nm_setting_vpn_get_secret (s_vpn, NM_VPNC_KEY_SECRET)) {
*setting_name = NM_SETTING_VPN_SETTING_NAME;
return TRUE;
}
- if (!g_hash_table_lookup (s_vpn->secrets, NM_VPNC_KEY_XAUTH_PASSWORD)) {
+ if (!nm_setting_vpn_get_secret (s_vpn, NM_VPNC_KEY_XAUTH_PASSWORD)) {
*setting_name = NM_SETTING_VPN_SETTING_NAME;
return TRUE;
}
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Remember to have fun...
--
To unsubscribe, e-mail: opensuse-commit+unsubscribe@opensuse.org
For additional commands, e-mail: opensuse-commit+help@opensuse.org