|
rpm-build |
88d58e |
/* -*- mode: c; c-basic-offset: 4; indent-tabs-mode: nil -*- */
|
|
rpm-build |
88d58e |
/*
|
|
rpm-build |
88d58e |
* Copyright (C) 2020 by Red Hat, Inc.
|
|
rpm-build |
88d58e |
* All rights reserved.
|
|
rpm-build |
88d58e |
*
|
|
rpm-build |
88d58e |
* Redistribution and use in source and binary forms, with or without
|
|
rpm-build |
88d58e |
* modification, are permitted provided that the following conditions
|
|
rpm-build |
88d58e |
* are met:
|
|
rpm-build |
88d58e |
*
|
|
rpm-build |
88d58e |
* * Redistributions of source code must retain the above copyright
|
|
rpm-build |
88d58e |
* notice, this list of conditions and the following disclaimer.
|
|
rpm-build |
88d58e |
*
|
|
rpm-build |
88d58e |
* * Redistributions in binary form must reproduce the above copyright
|
|
rpm-build |
88d58e |
* notice, this list of conditions and the following disclaimer in
|
|
rpm-build |
88d58e |
* the documentation and/or other materials provided with the
|
|
rpm-build |
88d58e |
* distribution.
|
|
rpm-build |
88d58e |
*
|
|
rpm-build |
88d58e |
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
rpm-build |
88d58e |
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
rpm-build |
88d58e |
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
|
rpm-build |
88d58e |
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
|
rpm-build |
88d58e |
* COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
|
|
rpm-build |
88d58e |
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
|
rpm-build |
88d58e |
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
rpm-build |
88d58e |
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
rpm-build |
88d58e |
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
|
rpm-build |
88d58e |
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
rpm-build |
88d58e |
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
|
|
rpm-build |
88d58e |
* OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
rpm-build |
88d58e |
*/
|
|
rpm-build |
88d58e |
|
|
rpm-build |
88d58e |
#include <stdio.h>
|
|
rpm-build |
88d58e |
#include <string.h>
|
|
rpm-build |
88d58e |
#include <assert.h>
|
|
rpm-build |
88d58e |
|
|
rpm-build |
88d58e |
#include "common.h"
|
|
rpm-build |
88d58e |
|
|
rpm-build |
88d58e |
/*
|
|
rpm-build |
88d58e |
* Establish contexts (without and with GSS_C_DCE_STYLE) with the default
|
|
rpm-build |
88d58e |
* initiator name, a specified principal name as target name, initiator
|
|
rpm-build |
88d58e |
* bindings, and acceptor bindings. If any call is unsuccessful, display an
|
|
rpm-build |
88d58e |
* error message. Output "yes" or "no" to indicate whether the contexts were
|
|
rpm-build |
88d58e |
* reported as channel-bound on the acceptor. Exit with status 0 if all
|
|
rpm-build |
88d58e |
* operations are successful, or 1 if not.
|
|
rpm-build |
88d58e |
*
|
|
rpm-build |
88d58e |
* Usage: ./t_bindings [-s] targetname icb acb
|
|
rpm-build |
88d58e |
*
|
|
rpm-build |
88d58e |
* An icb or abc value of "-" will not specify channel bindings.
|
|
rpm-build |
88d58e |
*/
|
|
rpm-build |
88d58e |
|
|
rpm-build |
88d58e |
int
|
|
rpm-build |
88d58e |
main(int argc, char *argv[])
|
|
rpm-build |
88d58e |
{
|
|
rpm-build |
88d58e |
OM_uint32 minor, flags1, flags2;
|
|
rpm-build |
88d58e |
gss_name_t target_name;
|
|
rpm-build |
88d58e |
gss_ctx_id_t ictx, actx;
|
|
rpm-build |
88d58e |
struct gss_channel_bindings_struct icb_data = {0}, acb_data = {0};
|
|
rpm-build |
88d58e |
gss_channel_bindings_t icb = GSS_C_NO_CHANNEL_BINDINGS;
|
|
rpm-build |
88d58e |
gss_channel_bindings_t acb = GSS_C_NO_CHANNEL_BINDINGS;
|
|
rpm-build |
88d58e |
gss_OID_desc *mech;
|
|
rpm-build |
88d58e |
|
|
rpm-build |
88d58e |
argv++;
|
|
rpm-build |
88d58e |
argc--;
|
|
rpm-build |
88d58e |
if (*argv != NULL && strcmp(*argv, "-s") == 0) {
|
|
rpm-build |
88d58e |
mech = &mech_spnego;
|
|
rpm-build |
88d58e |
argv++;
|
|
rpm-build |
88d58e |
argc--;
|
|
rpm-build |
88d58e |
} else {
|
|
rpm-build |
88d58e |
mech = &mech_krb5;
|
|
rpm-build |
88d58e |
}
|
|
rpm-build |
88d58e |
|
|
rpm-build |
88d58e |
if (argc != 3) {
|
|
rpm-build |
88d58e |
fprintf(stderr, "Usage: t_bindings [-s] targetname icb acb\n");
|
|
rpm-build |
88d58e |
return 1;
|
|
rpm-build |
88d58e |
}
|
|
rpm-build |
88d58e |
|
|
rpm-build |
88d58e |
target_name = import_name(argv[0]);
|
|
rpm-build |
88d58e |
|
|
rpm-build |
88d58e |
if (strcmp(argv[1], "-") != 0) {
|
|
rpm-build |
88d58e |
icb_data.application_data.length = strlen(argv[1]);
|
|
rpm-build |
88d58e |
icb_data.application_data.value = argv[1];
|
|
rpm-build |
88d58e |
icb = &icb_data;
|
|
rpm-build |
88d58e |
}
|
|
rpm-build |
88d58e |
|
|
rpm-build |
88d58e |
if (strcmp(argv[2], "-") != 0) {
|
|
rpm-build |
88d58e |
acb_data.application_data.length = strlen(argv[2]);
|
|
rpm-build |
88d58e |
acb_data.application_data.value = argv[2];
|
|
rpm-build |
88d58e |
acb = &acb_data;
|
|
rpm-build |
88d58e |
}
|
|
rpm-build |
88d58e |
|
|
rpm-build |
88d58e |
establish_contexts_ex(mech, GSS_C_NO_CREDENTIAL, GSS_C_NO_CREDENTIAL,
|
|
rpm-build |
88d58e |
target_name, 0, &ictx, &actx, icb, acb, &flags1,
|
|
rpm-build |
88d58e |
NULL, NULL, NULL);
|
|
rpm-build |
88d58e |
|
|
rpm-build |
88d58e |
/* Try again with GSS_C_DCE_STYLE */
|
|
rpm-build |
88d58e |
(void)gss_delete_sec_context(&minor, &ictx, NULL);
|
|
rpm-build |
88d58e |
(void)gss_delete_sec_context(&minor, &actx, NULL);
|
|
rpm-build |
88d58e |
|
|
rpm-build |
88d58e |
establish_contexts_ex(mech, GSS_C_NO_CREDENTIAL, GSS_C_NO_CREDENTIAL,
|
|
rpm-build |
88d58e |
target_name, GSS_C_DCE_STYLE, &ictx, &actx, icb, acb,
|
|
rpm-build |
88d58e |
&flags2, NULL, NULL, NULL);
|
|
rpm-build |
88d58e |
assert((flags1 & GSS_C_CHANNEL_BOUND_FLAG) ==
|
|
rpm-build |
88d58e |
(flags2 & GSS_C_CHANNEL_BOUND_FLAG));
|
|
rpm-build |
88d58e |
printf("%s\n", (flags1 & GSS_C_CHANNEL_BOUND_FLAG) ? "yes" : "no");
|
|
rpm-build |
88d58e |
|
|
rpm-build |
88d58e |
(void)gss_delete_sec_context(&minor, &ictx, NULL);
|
|
rpm-build |
88d58e |
(void)gss_delete_sec_context(&minor, &actx, NULL);
|
|
rpm-build |
88d58e |
(void)gss_release_name(&minor, &target_name);
|
|
rpm-build |
88d58e |
|
|
rpm-build |
88d58e |
return 0;
|
|
rpm-build |
88d58e |
}
|