xref: /illumos-gate/usr/src/lib/krb5/kdb/kdb5.c (revision 7c64d375)
154925bf6Swillf /*
22dd2efa5Swillf  * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
354925bf6Swillf  * Use is subject to license terms.
454925bf6Swillf  */
554925bf6Swillf 
654925bf6Swillf #pragma ident	"%Z%%M%	%I%	%E% SMI"
754925bf6Swillf /*
854925bf6Swillf  * Copyright 2006 by the Massachusetts Institute of Technology.
954925bf6Swillf  * All Rights Reserved.
1054925bf6Swillf  *
1154925bf6Swillf  * Export of this software from the United States of America may
1254925bf6Swillf  *   require a specific license from the United States Government.
1354925bf6Swillf  *   It is the responsibility of any person or organization contemplating
1454925bf6Swillf  *   export to obtain such a license before exporting.
1554925bf6Swillf  *
1654925bf6Swillf  * WITHIN THAT CONSTRAINT, permission to use, copy, modify, and
1754925bf6Swillf  * distribute this software and its documentation for any purpose and
1854925bf6Swillf  * without fee is hereby granted, provided that the above copyright
1954925bf6Swillf  * notice appear in all copies and that both that copyright notice and
2054925bf6Swillf  * this permission notice appear in supporting documentation, and that
2154925bf6Swillf  * the name of M.I.T. not be used in advertising or publicity pertaining
2254925bf6Swillf  * to distribution of the software without specific, written prior
2354925bf6Swillf  * permission.  Furthermore if you modify this software you must label
2454925bf6Swillf  * your software as modified software and not distribute it in such a
2554925bf6Swillf  * fashion that it might be confused with the original M.I.T. software.
2654925bf6Swillf  * M.I.T. makes no representations about the suitability of
2754925bf6Swillf  * this software for any purpose.  It is provided "as is" without express
2854925bf6Swillf  * or implied warranty.
2954925bf6Swillf  */
3054925bf6Swillf 
3154925bf6Swillf /*
3254925bf6Swillf  * This code was based on code donated to MIT by Novell for
3354925bf6Swillf  * distribution under the MIT license.
3454925bf6Swillf  */
3554925bf6Swillf 
3654925bf6Swillf /*
3754925bf6Swillf  * Include files
3854925bf6Swillf  */
3954925bf6Swillf 
4054925bf6Swillf #include <stdio.h>
4154925bf6Swillf #include <string.h>
4254925bf6Swillf #include <k5-int.h>
4354925bf6Swillf #include <osconf.h>
4454925bf6Swillf #include "kdb5.h"
4554925bf6Swillf #include <assert.h>
4654925bf6Swillf #include "k5-platform.h"
4754925bf6Swillf #include <libintl.h>
4854925bf6Swillf 
4954925bf6Swillf /* Currently DB2 policy related errors are exported from DAL.  But
5054925bf6Swillf    other databases should set_err function to return string.  */
5154925bf6Swillf #include "adb_err.h"
5254925bf6Swillf 
5354925bf6Swillf /*
5454925bf6Swillf  * Type definitions
5554925bf6Swillf  */
5654925bf6Swillf #define KRB5_TL_DB_ARGS                 0x7fff
5754925bf6Swillf 
5854925bf6Swillf /*
5954925bf6Swillf  * internal static variable
6054925bf6Swillf  */
6154925bf6Swillf 
6254925bf6Swillf static k5_mutex_t db_lock = K5_MUTEX_PARTIAL_INITIALIZER;
6354925bf6Swillf 
6454925bf6Swillf #ifdef _KDB5_STATIC_LINK
6554925bf6Swillf #undef _KDB5_DYNAMIC_LINK
6654925bf6Swillf #else
6754925bf6Swillf #undef _KDB5_DYNAMIC_LINK
6854925bf6Swillf /* to avoid redefinition problem */
6954925bf6Swillf #define _KDB5_DYNAMIC_LINK
7054925bf6Swillf #endif
7154925bf6Swillf 
7254925bf6Swillf static db_library lib_list;
7354925bf6Swillf 
7454925bf6Swillf /*
7554925bf6Swillf  * Helper Functions
7654925bf6Swillf  */
7754925bf6Swillf 
7854925bf6Swillf MAKE_INIT_FUNCTION(kdb_init_lock_list);
7954925bf6Swillf MAKE_FINI_FUNCTION(kdb_fini_lock_list);
8054925bf6Swillf 
8154925bf6Swillf int
kdb_init_lock_list(void)8254925bf6Swillf kdb_init_lock_list(void)
8354925bf6Swillf {
8454925bf6Swillf     return k5_mutex_finish_init(&db_lock);
8554925bf6Swillf }
8654925bf6Swillf 
8754925bf6Swillf static int
kdb_lock_list()8854925bf6Swillf kdb_lock_list()
8954925bf6Swillf {
9054925bf6Swillf     int err;
9154925bf6Swillf     err = CALL_INIT_FUNCTION (kdb_init_lock_list);
9254925bf6Swillf     if (err)
93