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 59698SPeter.Shoults@Sun.COM * Common Development and Distribution License (the "License"). 69698SPeter.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*13132SGlenn.Barry@oracle.com * Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved. 230Sstevel@tonic-gate */ 240Sstevel@tonic-gate 250Sstevel@tonic-gate /* 260Sstevel@tonic-gate * glue routine for gss_inquire_context 270Sstevel@tonic-gate */ 280Sstevel@tonic-gate 290Sstevel@tonic-gate #include <mechglueP.h> 30*13132SGlenn.Barry@oracle.com #include "gssapiP_generic.h" 310Sstevel@tonic-gate #include <stdlib.h> 320Sstevel@tonic-gate 339698SPeter.Shoults@Sun.COM static OM_uint32 349698SPeter.Shoults@Sun.COM val_inq_ctx_args( 359698SPeter.Shoults@Sun.COM OM_uint32 *minor_status, 369698SPeter.Shoults@Sun.COM gss_ctx_id_t context_handle, 379698SPeter.Shoults@Sun.COM gss_name_t *src_name, 389698SPeter.Shoults@Sun.COM gss_name_t *targ_name, 399698SPeter.Shoults@Sun.COM gss_OID *mech_type) 409698SPeter.Shoults@Sun.COM { 419698SPeter.Shoults@Sun.COM 429698SPeter.Shoults@Sun.COM /* Initialize outputs. */ 439698SPeter.Shoults@Sun.COM 449698SPeter.Shoults@Sun.COM if (minor_status != NULL) 459698SPeter.Shoults@Sun.COM *minor_status = 0; 469698SPeter.Shoults@Sun.COM 479698SPeter.Shoults@Sun.COM if (src_name != NULL) 489698SPeter.Shoults@Sun.COM *src_name = GSS_C_NO_NAME; 499698SPeter.Shoults@Sun.COM 509698SPeter.Shoults@Sun.COM if (targ_name != NULL) 519698SPeter.Shoults@Sun.COM *targ_name = GSS_C_NO_NAME; 529698SPeter.Shoults@Sun.COM 539698SPeter.Shoults@Sun.COM if (mech_type != NULL) 549698SPeter.Shoults@Sun.COM *mech_type = GSS_C_NO_OID; 559698SPeter.Shoults@Sun.COM 569698SPeter.Shoults@Sun.COM /* Validate arguments. */ 579698SPeter.Shoults@Sun.COM 589698SPeter.Shoults@Sun.COM if (minor_status == NULL) 599698SPeter.Shoults@Sun.COM return (GSS_S_CALL_INACCESSIBLE_WRITE); 609698SPeter.Shoults@Sun.COM 619698SPeter.Shoults@Sun.COM if (context_handle == GSS_C_NO_CONTEXT) 629698SPeter.Shoults@Sun.COM return (GSS_S_CALL_INACCESSIBLE_READ | GSS_S_NO_CONTEXT); 639698SPeter.Shoults@Sun.COM 649698SPeter.Shoults@Sun.COM return (GSS_S_COMPLETE); 659698SPeter.Shoults@Sun.COM } 669698SPeter.Shoults@Sun.COM 670Sstevel@tonic-gate /* Last argument new for V2 */ 680Sstevel@tonic-gate OM_uint32 690Sstevel@tonic-gate gss_inquire_context( 70*13132SGlenn.Barry@oracle.com OM_uint32 *minor_status, 71*13132SGlenn.Barry@oracle.com gss_ctx_id_t context_handle, 72*13132SGlenn.Barry@oracle.com gss_name_t *src_name, 73*13132SGlenn.Barry@oracle.com gss_name_t *targ_name, 74*13132SGlenn.Barry@oracle.com OM_uint32 *lifetime_rec, 75*13132SGlenn.Barry@oracle.com gss_OID *mech_type, 76*13132SGlenn.Barry@oracle.com OM_uint32 *ctx_flags, 77*13132SGlenn.Barry@oracle.com int *locally_initiated, 78*13132SGlenn.Barry@oracle.com int *opened) 790Sstevel@tonic-gate { 800Sstevel@tonic-gate gss_union_ctx_id_t ctx; 810Sstevel@tonic-gate gss_mechanism mech; 820Sstevel@tonic-gate OM_uint32 status, temp_minor; 830Sstevel@tonic-gate gss_name_t localTargName = NULL, localSourceName = NULL; 840Sstevel@tonic-gate 859698SPeter.Shoults@Sun.COM status = val_inq_ctx_args(minor_status, 869698SPeter.Shoults@Sun.COM context_handle, 879698SPeter.Shoults@Sun.COM src_name, 889698SPeter.Shoults@Sun.COM targ_name, 899698SPeter.Shoults@Sun.COM mech_type); 909698SPeter.Shoults@Sun.COM if (status != GSS_S_COMPLETE) 919698SPeter.Shoults@Sun.COM return (status); 920Sstevel@tonic-gate 930Sstevel@tonic-gate /* 940Sstevel@tonic-gate * select the approprate underlying mechanism routine and 950Sstevel@tonic-gate * call it. 960Sstevel@tonic-gate */ 970Sstevel@tonic-gate 980Sstevel@tonic-gate ctx = (gss_union_ctx_id_t)context_handle; 990Sstevel@tonic-gate mech = __gss_get_mechanism(ctx->mech_type); 1000Sstevel@tonic-gate 1010Sstevel@tonic-gate if (!mech || !mech->gss_inquire_context || !mech->gss_display_name || 1020Sstevel@tonic-gate !mech->gss_release_name) { 1030Sstevel@tonic-gate return (GSS_S_UNAVAILABLE); 1040Sstevel@tonic-gate } 1050Sstevel@tonic-gate 1060Sstevel@tonic-gate status = mech->gss_inquire_context( 1070Sstevel@tonic-gate mech->context, 1080Sstevel@tonic-gate minor_status, 1090Sstevel@tonic-gate ctx->internal_ctx_id, 1100Sstevel@tonic-gate (src_name ? &localSourceName : NULL), 1110Sstevel@tonic-gate (targ_name ? &localTargName : NULL), 1120Sstevel@tonic-gate lifetime_rec, 1130Sstevel@tonic-gate NULL, 1140Sstevel@tonic-gate ctx_flags, 1150Sstevel@tonic-gate locally_initiated, 116*13132SGlenn.Barry@oracle.com opened); 1170Sstevel@tonic-gate 1180Sstevel@tonic-gate if (status != GSS_S_COMPLETE) { 119*13132SGlenn.Barry@oracle.com map_error(minor_status, mech); 1200Sstevel@tonic-gate return (status); 1210Sstevel@tonic-gate } 1220Sstevel@tonic-gate 1230Sstevel@tonic-gate /* need to convert names */ 1240Sstevel@tonic-gate if (src_name) { 1250Sstevel@tonic-gate status = __gss_convert_name_to_union_name(minor_status, mech, 1260Sstevel@tonic-gate localSourceName, src_name); 1270Sstevel@tonic-gate if (status != GSS_S_COMPLETE) { 1280Sstevel@tonic-gate if (localTargName) 1290Sstevel@tonic-gate mech->gss_release_name(mech->context, 1300Sstevel@tonic-gate &temp_minor, &localTargName); 1310Sstevel@tonic-gate return (status); 1320Sstevel@tonic-gate } 1330Sstevel@tonic-gate } 1340Sstevel@tonic-gate 1350Sstevel@tonic-gate if (targ_name) { 1360Sstevel@tonic-gate status = __gss_convert_name_to_union_name(minor_status, mech, 1370Sstevel@tonic-gate localTargName, targ_name); 1380Sstevel@tonic-gate 1390Sstevel@tonic-gate if (status != GSS_S_COMPLETE) { 1400Sstevel@tonic-gate if (src_name) 1410Sstevel@tonic-gate (void) gss_release_name(&temp_minor, src_name); 1420Sstevel@tonic-gate 1430Sstevel@tonic-gate return (status); 1440Sstevel@tonic-gate } 1450Sstevel@tonic-gate } 1460Sstevel@tonic-gate 1470Sstevel@tonic-gate /* spec says mech type must point to static storage */ 1480Sstevel@tonic-gate if (mech_type) 1490Sstevel@tonic-gate *mech_type = &mech->mech_type; 1500Sstevel@tonic-gate return (GSS_S_COMPLETE); 1510Sstevel@tonic-gate } 152