[PATCH] Allow specifying server in configuration file

Daniel Lenski dlenski at gmail.com
Tue Apr 3 11:29:00 PDT 2018


On Tue, Apr 3, 2018 at 1:03 AM, Max Rees <maxcrees at me.com> wrote:
>
> This allows the configuration file to have an entry of the form:
> server https://server[:port][/group]
> similar to the CLI invocation.
>
> Signed-off-by: Max Rees <maxcrees at me.com>
> ---
>  main.c | 8 +++++++-
>  1 file changed, 7 insertions(+), 1 deletion(-)
>
> diff --git a/main.c b/main.c
> index d09efd5..23b0efc 100644
> --- a/main.c
> +++ b/main.c
> @@ -187,6 +187,7 @@ enum {
>         OPT_HTTP_AUTH,
>         OPT_LOCAL_HOSTNAME,
>         OPT_PROTOCOL,
> +       OPT_SERVER,
>         OPT_PASSTOS,
>  };
>
> @@ -269,6 +270,7 @@ static const struct option long_options[] = {
>         OPTION("dump-http-traffic", 0, OPT_DUMP_HTTP),
>         OPTION("no-system-trust", 0, OPT_NO_SYSTEM_TRUST),
>         OPTION("protocol", 1, OPT_PROTOCOL),
> +       OPTION("server", 1, OPT_SERVER),
>  #ifdef OPENCONNECT_GNUTLS
>         OPTION("gnutls-debug", 1, OPT_GNUTLS_DEBUG),
>  #endif
> @@ -1164,6 +1166,10 @@ int main(int argc, char **argv)
>                         if (openconnect_set_protocol(vpninfo, config_arg))
>                                 exit(1);
>                         break;
> +               case OPT_SERVER:
> +                       if (openconnect_parse_url(vpninfo, config_arg))
> +                               exit(1);
> +                       break;
>                 case OPT_JUNIPER:
>                         fprintf(stderr, "WARNING: Juniper Network Connect support is experimental.\n");
>                         fprintf(stderr, "It will probably be superseded by Junos Pulse support.\n");
> @@ -1457,7 +1463,7 @@ int main(int argc, char **argv)
>         if (optind < argc - 1) {

I think you should also check for the converse case of a
*double-specified* server (where the user specifies --server and an
argument with no option).
It'd be something like (optind < argc && vpninfo->hostname).

>                 fprintf(stderr, _("Too many arguments on command line\n"));
>                 usage();
> -       } else if (optind > argc - 1) {
> +       } else if (optind > argc - 1 && !vpninfo->hostname) {
>                 fprintf(stderr, _("No server specified\n"));
>                 usage();
>         }
> --
> 2.15.0
>
>
> _______________________________________________
> openconnect-devel mailing list
> openconnect-devel at lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/openconnect-devel



More information about the openconnect-devel mailing list