Blame SOURCES/rh1100750-cli-vpn-types.patch

708502
From 649e4be103589c5a137a582751a9ec84b12885e0 Mon Sep 17 00:00:00 2001
708502
From: =?UTF-8?q?Ji=C5=99=C3=AD=20Klime=C5=A1?= <jklimes@redhat.com>
708502
Date: Mon, 26 May 2014 14:51:24 +0200
708502
Subject: [PATCH 1/2] cli: extract username and gateway for some more VPN
708502
 types
708502
MIME-Version: 1.0
708502
Content-Type: text/plain; charset=UTF-8
708502
Content-Transfer-Encoding: 8bit
708502
708502
708502
Signed-off-by: Jiří Klimeš <jklimes@redhat.com>
708502
---
708502
 cli/src/connections.c | 5 +++++
708502
 1 file changed, 5 insertions(+)
708502
708502
diff --git a/cli/src/connections.c b/cli/src/connections.c
708502
index 267d17c..295ca61 100644
708502
--- a/cli/src/connections.c
708502
+++ b/cli/src/connections.c
708502
@@ -939,6 +939,9 @@ find_vpn_gateway_key (const char *vpn_type)
708502
 	if (g_strcmp0 (vpn_type, "pptp") == 0)        return "gateway";
708502
 	if (g_strcmp0 (vpn_type, "openconnect") == 0) return "gateway";
708502
 	if (g_strcmp0 (vpn_type, "openswan") == 0)    return "right";
708502
+	if (g_strcmp0 (vpn_type, "libreswan") == 0)   return "right";
708502
+	if (g_strcmp0 (vpn_type, "ssh") == 0)         return "remote";
708502
+	if (g_strcmp0 (vpn_type, "l2tp") == 0)        return "gateway";
708502
 	return "";
708502
 }
708502
 
708502
@@ -950,6 +953,8 @@ find_vpn_username_key (const char *vpn_type)
708502
 	if (g_strcmp0 (vpn_type, "pptp") == 0)        return "user";
708502
 	if (g_strcmp0 (vpn_type, "openconnect") == 0) return "username";
708502
 	if (g_strcmp0 (vpn_type, "openswan") == 0)    return "leftxauthusername";
708502
+	if (g_strcmp0 (vpn_type, "libreswan") == 0)   return "leftxauthusername";
708502
+	if (g_strcmp0 (vpn_type, "l2tp") == 0)        return "user";
708502
 	return "";
708502
 }
708502
 
708502
-- 
708502
1.7.11.7
708502
708502
708502
From d7216505bbfe0de976d477609c06528432c380d4 Mon Sep 17 00:00:00 2001
708502
From: =?UTF-8?q?Ji=C5=99=C3=AD=20Klime=C5=A1?= <jklimes@redhat.com>
708502
Date: Mon, 26 May 2014 15:19:47 +0200
708502
Subject: [PATCH 2/2] cli: do not restrict VPN type of created connections (rh
708502
 #1100750)
708502
MIME-Version: 1.0
708502
Content-Type: text/plain; charset=UTF-8
708502
Content-Transfer-Encoding: 8bit
708502
708502
There may be third-party VPN plugins nmcli is not aware of.
708502
We still print a warning if nmcli doesn't know the type. It helps to catch up
708502
typos.
708502
708502
https://bugzilla.redhat.com/show_bug.cgi?id=1100750
708502
708502
Signed-off-by: Jiří Klimeš <jklimes@redhat.com>
708502
---
708502
 cli/completion/nmcli  |  2 +-
708502
 cli/src/connections.c | 20 +++++++++-----------
708502
 man/nmcli.1.in        |  2 +-
708502
 3 files changed, 11 insertions(+), 13 deletions(-)
708502
708502
diff --git a/cli/completion/nmcli b/cli/completion/nmcli
708502
index bbfee3a..0a185a1 100644
708502
--- a/cli/completion/nmcli
708502
+++ b/cli/completion/nmcli
708502
@@ -419,7 +419,7 @@ _nmcli_compl_ARGS()
708502
                 ;;
708502
             vpn-type)
708502
                 if [[ "${#words[@]}" -eq 2 ]]; then
708502
-                    _nmcli_list "vpnc openvpn pptp openconnect openswan"
708502
+                    _nmcli_list "vpnc openvpn pptp openconnect openswan libreswan ssh l2tp iodine"
708502
                     return 0
708502
                 fi
708502
                 ;;
708502
diff --git a/cli/src/connections.c b/cli/src/connections.c
708502
index 295ca61..3580c79 100644
708502
--- a/cli/src/connections.c
708502
+++ b/cli/src/connections.c
708502
@@ -400,7 +400,7 @@ usage_connection_add (void)
708502
 	           "                  [priority <0-63>]\n"
708502
 	           "                  [path-cost <1-65535>]\n"
708502
 	           "                  [hairpin yes|no]\n\n"
708502
-	           "    vpn:          vpn-type vpnc|openvpn|pptp|openconnect|openswan\n"
708502
+	           "    vpn:          vpn-type vpnc|openvpn|pptp|openconnect|openswan|libreswan|ssh|l2tp|iodine|...\n"
708502
 	           "                  [user <username>]\n\n"
708502
 	           "    olpc-mesh:    ssid <SSID>\n"
708502
 	           "                  [channel <1-13>]\n"
708502
@@ -4758,14 +4758,14 @@ cleanup_bridge_slave:
708502
 	} else if (!strcmp (con_type, NM_SETTING_VPN_SETTING_NAME)) {
708502
 		/* Build up the settings required for 'vpn' */
708502
 		gboolean success = FALSE;
708502
-		const char *valid_vpns[] = { "openvpn", "vpnc", "pptp", "openconnect", "openswan", NULL };
708502
+		const char *known_vpns[] = { "openvpn", "vpnc", "pptp", "openconnect", "openswan", "libreswan",
708502
+		                             "ssh", "l2tp", "iodine", NULL };
708502
 		const char *vpn_type = NULL;
708502
 		char *vpn_type_ask = NULL;
708502
 		const char *user_c = NULL;
708502
 		char *user = NULL;
708502
 		const char *st;
708502
 		char *service_type = NULL;
708502
-		GError *tmp_err = NULL;
708502
 		nmc_arg_t exp_args[] = { {"vpn-type", TRUE, &vpn_type, !ask},
708502
 		                         {"user",     TRUE, &user_c,   FALSE},
708502
 		                         {NULL} };
708502
@@ -4781,19 +4781,17 @@ cleanup_bridge_slave:
708502
 			goto cleanup_vpn;
708502
 		}
708502
 
708502
+		if (!(st = nmc_string_is_valid (vpn_type, known_vpns, NULL))) {
708502
+			printf (_("Warning: 'vpn-type': %s not known.\n"), vpn_type);
708502
+			st = vpn_type;
708502
+		}
708502
+		service_type = g_strdup_printf ("%s.%s", NM_DBUS_INTERFACE, st);
708502
+
708502
 		/* Also ask for all optional arguments if '--ask' is specified. */
708502
 		user = user_c ? g_strdup (user_c) : NULL;
708502
 		if (ask)
708502
 			do_questionnaire_vpn (&user);
708502
 
708502
-		if (!(st = nmc_string_is_valid (vpn_type, valid_vpns, &tmp_err))) {
708502
-			g_set_error (error, NMCLI_ERROR, NMC_RESULT_ERROR_USER_INPUT,
708502
-			             _("Error: 'vpn-type': %s."), tmp_err->message);
708502
-			g_clear_error (&tmp_err);
708502
-			goto cleanup_vpn;
708502
-		}
708502
-		service_type = g_strdup_printf ("%s.%s", NM_DBUS_INTERFACE, st);
708502
-
708502
 		/* Add 'vpn' setting */
708502
 		s_vpn = (NMSettingVPN *) nm_setting_vpn_new ();
708502
 		nm_connection_add_setting (connection, NM_SETTING (s_vpn));
708502
diff --git a/man/nmcli.1.in b/man/nmcli.1.in
708502
index 6eb6f1f..1d91e89 100644
708502
--- a/man/nmcli.1.in
708502
+++ b/man/nmcli.1.in
708502
@@ -573,7 +573,7 @@ to be sent back out through the slave the frame was received on (default: yes)
708502
 .RS
708502
 .TP
708502
 .B vpn:
708502
-.IP "\fIvpn-type vpnc|openvpn|pptp|openconnect|openswan\fP" 42
708502
+.IP "\fIvpn-type vpnc|openvpn|pptp|openconnect|openswan|libreswan|ssh|l2tp|iodine|...\fP" 42
708502
 \(en VPN type
708502
 .IP "\fI[user <username>]\fP" 42
708502
 \(en VPN username
708502
-- 
708502
1.7.11.7
708502