-: 0:Source:db2_exp.c -: 0:Graph:/var/tsitkova/Sources/v10/trunk/src/plugins/kdb/db2/db2_exp.so.gcno -: 0:Data:/var/tsitkova/Sources/v10/trunk/src/plugins/kdb/db2/db2_exp.so.gcda -: 0:Runs:876 -: 0:Programs:1 -: 1:/* -*- mode: c; c-basic-offset: 4; indent-tabs-mode: nil -*- */ -: 2:/* -: 3: * Copyright 2006 by the Massachusetts Institute of Technology. -: 4: * All Rights Reserved. -: 5: * -: 6: * Export of this software from the United States of America may -: 7: * require a specific license from the United States Government. -: 8: * It is the responsibility of any person or organization contemplating -: 9: * export to obtain such a license before exporting. -: 10: * -: 11: * WITHIN THAT CONSTRAINT, permission to use, copy, modify, and -: 12: * distribute this software and its documentation for any purpose and -: 13: * without fee is hereby granted, provided that the above copyright -: 14: * notice appear in all copies and that both that copyright notice and -: 15: * this permission notice appear in supporting documentation, and that -: 16: * the name of M.I.T. not be used in advertising or publicity pertaining -: 17: * to distribution of the software without specific, written prior -: 18: * permission. Furthermore if you modify this software you must label -: 19: * your software as modified software and not distribute it in such a -: 20: * fashion that it might be confused with the original M.I.T. software. -: 21: * M.I.T. makes no representations about the suitability of -: 22: * this software for any purpose. It is provided "as is" without express -: 23: * or implied warranty. -: 24: */ -: 25: -: 26:/********************************************************************** -: 27: * -: 28: * C %name: db2_exp.c % -: 29: * Instance: idc_sec_2 -: 30: * Description: -: 31: * %created_by: spradeep % -: 32: * %date_created: Tue Apr 5 11:44:00 2005 % -: 33: * -: 34: **********************************************************************/ -: 35:#include "k5-int.h" -: 36: -: 37:#if HAVE_UNISTD_H -: 38:#include -: 39:#endif -: 40: -: 41:#include -: 42:#include -: 43:#include -: 44:#include -: 45:#include "kdb5.h" -: 46:#include "kdb_db2.h" -: 47:#include "kdb_xdr.h" -: 48:#include "policy_db.h" -: 49: -: 50:/* Quick and dirty wrapper functions to provide for thread safety -: 51: within the plugin, instead of making the kdb5 library do it. Eventually -: 52: these should be integrated into the real functions. -: 53: -: 54: Some of the functions wrapped here are also called directly from -: 55: within this library (e.g., create calls open), so simply dropping -: 56: locking code into the top and bottom of each referenced function -: 57: won't do. (We aren't doing recursive locks, currently.) */ -: 58: -: 59:k5_mutex_t *krb5_db2_mutex; -: 60: -: 61:#define WRAP(NAME,TYPE,ARGLIST,ARGNAMES,ERROR_RESULT) \ -: 62: static TYPE wrap_##NAME ARGLIST \ -: 63: { \ -: 64: TYPE result; \ -: 65: int code = k5_mutex_lock (krb5_db2_mutex); \ -: 66: if (code) { return ERROR_RESULT; } \ -: 67: result = NAME ARGNAMES; \ -: 68: k5_mutex_unlock (krb5_db2_mutex); \ -: 69: return result; \ -: 70: } \ -: 71: /* hack: decl to allow a following ";" */ \ -: 72: static TYPE wrap_##NAME () -: 73: -: 74:/* Two special cases: void (can't assign result), and krb5_error_code -: 75: (return error from locking code). */ -: 76: -: 77:#define WRAP_VOID(NAME,ARGLIST,ARGNAMES) \ -: 78: static void wrap_##NAME ARGLIST \ -: 79: { \ -: 80: int code = k5_mutex_lock (krb5_db2_mutex); \ -: 81: if (code) { return; } \ -: 82: NAME ARGNAMES; \ -: 83: k5_mutex_unlock (krb5_db2_mutex); \ -: 84: } \ -: 85: /* hack: decl to allow a following ";" */ \ -: 86: static void wrap_##NAME () -: 87: -: 88:#define WRAP_K(NAME,ARGLIST,ARGNAMES) \ -: 89: WRAP(NAME,krb5_error_code,ARGLIST,ARGNAMES,code) -: 90: 768: 91:WRAP_K (krb5_db2_open, -: 92: ( krb5_context kcontext, -: 93: char *conf_section, -: 94: char **db_args, -: 95: int mode ), 768: 96: (kcontext, conf_section, db_args, mode)); 846: 97:WRAP_K (krb5_db2_fini, (krb5_context ctx), (ctx)); 105: 98:WRAP_K (krb5_db2_create, -: 99: ( krb5_context kcontext, char *conf_section, char **db_args ), 105: 100: (kcontext, conf_section, db_args)); 3: 101:WRAP_K (krb5_db2_destroy, -: 102: ( krb5_context kcontext, char *conf_section, char **db_args ), 3: 103: (kcontext, conf_section, db_args)); #####: 104:WRAP_K (krb5_db2_get_age, -: 105: (krb5_context ctx, -: 106: char *s, -: 107: time_t *t), #####: 108: (ctx, s, t)); -: 109: 1: 110:WRAP_K (krb5_db2_lock, -: 111: ( krb5_context context, -: 112: int in_mode), 1: 113: (context, in_mode)); 1: 114:WRAP_K (krb5_db2_unlock, (krb5_context ctx), (ctx)); -: 115: 5759: 116:WRAP_K (krb5_db2_get_principal, -: 117: (krb5_context ctx, -: 118: krb5_const_principal p, -: 119: unsigned int f, -: 120: krb5_db_entry **d), 5759: 121: (ctx, p, f, d)); 6931: 122:WRAP_VOID (krb5_db2_free_principal, -: 123: (krb5_context ctx, -: 124: krb5_db_entry *d), 6931: 125: (ctx, d)); 2183: 126:WRAP_K (krb5_db2_put_principal, -: 127: (krb5_context ctx, -: 128: krb5_db_entry *d, -: 129: char **db_args), 2183: 130: (ctx, d, db_args)); 6: 131:WRAP_K (krb5_db2_delete_principal, -: 132: (krb5_context context, -: 133: krb5_const_principal searchfor), 6: 134: (context, searchfor)); -: 135: 10: 136:WRAP_K (krb5_db2_iterate, -: 137: (krb5_context ctx, char *s, -: 138: krb5_error_code (*f) (krb5_pointer, -: 139: krb5_db_entry *), -: 140: krb5_pointer p), 10: 141: (ctx, s, f, p)); -: 142: 13: 143:WRAP_K (krb5_db2_create_policy, -: 144: (krb5_context context, osa_policy_ent_t entry), 13: 145: (context, entry)); 330: 146:WRAP_K (krb5_db2_get_policy, -: 147: ( krb5_context kcontext, -: 148: char *name, -: 149: osa_policy_ent_t *policy), 330: 150: (kcontext, name, policy)); 1: 151:WRAP_K (krb5_db2_put_policy, -: 152: ( krb5_context kcontext, osa_policy_ent_t policy ), 1: 153: (kcontext, policy)); 16: 154:WRAP_K (krb5_db2_iter_policy, -: 155: ( krb5_context kcontext, -: 156: char *match_entry, -: 157: osa_adb_iter_policy_func func, -: 158: void *data ), 16: 159: (kcontext, match_entry, func, data)); #####: 160:WRAP_K (krb5_db2_delete_policy, -: 161: ( krb5_context kcontext, char *policy ), #####: 162: (kcontext, policy)); 2: 163:WRAP_VOID (krb5_db2_free_policy, -: 164: ( krb5_context kcontext, osa_policy_ent_t entry ), 2: 165: (kcontext, entry)); -: 166: 7: 167:WRAP_K (krb5_db2_promote_db, -: 168: ( krb5_context kcontext, char *conf_section, char **db_args ), 7: 169: (kcontext, conf_section, db_args)); -: 170: 210: 171:WRAP_K (krb5_db2_check_policy_as, -: 172: (krb5_context kcontext, krb5_kdc_req *request, krb5_db_entry *client, -: 173: krb5_db_entry *server, krb5_timestamp kdc_time, const char **status, -: 174: krb5_data *e_data), 210: 175: (kcontext, request, client, server, kdc_time, status, e_data)); -: 176: 210: 177:WRAP_VOID (krb5_db2_audit_as_req, -: 178: (krb5_context kcontext, krb5_kdc_req *request, -: 179: krb5_db_entry *client, krb5_db_entry *server, -: 180: krb5_timestamp authtime, krb5_error_code error_code), 210: 181: (kcontext, request, client, server, authtime, error_code)); -: 182: -: 183:static krb5_error_code 876: 184:hack_init (void) -: 185:{ -: 186: krb5_error_code c; -: 187: 876: 188: c = krb5int_mutex_alloc (&krb5_db2_mutex); 876: 189: if (c) #####: 190: return c; 876: 191: return krb5_db2_lib_init (); -: 192:} -: 193: -: 194:static krb5_error_code 846: 195:hack_cleanup (void) -: 196:{ 846: 197: krb5int_mutex_free (krb5_db2_mutex); 846: 198: krb5_db2_mutex = NULL; 846: 199: return krb5_db2_lib_cleanup(); -: 200:} -: 201: -: 202: -: 203:/* -: 204: * Exposed API -: 205: */ -: 206: -: 207:kdb_vftabl PLUGIN_SYMBOL_NAME(krb5_db2, kdb_function_table) = { -: 208: KRB5_KDB_DAL_MAJOR_VERSION, /* major version number */ -: 209: 0, /* minor version number 0 */ -: 210: /* init_library */ hack_init, -: 211: /* fini_library */ hack_cleanup, -: 212: /* init_module */ wrap_krb5_db2_open, -: 213: /* fini_module */ wrap_krb5_db2_fini, -: 214: /* create */ wrap_krb5_db2_create, -: 215: /* destroy */ wrap_krb5_db2_destroy, -: 216: /* get_age */ wrap_krb5_db2_get_age, -: 217: /* lock */ wrap_krb5_db2_lock, -: 218: /* unlock */ wrap_krb5_db2_unlock, -: 219: /* get_principal */ wrap_krb5_db2_get_principal, -: 220: /* free_principal */ wrap_krb5_db2_free_principal, -: 221: /* put_principal */ wrap_krb5_db2_put_principal, -: 222: /* delete_principal */ wrap_krb5_db2_delete_principal, -: 223: /* iterate */ wrap_krb5_db2_iterate, -: 224: /* create_policy */ wrap_krb5_db2_create_policy, -: 225: /* get_policy */ wrap_krb5_db2_get_policy, -: 226: /* put_policy */ wrap_krb5_db2_put_policy, -: 227: /* iter_policy */ wrap_krb5_db2_iter_policy, -: 228: /* delete_policy */ wrap_krb5_db2_delete_policy, -: 229: /* free_policy */ wrap_krb5_db2_free_policy, -: 230: /* alloc */ krb5_db2_alloc, -: 231: /* free */ krb5_db2_free, -: 232: /* blah blah blah */ 0,0,0,0,0, -: 233: /* promote_db */ wrap_krb5_db2_promote_db, -: 234: 0, 0, 0, 0, -: 235: /* check_policy_as */ wrap_krb5_db2_check_policy_as, -: 236: 0, -: 237: /* audit_as_req */ wrap_krb5_db2_audit_as_req, -: 238: 0, 0 -: 239:};