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*13132SGlenn.Barry@oracle.com * Common Development and Distribution License (the "License"). 6*13132SGlenn.Barry@oracle.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_release_cred 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 <stdio.h> 320Sstevel@tonic-gate #ifdef HAVE_STDLIB_H 330Sstevel@tonic-gate #include <stdlib.h> 340Sstevel@tonic-gate #endif 350Sstevel@tonic-gate 360Sstevel@tonic-gate OM_uint32 370Sstevel@tonic-gate gss_release_cred(minor_status, 380Sstevel@tonic-gate cred_handle) 390Sstevel@tonic-gate 400Sstevel@tonic-gate OM_uint32 *minor_status; 410Sstevel@tonic-gate gss_cred_id_t *cred_handle; 420Sstevel@tonic-gate 430Sstevel@tonic-gate { 440Sstevel@tonic-gate OM_uint32 status, temp_status; 450Sstevel@tonic-gate int j; 460Sstevel@tonic-gate gss_union_cred_t union_cred; 470Sstevel@tonic-gate gss_mechanism mech; 480Sstevel@tonic-gate 490Sstevel@tonic-gate if (minor_status == NULL) 500Sstevel@tonic-gate return (GSS_S_CALL_INACCESSIBLE_WRITE); 510Sstevel@tonic-gate 520Sstevel@tonic-gate *minor_status = 0; 530Sstevel@tonic-gate 540Sstevel@tonic-gate if (cred_handle == NULL) 550Sstevel@tonic-gate return (GSS_S_NO_CRED | GSS_S_CALL_INACCESSIBLE_READ); 560Sstevel@tonic-gate 570Sstevel@tonic-gate /* 580Sstevel@tonic-gate * Loop through the union_cred struct, selecting the approprate 590Sstevel@tonic-gate * underlying mechanism routine and calling it. At the end, 600Sstevel@tonic-gate * release all of the storage taken by the union_cred struct. 610Sstevel@tonic-gate */ 620Sstevel@tonic-gate 630Sstevel@tonic-gate union_cred = (gss_union_cred_t)*cred_handle; 640Sstevel@tonic-gate if (union_cred == (gss_union_cred_t)GSS_C_NO_CREDENTIAL) 650Sstevel@tonic-gate return (GSS_S_COMPLETE); 660Sstevel@tonic-gate 67*13132SGlenn.Barry@oracle.com if (GSSINT_CHK_LOOP(union_cred)) 68*13132SGlenn.Barry@oracle.com return (GSS_S_NO_CRED | GSS_S_CALL_INACCESSIBLE_READ); 69*13132SGlenn.Barry@oracle.com 70*13132SGlenn.Barry@oracle.com *cred_handle = NULL; 71*13132SGlenn.Barry@oracle.com 720Sstevel@tonic-gate status = GSS_S_COMPLETE; 730Sstevel@tonic-gate 740Sstevel@tonic-gate for (j = 0; j < union_cred->count; j++) { 750Sstevel@tonic-gate 760Sstevel@tonic-gate mech = __gss_get_mechanism(&union_cred->mechs_array[j]); 770Sstevel@tonic-gate 780Sstevel@tonic-gate if (union_cred->mechs_array[j].elements) 790Sstevel@tonic-gate free(union_cred->mechs_array[j].elements); 800Sstevel@tonic-gate if (mech) { 810Sstevel@tonic-gate if (mech->gss_release_cred) { 820Sstevel@tonic-gate temp_status = mech->gss_release_cred 830Sstevel@tonic-gate (mech->context, minor_status, 840Sstevel@tonic-gate &union_cred->cred_array[j]); 850Sstevel@tonic-gate 86*13132SGlenn.Barry@oracle.com if (temp_status != GSS_S_COMPLETE) { 87*13132SGlenn.Barry@oracle.com map_error(minor_status, mech); 880Sstevel@tonic-gate status = GSS_S_NO_CRED; 89*13132SGlenn.Barry@oracle.com } 900Sstevel@tonic-gate } else 910Sstevel@tonic-gate status = GSS_S_UNAVAILABLE; 920Sstevel@tonic-gate } else 930Sstevel@tonic-gate status = GSS_S_DEFECTIVE_CREDENTIAL; 940Sstevel@tonic-gate } 950Sstevel@tonic-gate 960Sstevel@tonic-gate (void) gss_release_buffer(minor_status, &union_cred->auxinfo.name); 970Sstevel@tonic-gate free(union_cred->cred_array); 980Sstevel@tonic-gate free(union_cred->mechs_array); 990Sstevel@tonic-gate free(union_cred); 1000Sstevel@tonic-gate 1010Sstevel@tonic-gate return (status); 1020Sstevel@tonic-gate } 103