Blob Blame History Raw
From 649e4be103589c5a137a582751a9ec84b12885e0 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Ji=C5=99=C3=AD=20Klime=C5=A1?= <jklimes@redhat.com>
Date: Mon, 26 May 2014 14:51:24 +0200
Subject: [PATCH 1/2] cli: extract username and gateway for some more VPN
 types
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit


Signed-off-by: Jiří Klimeš <jklimes@redhat.com>
---
 cli/src/connections.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/cli/src/connections.c b/cli/src/connections.c
index 267d17c..295ca61 100644
--- a/cli/src/connections.c
+++ b/cli/src/connections.c
@@ -939,6 +939,9 @@ find_vpn_gateway_key (const char *vpn_type)
 	if (g_strcmp0 (vpn_type, "pptp") == 0)        return "gateway";
 	if (g_strcmp0 (vpn_type, "openconnect") == 0) return "gateway";
 	if (g_strcmp0 (vpn_type, "openswan") == 0)    return "right";
+	if (g_strcmp0 (vpn_type, "libreswan") == 0)   return "right";
+	if (g_strcmp0 (vpn_type, "ssh") == 0)         return "remote";
+	if (g_strcmp0 (vpn_type, "l2tp") == 0)        return "gateway";
 	return "";
 }
 
@@ -950,6 +953,8 @@ find_vpn_username_key (const char *vpn_type)
 	if (g_strcmp0 (vpn_type, "pptp") == 0)        return "user";
 	if (g_strcmp0 (vpn_type, "openconnect") == 0) return "username";
 	if (g_strcmp0 (vpn_type, "openswan") == 0)    return "leftxauthusername";
+	if (g_strcmp0 (vpn_type, "libreswan") == 0)   return "leftxauthusername";
+	if (g_strcmp0 (vpn_type, "l2tp") == 0)        return "user";
 	return "";
 }
 
-- 
1.7.11.7


From d7216505bbfe0de976d477609c06528432c380d4 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Ji=C5=99=C3=AD=20Klime=C5=A1?= <jklimes@redhat.com>
Date: Mon, 26 May 2014 15:19:47 +0200
Subject: [PATCH 2/2] cli: do not restrict VPN type of created connections (rh
 #1100750)
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

There may be third-party VPN plugins nmcli is not aware of.
We still print a warning if nmcli doesn't know the type. It helps to catch up
typos.

https://bugzilla.redhat.com/show_bug.cgi?id=1100750

Signed-off-by: Jiří Klimeš <jklimes@redhat.com>
---
 cli/completion/nmcli  |  2 +-
 cli/src/connections.c | 20 +++++++++-----------
 man/nmcli.1.in        |  2 +-
 3 files changed, 11 insertions(+), 13 deletions(-)

diff --git a/cli/completion/nmcli b/cli/completion/nmcli
index bbfee3a..0a185a1 100644
--- a/cli/completion/nmcli
+++ b/cli/completion/nmcli
@@ -419,7 +419,7 @@ _nmcli_compl_ARGS()
                 ;;
             vpn-type)
                 if [[ "${#words[@]}" -eq 2 ]]; then
-                    _nmcli_list "vpnc openvpn pptp openconnect openswan"
+                    _nmcli_list "vpnc openvpn pptp openconnect openswan libreswan ssh l2tp iodine"
                     return 0
                 fi
                 ;;
diff --git a/cli/src/connections.c b/cli/src/connections.c
index 295ca61..3580c79 100644
--- a/cli/src/connections.c
+++ b/cli/src/connections.c
@@ -400,7 +400,7 @@ usage_connection_add (void)
 	           "                  [priority <0-63>]\n"
 	           "                  [path-cost <1-65535>]\n"
 	           "                  [hairpin yes|no]\n\n"
-	           "    vpn:          vpn-type vpnc|openvpn|pptp|openconnect|openswan\n"
+	           "    vpn:          vpn-type vpnc|openvpn|pptp|openconnect|openswan|libreswan|ssh|l2tp|iodine|...\n"
 	           "                  [user <username>]\n\n"
 	           "    olpc-mesh:    ssid <SSID>\n"
 	           "                  [channel <1-13>]\n"
@@ -4758,14 +4758,14 @@ cleanup_bridge_slave:
 	} else if (!strcmp (con_type, NM_SETTING_VPN_SETTING_NAME)) {
 		/* Build up the settings required for 'vpn' */
 		gboolean success = FALSE;
-		const char *valid_vpns[] = { "openvpn", "vpnc", "pptp", "openconnect", "openswan", NULL };
+		const char *known_vpns[] = { "openvpn", "vpnc", "pptp", "openconnect", "openswan", "libreswan",
+		                             "ssh", "l2tp", "iodine", NULL };
 		const char *vpn_type = NULL;
 		char *vpn_type_ask = NULL;
 		const char *user_c = NULL;
 		char *user = NULL;
 		const char *st;
 		char *service_type = NULL;
-		GError *tmp_err = NULL;
 		nmc_arg_t exp_args[] = { {"vpn-type", TRUE, &vpn_type, !ask},
 		                         {"user",     TRUE, &user_c,   FALSE},
 		                         {NULL} };
@@ -4781,19 +4781,17 @@ cleanup_bridge_slave:
 			goto cleanup_vpn;
 		}
 
+		if (!(st = nmc_string_is_valid (vpn_type, known_vpns, NULL))) {
+			printf (_("Warning: 'vpn-type': %s not known.\n"), vpn_type);
+			st = vpn_type;
+		}
+		service_type = g_strdup_printf ("%s.%s", NM_DBUS_INTERFACE, st);
+
 		/* Also ask for all optional arguments if '--ask' is specified. */
 		user = user_c ? g_strdup (user_c) : NULL;
 		if (ask)
 			do_questionnaire_vpn (&user);
 
-		if (!(st = nmc_string_is_valid (vpn_type, valid_vpns, &tmp_err))) {
-			g_set_error (error, NMCLI_ERROR, NMC_RESULT_ERROR_USER_INPUT,
-			             _("Error: 'vpn-type': %s."), tmp_err->message);
-			g_clear_error (&tmp_err);
-			goto cleanup_vpn;
-		}
-		service_type = g_strdup_printf ("%s.%s", NM_DBUS_INTERFACE, st);
-
 		/* Add 'vpn' setting */
 		s_vpn = (NMSettingVPN *) nm_setting_vpn_new ();
 		nm_connection_add_setting (connection, NM_SETTING (s_vpn));
diff --git a/man/nmcli.1.in b/man/nmcli.1.in
index 6eb6f1f..1d91e89 100644
--- a/man/nmcli.1.in
+++ b/man/nmcli.1.in
@@ -573,7 +573,7 @@ to be sent back out through the slave the frame was received on (default: yes)
 .RS
 .TP
 .B vpn:
-.IP "\fIvpn-type vpnc|openvpn|pptp|openconnect|openswan\fP" 42
+.IP "\fIvpn-type vpnc|openvpn|pptp|openconnect|openswan|libreswan|ssh|l2tp|iodine|...\fP" 42
 \(en VPN type
 .IP "\fI[user <username>]\fP" 42
 \(en VPN username
-- 
1.7.11.7