[network-manager-openconnect/nm-0-9-8] Support libopenconnect.so.4



commit 9e4b394da0c29d77de9a110603aefa437c6b4173
Author: David Woodhouse <David Woodhouse intel com>
Date:   Thu Oct 30 23:09:14 2014 +0000

    Support libopenconnect.so.4
    
    (cherry picked from commit 58944a3ef9c92f7afa07cbb539d062e1956bafc0)

 auth-dialog/main.c |   38 ++++++++++++++++++++++++++------------
 1 files changed, 26 insertions(+), 12 deletions(-)
---
diff --git a/auth-dialog/main.c b/auth-dialog/main.c
index 2a3544a..dc34386 100644
--- a/auth-dialog/main.c
+++ b/auth-dialog/main.c
@@ -88,6 +88,21 @@
 #define OC_FORM_RESULT_NEWGROUP                2
 #endif
 
+#if OPENCONNECT_CHECK_VER(4,0)
+#define dup_option_value(opt)          g_strdup((opt)->_value);
+#define OC3DUP(x)                      (x)
+#define write_config_const             const
+#else
+#define dup_option_value(opt)          g_strdup((opt)->value);
+#define openconnect_set_option_value(opt, val) do { \
+               struct oc_form_opt *_o = (opt);                         \
+               free(_o->value); _o->value = g_strdup(val);             \
+       } while (0)
+#define openconnect_free_cert_info(v, x) free(x)
+#define OC3DUP(x)                      g_strdup(x)
+#define write_config_const             /* */
+#endif
+
 #ifdef OPENCONNECT_OPENSSL
 #include <openssl/ssl.h>
 #include <openssl/bio.h>
@@ -722,7 +737,7 @@ static gboolean ui_form (struct oc_auth_form *form)
                                data->entry_text = g_strdup (find_form_answer(ui_data->secrets,
                                                                              form, opt));
                                if (!data->entry_text)
-                                       data->entry_text = g_strdup (opt->value);
+                                       data->entry_text = dup_option_value(opt);
                        } else {
                                data->find_request = gnome_keyring_find_password(
                                                OPENCONNECT_SCHEMA,
@@ -785,8 +800,7 @@ static gboolean set_initial_authgroup (auth_ui_data *ui_data, struct oc_auth_for
                for (i = 0; i < sopt->nr_choices; i++) {
                        struct oc_choice *ch = FORMCHOICE(sopt, i);
                        if (!strcmp(saved_group, ch->name) && i != AUTHGROUP_SELECTION(form)) {
-                               free(opt->value);
-                               opt->value = g_strdup(saved_group);
+                               openconnect_set_option_value(opt, saved_group);
                                return TRUE;
                        }
                }
@@ -832,7 +846,7 @@ static int nm_process_auth_form (void *cbdata, struct oc_auth_form *form)
                                gnome_keyring_cancel_request(data->find_request);
 
                        if (data->entry_text) {
-                               data->opt->value = g_strdup (data->entry_text);
+                               openconnect_set_option_value(data->opt, data->entry_text);
 
                                if (data->opt->type == OC_FORM_OPT_TEXT ||
                                    data->opt->type == OC_FORM_OPT_SELECT) {
@@ -941,7 +955,7 @@ static gboolean user_validate_cert(cert_data *data)
        text = gtk_text_view_new();
        buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(text));
        gtk_text_buffer_set_text(buffer, details, -1);
-       free(details);
+       openconnect_free_cert_info(data->ui_data->vpninfo, details);
        gtk_text_view_set_editable(GTK_TEXT_VIEW(text), 0);
        gtk_text_view_set_cursor_visible(GTK_TEXT_VIEW(text), FALSE);
        gtk_container_add(GTK_CONTAINER(scroll), text);
@@ -1175,7 +1189,7 @@ static int get_config (GHashTable *options, GHashTable *secrets,
 
        cafile = g_hash_table_lookup (options, NM_OPENCONNECT_KEY_CACERT);
        if (cafile)
-               openconnect_set_cafile(vpninfo, g_strdup (cafile));
+               openconnect_set_cafile(vpninfo, OC3DUP (cafile));
 
        csd = g_hash_table_lookup (options, NM_OPENCONNECT_KEY_CSD_ENABLE);
        if (csd && !strcmp(csd, "yes")) {
@@ -1185,16 +1199,16 @@ static int get_config (GHashTable *options, GHashTable *secrets,
                if (csd_wrapper && !csd_wrapper[0])
                        csd_wrapper = NULL;
 
-               openconnect_setup_csd(vpninfo, getuid(), 1, g_strdup (csd_wrapper));
+               openconnect_setup_csd(vpninfo, getuid(), 1, OC3DUP (csd_wrapper));
        }
 
        proxy = g_hash_table_lookup (options, NM_OPENCONNECT_KEY_PROXY);
-       if (proxy && proxy[0] && openconnect_set_http_proxy(vpninfo, g_strdup (proxy)))
+       if (proxy && proxy[0] && openconnect_set_http_proxy(vpninfo, OC3DUP (proxy)))
                return -EINVAL;
 
        cert = g_hash_table_lookup (options, NM_OPENCONNECT_KEY_USERCERT);
        sslkey = g_hash_table_lookup (options, NM_OPENCONNECT_KEY_PRIVKEY);
-       openconnect_set_client_cert (vpninfo, g_strdup (cert), g_strdup (sslkey));
+       openconnect_set_client_cert (vpninfo, OC3DUP (cert), OC3DUP (sslkey));
 
        pem_passphrase_fsid = g_hash_table_lookup (options,
                                                   NM_OPENCONNECT_KEY_PEM_PASSPHRASE_FSID);
@@ -1254,7 +1268,7 @@ static int update_token(void *cbdata, const char *tok)
 }
 #endif
 
-static int write_new_config(void *cbdata, char *buf, int buflen)
+static int write_new_config(void *cbdata, write_config_const char *buf, int buflen)
 {
        auth_ui_data *ui_data = cbdata;
        g_hash_table_insert (ui_data->secrets, g_strdup ("xmlconfig"),
@@ -1500,11 +1514,11 @@ static void connect_host(auth_ui_data *ui_data)
        if (openconnect_parse_url(ui_data->vpninfo, host->hostaddress)) {
                fprintf(stderr, "Failed to parse server URL '%s'\n",
                        host->hostaddress);
-               openconnect_set_hostname (ui_data->vpninfo, g_strdup(host->hostaddress));
+               openconnect_set_hostname (ui_data->vpninfo, OC3DUP (host->hostaddress));
        }
 
        if (!openconnect_get_urlpath(ui_data->vpninfo) && host->usergroup)
-               openconnect_set_urlpath(ui_data->vpninfo, g_strdup(host->usergroup));
+               openconnect_set_urlpath(ui_data->vpninfo, OC3DUP (host->usergroup));
 
 
        g_hash_table_insert (ui_data->success_secrets, g_strdup("lasthost"),


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