[network-manager-openconnect] Add Juniper NC support



commit 34051bb91c69e17b0932eff89df4343f78e0db21
Author: David Woodhouse <David Woodhouse intel com>
Date:   Fri Jun 3 14:37:20 2016 +0100

    Add Juniper NC support
    
    Signed-off-by: David Woodhouse <David Woodhouse intel com>

 auth-dialog/main.c             |   15 ++++++++++++++-
 nm-openconnect-service.name.in |    1 +
 src/nm-openconnect-service.c   |   16 +++++++++++++++-
 3 files changed, 30 insertions(+), 2 deletions(-)
---
diff --git a/auth-dialog/main.c b/auth-dialog/main.c
index 7e28db2..c40ad2c 100644
--- a/auth-dialog/main.c
+++ b/auth-dialog/main.c
@@ -937,6 +937,7 @@ static int get_config (GHashTable *options, GHashTable *secrets,
        char *hostname;
        char *group;
        char *csd;
+       char *protocol;
        char *sslkey, *cert;
        char *csd_wrapper;
        char *pem_passphrase_fsid;
@@ -985,6 +986,18 @@ static int get_config (GHashTable *options, GHashTable *secrets,
                parse_xmlconfig (config_str);
        }
 
+       protocol = g_hash_table_lookup(options, NM_SETTING_VPN_SERVICE_TYPE);
+       if (protocol && g_str_has_prefix(protocol, NM_DBUS_SERVICE_OPENCONNECT ".")) {
+#if OPENCONNECT_CHECK_VER(5,2)
+               int ret = openconnect_set_protocol(vpninfo, protocol +
+                                 strlen(NM_DBUS_SERVICE_OPENCONENCT "."));
+               if (ret)
+                       return ret;
+#else
+               return -EINVAL;
+#endif
+       }
+
        cafile = g_hash_table_lookup (options, NM_OPENCONNECT_KEY_CACERT);
        if (cafile)
                openconnect_set_cafile(vpninfo, OC3DUP (cafile));
@@ -1623,7 +1636,7 @@ int main (int argc, char **argv)
                return 1;
        }
 
-       if (strcmp(vpn_service, NM_VPN_SERVICE_TYPE_OPENCONNECT) != 0) {
+       if (!g_str_has_prefix(vpn_service, NM_VPN_SERVICE_TYPE_OPENCONNECT)) {
                fprintf (stderr, "This dialog only works with the '%s' service\n",
                         NM_VPN_SERVICE_TYPE_OPENCONNECT);
                return 1;
diff --git a/nm-openconnect-service.name.in b/nm-openconnect-service.name.in
index 78d8535..38adcea 100644
--- a/nm-openconnect-service.name.in
+++ b/nm-openconnect-service.name.in
@@ -1,5 +1,6 @@
 [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
diff --git a/src/nm-openconnect-service.c b/src/nm-openconnect-service.c
index 9cc1d75..7e8be4f 100644
--- a/src/nm-openconnect-service.c
+++ b/src/nm-openconnect-service.c
@@ -364,7 +364,8 @@ 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;
+
        /* Find openconnect */
        openconnect_binary = openconnect_binary_paths;
        while (*openconnect_binary != NULL) {
@@ -409,10 +410,23 @@ 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 ".");
+
+               /* Special case for OpenConnect 7.06 which had --juniper but not --protocol */
+               if (!strcmp(service, "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);
+               }
+       }
+
        if (props_gwcert && strlen(props_gwcert)) {
                g_ptr_array_add (openconnect_argv, (gpointer) "--servercert");
                g_ptr_array_add (openconnect_argv, (gpointer) props_gwcert);


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