1109412Smdodd/* 2109412Smdodd * Copyright (c) 2004, PADL Software Pty Ltd. 3109412Smdodd * All rights reserved. 4109412Smdodd * 5109412Smdodd * Redistribution and use in source and binary forms, with or without 6109412Smdodd * modification, are permitted provided that the following conditions 7109412Smdodd * are met: 8109412Smdodd * 9109412Smdodd * 1. Redistributions of source code must retain the above copyright 10109412Smdodd * notice, this list of conditions and the following disclaimer. 11109412Smdodd * 12109412Smdodd * 2. Redistributions in binary form must reproduce the above copyright 13109412Smdodd * notice, this list of conditions and the following disclaimer in the 14109412Smdodd * documentation and/or other materials provided with the distribution. 15109412Smdodd * 16109412Smdodd * 3. Neither the name of PADL Software nor the names of its contributors 17109412Smdodd * may be used to endorse or promote products derived from this software 18109412Smdodd * without specific prior written permission. 19109412Smdodd * 20109412Smdodd * THIS SOFTWARE IS PROVIDED BY PADL SOFTWARE AND CONTRIBUTORS ``AS IS'' AND 21109412Smdodd * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22109412Smdodd * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 23109412Smdodd * ARE DISCLAIMED. IN NO EVENT SHALL PADL SOFTWARE OR CONTRIBUTORS BE LIABLE 24109412Smdodd * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 25109412Smdodd * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 26109412Smdodd * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 27115679Sobrien * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 28115679Sobrien * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 29115679Sobrien * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 30109412Smdodd * SUCH DAMAGE. 31109412Smdodd */ 32109412Smdodd/* $FreeBSD$ */ 33241073Skevlo/* RCSID("$Id: gss_set_sec_context_option.c 19928 2007-01-16 10:37:54Z lha $"); */ 34109412Smdodd 35109412Smdodd#include <gssapi/gssapi.h> 36109412Smdodd 37109412Smdodd#include "mech_switch.h" 38109412Smdodd#include "context.h" 39109412Smdodd 40109412SmdoddOM_uint32 41109412Smdoddgss_set_sec_context_option (OM_uint32 *minor_status, 42109412Smdodd gss_ctx_id_t *context_handle, 43112554Smdodd const gss_OID object, 44112554Smdodd const gss_buffer_t value) 45130312Sjhb{ 46112554Smdodd struct _gss_context *ctx; 47112554Smdodd OM_uint32 major_status; 48112554Smdodd struct _gss_mech_switch *m; 49112554Smdodd int one_ok = 0; 50109412Smdodd 51109412Smdodd *minor_status = 0; 52112554Smdodd 53112554Smdodd if (context_handle == NULL) { 54112554Smdodd _gss_load_mech(); 55112554Smdodd major_status = GSS_S_BAD_MECH; 56112554Smdodd SLIST_FOREACH(m, &_gss_mechs, gm_link) { 57112554Smdodd if (!m->gm_set_sec_context_option) 58112554Smdodd continue; 59112556Smdodd major_status = m->gm_set_sec_context_option( 60112554Smdodd minor_status, 61112554Smdodd NULL, object, value); 62192441Simp if (major_status == GSS_S_COMPLETE) 63112554Smdodd one_ok = 1; 64112554Smdodd } 65112554Smdodd if (one_ok) { 66112554Smdodd *minor_status = 0; 67112554Smdodd return (GSS_S_COMPLETE); 68112554Smdodd } 69112554Smdodd return (major_status); 70112554Smdodd } 71112554Smdodd 72116275Smdodd ctx = (struct _gss_context *) *context_handle; 73116275Smdodd 74109412Smdodd if (ctx == NULL) 75109412Smdodd return (GSS_S_NO_CONTEXT); 76109412Smdodd 77109412Smdodd m = ctx->gc_mech; 78109412Smdodd 79109412Smdodd if (m == NULL) 80126080Sphk return (GSS_S_BAD_MECH); 81111815Sphk 82111815Sphk if (m->gm_set_sec_context_option != NULL) { 83126080Sphk major_status = m->gm_set_sec_context_option(minor_status, 84109412Smdodd &ctx->gc_ctx, object, value); 85109412Smdodd if (major_status != GSS_S_COMPLETE) 86192441Simp _gss_mg_error(m, major_status, *minor_status); 87192441Simp } else 88192441Simp major_status = (GSS_S_BAD_MECH); 89192441Simp 90192441Simp return (major_status); 91112554Smdodd} 92192441Simp 93109412Smdodd