1 /* 2 * Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved. 3 */ 4 5 #include <assert.h> 6 7 #include "gssapi_err_generic.h" 8 #include "gssapi_err_krb5.h" 9 #include "gssapiP_krb5.h" 10 11 #include "gss_libinit.h" 12 #include "k5-platform.h" 13 14 #include "mglueP.h" 15 /* 16 * Initialize the GSSAPI library. 17 */ 18 19 MAKE_INIT_FUNCTION(gssint_lib_init); 20 MAKE_FINI_FUNCTION(gssint_lib_fini); 21 gssint_lib_init(void)22int gssint_lib_init(void) 23 { 24 int err; 25 26 #ifdef SHOW_INITFINI_FUNCS 27 printf("gssint_lib_init\n"); 28 #endif 29 30 #if !USE_BUNDLE_ERROR_STRINGS 31 add_error_table(&et_k5g_error_table); 32 add_error_table(&et_ggss_error_table); 33 #endif 34 #if 0 /* SUNW15resync */ 35 err = gssint_mechglue_init(); 36 if (err) 37 return err; 38 #endif 39 err = k5_mutex_finish_init(&gssint_krb5_keytab_lock); 40 if (err) 41 return err; 42 err = k5_key_register(K5_KEY_GSS_KRB5_SET_CCACHE_OLD_NAME, free); 43 if (err) 44 return err; 45 err = k5_key_register(K5_KEY_GSS_KRB5_CCACHE_NAME, free); 46 if (err) 47 return err; 48 err = k5_key_register(K5_KEY_GSS_KRB5_ERROR_MESSAGE, 49 krb5_gss_delete_error_info); 50 if (err) 51 return err; 52 #ifndef _WIN32 53 err = k5_mutex_finish_init(&kg_kdc_flag_mutex); 54 if (err) 55 return err; 56 #endif 57 return k5_mutex_finish_init(&kg_vdb.mutex); 58 } 59 gssint_lib_fini(void)60void gssint_lib_fini(void) 61 { 62 if (!INITIALIZER_RAN(gssint_lib_init) || PROGRAM_EXITING()) { 63 #ifdef SHOW_INITFINI_FUNCS 64 printf("gssint_lib_fini: skipping\n"); 65 #endif 66 return; 67 } 68 #ifdef SHOW_INITFINI_FUNCS 69 printf("gssint_lib_fini\n"); 70 #endif 71 #if !USE_BUNDLE_ERROR_STRINGS 72 remove_error_table(&et_k5g_error_table); 73 remove_error_table(&et_ggss_error_table); 74 #endif 75 k5_key_delete(K5_KEY_GSS_KRB5_SET_CCACHE_OLD_NAME); 76 k5_key_delete(K5_KEY_GSS_KRB5_CCACHE_NAME); 77 k5_mutex_destroy(&kg_vdb.mutex); 78 #ifndef _WIN32 79 k5_mutex_destroy(&kg_kdc_flag_mutex); 80 #endif 81 k5_mutex_destroy(&gssint_krb5_keytab_lock); 82 #if 0 /* SUNW15resync */ 83 gssint_mechglue_fini(); 84 #endif 85 } 86 gssint_initialize_library(void)87OM_uint32 gssint_initialize_library (void) 88 { 89 return CALL_INIT_FUNCTION(gssint_lib_init); 90 } 91