1 /* -*- mode: c; c-basic-offset: 4; indent-tabs-mode: nil -*- */ 2 3 #include "k5-int.h" 4 5 #if defined(_WIN32) || defined(USE_CCAPI) 6 #include "stdcc.h" 7 #endif 8 9 #include "krb5_libinit.h" 10 #include "k5-platform.h" 11 #include "cc-int.h" 12 #include "kt-int.h" 13 #include "os-proto.h" 14 15 /* 16 * Initialize the Kerberos v5 library. 17 */ 18 19 MAKE_INIT_FUNCTION(krb5int_lib_init); 20 MAKE_FINI_FUNCTION(krb5int_lib_fini); 21 22 /* Possibly load-time initialization -- mutexes, etc. */ krb5int_lib_init(void)23int krb5int_lib_init(void) 24 { 25 int err; 26 27 k5_set_error_info_callout_fn(error_message); 28 29 #ifdef SHOW_INITFINI_FUNCS 30 printf("krb5int_lib_init\n"); 31 #endif 32 33 add_error_table(&et_krb5_error_table); 34 add_error_table(&et_k5e1_error_table); 35 add_error_table(&et_kv5m_error_table); 36 add_error_table(&et_kdb5_error_table); 37 add_error_table(&et_asn1_error_table); 38 add_error_table(&et_k524_error_table); 39 40 bindtextdomain(KRB5_TEXTDOMAIN, LOCALEDIR); 41 42 #ifndef LEAN_CLIENT 43 err = krb5int_kt_initialize(); 44 if (err) 45 return err; 46 #endif /* LEAN_CLIENT */ 47 err = krb5int_cc_initialize(); 48 if (err) 49 return err; 50 err = k5_mutex_finish_init(&krb5int_us_time_mutex); 51 if (err) 52 return err; 53 54 return 0; 55 } 56 57 /* Always-delayed initialization -- error table linkage, etc. */ krb5int_initialize_library(void)58krb5_error_code krb5int_initialize_library (void) 59 { 60 return CALL_INIT_FUNCTION(krb5int_lib_init); 61 } 62 63 /* 64 * Clean up the Kerberos v5 library state 65 */ 66 krb5int_lib_fini(void)67void krb5int_lib_fini(void) 68 { 69 if (!INITIALIZER_RAN(krb5int_lib_init) || PROGRAM_EXITING()) { 70 #ifdef SHOW_INITFINI_FUNCS 71 printf("krb5int_lib_fini: skipping\n"); 72 #endif 73 return; 74 } 75 76 #ifdef SHOW_INITFINI_FUNCS 77 printf("krb5int_lib_fini\n"); 78 #endif 79 80 k5_mutex_destroy(&krb5int_us_time_mutex); 81 82 krb5int_cc_finalize(); 83 #ifndef LEAN_CLIENT 84 krb5int_kt_finalize(); 85 #endif /* LEAN_CLIENT */ 86 87 #if defined(_WIN32) || defined(USE_CCAPI) 88 krb5_stdcc_shutdown(); 89 #endif 90 91 remove_error_table(&et_krb5_error_table); 92 remove_error_table(&et_k5e1_error_table); 93 remove_error_table(&et_kv5m_error_table); 94 remove_error_table(&et_kdb5_error_table); 95 remove_error_table(&et_asn1_error_table); 96 remove_error_table(&et_k524_error_table); 97 98 k5_set_error_info_callout_fn(NULL); 99 } 100 101 /* Still exists because it went into the export list on Windows. But 102 since the above function should be invoked at unload time, we don't 103 actually want to do anything here. */ krb5int_cleanup_library(void)104void krb5int_cleanup_library (void) 105 { 106 } 107