10Sstevel@tonic-gate /* 20Sstevel@tonic-gate * CDDL HEADER START 30Sstevel@tonic-gate * 40Sstevel@tonic-gate * The contents of this file are subject to the terms of the 5*9698SPeter.Shoults@Sun.COM * Common Development and Distribution License (the "License"). 6*9698SPeter.Shoults@Sun.COM * You may not use this file except in compliance with the License. 70Sstevel@tonic-gate * 80Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 90Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 100Sstevel@tonic-gate * See the License for the specific language governing permissions 110Sstevel@tonic-gate * and limitations under the License. 120Sstevel@tonic-gate * 130Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 140Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 150Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 160Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 170Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 180Sstevel@tonic-gate * 190Sstevel@tonic-gate * CDDL HEADER END 200Sstevel@tonic-gate */ 210Sstevel@tonic-gate /* 22*9698SPeter.Shoults@Sun.COM * Copyright 2009 Sun Microsystems, Inc. All rights reserved. 230Sstevel@tonic-gate * Use is subject to license terms. 240Sstevel@tonic-gate */ 250Sstevel@tonic-gate 260Sstevel@tonic-gate /* 270Sstevel@tonic-gate * glue routine for gss_inquire_context 280Sstevel@tonic-gate */ 290Sstevel@tonic-gate 300Sstevel@tonic-gate #include <mechglueP.h> 310Sstevel@tonic-gate #include <stdlib.h> 320Sstevel@tonic-gate 33*9698SPeter.Shoults@Sun.COM static OM_uint32 34*9698SPeter.Shoults@Sun.COM val_inq_ctx_args( 35*9698SPeter.Shoults@Sun.COM OM_uint32 *minor_status, 36*9698SPeter.Shoults@Sun.COM gss_ctx_id_t context_handle, 37*9698SPeter.Shoults@Sun.COM gss_name_t *src_name, 38*9698SPeter.Shoults@Sun.COM gss_name_t *targ_name, 39*9698SPeter.Shoults@Sun.COM gss_OID *mech_type) 40*9698SPeter.Shoults@Sun.COM { 41*9698SPeter.Shoults@Sun.COM 42*9698SPeter.Shoults@Sun.COM /* Initialize outputs. */ 43*9698SPeter.Shoults@Sun.COM 44*9698SPeter.Shoults@Sun.COM if (minor_status != NULL) 45*9698SPeter.Shoults@Sun.COM *minor_status = 0; 46*9698SPeter.Shoults@Sun.COM 47*9698SPeter.Shoults@Sun.COM if (src_name != NULL) 48*9698SPeter.Shoults@Sun.COM *src_name = GSS_C_NO_NAME; 49*9698SPeter.Shoults@Sun.COM 50*9698SPeter.Shoults@Sun.COM if (targ_name != NULL) 51*9698SPeter.Shoults@Sun.COM *targ_name = GSS_C_NO_NAME; 52*9698SPeter.Shoults@Sun.COM 53*9698SPeter.Shoults@Sun.COM if (mech_type != NULL) 54*9698SPeter.Shoults@Sun.COM *mech_type = GSS_C_NO_OID; 55*9698SPeter.Shoults@Sun.COM 56*9698SPeter.Shoults@Sun.COM /* Validate arguments. */ 57*9698SPeter.Shoults@Sun.COM 58*9698SPeter.Shoults@Sun.COM if (minor_status == NULL) 59*9698SPeter.Shoults@Sun.COM return (GSS_S_CALL_INACCESSIBLE_WRITE); 60*9698SPeter.Shoults@Sun.COM 61*9698SPeter.Shoults@Sun.COM if (context_handle == GSS_C_NO_CONTEXT) 62*9698SPeter.Shoults@Sun.COM return (GSS_S_CALL_INACCESSIBLE_READ | GSS_S_NO_CONTEXT); 63*9698SPeter.Shoults@Sun.COM 64*9698SPeter.Shoults@Sun.COM return (GSS_S_COMPLETE); 65*9698SPeter.Shoults@Sun.COM } 66*9698SPeter.Shoults@Sun.COM 670Sstevel@tonic-gate /* Last argument new for V2 */ 680Sstevel@tonic-gate OM_uint32 690Sstevel@tonic-gate gss_inquire_context( 700Sstevel@tonic-gate minor_status, 710Sstevel@tonic-gate context_handle, 720Sstevel@tonic-gate src_name, 730Sstevel@tonic-gate targ_name, 740Sstevel@tonic-gate lifetime_rec, 750Sstevel@tonic-gate mech_type, 760Sstevel@tonic-gate ctx_flags, 770Sstevel@tonic-gate locally_initiated, 780Sstevel@tonic-gate open) 790Sstevel@tonic-gate 800Sstevel@tonic-gate OM_uint32 *minor_status; 810Sstevel@tonic-gate const gss_ctx_id_t context_handle; 820Sstevel@tonic-gate gss_name_t *src_name; 830Sstevel@tonic-gate gss_name_t *targ_name; 840Sstevel@tonic-gate OM_uint32 *lifetime_rec; 850Sstevel@tonic-gate gss_OID *mech_type; 860Sstevel@tonic-gate OM_uint32 *ctx_flags; 870Sstevel@tonic-gate int *locally_initiated; 880Sstevel@tonic-gate int *open; 890Sstevel@tonic-gate 900Sstevel@tonic-gate { 910Sstevel@tonic-gate gss_union_ctx_id_t ctx; 920Sstevel@tonic-gate gss_mechanism mech; 930Sstevel@tonic-gate OM_uint32 status, temp_minor; 940Sstevel@tonic-gate gss_name_t localTargName = NULL, localSourceName = NULL; 950Sstevel@tonic-gate 96*9698SPeter.Shoults@Sun.COM status = val_inq_ctx_args(minor_status, 97*9698SPeter.Shoults@Sun.COM context_handle, 98*9698SPeter.Shoults@Sun.COM src_name, 99*9698SPeter.Shoults@Sun.COM targ_name, 100*9698SPeter.Shoults@Sun.COM mech_type); 101*9698SPeter.Shoults@Sun.COM if (status != GSS_S_COMPLETE) 102*9698SPeter.Shoults@Sun.COM return (status); 1030Sstevel@tonic-gate 1040Sstevel@tonic-gate /* 1050Sstevel@tonic-gate * select the approprate underlying mechanism routine and 1060Sstevel@tonic-gate * call it. 1070Sstevel@tonic-gate */ 1080Sstevel@tonic-gate 1090Sstevel@tonic-gate ctx = (gss_union_ctx_id_t)context_handle; 1100Sstevel@tonic-gate mech = __gss_get_mechanism(ctx->mech_type); 1110Sstevel@tonic-gate 1120Sstevel@tonic-gate if (!mech || !mech->gss_inquire_context || !mech->gss_display_name || 1130Sstevel@tonic-gate !mech->gss_release_name) { 1140Sstevel@tonic-gate return (GSS_S_UNAVAILABLE); 1150Sstevel@tonic-gate } 1160Sstevel@tonic-gate 1170Sstevel@tonic-gate status = mech->gss_inquire_context( 1180Sstevel@tonic-gate mech->context, 1190Sstevel@tonic-gate minor_status, 1200Sstevel@tonic-gate ctx->internal_ctx_id, 1210Sstevel@tonic-gate (src_name ? &localSourceName : NULL), 1220Sstevel@tonic-gate (targ_name ? &localTargName : NULL), 1230Sstevel@tonic-gate lifetime_rec, 1240Sstevel@tonic-gate NULL, 1250Sstevel@tonic-gate ctx_flags, 1260Sstevel@tonic-gate locally_initiated, 1270Sstevel@tonic-gate open); 1280Sstevel@tonic-gate 1290Sstevel@tonic-gate if (status != GSS_S_COMPLETE) { 1300Sstevel@tonic-gate return (status); 1310Sstevel@tonic-gate } 1320Sstevel@tonic-gate 1330Sstevel@tonic-gate /* need to convert names */ 1340Sstevel@tonic-gate if (src_name) { 1350Sstevel@tonic-gate status = __gss_convert_name_to_union_name(minor_status, mech, 1360Sstevel@tonic-gate localSourceName, src_name); 1370Sstevel@tonic-gate if (status != GSS_S_COMPLETE) { 1380Sstevel@tonic-gate if (localTargName) 1390Sstevel@tonic-gate mech->gss_release_name(mech->context, 1400Sstevel@tonic-gate &temp_minor, &localTargName); 1410Sstevel@tonic-gate return (status); 1420Sstevel@tonic-gate } 1430Sstevel@tonic-gate } 1440Sstevel@tonic-gate 1450Sstevel@tonic-gate if (targ_name) { 1460Sstevel@tonic-gate status = __gss_convert_name_to_union_name(minor_status, mech, 1470Sstevel@tonic-gate localTargName, targ_name); 1480Sstevel@tonic-gate 1490Sstevel@tonic-gate if (status != GSS_S_COMPLETE) { 1500Sstevel@tonic-gate if (src_name) 1510Sstevel@tonic-gate (void) gss_release_name(&temp_minor, src_name); 1520Sstevel@tonic-gate 1530Sstevel@tonic-gate return (status); 1540Sstevel@tonic-gate } 1550Sstevel@tonic-gate } 1560Sstevel@tonic-gate 1570Sstevel@tonic-gate /* spec says mech type must point to static storage */ 1580Sstevel@tonic-gate if (mech_type) 1590Sstevel@tonic-gate *mech_type = &mech->mech_type; 1600Sstevel@tonic-gate return (GSS_S_COMPLETE); 1610Sstevel@tonic-gate } 162