From 24c4ad95aee0773908b5389702d3ed5c6b620720 Mon Sep 17 00:00:00 2001 From: Alexandre Rostovtsev Date: Wed, 12 Mar 2014 04:40:46 +0000 Subject: Fix support for >=openconnect-4.99 (bug #504192, thanks to Kobboi and Pacho Ramos). (Portage version: 2.2.8-r1/cvs/Linux x86_64, signed Manifest commit with key CF0ADD61) --- net-misc/networkmanager-openconnect/ChangeLog | 14 +- ...penconnect-0.9.8.4-auth-dialog-formchoice.patch | 60 ++++++ ...er-openconnect-0.9.8.4-auth-dialog-ignore.patch | 39 ++++ ...-openconnect-0.9.8.4-auth-dialog-newgroup.patch | 227 +++++++++++++++++++++ .../networkmanager-openconnect-0.9.8.4-r1.ebuild | 59 ++++++ 5 files changed, 397 insertions(+), 2 deletions(-) create mode 100644 net-misc/networkmanager-openconnect/files/networkmanager-openconnect-0.9.8.4-auth-dialog-formchoice.patch create mode 100644 net-misc/networkmanager-openconnect/files/networkmanager-openconnect-0.9.8.4-auth-dialog-ignore.patch create mode 100644 net-misc/networkmanager-openconnect/files/networkmanager-openconnect-0.9.8.4-auth-dialog-newgroup.patch create mode 100644 net-misc/networkmanager-openconnect/networkmanager-openconnect-0.9.8.4-r1.ebuild (limited to 'net-misc') diff --git a/net-misc/networkmanager-openconnect/ChangeLog b/net-misc/networkmanager-openconnect/ChangeLog index 994a8d4d1736..116db5b9c2c5 100644 --- a/net-misc/networkmanager-openconnect/ChangeLog +++ b/net-misc/networkmanager-openconnect/ChangeLog @@ -1,6 +1,16 @@ # ChangeLog for net-misc/networkmanager-openconnect -# Copyright 1999-2013 Gentoo Foundation; Distributed under the GPL v2 -# $Header: /var/cvsroot/gentoo-x86/net-misc/networkmanager-openconnect/ChangeLog,v 1.21 2013/12/08 19:30:06 pacho Exp $ +# Copyright 1999-2014 Gentoo Foundation; Distributed under the GPL v2 +# $Header: /var/cvsroot/gentoo-x86/net-misc/networkmanager-openconnect/ChangeLog,v 1.22 2014/03/12 04:40:46 tetromino Exp $ + +*networkmanager-openconnect-0.9.8.4-r1 (12 Mar 2014) + + 12 Mar 2014; Alexandre Rostovtsev + +networkmanager-openconnect-0.9.8.4-r1.ebuild, + +files/networkmanager-openconnect-0.9.8.4-auth-dialog-formchoice.patch, + +files/networkmanager-openconnect-0.9.8.4-auth-dialog-ignore.patch, + +files/networkmanager-openconnect-0.9.8.4-auth-dialog-newgroup.patch: + Fix support for >=openconnect-4.99 (bug #504192, thanks to Kobboi and Pacho + Ramos). 08 Dec 2013; Pacho Ramos networkmanager-openconnect-0.9.8.4.ebuild: diff --git a/net-misc/networkmanager-openconnect/files/networkmanager-openconnect-0.9.8.4-auth-dialog-formchoice.patch b/net-misc/networkmanager-openconnect/files/networkmanager-openconnect-0.9.8.4-auth-dialog-formchoice.patch new file mode 100644 index 000000000000..26dd1966e42a --- /dev/null +++ b/net-misc/networkmanager-openconnect/files/networkmanager-openconnect-0.9.8.4-auth-dialog-formchoice.patch @@ -0,0 +1,60 @@ +From d846b4e5bb9b89c1110d8ae38fd06021f3e4a9f2 Mon Sep 17 00:00:00 2001 +From: Kevin Cernekee +Date: Mon, 30 Dec 2013 17:49:35 -0800 +Subject: [PATCH] auth-dialog: Introduce FORMCHOICE helper macro + +libopenconnect >= 3.0 uses a pointer array so we need to change the way +the "choices" field is accessed. + + +diff --git a/auth-dialog/main.c b/auth-dialog/main.c +index 2d8c830..9b32f61 100644 +--- a/auth-dialog/main.c ++++ b/auth-dialog/main.c +@@ -70,6 +70,8 @@ + #define __openconnect_set_token_mode openconnect_set_token_mode + #endif + ++#define FORMCHOICE(sopt, i) (&(sopt)->choices[i]) ++ + #ifdef OPENCONNECT_OPENSSL + #include + #include +@@ -350,10 +352,10 @@ static void combo_changed(GtkComboBox *combo, ui_fragment_data *data) + if (entry < 0) + return; + +- data->entry_text = sopt->choices[entry].name; ++ data->entry_text = FORMCHOICE(sopt, entry)->name; + + g_queue_foreach(data->ui_data->form_entries, (GFunc)do_override_label, +- &sopt->choices[entry]); ++ FORMCHOICE(sopt, entry)); + } + + #ifdef OPENCONNECT_OPENSSL +@@ -449,17 +451,17 @@ static gboolean ui_add_select (ui_fragment_data *data) + combo = gtk_combo_box_text_new(); + gtk_box_pack_end(GTK_BOX(hbox), combo, FALSE, FALSE, 0); + for (i = 0; i < sopt->nr_choices; i++) { +- gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(combo), sopt->choices[i].label); ++ gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(combo), FORMCHOICE(sopt, i)->label); + if (data->entry_text && +- !strcmp(data->entry_text, sopt->choices[i].name)) { ++ !strcmp(data->entry_text, FORMCHOICE(sopt, i)->name)) { + gtk_combo_box_set_active(GTK_COMBO_BOX(combo), i); + g_free(data->entry_text); +- data->entry_text = sopt->choices[i].name; ++ data->entry_text = FORMCHOICE(sopt, i)->name; + } + } + if (gtk_combo_box_get_active(GTK_COMBO_BOX(combo)) < 0) { + gtk_combo_box_set_active(GTK_COMBO_BOX(combo), 0); +- data->entry_text = sopt->choices[0].name; ++ data->entry_text = FORMCHOICE(sopt, 0)->name; + } + + if (g_queue_peek_tail(ui_data->form_entries) == data) +-- +Gitg + diff --git a/net-misc/networkmanager-openconnect/files/networkmanager-openconnect-0.9.8.4-auth-dialog-ignore.patch b/net-misc/networkmanager-openconnect/files/networkmanager-openconnect-0.9.8.4-auth-dialog-ignore.patch new file mode 100644 index 000000000000..2bda8e529c5a --- /dev/null +++ b/net-misc/networkmanager-openconnect/files/networkmanager-openconnect-0.9.8.4-auth-dialog-ignore.patch @@ -0,0 +1,39 @@ +From e2144cbd1b7f71c2fc57264f125ef298c60f22b7 Mon Sep 17 00:00:00 2001 +From: Kevin Cernekee +Date: Mon, 30 Dec 2013 17:49:37 -0800 +Subject: [PATCH] auth-dialog: Add support for OC_FORM_OPT_IGNORE + +Hide any options that libopenconnect doesn't want us to display. + + +diff --git a/auth-dialog/main.c b/auth-dialog/main.c +index 4ab28cb..2174ea8 100644 +--- a/auth-dialog/main.c ++++ b/auth-dialog/main.c +@@ -75,11 +75,13 @@ + #define AUTHGROUP_OPT(form) (void *)(form)->authgroup_opt + #define AUTHGROUP_SELECTION(form) (form)->authgroup_selection + #define FORMCHOICE(sopt, i) ((sopt)->choices[i]) ++#define IGNORE_OPT(opt) ((opt)->flags & OC_FORM_OPT_IGNORE) + #else + #define NEWGROUP_SUPPORTED 0 + #define AUTHGROUP_OPT(form) NULL + #define AUTHGROUP_SELECTION(form) 0 + #define FORMCHOICE(sopt, i) (&(sopt)->choices[i]) ++#define IGNORE_OPT(opt) 0 + #define OC_FORM_RESULT_ERR -1 + #define OC_FORM_RESULT_OK 0 + #define OC_FORM_RESULT_CANCELLED 1 +@@ -704,7 +706,8 @@ static gboolean ui_form (struct oc_auth_form *form) + for (opt = form->opts; opt; opt = opt->next) { + ui_fragment_data *data; + +- if (opt->type == OC_FORM_OPT_HIDDEN) ++ if (opt->type == OC_FORM_OPT_HIDDEN || ++ IGNORE_OPT(opt)) + continue; + + data = g_slice_new0 (ui_fragment_data); +-- +Gitg + diff --git a/net-misc/networkmanager-openconnect/files/networkmanager-openconnect-0.9.8.4-auth-dialog-newgroup.patch b/net-misc/networkmanager-openconnect/files/networkmanager-openconnect-0.9.8.4-auth-dialog-newgroup.patch new file mode 100644 index 000000000000..fe6f8ad5cfd9 --- /dev/null +++ b/net-misc/networkmanager-openconnect/files/networkmanager-openconnect-0.9.8.4-auth-dialog-newgroup.patch @@ -0,0 +1,227 @@ +From 944389128a6cd95b7e6a3e9e4c7700528e6c14b0 Mon Sep 17 00:00:00 2001 +From: Kevin Cernekee +Date: Mon, 30 Dec 2013 17:49:36 -0800 +Subject: [PATCH] auth-dialog: Add support for NEWGROUP + +When the user selects a different authgroup, return NEWGROUP to +libopenconnect to allow it to refresh the form. Different groups may +require different prompts. + +Also, if secondary_username is provided by the server, prepopulate the +form field. + +[dwmw2: Update to use form->authgrop_opt and fix crash due to calling + gtk_dialog_response() from combo_changed callback.] + + +diff --git a/auth-dialog/main.c b/auth-dialog/main.c +index 9b32f61..4ab28cb 100644 +--- a/auth-dialog/main.c ++++ b/auth-dialog/main.c +@@ -70,7 +70,21 @@ + #define __openconnect_set_token_mode openconnect_set_token_mode + #endif + ++#if OPENCONNECT_CHECK_VER(3,0) ++#define NEWGROUP_SUPPORTED 1 ++#define AUTHGROUP_OPT(form) (void *)(form)->authgroup_opt ++#define AUTHGROUP_SELECTION(form) (form)->authgroup_selection ++#define FORMCHOICE(sopt, i) ((sopt)->choices[i]) ++#else ++#define NEWGROUP_SUPPORTED 0 ++#define AUTHGROUP_OPT(form) NULL ++#define AUTHGROUP_SELECTION(form) 0 + #define FORMCHOICE(sopt, i) (&(sopt)->choices[i]) ++#define OC_FORM_RESULT_ERR -1 ++#define OC_FORM_RESULT_OK 0 ++#define OC_FORM_RESULT_CANCELLED 1 ++#define OC_FORM_RESULT_NEWGROUP 2 ++#endif + + #ifdef OPENCONNECT_OPENSSL + #include +@@ -185,6 +199,9 @@ typedef struct auth_ui_data { + GCond *form_shown_changed; + gboolean form_shown; + ++ gboolean newgroup; ++ gboolean group_set; ++ + GCond *cert_response_changed; + enum certificate_response cert_response; + +@@ -291,6 +308,7 @@ typedef struct ui_fragment_data { + #endif + struct oc_form_opt *opt; + char *entry_text; ++ int initial_selection; + int grab_focus; + } ui_fragment_data; + +@@ -345,6 +363,13 @@ static void do_override_label(ui_fragment_data *data, struct oc_choice *choice) + gtk_label_set_text(GTK_LABEL(data->widget), new_label); + + } ++ ++static gboolean do_newgroup(GtkDialog *dialog) ++{ ++ gtk_dialog_response(dialog, AUTH_DIALOG_RESPONSE_LOGIN); ++ return FALSE; ++} ++ + static void combo_changed(GtkComboBox *combo, ui_fragment_data *data) + { + struct oc_form_opt_select *sopt = (void *)data->opt; +@@ -354,6 +379,12 @@ static void combo_changed(GtkComboBox *combo, ui_fragment_data *data) + + data->entry_text = FORMCHOICE(sopt, entry)->name; + ++ if (NEWGROUP_SUPPORTED && entry != data->initial_selection) { ++ data->ui_data->newgroup = TRUE; ++ g_idle_add ((GSourceFunc)do_newgroup, data->ui_data->dialog); ++ return; ++ } ++ + g_queue_foreach(data->ui_data->form_entries, (GFunc)do_override_label, + FORMCHOICE(sopt, entry)); + } +@@ -436,7 +467,7 @@ static gboolean ui_add_select (ui_fragment_data *data) + auth_ui_data *ui_data = _ui_data; /* FIXME global */ + GtkWidget *hbox, *text, *combo; + struct oc_form_opt_select *sopt = (void *)data->opt; +- int i; ++ int i, user_selection = -1; + + #if GTK_CHECK_VERSION(3,1,6) + hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0); +@@ -450,20 +481,21 @@ static gboolean ui_add_select (ui_fragment_data *data) + + combo = gtk_combo_box_text_new(); + gtk_box_pack_end(GTK_BOX(hbox), combo, FALSE, FALSE, 0); ++ + for (i = 0; i < sopt->nr_choices; i++) { + gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(combo), FORMCHOICE(sopt, i)->label); + if (data->entry_text && +- !strcmp(data->entry_text, FORMCHOICE(sopt, i)->name)) { +- gtk_combo_box_set_active(GTK_COMBO_BOX(combo), i); +- g_free(data->entry_text); +- data->entry_text = FORMCHOICE(sopt, i)->name; +- } +- } +- if (gtk_combo_box_get_active(GTK_COMBO_BOX(combo)) < 0) { +- gtk_combo_box_set_active(GTK_COMBO_BOX(combo), 0); +- data->entry_text = FORMCHOICE(sopt, 0)->name; ++ !strcmp(data->entry_text, FORMCHOICE(sopt, i)->name)) ++ user_selection = i; + } + ++ i = data->initial_selection != -1 ? data->initial_selection : ++ user_selection != -1 ? user_selection : 0; ++ gtk_combo_box_set_active(GTK_COMBO_BOX(combo), i); ++ g_free(data->entry_text); ++ data->entry_text = FORMCHOICE(sopt, i)->name; ++ data->initial_selection = i; ++ + if (g_queue_peek_tail(ui_data->form_entries) == data) + gtk_widget_grab_focus (combo); + g_signal_connect(G_OBJECT(combo), "changed", G_CALLBACK(combo_changed), data); +@@ -684,10 +716,12 @@ static gboolean ui_form (struct oc_auth_form *form) + g_mutex_lock (ui_data->form_mutex); + g_queue_push_head(ui_data->form_entries, data); + g_mutex_unlock (ui_data->form_mutex); +- if (opt->type != OC_FORM_OPT_PASSWORD) ++ if (opt->type != OC_FORM_OPT_PASSWORD) { + data->entry_text = g_strdup (find_form_answer(ui_data->secrets, + form, opt)); +- else { ++ if (!data->entry_text) ++ data->entry_text = g_strdup (opt->value); ++ } else { + data->find_request = gnome_keyring_find_password( + OPENCONNECT_SCHEMA, + got_keyring_pw, +@@ -709,6 +743,11 @@ static gboolean ui_form (struct oc_auth_form *form) + data->entry_text = g_strdup (find_form_answer(ui_data->secrets, + form, opt)); + ++ if (opt == AUTHGROUP_OPT(form)) ++ data->initial_selection = AUTHGROUP_SELECTION(form); ++ else ++ data->initial_selection = -1; ++ + ui_add_select(data); + } else + g_slice_free (ui_fragment_data, data); +@@ -717,11 +756,51 @@ static gboolean ui_form (struct oc_auth_form *form) + return ui_show(ui_data); + } + ++/* If our stored group_list selection differs from the server default, send a ++ NEWGROUP request to try to change it before rendering the form */ ++ ++static gboolean set_initial_authgroup (auth_ui_data *ui_data, struct oc_auth_form *form) ++{ ++ struct oc_form_opt *opt; ++ ++ if (!NEWGROUP_SUPPORTED || ui_data->group_set || !AUTHGROUP_OPT(form)) ++ return FALSE; ++ ui_data->group_set = TRUE; ++ ++ for (opt = form->opts; opt; opt = opt->next) { ++ int i; ++ char *saved_group; ++ struct oc_form_opt_select *sopt; ++ ++ if (opt != AUTHGROUP_OPT(form)) ++ continue; ++ ++ saved_group = find_form_answer(ui_data->secrets, form, opt); ++ if (!saved_group) ++ return FALSE; ++ ++ sopt = (struct oc_form_opt_select *)opt; ++ 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); ++ return TRUE; ++ } ++ } ++ } ++ return FALSE; ++} ++ + static int nm_process_auth_form (void *cbdata, struct oc_auth_form *form) + { + auth_ui_data *ui_data = cbdata; + int response; + ++ if (set_initial_authgroup(ui_data, form)) ++ return OC_FORM_RESULT_NEWGROUP; ++ ++ ui_data->newgroup = FALSE; + g_idle_add((GSourceFunc)ui_form, form); + + g_mutex_lock(ui_data->form_mutex); +@@ -782,10 +861,13 @@ static int nm_process_auth_form (void *cbdata, struct oc_auth_form *form) + ui_data->form_grabbed = 0; + g_mutex_unlock(ui_data->form_mutex); + +- /* -1 = cancel, +- * 0 = failure, +- * 1 = success */ +- return (response == AUTH_DIALOG_RESPONSE_LOGIN ? 0 : 1); ++ if (response == AUTH_DIALOG_RESPONSE_LOGIN) { ++ if (ui_data->newgroup) ++ return OC_FORM_RESULT_NEWGROUP; ++ else ++ return OC_FORM_RESULT_OK; ++ } else ++ return OC_FORM_RESULT_CANCELLED; + + } + +-- +Gitg + diff --git a/net-misc/networkmanager-openconnect/networkmanager-openconnect-0.9.8.4-r1.ebuild b/net-misc/networkmanager-openconnect/networkmanager-openconnect-0.9.8.4-r1.ebuild new file mode 100644 index 000000000000..e85d37646bf2 --- /dev/null +++ b/net-misc/networkmanager-openconnect/networkmanager-openconnect-0.9.8.4-r1.ebuild @@ -0,0 +1,59 @@ +# Copyright 1999-2014 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 +# $Header: /var/cvsroot/gentoo-x86/net-misc/networkmanager-openconnect/networkmanager-openconnect-0.9.8.4-r1.ebuild,v 1.1 2014/03/12 04:40:46 tetromino Exp $ + +EAPI="5" +GNOME_ORG_MODULE="NetworkManager-${PN##*-}" + +inherit eutils gnome.org gnome2-utils user + +DESCRIPTION="NetworkManager OpenConnect plugin" +HOMEPAGE="http://www.gnome.org/projects/NetworkManager/" + +LICENSE="GPL-2+" +SLOT="0" +KEYWORDS="~amd64 ~x86" +IUSE="gtk" + +RDEPEND=" + >=net-misc/networkmanager-0.9.8:= + >=dev-libs/dbus-glib-0.74 + dev-libs/libxml2:2 + gnome-base/libgnome-keyring + >=net-misc/openconnect-3.02:= + gtk? ( + >=x11-libs/gtk+-2.91.4:3 + gnome-base/gnome-keyring + )" + +DEPEND="${RDEPEND} + sys-devel/gettext + dev-util/intltool + virtual/pkgconfig +" + +src_prepare() { + # fix build failure with >=openconnect-5.99; in next release + epatch "${FILESDIR}/${P}-auth-dialog-"{formchoice,newgroup,ignore}.patch + gnome2_disable_deprecation_warning + default +} + +src_configure() { + econf \ + --disable-more-warnings \ + --disable-static \ + --with-gtkver=3 \ + $(use_with gtk gnome) \ + $(use_with gtk authdlg) +} + +src_install() { + default + prune_libtool_files --modules +} + +pkg_postinst() { + enewgroup nm-openconnect + enewuser nm-openconnect -1 -1 -1 nm-openconnect +} -- cgit v1.2.3-65-gdbad