summaryrefslogtreecommitdiff
blob: 835f694e4fb16f924de6892868c141507be8f9d1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
From b8c7e773204d3b4a85a27d7d2ae58dfc1939e1a8 Mon Sep 17 00:00:00 2001
From: David Woodhouse <David.Woodhouse@intel.com>
Date: Thu, 30 Oct 2014 23:16:20 +0000
Subject: [PATCH 26/34] Drop support for libopenconnect.so.1

---
 auth-dialog/main.c | 201 +----------------------------------------------------
 1 file changed, 2 insertions(+), 199 deletions(-)

diff --git a/auth-dialog/main.c b/auth-dialog/main.c
index 8285bf4..df0146c 100644
--- a/auth-dialog/main.c
+++ b/auth-dialog/main.c
@@ -49,20 +49,6 @@
 
 #include "openconnect.h"
 
-#if OPENCONNECT_API_VERSION_MAJOR == 1
-#define openconnect_vpninfo_new openconnect_vpninfo_new_with_cbdata
-#define openconnect_init_ssl openconnect_init_openssl
-#endif
-
-#ifndef OPENCONNECT_CHECK_VER
-#define OPENCONNECT_CHECK_VER(x,y) 0
-#endif
-
-#if !OPENCONNECT_CHECK_VER(1,5)
-#define OPENCONNECT_X509 X509
-#define OPENCONNECT_OPENSSL
-#endif
-
 #if !OPENCONNECT_CHECK_VER(2,1)
 #define __openconnect_set_token_mode(...) -EOPNOTSUPP
 #elif !OPENCONNECT_CHECK_VER(2,2)
@@ -104,12 +90,6 @@
 #define write_config_const		/* */
 #endif
 
-#ifdef OPENCONNECT_OPENSSL
-#include <openssl/ssl.h>
-#include <openssl/bio.h>
-#include <openssl/ui.h>
-#endif
-
 static const SecretSchema openconnect_secret_schema = {
 	"org.freedesktop.NetworkManager.Connection.Openconnect",
 	SECRET_SCHEMA_DONT_MATCH_NAME,
@@ -301,9 +281,6 @@ typedef struct ui_fragment_data {
 	GtkWidget *entry;
 	GCancellable *cancel;
 	auth_ui_data *ui_data;
-#ifdef OPENCONNECT_OPENSSL
-	UI_STRING *uis;
-#endif
 	struct oc_form_opt *opt;
 	char *entry_text;
 	int initial_selection;
@@ -315,27 +292,9 @@ static void entry_activate_cb(GtkWidget *widget, auth_ui_data *ui_data)
 	gtk_dialog_response(GTK_DIALOG(ui_data->dialog), AUTH_DIALOG_RESPONSE_LOGIN);
 }
 
-#ifdef OPENCONNECT_OPENSSL
-static void do_check_visibility(ui_fragment_data *data, gboolean *visible)
-{
-	int min_len;
-
-	if (!data->uis)
-		return;
-
-	min_len = UI_get_result_minsize(data->uis);
-
-	if (min_len && (!data->entry_text || strlen(data->entry_text) < min_len))
-		*visible = FALSE;
-}
-#endif
 static void evaluate_login_visibility(auth_ui_data *ui_data)
 {
 	gboolean visible = TRUE;
-#ifdef OPENCONNECT_OPENSSL
-	g_queue_foreach(ui_data->form_entries, (GFunc)do_check_visibility,
-			&visible);
-#endif
 	gtk_widget_set_sensitive (ui_data->login_button, visible);
 }
 
@@ -343,9 +302,6 @@ static void entry_changed(GtkEntry *entry, ui_fragment_data *data)
 {
 	g_free (data->entry_text);
 	data->entry_text = g_strdup(gtk_entry_get_text(entry));
-#ifdef OPENCONNECT_OPENSSL
-	evaluate_login_visibility(data->ui_data);
-#endif
 }
 
 static void do_override_label(ui_fragment_data *data, struct oc_choice *choice)
@@ -387,26 +343,6 @@ static void combo_changed(GtkComboBox *combo, ui_fragment_data *data)
 			FORMCHOICE(sopt, entry));
 }
 
-#ifdef OPENCONNECT_OPENSSL
-static gboolean ui_write_error (ui_fragment_data *data)
-{
-	ssl_box_add_error(data->ui_data, UI_get0_output_string(data->uis));
-
-	g_slice_free (ui_fragment_data, data);
-
-	return FALSE;
-}
-
-static gboolean ui_write_info (ui_fragment_data *data)
-{
-	ssl_box_add_info(data->ui_data, UI_get0_output_string(data->uis));
-
-	g_slice_free (ui_fragment_data, data);
-
-	return FALSE;
-}
-#endif
-
 static gboolean ui_write_prompt (ui_fragment_data *data)
 {
 	auth_ui_data *ui_data = _ui_data; /* FIXME global */
@@ -414,16 +350,8 @@ static gboolean ui_write_prompt (ui_fragment_data *data)
 	int visible;
 	const char *label;
 
-#ifdef OPENCONNECT_OPENSSL
-	if (data->uis) {
-		label = UI_get0_output_string(data->uis);
-		visible = UI_get_input_flags(data->uis) & UI_INPUT_FLAG_ECHO;
-	} else 
-#endif
-	{
-		label = data->opt->label;
-		visible = (data->opt->type == OC_FORM_OPT_TEXT);
-	}
+	label = data->opt->label;
+	visible = (data->opt->type == OC_FORM_OPT_TEXT);
 
 	hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
 	gtk_box_pack_start(GTK_BOX(data->ui_data->ssl_box), hbox, FALSE, FALSE, 0);
@@ -512,128 +440,6 @@ static gboolean ui_show (auth_ui_data *ui_data)
 	return FALSE;
 }
 
-#ifdef OPENCONNECT_OPENSSL
-/* runs in worker thread */
-static int ui_open(UI *ui)
-{
-	auth_ui_data *ui_data = _ui_data; /* FIXME global */
-
-	UI_add_user_data(ui, ui_data);
-
-	return 1;
-}
-
-/* runs in worker thread */
-static int ui_write(UI *ui, UI_STRING *uis)
-{
-	auth_ui_data *ui_data;
-	ui_fragment_data *data;
-
-	ui_data = UI_get0_user_data(ui);
-
-	/* return if a new host has been selected */
-	if (ui_data->cancelled) {
-		return 1;
-	}
-
-	data = g_slice_new0 (ui_fragment_data);
-	data->ui_data = ui_data;
-	data->uis = uis;
-
-	switch(UI_get_string_type(uis)) {
-	case UIT_ERROR:
-		g_idle_add ((GSourceFunc)ui_write_error, data);
-		break;
-
-	case UIT_INFO:
-		g_idle_add ((GSourceFunc)ui_write_info, data);
-		break;
-
-	case UIT_PROMPT:
-	case UIT_VERIFY:
-		g_mutex_lock (&ui_data->form_mutex);
-		g_queue_push_head(ui_data->form_entries, data);
-		g_mutex_unlock (&ui_data->form_mutex);
-
-		g_idle_add ((GSourceFunc)ui_write_prompt, data);
-		break;
-
-	case UIT_BOOLEAN:
-		/* FIXME */
-	case UIT_NONE:
-	default:
-		g_slice_free (ui_fragment_data, data);
-	}
-	return 1;
-}
-
-/* runs in worker thread */
-static int ui_flush(UI* ui)
-{
-	auth_ui_data *ui_data;
-	int response;
-
-	ui_data = UI_get0_user_data(ui);
-
-	g_idle_add((GSourceFunc)ui_show, ui_data);
-	g_mutex_lock(&ui_data->form_mutex);
-	/* wait for ui to show */
-	while (!ui_data->form_shown) {
-		g_cond_wait(&ui_data->form_shown_changed, &ui_data->form_mutex);
-	}
-	ui_data->form_shown = FALSE;
-
-	if (!ui_data->cancelled) {
-		/* wait for form submission or cancel */
-		while (!ui_data->form_retval) {
-			g_cond_wait(&ui_data->form_retval_changed, &ui_data->form_mutex);
-		}
-		response = GPOINTER_TO_INT (ui_data->form_retval);
-		ui_data->form_retval = NULL;
-	} else
-		response = AUTH_DIALOG_RESPONSE_CANCEL;
-
-	/* set entry results and free temporary data structures */
-	while (!g_queue_is_empty (ui_data->form_entries)) {
-		ui_fragment_data *data;
-		data = g_queue_pop_tail (ui_data->form_entries);
-		if (data->entry_text) {
-			UI_set_result(ui, data->uis, data->entry_text);
-		}
-		if (data->cancel) {
-			g_cancellable_cancel(data->cancel);
-		}
-		g_slice_free (ui_fragment_data, data);
-	}
-	ui_data->form_grabbed = 0;
-	g_mutex_unlock(&ui_data->form_mutex);
-
-	/* -1 = cancel,
-	 *  0 = failure,
-	 *  1 = success */
-	return (response == AUTH_DIALOG_RESPONSE_LOGIN ? 1 : -1);
-}
-
-/* runs in worker thread */
-static int ui_close(UI *ui)
-{
-	return 1;
-}
-
-static int init_openssl_ui(void)
-{
-	UI_METHOD *ui_method = UI_create_method("OpenConnect VPN UI (gtk)");
-
-	UI_method_set_opener(ui_method, ui_open);
-	UI_method_set_flusher(ui_method, ui_flush);
-	UI_method_set_writer(ui_method, ui_write);
-	UI_method_set_closer(ui_method, ui_close);
-
-	UI_set_default_method(ui_method);
-	return 0;
-}
-#endif /* OPENCONNECT_OPENSSL */
-
 static char *find_form_answer(GHashTable *secrets, struct oc_auth_form *form,
 			      struct oc_form_opt *opt)
 {
@@ -1834,9 +1640,6 @@ int main (int argc, char **argv)
 
 	build_main_dialog(_ui_data);
 
-#ifdef OPENCONNECT_OPENSSL
-	init_openssl_ui();
-#endif
 	openconnect_init_ssl();
 
 	/* Start connecting now if there's only one host. Or if configured to */
-- 
2.2.0