From 09782a566429931ab1221adfacf375963a59f57f Mon Sep 17 00:00:00 2001 From: Katelyn Schiesser Date: Tue, 14 Jun 2016 16:04:44 -0700 Subject: [PATCH] Add support for Juniper's Post Sign-in Message --- auth-juniper.c | 30 ++++++++++++++++++++++++++---- 1 file changed, 26 insertions(+), 4 deletions(-) diff --git a/auth-juniper.c b/auth-juniper.c index b56e6e5..713252a 100644 --- a/auth-juniper.c +++ b/auth-juniper.c @@ -123,10 +123,16 @@ static int parse_input_node(struct openconnect_info *vpninfo, struct oc_auth_for } } else if (!strcasecmp(type, "submit")) { xmlnode_get_prop(node, "name", &opt->name); - if (!opt->name || strcmp(opt->name, submit_button)) { + if (!strcmp(opt->name, "sn-postauth-decline")) { + // ignore the decline button for a post-auth message + ret = -EINVAL; + goto out; + } else if (strcmp(opt->name, "sn-postauth-proceed") && + (!opt->name || strcmp(opt->name, submit_button))) { + // button is not sn-postauth-* so must be unknown vpn_progress(vpninfo, PRG_DEBUG, - _("Ignoring unknown form submit item '%s'\n"), - opt->name); + _("Ignoring unknown form submit item '%s'\n"), + opt->name); ret = -EINVAL; goto out; } @@ -240,7 +246,23 @@ static struct oc_auth_form *parse_form_node(struct openconnect_info *vpninfo, /* Skip its children */ while (child->children) child = child->last; - } + } else if (!strcasecmp((char *)child->name, "textarea")) { + /* display the post sign-in message, if any */ + char *fieldname = calloc(1, sizeof(char)); + xmlnode_get_prop(child, "name", &fieldname); + if (!strcasecmp(fieldname, "sn-postauth-text")) { + char *postauth_msg = (char *)xmlNodeGetContent(child); + if (postauth_msg) { + vpn_progress(vpninfo, PRG_INFO, + _("\nPost Sign-In Message:\n %s\n\n"), postauth_msg); + free(postauth_msg); + } + } else { + vpn_progress(vpninfo, PRG_ERR, + _("Unknown textarea field: '%s'\n"), fieldname); + } + free(fieldname); + } } return form; } -- 2.8.3