Sdiff g_rel_cred.c
  1 /*
  2  * Copyright 2004 Sun Microsystems, Inc.  All rights reserved.
  3  * Use is subject to license terms.
  4  */
  5 
  6 #pragma ident   "@(#)g_rel_cred.c       1.15    04/09/08 SMI" 
  7 
  8 /*
  9  *  glue routine for gss_release_cred
 10  */
 11 
 12 #include <mechglueP.h>
 13 #include <stdio.h>
 14 #ifdef HAVE_STDLIB_H
 15 #include <stdlib.h>
 16 #endif
 17 
 18 OM_uint32
 19 gss_release_cred(minor_status,
 20                         cred_handle)
 21 
 22 OM_uint32               *minor_status;
 23 gss_cred_id_t           *cred_handle;
 24 
 25 {
 26         OM_uint32               status, temp_status;
 27         int                     j;
 28         gss_union_cred_t        union_cred;
 29         gss_mechanism           mech;
 30 
 31         gss_initialize(); 

 32 
 33         if (minor_status) 
 34                 *minor_status = 0;
 35 
 36         /* if the cred_handle is null, return a NO_CRED error */ 

 37 
 38         if (cred_handle == GSS_C_NO_CREDENTIAL) 
 39                 return (GSS_S_NO_CRED); 
 40  
 41         /*
 42          * Loop through the union_cred struct, selecting the approprate
 43          * underlying mechanism routine and calling it. At the end,
 44          * release all of the storage taken by the union_cred struct.
 45          */
 46 
 47         union_cred = (gss_union_cred_t)*cred_handle;
 48         *cred_handle = NULL;
 49 
 50         if (union_cred == NULL) 
 51                 return (GSS_S_NO_CRED); 
 52 
 53         status = GSS_S_COMPLETE;
 54 
 55         for (j = 0; j < union_cred->count; j++) {
 56 
 57                 mech = __gss_get_mechanism(&union_cred->mechs_array[j]);
 58 
 59                 if (union_cred->mechs_array[j].elements)
 60                         free(union_cred->mechs_array[j].elements);
 61                 if (mech) {
 62                         if (mech->gss_release_cred) {
 63                                 temp_status = mech->gss_release_cred
 64                                                 (mech->context, minor_status,
 65                                                 &union_cred->cred_array[j]);
 66 
 67                                 if (temp_status != GSS_S_COMPLETE)
 68                                         status = GSS_S_NO_CRED;
 69                         } else
 70                                 status = GSS_S_NO_CRED; 
 71                 } else
 72                         status = GSS_S_NO_CRED; 
 73         }
 74 
 75         (void) gss_release_buffer(minor_status, &union_cred->auxinfo.name);
 76         free(union_cred->cred_array);
 77         free(union_cred->mechs_array);
 78         free(union_cred);
 79 
 80         return (status);
 81 }
  1 /*
  2  * Copyright 2004 Sun Microsystems, Inc.  All rights reserved.
  3  * Use is subject to license terms.
  4  */
  5 
  6 #pragma ident   "@(#)g_rel_cred.c       1.14    04/02/23 SMI" 
  7 
  8 /*
  9  *  glue routine for gss_release_cred
 10  */
 11 
 12 #include <mechglueP.h>
 13 #include <stdio.h>
 14 #ifdef HAVE_STDLIB_H
 15 #include <stdlib.h>
 16 #endif
 17 
 18 OM_uint32
 19 gss_release_cred(minor_status,
 20                         cred_handle)
 21 
 22 OM_uint32               *minor_status;
 23 gss_cred_id_t           *cred_handle;
 24 
 25 {
 26         OM_uint32               status, temp_status;
 27         int                     j;
 28         gss_union_cred_t        union_cred;
 29         gss_mechanism           mech;
 30 
 31         if (minor_status == NULL) 
 32                 return (GSS_S_CALL_INACCESSIBLE_WRITE); 
 33 

 34         *minor_status = 0;
 35 
 36         if (cred_handle == NULL) 
 37                 return (GSS_S_NO_CRED | GSS_S_CALL_INACCESSIBLE_READ); 
 38 



 39         /*
 40          * Loop through the union_cred struct, selecting the approprate
 41          * underlying mechanism routine and calling it. At the end,
 42          * release all of the storage taken by the union_cred struct.
 43          */
 44 
 45         union_cred = (gss_union_cred_t)*cred_handle;
 46         *cred_handle = NULL;
 47 
 48         if (union_cred == (gss_union_cred_t)GSS_C_NO_CREDENTIAL) 
 49                 return (GSS_S_COMPLETE); 
 50 
 51         status = GSS_S_COMPLETE;
 52 
 53         for (j = 0; j < union_cred->count; j++) {
 54 
 55                 mech = __gss_get_mechanism(&union_cred->mechs_array[j]);
 56 
 57                 if (union_cred->mechs_array[j].elements)
 58                         free(union_cred->mechs_array[j].elements);
 59                 if (mech) {
 60                         if (mech->gss_release_cred) {
 61                                 temp_status = mech->gss_release_cred
 62                                                 (mech->context, minor_status,
 63                                                 &union_cred->cred_array[j]);
 64 
 65                                 if (temp_status != GSS_S_COMPLETE)
 66                                         status = GSS_S_NO_CRED;
 67                         } else
 68                                 status = GSS_S_UNAVAILABLE; 
 69                 } else
 70                         status = GSS_S_DEFECTIVE_CREDENTIAL; 
 71         }
 72 
 73         (void) gss_release_buffer(minor_status, &union_cred->auxinfo.name);
 74         free(union_cred->cred_array);
 75         free(union_cred->mechs_array);
 76         free(union_cred);
 77 
 78         return (status);
 79 }