17c478bd9Sstevel@tonic-gate /* 27c478bd9Sstevel@tonic-gate * CDDL HEADER START 37c478bd9Sstevel@tonic-gate * 47c478bd9Sstevel@tonic-gate * The contents of this file are subject to the terms of the 5503a2b89SPeter Shoults * Common Development and Distribution License (the "License"). 6503a2b89SPeter Shoults * You may not use this file except in compliance with the License. 77c478bd9Sstevel@tonic-gate * 87c478bd9Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 97c478bd9Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 107c478bd9Sstevel@tonic-gate * See the License for the specific language governing permissions 117c478bd9Sstevel@tonic-gate * and limitations under the License. 127c478bd9Sstevel@tonic-gate * 137c478bd9Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 147c478bd9Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 157c478bd9Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 167c478bd9Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 177c478bd9Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 187c478bd9Sstevel@tonic-gate * 197c478bd9Sstevel@tonic-gate * CDDL HEADER END 207c478bd9Sstevel@tonic-gate */ 217c478bd9Sstevel@tonic-gate /* 22*5e01956fSGlenn Barry * Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved. 237c478bd9Sstevel@tonic-gate */ 247c478bd9Sstevel@tonic-gate 257c478bd9Sstevel@tonic-gate /* 267c478bd9Sstevel@tonic-gate * glue routine for gss_inquire_context 277c478bd9Sstevel@tonic-gate */ 287c478bd9Sstevel@tonic-gate 297c478bd9Sstevel@tonic-gate #include <mechglueP.h> 30*5e01956fSGlenn Barry #include "gssapiP_generic.h" 317c478bd9Sstevel@tonic-gate #include <stdlib.h> 327c478bd9Sstevel@tonic-gate 33503a2b89SPeter Shoults static OM_uint32 34503a2b89SPeter Shoults val_inq_ctx_args( 35503a2b89SPeter Shoults OM_uint32 *minor_status, 36503a2b89SPeter Shoults gss_ctx_id_t context_handle, 37503a2b89SPeter Shoults gss_name_t *src_name, 38503a2b89SPeter Shoults gss_name_t *targ_name, 39503a2b89SPeter Shoults gss_OID *mech_type) 40503a2b89SPeter Shoults { 41503a2b89SPeter Shoults 42503a2b89SPeter Shoults /* Initialize outputs. */ 43503a2b89SPeter Shoults 44503a2b89SPeter Shoults if (minor_status != NULL) 45503a2b89SPeter Shoults *minor_status = 0; 46503a2b89SPeter Shoults 47503a2b89SPeter Shoults if (src_name != NULL) 48503a2b89SPeter Shoults *src_name = GSS_C_NO_NAME; 49503a2b89SPeter Shoults 50503a2b89SPeter Shoults if (targ_name != NULL) 51503a2b89SPeter Shoults *targ_name = GSS_C_NO_NAME; 52503a2b89SPeter Shoults 53503a2b89SPeter Shoults if (mech_type != NULL) 54503a2b89SPeter Shoults *mech_type = GSS_C_NO_OID; 55503a2b89SPeter Shoults 56503a2b89SPeter Shoults /* Validate arguments. */ 57503a2b89SPeter Shoults 58503a2b89SPeter Shoults if (minor_status == NULL) 59503a2b89SPeter Shoults return (GSS_S_CALL_INACCESSIBLE_WRITE); 60503a2b89SPeter Shoults 61503a2b89SPeter Shoults if (context_handle == GSS_C_NO_CONTEXT) 62503a2b89SPeter Shoults return (GSS_S_CALL_INACCESSIBLE_READ | GSS_S_NO_CONTEXT); 63503a2b89SPeter Shoults 64503a2b89SPeter Shoults return (GSS_S_COMPLETE); 65503a2b89SPeter Shoults } 66503a2b89SPeter Shoults 677c478bd9Sstevel@tonic-gate /* Last argument new for V2 */ 687c478bd9Sstevel@tonic-gate OM_uint32 697c478bd9Sstevel@tonic-gate gss_inquire_context( 70*5e01956fSGlenn Barry OM_uint32 *minor_status, 71*5e01956fSGlenn Barry gss_ctx_id_t context_handle, 72*5e01956fSGlenn Barry gss_name_t *src_name, 73*5e01956fSGlenn Barry gss_name_t *targ_name, 74*5e01956fSGlenn Barry OM_uint32 *lifetime_rec, 75*5e01956fSGlenn Barry gss_OID *mech_type, 76*5e01956fSGlenn Barry OM_uint32 *ctx_flags, 77*5e01956fSGlenn Barry int *locally_initiated, 78*5e01956fSGlenn Barry int *opened) 797c478bd9Sstevel@tonic-gate { 807c478bd9Sstevel@tonic-gate gss_union_ctx_id_t ctx; 817c478bd9Sstevel@tonic-gate gss_mechanism mech; 827c478bd9Sstevel@tonic-gate OM_uint32 status, temp_minor; 837c478bd9Sstevel@tonic-gate gss_name_t localTargName = NULL, localSourceName = NULL; 847c478bd9Sstevel@tonic-gate 85503a2b89SPeter Shoults status = val_inq_ctx_args(minor_status, 86503a2b89SPeter Shoults context_handle, 87503a2b89SPeter Shoults src_name, 88503a2b89SPeter Shoults targ_name, 89503a2b89SPeter Shoults mech_type); 90503a2b89SPeter Shoults if (status != GSS_S_COMPLETE) 91503a2b89SPeter Shoults return (status); 927c478bd9Sstevel@tonic-gate 937c478bd9Sstevel@tonic-gate /* 947c478bd9Sstevel@tonic-gate * select the approprate underlying mechanism routine and 957c478bd9Sstevel@tonic-gate * call it. 967c478bd9Sstevel@tonic-gate */ 977c478bd9Sstevel@tonic-gate 987c478bd9Sstevel@tonic-gate ctx = (gss_union_ctx_id_t)context_handle; 997c478bd9Sstevel@tonic-gate mech = __gss_get_mechanism(ctx->mech_type); 1007c478bd9Sstevel@tonic-gate 1017c478bd9Sstevel@tonic-gate if (!mech || !mech->gss_inquire_context || !mech->gss_display_name || 1027c478bd9Sstevel@tonic-gate !mech->gss_release_name) { 1037c478bd9Sstevel@tonic-gate return (GSS_S_UNAVAILABLE); 1047c478bd9Sstevel@tonic-gate } 1057c478bd9Sstevel@tonic-gate 1067c478bd9Sstevel@tonic-gate status = mech->gss_inquire_context( 1077c478bd9Sstevel@tonic-gate mech->context, 1087c478bd9Sstevel@tonic-gate minor_status, 1097c478bd9Sstevel@tonic-gate ctx->internal_ctx_id, 1107c478bd9Sstevel@tonic-gate (src_name ? &localSourceName : NULL), 1117c478bd9Sstevel@tonic-gate (targ_name ? &localTargName : NULL), 1127c478bd9Sstevel@tonic-gate lifetime_rec, 1137c478bd9Sstevel@tonic-gate NULL, 1147c478bd9Sstevel@tonic-gate ctx_flags, 1157c478bd9Sstevel@tonic-gate locally_initiated, 116*5e01956fSGlenn Barry opened); 1177c478bd9Sstevel@tonic-gate 1187c478bd9Sstevel@tonic-gate if (status != GSS_S_COMPLETE) { 119*5e01956fSGlenn Barry map_error(minor_status, mech); 1207c478bd9Sstevel@tonic-gate return (status); 1217c478bd9Sstevel@tonic-gate } 1227c478bd9Sstevel@tonic-gate 1237c478bd9Sstevel@tonic-gate /* need to convert names */ 1247c478bd9Sstevel@tonic-gate if (src_name) { 1257c478bd9Sstevel@tonic-gate status = __gss_convert_name_to_union_name(minor_status, mech, 1267c478bd9Sstevel@tonic-gate localSourceName, src_name); 1277c478bd9Sstevel@tonic-gate if (status != GSS_S_COMPLETE) { 1287c478bd9Sstevel@tonic-gate if (localTargName) 1297c478bd9Sstevel@tonic-gate mech->gss_release_name(mech->context, 1307c478bd9Sstevel@tonic-gate &temp_minor, &localTargName); 1317c478bd9Sstevel@tonic-gate return (status); 1327c478bd9Sstevel@tonic-gate } 1337c478bd9Sstevel@tonic-gate } 1347c478bd9Sstevel@tonic-gate 1357c478bd9Sstevel@tonic-gate if (targ_name) { 1367c478bd9Sstevel@tonic-gate status = __gss_convert_name_to_union_name(minor_status, mech, 1377c478bd9Sstevel@tonic-gate localTargName, targ_name); 1387c478bd9Sstevel@tonic-gate 1397c478bd9Sstevel@tonic-gate if (status != GSS_S_COMPLETE) { 1407c478bd9Sstevel@tonic-gate if (src_name) 1417c478bd9Sstevel@tonic-gate (void) gss_release_name(&temp_minor, src_name); 1427c478bd9Sstevel@tonic-gate 1437c478bd9Sstevel@tonic-gate return (status); 1447c478bd9Sstevel@tonic-gate } 1457c478bd9Sstevel@tonic-gate } 1467c478bd9Sstevel@tonic-gate 1477c478bd9Sstevel@tonic-gate /* spec says mech type must point to static storage */ 1487c478bd9Sstevel@tonic-gate if (mech_type) 1497c478bd9Sstevel@tonic-gate *mech_type = &mech->mech_type; 1507c478bd9Sstevel@tonic-gate return (GSS_S_COMPLETE); 1517c478bd9Sstevel@tonic-gate } 152