1 #pragma ident "%Z%%M% %I% %E% SMI" 2 /* 3 * lib/kdb/kdb_db2.h 4 * 5 * Copyright 1997 by the Massachusetts Institute of Technology. 6 * All Rights Reserved. 7 * 8 * Export of this software from the United States of America may 9 * require a specific license from the United States Government. 10 * It is the responsibility of any person or organization contemplating 11 * export to obtain such a license before exporting. 12 * 13 * WITHIN THAT CONSTRAINT, permission to use, copy, modify, and 14 * distribute this software and its documentation for any purpose and 15 * without fee is hereby granted, provided that the above copyright 16 * notice appear in all copies and that both that copyright notice and 17 * this permission notice appear in supporting documentation, and that 18 * the name of M.I.T. not be used in advertising or publicity pertaining 19 * to distribution of the software without specific, written prior 20 * permission. Furthermore if you modify this software you must label 21 * your software as modified software and not distribute it in such a 22 * fashion that it might be confused with the original M.I.T. software. 23 * M.I.T. makes no representations about the suitability of 24 * this software for any purpose. It is provided "as is" without express 25 * or implied warranty. 26 * 27 * 28 * KDC Database backend definitions for Berkely DB. 29 */ 30 #ifndef KRB5_KDB_DB2_H 31 #define KRB5_KDB_DB2_H 32 33 #include "policy_db.h" 34 35 typedef struct _krb5_db2_context { 36 krb5_boolean db_inited; /* Context initialized */ 37 char * db_name; /* Name of database */ 38 DB * db; /* DB handle */ 39 krb5_boolean hashfirst; /* Try hash database type first */ 40 char * db_lf_name; /* Name of lock file */ 41 int db_lf_file; /* File descriptor of lock file */ 42 time_t db_lf_time; /* Time last updated */ 43 int db_locks_held; /* Number of times locked */ 44 int db_lock_mode; /* Last lock mode, e.g. greatest*/ 45 krb5_boolean db_nb_locks; /* [Non]Blocking lock modes */ 46 krb5_keyblock *db_master_key; /* Master key of database */ 47 osa_adb_policy_t policy_db; 48 krb5_boolean tempdb; 49 } krb5_db2_context; 50 51 #define KRB5_DB2_MAX_RETRY 5 52 53 #define KDB2_LOCK_EXT ".ok" 54 #define KDB2_TEMP_LOCK_EXT "~.ok" 55 56 krb5_error_code krb5_db2_db_init 57 (krb5_context); 58 krb5_error_code krb5_db2_db_fini 59 (krb5_context); 60 krb5_error_code krb5_db2_db_get_age 61 (krb5_context, 62 char *, 63 time_t * ); 64 krb5_error_code krb5_db2_db_create 65 (krb5_context, 66 char *, 67 krb5_int32); 68 krb5_error_code krb5_db2_db_destroy 69 (krb5_context, 70 char * ); 71 krb5_error_code krb5_db2_db_rename 72 (krb5_context, 73 char *, 74 char * ); 75 krb5_error_code krb5_db2_db_get_principal 76 (krb5_context, 77 krb5_const_principal, 78 krb5_db_entry *, 79 int *, 80 krb5_boolean * ); 81 krb5_error_code krb5_db2_db_free_principal 82 (krb5_context, 83 krb5_db_entry *, 84 int ); 85 krb5_error_code krb5_db2_db_put_principal 86 (krb5_context, 87 krb5_db_entry *, 88 int *, 89 char **db_args 90 ); 91 krb5_error_code krb5_db2_db_iterate_ext 92 (krb5_context, 93 krb5_error_code (*) (krb5_pointer, 94 krb5_db_entry *), 95 krb5_pointer, int, int ); 96 krb5_error_code krb5_db2_db_iterate 97 (krb5_context,char *, 98 krb5_error_code (*) (krb5_pointer, 99 krb5_db_entry *), 100 krb5_pointer ); 101 krb5_error_code krb5_db2_db_set_nonblocking 102 (krb5_context, 103 krb5_boolean, 104 krb5_boolean * ); 105 krb5_boolean krb5_db2_db_set_lockmode 106 (krb5_context, 107 krb5_boolean ); 108 krb5_error_code krb5_db2_db_open_database 109 (krb5_context); 110 krb5_error_code krb5_db2_db_close_database 111 (krb5_context); 112 113 krb5_error_code 114 krb5_db2_set_master_key_ext ( krb5_context kcontext, 115 char *pwd, 116 krb5_keyblock *key); 117 118 krb5_error_code 119 krb5_db2_db_set_mkey( krb5_context context, 120 krb5_keyblock *key); 121 122 krb5_error_code 123 krb5_db2_db_get_mkey( krb5_context context, 124 krb5_keyblock **key); 125 126 krb5_error_code 127 krb5_db2_db_put_principal( krb5_context context, 128 krb5_db_entry *entries, 129 register int *nentries, 130 char **db_args); 131 132 krb5_error_code 133 krb5_db2_db_delete_principal(krb5_context context, 134 krb5_const_principal searchfor, 135 int *nentries); 136 137 krb5_error_code krb5_db2_lib_init(void); 138 139 krb5_error_code krb5_db2_lib_cleanup(void); 140 141 krb5_error_code 142 krb5_db2_db_unlock(krb5_context); 143 144 krb5_error_code 145 krb5_db2_promote_db(krb5_context kcontext, 146 char *conf_section, 147 char **db_args); 148 149 krb5_error_code 150 krb5_db2_db_set_option ( krb5_context kcontext, 151 int option, 152 void *value ); 153 154 krb5_error_code 155 krb5_db2_db_lock( krb5_context context, 156 int in_mode); 157 158 159 krb5_error_code 160 krb5_db2_open( krb5_context kcontext, 161 char *conf_section, 162 char **db_args, 163 int mode ); 164 165 krb5_error_code krb5_db2_create( krb5_context kcontext, 166 char *conf_section, 167 char **db_args ); 168 169 krb5_error_code krb5_db2_destroy( krb5_context kcontext, 170 char *conf_section, 171 char **db_args ); 172 173 const char * krb5_db2_err2str( krb5_context kcontext, 174 long err_code ); 175 176 void * 177 krb5_db2_alloc( krb5_context kcontext, 178 void *ptr, 179 size_t size ); 180 181 void 182 krb5_db2_free( krb5_context kcontext, 183 void *ptr ); 184 185 186 187 188 189 /* policy management functions */ 190 krb5_error_code 191 krb5_db2_create_policy(krb5_context context, osa_policy_ent_t entry); 192 193 krb5_error_code krb5_db2_get_policy ( krb5_context kcontext, 194 char *name, 195 osa_policy_ent_t *policy, 196 int *cnt); 197 198 krb5_error_code krb5_db2_put_policy ( krb5_context kcontext, 199 osa_policy_ent_t policy ); 200 201 krb5_error_code krb5_db2_iter_policy ( krb5_context kcontext, 202 char *match_entry, 203 osa_adb_iter_policy_func func, 204 void *data ); 205 206 krb5_error_code krb5_db2_delete_policy ( krb5_context kcontext, 207 char *policy ); 208 209 void krb5_db2_free_policy( krb5_context kcontext, 210 osa_policy_ent_t entry ); 211 212 #endif /* KRB5_KDB_DB2_H */ 213