[network-manager-openconnect] Fix auth-dialog for new protocol handling



commit 3a9c053be20084d5a681709074b5948fab3ac458
Author: David Woodhouse <David Woodhouse intel com>
Date:   Wed Jun 15 21:13:08 2016 +0100

    Fix auth-dialog for new protocol handling

 auth-dialog/main.c |   22 ++++++++++------------
 1 files changed, 10 insertions(+), 12 deletions(-)
---
diff --git a/auth-dialog/main.c b/auth-dialog/main.c
index 68f297d..fdf7a9d 100644
--- a/auth-dialog/main.c
+++ b/auth-dialog/main.c
@@ -943,6 +943,7 @@ static int get_config (GHashTable *options, GHashTable *secrets,
        char *cafile;
        char *token_mode;
        char *token_secret;
+       char *protocol;
 
        hostname = g_hash_table_lookup (options, NM_OPENCONNECT_KEY_GATEWAY);
        if (!hostname) {
@@ -985,6 +986,14 @@ static int get_config (GHashTable *options, GHashTable *secrets,
                parse_xmlconfig (config_str);
        }
 
+       protocol = g_hash_table_lookup (options, NM_OPENCONNECT_KEY_PROTOCOL);
+       if (protocol && strcmp(protocol, "anyconnect")) {
+#if OPENCONNECT_CHECK_VER(5,1)
+               if (openconnect_set_protocol(vpninfo, protocol))
+#endif
+                       return -EINVAL;
+       }
+
        cafile = g_hash_table_lookup (options, NM_OPENCONNECT_KEY_CACERT);
        if (cafile)
                openconnect_set_cafile(vpninfo, OC3DUP (cafile));
@@ -1623,7 +1632,7 @@ int main (int argc, char **argv)
                return 1;
        }
 
-       if (!g_str_has_prefix(vpn_service, NM_VPN_SERVICE_TYPE_OPENCONNECT)) {
+       if (strcmp(vpn_service, NM_VPN_SERVICE_TYPE_OPENCONNECT) != 0) {
                fprintf (stderr, "This dialog only works with the '%s' service\n",
                         NM_VPN_SERVICE_TYPE_OPENCONNECT);
                return 1;
@@ -1643,17 +1652,6 @@ int main (int argc, char **argv)
                return 1;
        }
 
-       if (g_str_has_prefix(vpn_service, NM_VPN_SERVICE_TYPE_OPENCONNECT ".")) {
-               char *proto = vpn_service + strlen(NM_VPN_SERVICE_TYPE_OPENCONNECT ".");
-#if OPENCONNECT_CHECK_VER(5,1)
-               if (openconnect_set_protocol(_ui_data->vpninfo, proto))
-#endif
-               {
-                       fprintf (stderr, "Protocol '%s' not supported\n", proto);
-                       return 1;
-               }
-       }
-
 #if OPENCONNECT_CHECK_VER(3,4)
        openconnect_set_token_callbacks (_ui_data->vpninfo, _ui_data, NULL, update_token);
 #endif


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