[network-manager-openconnect: 3/4] change multiprotocol support to use a new "protocol" option



commit 93a807a8d75a268d2c6b25602cf6c7ef6392c849
Author: Thomas Haller <thaller redhat com>
Date:   Wed Jun 8 01:45:20 2016 +0200

    change multiprotocol support to use a new "protocol" option
    
    The recently added Juniper VPN support was realized by adding a
    service-type alias openconnect.nc. Thereby, the protocol was encoded in
    the service-type. The service-type was traditionally the D-Bus bus name
    of the VPN service and since multi-VPN it is a prefix for the bus name.
    Another important role of the service-type is that it is stored inside a
    connection, so that the vpn.service-type setting associates a connection
    with its plugin.
    
    The service-type should not be hacked to encode the openconnect protocol
    option. That is, the service-type field already has different meanings,
    and it should not be reused. Instead, add a new NM_OPENCONNECT_KEY_PROTOCOL
    key.
    
    However, in nm-connection-editor's UI we don't want to show the protocol
    as an option inside the VPN dialog. Instead, the two protocols
    "anyconnect" and "nc" should result in two separate entires in the
    "add-connection" list. This way, the user first selects to create either
    an "anyconnect" or "nc" VPN connection, and then the UI doesn't let
    him switch protocol anymore.
    
    This is realized by exposing the protocol as an "add-detail". When
    populating the list of VPN types, connection-editor can ask the plugin
    whether it supports multiple entires. Later, when adding the connection,
    the protocol field is pre-filled with the "add-detail-key".
    
    Note that the nm-openconnect plugin is mostly agnostic to the actual
    protocol setting. When openconnect gains support for a new protocol, the
    plugin's service part will just support it right away.
    The only thing missing is to generate an additional add-connection entry
    in the properties plugin. Note how the supported protocols are declared
    in the .name file. So, the user could extend the plugin's .name file with
    a new protocol and as a result, the new protocol would show up in the list.
    However, then the plugin is unable to show a proper name and description
    to the user, so to truly support new protocols, the plugin must be
    extended too.
    That also makes sense, as the .name file is not user-configuration. But
    editing the .name file is a suitable workaround to support new protocols.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=767197

 nm-openconnect-service.name.in              |    4 +-
 properties/Makefile.am                      |    1 +
 properties/nm-openconnect.c                 |  132 +++++++++++++++++++
 shared/Makefile.am                          |    4 +-
 shared/nm-utils/nm-vpn-editor-plugin-call.h |  189 +++++++++++++++++++++++++++
 src/nm-openconnect-service-defines.h        |    1 +
 src/nm-openconnect-service.c                |   14 +-
 7 files changed, 335 insertions(+), 10 deletions(-)
---
diff --git a/nm-openconnect-service.name.in b/nm-openconnect-service.name.in
index 38adcea..0dde170 100644
--- a/nm-openconnect-service.name.in
+++ b/nm-openconnect-service.name.in
@@ -1,6 +1,5 @@
 [VPN Connection]
 name=openconnect
-aliases=org.freedesktop.NetworkManager.openconnect.anyconnect;org.freedesktop.NetworkManager.openconnect.nc
 service=org.freedesktop.NetworkManager.openconnect
 program= LIBEXECDIR@/nm-openconnect-service
 supports-multiple-connections=true
@@ -11,3 +10,6 @@ plugin= PLUGINDIR@/libnm-vpn-plugin-openconnect.so
 [GNOME]
 auth-dialog= LIBEXECDIR@/nm-openconnect-auth-dialog
 properties= PLUGINDIR@/libnm-openconnect-properties
+
+[openconnect]
+supported-protocols=anyconnect,nc
diff --git a/properties/Makefile.am b/properties/Makefile.am
index f79c5ad..90269f5 100644
--- a/properties/Makefile.am
+++ b/properties/Makefile.am
@@ -20,6 +20,7 @@ common_CFLAGS =                                         \
        $(GLIB_CFLAGS)                                  \
        $(GTK_CFLAGS)                                   \
        $(OPENCONNECT_CFLAGS)                           \
+       -I$(top_srcdir)/shared                          \
        -I$(top_srcdir)/src                             \
        -DICONDIR=\""$(datadir)/pixmaps"\"              \
        -DUIDIR=\""$(uidir)"\"                          \
diff --git a/properties/nm-openconnect.c b/properties/nm-openconnect.c
index ec1a3e8..f2b7abd 100644
--- a/properties/nm-openconnect.c
+++ b/properties/nm-openconnect.c
@@ -76,6 +76,10 @@
 #include "nm-openconnect.h"
 #include "auth-helpers.h"
 
+#ifndef NM_OPENCONNECT_OLD
+#include "nm-utils/nm-vpn-editor-plugin-call.h"
+#endif
+
 #define OPENCONNECT_PLUGIN_NAME    _("Cisco AnyConnect Compatible VPN (openconnect)")
 #define OPENCONNECT_PLUGIN_DESC    _("Compatible with Cisco AnyConnect SSL VPN.")
 
@@ -94,6 +98,12 @@ G_DEFINE_TYPE_EXTENDED (OpenconnectEditorPlugin, openconnect_editor_plugin, G_TY
                         G_IMPLEMENT_INTERFACE (NM_TYPE_VPN_EDITOR_PLUGIN,
                                                openconnect_editor_plugin_interface_init))
 
+typedef struct {
+       char **supported_protocols;
+} OpenconnectEditorPluginPrivate;
+
+#define OPENCONNECT_EDITOR_PLUGIN_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), 
OPENCONNECT_TYPE_EDITOR_PLUGIN, OpenconnectEditorPluginPrivate))
+
 /************** UI widget class **************/
 
 static void openconnect_editor_interface_init (NMVpnEditorInterface *iface_class);
@@ -595,10 +605,18 @@ update_connection (NMVpnEditor *iface,
        GtkTextIter iter_start, iter_end;
        GtkTextBuffer *buffer;
        const char *auth_type = NULL;
+       const char *protocol = NULL;
+
+       s_vpn = nm_connection_get_setting_vpn (connection);
+       if (s_vpn)
+               protocol = nm_setting_vpn_get_data_item (s_vpn, NM_OPENCONNECT_KEY_PROTOCOL);
 
        s_vpn = NM_SETTING_VPN (nm_setting_vpn_new ());
        g_object_set (s_vpn, NM_SETTING_VPN_SERVICE_TYPE, NM_VPN_SERVICE_TYPE_OPENCONNECT, NULL);
 
+       if (protocol)
+               nm_setting_vpn_add_data_item (s_vpn, NM_OPENCONNECT_KEY_PROTOCOL, protocol);
+
        widget = GTK_WIDGET (gtk_builder_get_object (priv->builder, "gateway_entry"));
        str = (char *) gtk_entry_get_text (GTK_ENTRY (widget));
        if (str && strlen (str))
@@ -792,6 +810,93 @@ get_capabilities (NMVpnEditorPlugin *iface)
                NM_VPN_EDITOR_PLUGIN_CAPABILITY_IPV6);
 }
 
+#ifndef NM_OPENCONNECT_OLD
+static void
+notify_plugin_info_set (NMVpnEditorPlugin *plugin,
+                        NMVpnPluginInfo *plugin_info)
+{
+       OpenconnectEditorPluginPrivate *priv = OPENCONNECT_EDITOR_PLUGIN_GET_PRIVATE (plugin);
+       const char *supported_protocols;
+       guint i, j;
+
+       if (!plugin_info)
+               return;
+
+       supported_protocols = nm_vpn_plugin_info_lookup_property (plugin_info, "openconnect", 
"supported-protocols");
+
+       g_strfreev (priv->supported_protocols);
+       priv->supported_protocols = supported_protocols
+           ? g_strsplit_set (supported_protocols, ",", -1)
+           : g_new0 (char *, 1);
+
+       /*remove empty entries and whitespace */
+       for (i = 0, j = 0; priv->supported_protocols[j]; j++) {
+               g_strstrip (priv->supported_protocols[j]);
+               if (priv->supported_protocols[j][0] == '\0')
+                       g_free (priv->supported_protocols[j]);
+               else
+                       priv->supported_protocols[i++] = priv->supported_protocols[j];
+       }
+       priv->supported_protocols[i] = NULL;
+}
+
+static char **
+_vt_impl_get_service_add_details (NMVpnEditorPlugin *plugin,
+                                  const char *service_type)
+{
+       return g_strdupv (OPENCONNECT_EDITOR_PLUGIN_GET_PRIVATE (plugin)->supported_protocols);
+}
+
+static gboolean
+_vt_impl_get_service_add_detail (NMVpnEditorPlugin *plugin,
+                                 const char *service_type,
+                                 const char *add_detail,
+                                 char **out_pretty_name,
+                                 char **out_description,
+                                 char **out_add_detail_key,
+                                 char **out_add_detail_val,
+                                 guint *out_flags)
+{
+       OpenconnectEditorPluginPrivate *priv;
+       guint i;
+
+       if (!nm_streq (service_type, NM_VPN_SERVICE_TYPE_OPENCONNECT))
+               return FALSE;
+
+       priv = OPENCONNECT_EDITOR_PLUGIN_GET_PRIVATE (plugin);
+       for (i = 0; priv->supported_protocols[i]; i++) {
+               if (!nm_streq (add_detail, priv->supported_protocols[i]))
+                       continue;
+               if (nm_streq (add_detail, "anyconnect")) {
+                       NM_SET_OUT (out_pretty_name, g_strdup (OPENCONNECT_PLUGIN_NAME));
+                       NM_SET_OUT (out_description, g_strdup (OPENCONNECT_PLUGIN_DESC));
+                       /* we unset @add_detail, because "anyconnect" is the default and no need
+                        * to set the protocol explicitly. */
+                       add_detail = NULL;
+               } else if (nm_streq (add_detail, "nc")) {
+                       NM_SET_OUT (out_pretty_name, g_strdup (_("Juniper Network Connect (openconnect)")));
+                       NM_SET_OUT (out_description, g_strdup (_("Compatible with Juniper Network Connect / 
Pulse Secure SSL VPN")));
+               } else {
+                       /* we don't know this protocol by name, but it's configured in the .name file,
+                        * so just take it. */
+                       NM_SET_OUT (out_pretty_name, g_strdup_printf (_("Openconnect VPN (%s)"), add_detail));
+                       NM_SET_OUT (out_description, g_strdup_printf (_("Openconnect SSL VPN with %s 
protocol"), add_detail));
+               }
+               NM_SET_OUT (out_add_detail_key, g_strdup (add_detail ? NM_OPENCONNECT_KEY_PROTOCOL : NULL));
+               NM_SET_OUT (out_add_detail_val, g_strdup (add_detail));
+               NM_SET_OUT (out_flags, 0);
+               return TRUE;
+       }
+       return FALSE;
+}
+
+NM_VPN_EDITOR_PLUGIN_VT_DEFINE (vt, _get_vt,
+       .fcn_get_service_add_details = _vt_impl_get_service_add_details,
+       .fcn_get_service_add_detail  = _vt_impl_get_service_add_detail,
+)
+
+#endif
+
 static NMVpnEditor *
 get_editor (NMVpnEditorPlugin *iface, NMConnection *connection, GError **error)
 {
@@ -819,11 +924,26 @@ get_property (GObject *object, guint prop_id,
 }
 
 static void
+openconnect_editor_plugin_dispose (GObject *object)
+{
+       OpenconnectEditorPlugin *plugin = OPENCONNECT_EDITOR_PLUGIN (object);
+       OpenconnectEditorPluginPrivate *priv = OPENCONNECT_EDITOR_PLUGIN_GET_PRIVATE (plugin);
+
+       g_strfreev (priv->supported_protocols);
+       priv->supported_protocols = NULL;
+
+       G_OBJECT_CLASS (openconnect_editor_plugin_parent_class)->dispose (object);
+}
+
+static void
 openconnect_editor_plugin_class_init (OpenconnectEditorPluginClass *req_class)
 {
        GObjectClass *object_class = G_OBJECT_CLASS (req_class);
 
+       g_type_class_add_private (req_class, sizeof (OpenconnectEditorPluginPrivate));
+
        object_class->get_property = get_property;
+       object_class->dispose = openconnect_editor_plugin_dispose;
 
        g_object_class_override_property (object_class,
                                          PROP_NAME,
@@ -841,6 +961,14 @@ openconnect_editor_plugin_class_init (OpenconnectEditorPluginClass *req_class)
 static void
 openconnect_editor_plugin_init (OpenconnectEditorPlugin *plugin)
 {
+       OpenconnectEditorPluginPrivate *priv = OPENCONNECT_EDITOR_PLUGIN_GET_PRIVATE (plugin);
+       char *dflt[] = {
+               "anyconnect",
+               "nc",
+               NULL,
+       };
+
+       priv->supported_protocols = g_strdupv (dflt);
 }
 
 static void
@@ -851,6 +979,10 @@ openconnect_editor_plugin_interface_init (NMVpnEditorPluginInterface *iface_clas
        iface_class->get_capabilities = get_capabilities;
        iface_class->import_from_file = import;
        iface_class->export_to_file = export;
+#ifndef NM_OPENCONNECT_OLD
+       iface_class->notify_plugin_info_set = notify_plugin_info_set;
+       iface_class->get_vt = _get_vt;
+#endif
 }
 
 G_MODULE_EXPORT NMVpnEditorPlugin *
diff --git a/shared/Makefile.am b/shared/Makefile.am
index 82244bc..7896aa5 100644
--- a/shared/Makefile.am
+++ b/shared/Makefile.am
@@ -1,3 +1,5 @@
 EXTRA_DIST = \
     nm-utils/gsystem-local-alloc.h \
-    nm-utils/nm-macros-internal.h
+    nm-utils/nm-macros-internal.h \
+    nm-utils/nm-vpn-editor-plugin-call.h \
+    $(NULL)
diff --git a/shared/nm-utils/nm-vpn-editor-plugin-call.h b/shared/nm-utils/nm-vpn-editor-plugin-call.h
new file mode 100644
index 0000000..c6b7ee7
--- /dev/null
+++ b/shared/nm-utils/nm-vpn-editor-plugin-call.h
@@ -0,0 +1,189 @@
+/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
+/* NetworkManager -- Network link manager
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Copyright (C) 2016 Red Hat, Inc.
+ */
+
+#ifndef __NM_VPN_EDITOR_PLUGIN_CALL_H__
+#define __NM_VPN_EDITOR_PLUGIN_CALL_H__
+
+/* This header is an internal, header-only file that can be copied to
+ * other projects to call well-known service functions on VPN plugins.
+ *
+ * This uses the NMVpnEditorPluginVT and allows a user (nm-applet)
+ * to directly communicate with a VPN plugin using API that is newer
+ * then the current libnm version. That is, it allows to call to a VPN
+ * plugin bypassing libnm. */
+
+#include <NetworkManager.h>
+
+/* we make use of other internal header files, you need those too. */
+#include "gsystem-local-alloc.h"
+#include "nm-macros-internal.h"
+
+/*****************************************************************************/
+
+/**
+ * NMVpnEditorPluginServiceFlags:
+ * @NM_VPN_EDITOR_PLUGIN_SERVICE_FLAGS_NONE: no flags
+ * @NM_VPN_EDITOR_PLUGIN_SERVICE_FLAGS_CAN_ADD: whether the plugin can
+ *   add a new connection for the given service-type.
+ **/
+typedef enum { /*< skip >*/
+       NM_VPN_EDITOR_PLUGIN_SERVICE_FLAGS_NONE     = 0x00,
+       NM_VPN_EDITOR_PLUGIN_SERVICE_FLAGS_CAN_ADD  = 0x01,
+} NMVpnEditorPluginServiceFlags;
+
+struct _NMVpnEditorPluginVT {
+       gboolean (*fcn_get_service_info) (NMVpnEditorPlugin *plugin,
+                                         const char *service_type,
+                                         char **out_short_name,
+                                         char **out_pretty_name,
+                                         char **out_description,
+                                         NMVpnEditorPluginServiceFlags *out_flags);
+       char **(*fcn_get_service_add_details) (NMVpnEditorPlugin *plugin,
+                                              const char *service_name);
+       gboolean (*fcn_get_service_add_detail) (NMVpnEditorPlugin *plugin,
+                                               const char *service_type,
+                                               const char *add_detail,
+                                               char **out_pretty_name,
+                                               char **out_description,
+                                               char **out_add_detail_key,
+                                               char **out_add_detail_val,
+                                               guint *out_flags);
+};
+
+/*****************************************************************************
+ * Call
+ *
+ * The following wrap the calling of generic functions for a VPN plugin.
+ * They are used by callers (for example nm-connection-editor).
+ *****************************************************************************/
+
+static inline gboolean
+nm_vpn_editor_plugin_get_service_info (NMVpnEditorPlugin *plugin,
+                                       const char *service_type,
+                                       char **out_short_name,
+                                       char **out_pretty_name,
+                                       char **out_description,
+                                       NMVpnEditorPluginServiceFlags *out_flags)
+{
+       NMVpnEditorPluginVT vt;
+       gs_free char *short_name_local = NULL;
+       gs_free char *pretty_name_local = NULL;
+       gs_free char *description_local = NULL;
+       guint flags_local = 0;
+
+       g_return_val_if_fail (NM_IS_VPN_EDITOR_PLUGIN (plugin), FALSE);
+       g_return_val_if_fail (service_type, FALSE);
+
+       nm_vpn_editor_plugin_get_vt (plugin, &vt, sizeof (vt));
+       if (   !vt.fcn_get_service_info
+           || !vt.fcn_get_service_info (plugin,
+                                        service_type,
+                                        out_short_name  ? &short_name_local : NULL,
+                                        out_pretty_name ? &pretty_name_local : NULL,
+                                        out_description ? &description_local : NULL,
+                                        out_flags       ? &flags_local : NULL))
+               return FALSE;
+       NM_SET_OUT (out_short_name, g_steal_pointer (&short_name_local));
+       NM_SET_OUT (out_pretty_name, g_steal_pointer (&pretty_name_local));
+       NM_SET_OUT (out_description, g_steal_pointer (&description_local));
+       NM_SET_OUT (out_flags, flags_local);
+       return TRUE;
+}
+
+static inline char **
+nm_vpn_editor_plugin_get_service_add_details (NMVpnEditorPlugin *plugin,
+                                              const char *service_name)
+{
+       NMVpnEditorPluginVT vt;
+       char **details = NULL;
+
+       g_return_val_if_fail (NM_IS_VPN_EDITOR_PLUGIN (plugin), NULL);
+       g_return_val_if_fail (service_name, NULL);
+
+       nm_vpn_editor_plugin_get_vt (plugin, &vt, sizeof (vt));
+       if (vt.fcn_get_service_add_details)
+               details = vt.fcn_get_service_add_details (plugin, service_name);
+       if (!details)
+               return g_new0 (char *, 1);
+       return details;
+}
+
+static inline gboolean
+nm_vpn_editor_plugin_get_service_add_detail (NMVpnEditorPlugin *plugin,
+                                             const char *service_type,
+                                             const char *add_detail,
+                                             char **out_pretty_name,
+                                             char **out_description,
+                                             char **out_add_detail_key,
+                                             char **out_add_detail_val,
+                                             guint *out_flags)
+{
+       NMVpnEditorPluginVT vt;
+       gs_free char *pretty_name_local = NULL;
+       gs_free char *description_local = NULL;
+       gs_free char *add_detail_key_local = NULL;
+       gs_free char *add_detail_val_local = NULL;
+       guint flags_local = 0;
+
+       g_return_val_if_fail (NM_IS_VPN_EDITOR_PLUGIN (plugin), FALSE);
+       g_return_val_if_fail (service_type, FALSE);
+       g_return_val_if_fail (add_detail, FALSE);
+
+       nm_vpn_editor_plugin_get_vt (plugin, &vt, sizeof (vt));
+       if (   !vt.fcn_get_service_add_detail
+           || !vt.fcn_get_service_add_detail (plugin,
+                                              service_type,
+                                              add_detail,
+                                              out_pretty_name    ? &pretty_name_local : NULL,
+                                              out_description    ? &description_local : NULL,
+                                              out_add_detail_key ? &add_detail_key_local : NULL,
+                                              out_add_detail_val ? &add_detail_val_local : NULL,
+                                              out_flags          ? &flags_local : NULL))
+               return FALSE;
+       NM_SET_OUT (out_pretty_name, g_steal_pointer (&pretty_name_local));
+       NM_SET_OUT (out_description, g_steal_pointer (&description_local));
+       NM_SET_OUT (out_add_detail_key, g_steal_pointer (&add_detail_key_local));
+       NM_SET_OUT (out_add_detail_val, g_steal_pointer (&add_detail_val_local));
+       NM_SET_OUT (out_flags, flags_local);
+       return TRUE;
+}
+
+/*****************************************************************************
+ * Implementation
+ *
+ * The following glue code can be used to implement calls in a VPN plugin.
+ *****************************************************************************/
+
+#define NM_VPN_EDITOR_PLUGIN_VT_DEFINE(vt_name, get_vt, ...) \
+static const NMVpnEditorPluginVT vt_name = { \
+               __VA_ARGS__ \
+       }; \
+static const NMVpnEditorPluginVT * \
+get_vt (NMVpnEditorPlugin *plugin, \
+        gsize *out_vt_size) \
+{ \
+       nm_assert (NM_IS_VPN_EDITOR_PLUGIN (plugin)); \
+       nm_assert (out_vt_size); \
+       \
+       *out_vt_size = sizeof (vt_name); \
+       return &vt_name; \
+}
+
+#endif /* __NM_VPN_EDITOR_PLUGIN_CALL_H__ */
diff --git a/src/nm-openconnect-service-defines.h b/src/nm-openconnect-service-defines.h
index 8bc2626..6853505 100644
--- a/src/nm-openconnect-service-defines.h
+++ b/src/nm-openconnect-service-defines.h
@@ -40,6 +40,7 @@
 #define NM_OPENCONNECT_KEY_PRIVKEY "userkey"
 #define NM_OPENCONNECT_KEY_MTU "mtu"
 #define NM_OPENCONNECT_KEY_PEM_PASSPHRASE_FSID "pem_passphrase_fsid"
+#define NM_OPENCONNECT_KEY_PROTOCOL "protocol"
 #define NM_OPENCONNECT_KEY_PROXY "proxy"
 #define NM_OPENCONNECT_KEY_CSD_ENABLE "enable_csd_trojan"
 #define NM_OPENCONNECT_KEY_CSD_WRAPPER "csd_wrapper"
diff --git a/src/nm-openconnect-service.c b/src/nm-openconnect-service.c
index 7e8be4f..4fccba2 100644
--- a/src/nm-openconnect-service.c
+++ b/src/nm-openconnect-service.c
@@ -364,7 +364,7 @@ nm_openconnect_start_openconnect_binary (NMOpenconnectPlugin *plugin,
        GSource *openconnect_watch;
        gint    stdin_fd;
        const char *props_vpn_gw, *props_cookie, *props_cacert, *props_mtu, *props_gwcert, *props_proxy;
-       const char *service;
+       const char *protocol;
 
        /* Find openconnect */
        openconnect_binary = openconnect_binary_paths;
@@ -410,20 +410,18 @@ nm_openconnect_start_openconnect_binary (NMOpenconnectPlugin *plugin,
        props_mtu = nm_setting_vpn_get_data_item (s_vpn, NM_OPENCONNECT_KEY_MTU);
 
        props_proxy = nm_setting_vpn_get_data_item (s_vpn, NM_OPENCONNECT_KEY_PROXY);
-       service = nm_setting_vpn_get_service_type (s_vpn);
 
        openconnect_argv = g_ptr_array_new ();
        g_ptr_array_add (openconnect_argv, (gpointer) (*openconnect_binary));
 
-       if (service && g_str_has_prefix(service, NM_DBUS_SERVICE_OPENCONNECT ".")) {
-               service += strlen(NM_DBUS_SERVICE_OPENCONNECT ".");
-
+       protocol = nm_setting_vpn_get_data_item (s_vpn, NM_OPENCONNECT_KEY_PROTOCOL);
+       if (protocol && strcmp (protocol, "anyconnect")) {
                /* Special case for OpenConnect 7.06 which had --juniper but not --protocol */
-               if (!strcmp(service, "juniper"))
+               if (!strcmp (protocol, "juniper"))
                        g_ptr_array_add (openconnect_argv, (gpointer) "--juniper");
                else {
                        g_ptr_array_add (openconnect_argv, (gpointer) "--protocol");
-                       g_ptr_array_add (openconnect_argv, (gpointer) service);
+                       g_ptr_array_add (openconnect_argv, (gpointer) protocol);
                }
        }
 
@@ -444,7 +442,7 @@ nm_openconnect_start_openconnect_binary (NMOpenconnectPlugin *plugin,
                g_ptr_array_add (openconnect_argv, (gpointer) "--proxy");
                g_ptr_array_add (openconnect_argv, (gpointer) props_proxy);
        }
-               
+
        g_ptr_array_add (openconnect_argv, (gpointer) "--syslog");
        g_ptr_array_add (openconnect_argv, (gpointer) "--cookie-on-stdin");
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]