[network-manager-openvpn] properties: support multiple 'remote' values when importing/exporting
- From: JiÅÃ KlimeÅ <jklimes src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [network-manager-openvpn] properties: support multiple 'remote' values when importing/exporting
- Date: Mon, 4 Feb 2013 14:54:46 +0000 (UTC)
commit b6e780fd738041380bd9d4bedc7d0bc5fc962b2c
Author: JiÅÃ KlimeÅ <jklimes redhat com>
Date: Mon Feb 4 15:44:17 2013 +0100
properties: support multiple 'remote' values when importing/exporting
Basically that should have been added together with cb81bdcea8b043ee8890cf930d88c9e30fc28612.
Note we still doesn't support multiple ports. So when exporting we get:
remote gatewayA 1234
remote gatewayB 1234
remote gatewayC 1234
On import, port from the last 'remote' line is taken.
remote gatewayA 1111
remote gatewayB 2222
remote gatewayC 3333
will result in using port 3333
properties/import-export.c | 27 +++++++++++++++++++--------
1 files changed, 19 insertions(+), 8 deletions(-)
---
diff --git a/properties/import-export.c b/properties/import-export.c
index 9fc6e0e..5312e36 100644
--- a/properties/import-export.c
+++ b/properties/import-export.c
@@ -15,7 +15,7 @@
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
- * Copyright (C) 2008 - 2011 Dan Williams <dcbw redhat com> and Red Hat, Inc.
+ * Copyright (C) 2008 - 2013 Dan Williams <dcbw redhat com> and Red Hat, Inc.
*
**************************************************************************/
@@ -501,7 +501,10 @@ do_import (const char *path, char **lines, GError **error)
if (!strncmp (*line, REMOTE_TAG, strlen (REMOTE_TAG))) {
items = get_args (*line + strlen (REMOTE_TAG), &nitems);
if (nitems >= 1 && nitems <= 3) {
- nm_setting_vpn_add_data_item (s_vpn, NM_OPENVPN_KEY_REMOTE, items[0]);
+ const char *prev = nm_setting_vpn_get_data_item (s_vpn, NM_OPENVPN_KEY_REMOTE);
+ char *new_remote = g_strdup_printf ("%s%s%s", prev ? prev : "", prev ? ", " : "", items[0]);
+ nm_setting_vpn_add_data_item (s_vpn, NM_OPENVPN_KEY_REMOTE, new_remote);
+ g_free (new_remote);
have_remote = TRUE;
if (nitems >= 2) {
@@ -729,7 +732,8 @@ do_export (const char *path, NMConnection *connection, GError **error)
NMSettingVPN *s_vpn;
FILE *f;
const char *value;
- const char *gateway = NULL;
+ const char *gateways = NULL;
+ char **gw_list, **gw_iter;
const char *cipher = NULL;
const char *cacert = NULL;
const char *connection_type = NULL;
@@ -770,7 +774,7 @@ do_export (const char *path, NMConnection *connection, GError **error)
value = nm_setting_vpn_get_data_item (s_vpn, NM_OPENVPN_KEY_REMOTE);
if (value && strlen (value))
- gateway = value;
+ gateways = value;
else {
g_set_error (error, 0, 0, "connection was incomplete (missing gateway)");
goto done;
@@ -864,10 +868,17 @@ do_export (const char *path, NMConnection *connection, GError **error)
/* Advanced values end */
fprintf (f, "client\n");
- fprintf (f, "remote %s%s%s\n",
- gateway,
- port ? " " : "",
- port ? port : "");
+
+ gw_list = g_strsplit_set (gateways, " ,", 0);
+ for (gw_iter = gw_list; gw_iter && *gw_iter; gw_iter++) {
+ if (**gw_iter == '\0')
+ continue;
+ fprintf (f, "remote %s%s%s\n",
+ *gw_iter,
+ port ? " " : "",
+ port ? port : "");
+ }
+ g_strfreev (gw_list);
/* Handle PKCS#12 (all certs are the same file) */
if ( cacert && user_cert && private_key
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]