Path: blob/main/crypto/krb5/src/lib/krb5/krb5_libinit.c
39536 views
/* -*- mode: c; c-basic-offset: 4; indent-tabs-mode: nil -*- */12#include "k5-int.h"34#if defined(_WIN32) || defined(USE_CCAPI)5#include "stdcc.h"6#endif78#include "krb5_libinit.h"9#include "k5-platform.h"10#include "cc-int.h"11#include "kt-int.h"12#include "os-proto.h"1314/*15* Initialize the Kerberos v5 library.16*/1718MAKE_INIT_FUNCTION(krb5int_lib_init);19MAKE_FINI_FUNCTION(krb5int_lib_fini);2021/* Possibly load-time initialization -- mutexes, etc. */22int krb5int_lib_init(void)23{24int err;2526k5_set_error_info_callout_fn(error_message);2728#ifdef SHOW_INITFINI_FUNCS29printf("krb5int_lib_init\n");30#endif3132add_error_table(&et_krb5_error_table);33add_error_table(&et_k5e1_error_table);34add_error_table(&et_kv5m_error_table);35add_error_table(&et_kdb5_error_table);36add_error_table(&et_asn1_error_table);37add_error_table(&et_k524_error_table);3839bindtextdomain(KRB5_TEXTDOMAIN, LOCALEDIR);4041#ifndef LEAN_CLIENT42err = krb5int_kt_initialize();43if (err)44return err;45#endif /* LEAN_CLIENT */46err = krb5int_cc_initialize();47if (err)48return err;49err = k5_mutex_finish_init(&krb5int_us_time_mutex);50if (err)51return err;5253return 0;54}5556/* Always-delayed initialization -- error table linkage, etc. */57krb5_error_code krb5int_initialize_library (void)58{59return CALL_INIT_FUNCTION(krb5int_lib_init);60}6162/*63* Clean up the Kerberos v5 library state64*/6566void krb5int_lib_fini(void)67{68if (!INITIALIZER_RAN(krb5int_lib_init) || PROGRAM_EXITING()) {69#ifdef SHOW_INITFINI_FUNCS70printf("krb5int_lib_fini: skipping\n");71#endif72return;73}7475#ifdef SHOW_INITFINI_FUNCS76printf("krb5int_lib_fini\n");77#endif7879k5_mutex_destroy(&krb5int_us_time_mutex);8081krb5int_cc_finalize();82#ifndef LEAN_CLIENT83krb5int_kt_finalize();84#endif /* LEAN_CLIENT */8586#if defined(_WIN32) || defined(USE_CCAPI)87krb5_stdcc_shutdown();88#endif8990remove_error_table(&et_krb5_error_table);91remove_error_table(&et_k5e1_error_table);92remove_error_table(&et_kv5m_error_table);93remove_error_table(&et_kdb5_error_table);94remove_error_table(&et_asn1_error_table);95remove_error_table(&et_k524_error_table);9697k5_set_error_info_callout_fn(NULL);98}99100/* Still exists because it went into the export list on Windows. But101since the above function should be invoked at unload time, we don't102actually want to do anything here. */103void krb5int_cleanup_library (void)104{105}106107108