Make constent with rest of the gssapi test programs

git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@14659 ec53bebd-3082-4978-b11e-865c3cabbd6b
This commit is contained in:
Love Hörnquist Åstrand
2005-03-19 02:52:26 +00:00
parent 1b28bc69c3
commit b925aac02c

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2003 Kungliga Tekniska H<>gskolan * Copyright (c) 2003 - 2005 Kungliga Tekniska H<>gskolan
* (Royal Institute of Technology, Stockholm, Sweden). * (Royal Institute of Technology, Stockholm, Sweden).
* All rights reserved. * All rights reserved.
* *
@@ -112,27 +112,26 @@ static int verbose_flag;
static int mutual_flag = 1; static int mutual_flag = 1;
static int delegate_flag; static int delegate_flag;
static char *port_str = "http"; static char *port_str = "http";
static char *service = "HTTP"; static char *gss_service = "HTTP";
static char *gss_mech = "SPNEGO";
static struct getargs args[] = { static struct getargs http_args[] = {
{ "verbose", 'v', arg_flag, &verbose_flag, "verbose logging", }, { "verbose", 'v', arg_flag, &verbose_flag, "verbose logging", },
{ "port", 'p', arg_string, &port_str, "port to connect to", "port" }, { "port", 'p', arg_string, &port_str, "port to connect to", "port" },
{ "delegate", 0, arg_flag, &delegate_flag, "gssapi delegate credential" }, { "delegate", 0, arg_flag, &delegate_flag, "gssapi delegate credential" },
{ "gss-service", 's', arg_string, &service, "gssapi service to use", { "gss-service", 's', arg_string, &gss_service, "gssapi service to use",
"service" }, "service" },
{ "mech", 'm', arg_string, &gss_mech, "gssapi mech to use", "mech" }, { "mech", 'm', arg_string, &mech, "gssapi mech to use", "mech" },
{ "mutual", 0, arg_negative_flag, &mutual_flag, "no gssapi mutual auth" }, { "mutual", 0, arg_negative_flag, &mutual_flag, "no gssapi mutual auth" },
{ "help", 'h', arg_flag, &help_flag }, { "help", 'h', arg_flag, &help_flag },
{ "version", 0, arg_flag, &version_flag } { "version", 0, arg_flag, &version_flag }
}; };
static int num_args = sizeof(args) / sizeof(args[0]); static int num_http_args = sizeof(http_args) / sizeof(http_args[0]);
static void static void
usage(int code) usage(int code)
{ {
arg_printusage(args, num_args, NULL, "host [page]"); arg_printusage(http_args, num_http_args, NULL, "host [page]");
exit(code); exit(code);
} }
@@ -290,10 +289,12 @@ main(int argc, char **argv)
gss_ctx_id_t context_hdl = GSS_C_NO_CONTEXT; gss_ctx_id_t context_hdl = GSS_C_NO_CONTEXT;
gss_name_t server = GSS_C_NO_NAME; gss_name_t server = GSS_C_NO_NAME;
int optind = 0; int optind = 0;
gss_OID mech; gss_OID mech_oid;
OM_uint32 flags; OM_uint32 flags;
if(getarg(args, sizeof(args) / sizeof(args[0]), argc, argv, &optind)) setprogname(argv[0]);
if(getarg(http_args, num_http_args, argc, argv, &optind))
usage(1); usage(1);
if (help_flag) if (help_flag)
@@ -307,7 +308,7 @@ main(int argc, char **argv)
argc -= optind; argc -= optind;
argv += optind; argv += optind;
mech = select_mech(gss_mech); mech_oid = select_mech(mech);
if (argc != 1 && argc != 2) if (argc != 1 && argc != 2)
errx(1, "usage: %s host [page]", getprogname()); errx(1, "usage: %s host [page]", getprogname());
@@ -358,7 +359,7 @@ main(int argc, char **argv)
if (server == GSS_C_NO_NAME) { if (server == GSS_C_NO_NAME) {
char *name; char *name;
asprintf(&name, "%s@%s", service, host); asprintf(&name, "%s@%s", gss_service, host);
input_token.length = strlen(name); input_token.length = strlen(name);
input_token.value = name; input_token.value = name;
@@ -399,7 +400,7 @@ main(int argc, char **argv)
GSS_C_NO_CREDENTIAL, GSS_C_NO_CREDENTIAL,
&context_hdl, &context_hdl,
server, server,
mech, mech_oid,
flags, flags,
0, 0,
GSS_C_NO_CHANNEL_BINDINGS, GSS_C_NO_CHANNEL_BINDINGS,
@@ -419,7 +420,7 @@ main(int argc, char **argv)
gssapi_done = 1; gssapi_done = 1;
printf("Negotiate done: %s\n", gss_mech); printf("Negotiate done: %s\n", mech);
maj_stat = gss_inquire_context(&min_stat, maj_stat = gss_inquire_context(&min_stat,
context_hdl, context_hdl,