Path: blob/main/crypto/heimdal/lib/gssapi/ntlm/acquire_cred.c
34914 views
/*1* Copyright (c) 1997 - 2004 Kungliga Tekniska Högskolan2* (Royal Institute of Technology, Stockholm, Sweden).3* All rights reserved.4*5* Redistribution and use in source and binary forms, with or without6* modification, are permitted provided that the following conditions7* are met:8*9* 1. Redistributions of source code must retain the above copyright10* notice, this list of conditions and the following disclaimer.11*12* 2. Redistributions in binary form must reproduce the above copyright13* notice, this list of conditions and the following disclaimer in the14* documentation and/or other materials provided with the distribution.15*16* 3. Neither the name of the Institute nor the names of its contributors17* may be used to endorse or promote products derived from this software18* without specific prior written permission.19*20* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND21* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE22* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE23* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE24* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL25* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS26* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)27* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT28* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY29* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF30* SUCH DAMAGE.31*/3233#include "ntlm.h"3435OM_uint32 GSSAPI_CALLCONV _gss_ntlm_acquire_cred36(OM_uint32 * min_stat,37const gss_name_t desired_name,38OM_uint32 time_req,39const gss_OID_set desired_mechs,40gss_cred_usage_t cred_usage,41gss_cred_id_t * output_cred_handle,42gss_OID_set * actual_mechs,43OM_uint32 * time_rec44)45{46ntlm_name name = (ntlm_name) desired_name;47OM_uint32 maj_stat;48ntlm_ctx ctx;4950*min_stat = 0;51*output_cred_handle = GSS_C_NO_CREDENTIAL;52if (actual_mechs)53*actual_mechs = GSS_C_NO_OID_SET;54if (time_rec)55*time_rec = GSS_C_INDEFINITE;5657if (desired_name == NULL)58return GSS_S_NO_CRED;5960if (cred_usage == GSS_C_BOTH || cred_usage == GSS_C_ACCEPT) {6162maj_stat = _gss_ntlm_allocate_ctx(min_stat, &ctx);63if (maj_stat != GSS_S_COMPLETE)64return maj_stat;6566maj_stat = (*ctx->server->nsi_probe)(min_stat, ctx->ictx,67name->domain);68{69gss_ctx_id_t context = (gss_ctx_id_t)ctx;70OM_uint32 junk;71_gss_ntlm_delete_sec_context(&junk, &context, NULL);72}73if (maj_stat)74return maj_stat;75}76if (cred_usage == GSS_C_BOTH || cred_usage == GSS_C_INITIATE) {77ntlm_cred cred;7879*min_stat = _gss_ntlm_get_user_cred(name, &cred);80if (*min_stat)81return GSS_S_FAILURE;82cred->usage = cred_usage;8384*output_cred_handle = (gss_cred_id_t)cred;85}8687return (GSS_S_COMPLETE);88}899091