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 327c478bd9Sstevel@tonic-gate #define MAX_MECH_OID_PAIRS 32 337c478bd9Sstevel@tonic-gate 347c478bd9Sstevel@tonic-gate /* Last argument new for V2 */ 357c478bd9Sstevel@tonic-gate OM_uint32 367c478bd9Sstevel@tonic-gate gss_inquire_names_for_mech(minor_status, mechanism, name_types) 377c478bd9Sstevel@tonic-gate 387c478bd9Sstevel@tonic-gate OM_uint32 * minor_status; 397c478bd9Sstevel@tonic-gate const gss_OID mechanism; 407c478bd9Sstevel@tonic-gate gss_OID_set * name_types; 417c478bd9Sstevel@tonic-gate 427c478bd9Sstevel@tonic-gate { 437c478bd9Sstevel@tonic-gate OM_uint32 status; 447c478bd9Sstevel@tonic-gate gss_mechanism mech; 457c478bd9Sstevel@tonic-gate 46503a2b89SPeter Shoults /* Initialize outputs. */ 47503a2b89SPeter Shoults 48503a2b89SPeter Shoults if (minor_status != NULL) 49503a2b89SPeter Shoults *minor_status = 0; 50503a2b89SPeter Shoults 51503a2b89SPeter Shoults if (name_types != NULL) 52503a2b89SPeter Shoults *name_types = GSS_C_NO_OID_SET; 53503a2b89SPeter Shoults 54503a2b89SPeter Shoults /* Validate arguments. */ 55503a2b89SPeter Shoults 567c478bd9Sstevel@tonic-gate if (minor_status == NULL) 577c478bd9Sstevel@tonic-gate return (GSS_S_CALL_INACCESSIBLE_WRITE); 587c478bd9Sstevel@tonic-gate 597c478bd9Sstevel@tonic-gate if (name_types == NULL) 607c478bd9Sstevel@tonic-gate return (GSS_S_CALL_INACCESSIBLE_WRITE); 617c478bd9Sstevel@tonic-gate 627c478bd9Sstevel@tonic-gate /* 637c478bd9Sstevel@tonic-gate * select the approprate underlying mechanism routine and 647c478bd9Sstevel@tonic-gate * call it. 657c478bd9Sstevel@tonic-gate */ 667c478bd9Sstevel@tonic-gate 677c478bd9Sstevel@tonic-gate mech = __gss_get_mechanism(mechanism); 687c478bd9Sstevel@tonic-gate 697c478bd9Sstevel@tonic-gate if (mech) { 707c478bd9Sstevel@tonic-gate 71*5e01956fSGlenn Barry if (mech->gss_inquire_names_for_mech) { 727c478bd9Sstevel@tonic-gate status = mech->gss_inquire_names_for_mech( 737c478bd9Sstevel@tonic-gate mech->context, 747c478bd9Sstevel@tonic-gate minor_status, 757c478bd9Sstevel@tonic-gate mechanism, 767c478bd9Sstevel@tonic-gate name_types); 77*5e01956fSGlenn Barry if (status != GSS_S_COMPLETE) 78*5e01956fSGlenn Barry map_error(minor_status, mech); 79*5e01956fSGlenn Barry } else 807c478bd9Sstevel@tonic-gate status = GSS_S_UNAVAILABLE; 817c478bd9Sstevel@tonic-gate 827c478bd9Sstevel@tonic-gate return (status); 837c478bd9Sstevel@tonic-gate } 847c478bd9Sstevel@tonic-gate 857c478bd9Sstevel@tonic-gate return (GSS_S_BAD_MECH); 867c478bd9Sstevel@tonic-gate } 877c478bd9Sstevel@tonic-gate 88503a2b89SPeter Shoults static OM_uint32 val_inq_mechs4name_args( 89503a2b89SPeter Shoults OM_uint32 *minor_status, 90503a2b89SPeter Shoults const gss_name_t input_name, 91503a2b89SPeter Shoults gss_OID_set *mech_set) 92503a2b89SPeter Shoults { 93503a2b89SPeter Shoults 94503a2b89SPeter Shoults /* Initialize outputs. */ 95503a2b89SPeter Shoults if (minor_status != NULL) 96503a2b89SPeter Shoults *minor_status = 0; 97503a2b89SPeter Shoults 98503a2b89SPeter Shoults if (mech_set != NULL) 99503a2b89SPeter Shoults *mech_set = GSS_C_NO_OID_SET; 100503a2b89SPeter Shoults 101503a2b89SPeter Shoults /* Validate arguments. */ 102503a2b89SPeter Shoults 103503a2b89SPeter Shoults if (minor_status == NULL) 104503a2b89SPeter Shoults return (GSS_S_CALL_INACCESSIBLE_WRITE); 105503a2b89SPeter Shoults 106503a2b89SPeter Shoults if (input_name == GSS_C_NO_NAME) 107503a2b89SPeter Shoults return (GSS_S_BAD_NAME); 108503a2b89SPeter Shoults 109503a2b89SPeter Shoults return (GSS_S_COMPLETE); 110503a2b89SPeter Shoults } 111503a2b89SPeter Shoults 1127c478bd9Sstevel@tonic-gate OM_uint32 1137c478bd9Sstevel@tonic-gate gss_inquire_mechs_for_name(minor_status, input_name, mech_set) 1147c478bd9Sstevel@tonic-gate 1157c478bd9Sstevel@tonic-gate OM_uint32 * minor_status; 1167c478bd9Sstevel@tonic-gate const gss_name_t input_name; 1177c478bd9Sstevel@tonic-gate gss_OID_set * mech_set; 1187c478bd9Sstevel@tonic-gate 1197c478bd9Sstevel@tonic-gate { 1207c478bd9Sstevel@tonic-gate OM_uint32 status; 1217c478bd9Sstevel@tonic-gate static char *mech_list[MAX_MECH_OID_PAIRS+1]; 1227c478bd9Sstevel@tonic-gate gss_OID_set mech_name_types; 1237c478bd9Sstevel@tonic-gate int present; 1247c478bd9Sstevel@tonic-gate char *mechanism; 1257c478bd9Sstevel@tonic-gate gss_OID mechOid; 1267c478bd9Sstevel@tonic-gate gss_OID name_type; 1277c478bd9Sstevel@tonic-gate gss_buffer_desc name_buffer; 1287c478bd9Sstevel@tonic-gate int i; 1297c478bd9Sstevel@tonic-gate 130503a2b89SPeter Shoults status = val_inq_mechs4name_args(minor_status, input_name, mech_set); 131503a2b89SPeter Shoults if (status != GSS_S_COMPLETE) 132503a2b89SPeter Shoults return (status); 1337c478bd9Sstevel@tonic-gate 1347c478bd9Sstevel@tonic-gate status = gss_create_empty_oid_set(minor_status, mech_set); 1357c478bd9Sstevel@tonic-gate if (status != GSS_S_COMPLETE) 1367c478bd9Sstevel@tonic-gate return (status); 1377c478bd9Sstevel@tonic-gate *mech_list = NULL; 1387c478bd9Sstevel@tonic-gate status = __gss_get_mechanisms(mech_list, MAX_MECH_OID_PAIRS+1); 1397c478bd9Sstevel@tonic-gate if (status != GSS_S_COMPLETE) 1407c478bd9Sstevel@tonic-gate return (status); 1417c478bd9Sstevel@tonic-gate for (i = 0; i < MAX_MECH_OID_PAIRS && mech_list[i] != NULL; i++) { 1427c478bd9Sstevel@tonic-gate mechanism = mech_list[i]; 1437c478bd9Sstevel@tonic-gate if (__gss_mech_to_oid(mechanism, &mechOid) == GSS_S_COMPLETE) { 1447c478bd9Sstevel@tonic-gate status = gss_inquire_names_for_mech( 1457c478bd9Sstevel@tonic-gate minor_status, 1467c478bd9Sstevel@tonic-gate mechOid, 1477c478bd9Sstevel@tonic-gate &mech_name_types); 1487c478bd9Sstevel@tonic-gate if (status == GSS_S_COMPLETE) { 1497c478bd9Sstevel@tonic-gate status = gss_display_name(minor_status, 1507c478bd9Sstevel@tonic-gate input_name, 1517c478bd9Sstevel@tonic-gate &name_buffer, 1527c478bd9Sstevel@tonic-gate &name_type); 1537c478bd9Sstevel@tonic-gate 1547c478bd9Sstevel@tonic-gate (void) gss_release_buffer(NULL, &name_buffer); 1557c478bd9Sstevel@tonic-gate 1567c478bd9Sstevel@tonic-gate if (status == GSS_S_COMPLETE && name_type) { 1577c478bd9Sstevel@tonic-gate status = gss_test_oid_set_member( 1587c478bd9Sstevel@tonic-gate minor_status, 1597c478bd9Sstevel@tonic-gate name_type, 1607c478bd9Sstevel@tonic-gate mech_name_types, 1617c478bd9Sstevel@tonic-gate &present); 1627c478bd9Sstevel@tonic-gate if (status == GSS_S_COMPLETE && 1637c478bd9Sstevel@tonic-gate present) { 1647c478bd9Sstevel@tonic-gate status = gss_add_oid_set_member( 1657c478bd9Sstevel@tonic-gate minor_status, 1667c478bd9Sstevel@tonic-gate mechOid, 1677c478bd9Sstevel@tonic-gate mech_set); 1687c478bd9Sstevel@tonic-gate if (status != GSS_S_COMPLETE) { 1697c478bd9Sstevel@tonic-gate (void) gss_release_oid_set( 1707c478bd9Sstevel@tonic-gate minor_status, 1717c478bd9Sstevel@tonic-gate &mech_name_types); 1727c478bd9Sstevel@tonic-gate (void) gss_release_oid_set( 1737c478bd9Sstevel@tonic-gate minor_status, 1747c478bd9Sstevel@tonic-gate mech_set); 1757c478bd9Sstevel@tonic-gate return (status); 1767c478bd9Sstevel@tonic-gate } 1777c478bd9Sstevel@tonic-gate } 1787c478bd9Sstevel@tonic-gate } 1797c478bd9Sstevel@tonic-gate (void) gss_release_oid_set( 1807c478bd9Sstevel@tonic-gate minor_status, 1817c478bd9Sstevel@tonic-gate &mech_name_types); 1827c478bd9Sstevel@tonic-gate } 1837c478bd9Sstevel@tonic-gate } else { 1847c478bd9Sstevel@tonic-gate (void) gss_release_oid_set( 1857c478bd9Sstevel@tonic-gate minor_status, 1867c478bd9Sstevel@tonic-gate mech_set); 1877c478bd9Sstevel@tonic-gate return (GSS_S_FAILURE); 1887c478bd9Sstevel@tonic-gate } 1897c478bd9Sstevel@tonic-gate } 1907c478bd9Sstevel@tonic-gate return (GSS_S_COMPLETE); 1917c478bd9Sstevel@tonic-gate } 192