Path: blob/main/crypto/heimdal/lib/gssapi/krb5/authorize_localname.c
34923 views
/*1* Copyright (c) 2011, PADL Software Pty Ltd.2* All rights reserved.3*4* Redistribution and use in source and binary forms, with or without5* modification, are permitted provided that the following conditions6* are met:7*8* 1. Redistributions of source code must retain the above copyright9* notice, this list of conditions and the following disclaimer.10*11* 2. Redistributions in binary form must reproduce the above copyright12* notice, this list of conditions and the following disclaimer in the13* documentation and/or other materials provided with the distribution.14*15* 3. Neither the name of PADL Software nor the names of its contributors16* may be used to endorse or promote products derived from this software17* without specific prior written permission.18*19* THIS SOFTWARE IS PROVIDED BY PADL SOFTWARE AND CONTRIBUTORS ``AS IS'' AND20* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE21* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE22* ARE DISCLAIMED. IN NO EVENT SHALL PADL SOFTWARE OR CONTRIBUTORS BE LIABLE23* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL24* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS25* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)26* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT27* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY28* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF29* SUCH DAMAGE.30*/3132#include "gsskrb5_locl.h"3334OM_uint32 GSSAPI_CALLCONV35_gsskrb5_authorize_localname(OM_uint32 *minor_status,36const gss_name_t input_name,37gss_const_buffer_t user_name,38gss_const_OID user_name_type)39{40krb5_context context;41krb5_principal princ = (krb5_principal)input_name;42char *user;43int user_ok;4445if (!gss_oid_equal(user_name_type, GSS_C_NT_USER_NAME))46return GSS_S_BAD_NAMETYPE;4748GSSAPI_KRB5_INIT(&context);4950user = malloc(user_name->length + 1);51if (user == NULL) {52*minor_status = ENOMEM;53return GSS_S_FAILURE;54}5556memcpy(user, user_name->value, user_name->length);57user[user_name->length] = '\0';5859*minor_status = 0;60user_ok = krb5_kuserok(context, princ, user);6162free(user);6364return user_ok ? GSS_S_COMPLETE : GSS_S_UNAUTHORIZED;65}666768