The current process_auth_form_cb hard-codes the interpretation of these form fields based on their names. Other protocols (GlobalProtect, possibly other future protocols) have identical fields but with slightly different names, so we add flags to hint at the purpose of form fields independent of their names. Signed-off-by: Daniel Lenski <dlenski at gmail.com> --- main.c | 4 ++-- openconnect.h | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/main.c b/main.c index 7869f72..cc373ac 100644 --- a/main.c +++ b/main.c @@ -1967,7 +1967,7 @@ static int process_auth_form_cb(void *_vpninfo, } else if (opt->type == OC_FORM_OPT_TEXT) { if (username && - !strcmp(opt->name, "username")) { + (!strcmp(opt->name, "username") || opt->flags & OC_FORM_OPT_FILL_USERNAME)) { opt->_value = username; username = NULL; } else { @@ -1980,7 +1980,7 @@ static int process_auth_form_cb(void *_vpninfo, } else if (opt->type == OC_FORM_OPT_PASSWORD) { if (password && - !strcmp(opt->name, "password")) { + (!strcmp(opt->name, "password") || opt->flags & OC_FORM_OPT_FILL_PASSWORD)) { opt->_value = password; password = NULL; } else { diff --git a/openconnect.h b/openconnect.h index e97dacb..06bf48e 100644 --- a/openconnect.h +++ b/openconnect.h @@ -208,6 +208,8 @@ struct oc_vpn_proto { #define OC_FORM_OPT_IGNORE 0x0001 #define OC_FORM_OPT_NUMERIC 0x0002 +#define OC_FORM_OPT_FILL_USERNAME 0x0004 +#define OC_FORM_OPT_FILL_PASSWORD 0x0008 /* char * fields are static (owned by XML parser) and don't need to be freed by the form handling code ? except for value, which for TEXT -- 2.7.4