4 * Copyright 1997 by the Massachusetts Institute of Technology.
7 * Export of this software from the United States of America may
8 * require a specific license from the United States Government.
9 * It is the responsibility of any person or organization contemplating
10 * export to obtain such a license before exporting.
12 * WITHIN THAT CONSTRAINT, permission to use, copy, modify, and
13 * distribute this software and its documentation for any purpose and
14 * without fee is hereby granted, provided that the above copyright
15 * notice appear in all copies and that both that copyright notice and
16 * this permission notice appear in supporting documentation, and that
17 * the name of M.I.T. not be used in advertising or publicity pertaining
18 * to distribution of the software without specific, written prior
19 * permission. Furthermore if you modify this software you must label
20 * your software as modified software and not distribute it in such a
21 * fashion that it might be confused with the original M.I.T. software.
22 * M.I.T. makes no representations about the suitability of
23 * this software for any purpose. It is provided "as is" without express
24 * or implied warranty.
27 * KDC Database backend definitions for Berkely DB.
29 #ifndef KRB5_KDB_DB2_H
30 #define KRB5_KDB_DB2_H
32 #include "policy_db.h"
34 typedef struct _krb5_db2_context {
35 krb5_boolean db_inited; /* Context initialized */
36 char * db_name; /* Name of database */
37 DB * db; /* DB handle */
38 krb5_boolean hashfirst; /* Try hash database type first */
39 char * db_lf_name; /* Name of lock file */
40 int db_lf_file; /* File descriptor of lock file */
41 time_t db_lf_time; /* Time last updated */
42 int db_locks_held; /* Number of times locked */
43 int db_lock_mode; /* Last lock mode, e.g. greatest*/
44 krb5_boolean db_nb_locks; /* [Non]Blocking lock modes */
45 krb5_keyblock *db_master_key; /* Master key of database */
46 krb5_keylist_node *db_master_key_list; /* Master key list of database */
47 osa_adb_policy_t policy_db;
51 #define KRB5_DB2_MAX_RETRY 5
53 #define KDB2_LOCK_EXT ".ok"
54 #define KDB2_TEMP_LOCK_EXT "~.ok"
56 krb5_error_code krb5_db2_db_init
58 krb5_error_code krb5_db2_db_fini
60 krb5_error_code krb5_db2_db_get_age
64 krb5_error_code krb5_db2_db_create
68 krb5_error_code krb5_db2_db_destroy
71 krb5_error_code krb5_db2_db_rename
76 krb5_error_code krb5_db2_db_get_principal
82 krb5_error_code krb5_db2_db_free_principal
86 krb5_error_code krb5_db2_db_put_principal
92 krb5_error_code krb5_db2_db_iterate_ext
94 krb5_error_code (*) (krb5_pointer,
96 krb5_pointer, int, int );
97 krb5_error_code krb5_db2_db_iterate
99 krb5_error_code (*) (krb5_pointer,
102 krb5_error_code krb5_db2_db_set_nonblocking
106 krb5_boolean krb5_db2_db_set_lockmode
109 krb5_error_code krb5_db2_db_open_database
111 krb5_error_code krb5_db2_db_close_database
115 krb5_db2_set_master_key_ext ( krb5_context kcontext,
120 krb5_db2_db_set_mkey( krb5_context context,
124 krb5_db2_db_get_mkey( krb5_context context,
125 krb5_keyblock **key);
127 krb5_db2_db_set_mkey_list( krb5_context context,
128 krb5_keylist_node *keylist);
131 krb5_db2_db_get_mkey_list( krb5_context context,
132 krb5_keylist_node **keylist);
135 krb5_db2_db_put_principal( krb5_context context,
136 krb5_db_entry *entries,
137 register int *nentries,
141 krb5_db2_db_delete_principal(krb5_context context,
142 krb5_const_principal searchfor,
145 krb5_error_code krb5_db2_lib_init(void);
147 krb5_error_code krb5_db2_lib_cleanup(void);
150 krb5_db2_db_unlock(krb5_context);
153 krb5_db2_promote_db(krb5_context kcontext,
158 krb5_db2_db_set_option ( krb5_context kcontext,
163 krb5_db2_db_lock( krb5_context context,
168 krb5_db2_open( krb5_context kcontext,
173 krb5_error_code krb5_db2_create( krb5_context kcontext,
177 krb5_error_code krb5_db2_destroy( krb5_context kcontext,
181 const char * krb5_db2_err2str( krb5_context kcontext,
185 krb5_db2_alloc( krb5_context kcontext,
190 krb5_db2_free( krb5_context kcontext,
197 /* policy management functions */
199 krb5_db2_create_policy(krb5_context context, osa_policy_ent_t entry);
201 krb5_error_code krb5_db2_get_policy ( krb5_context kcontext,
203 osa_policy_ent_t *policy,
206 krb5_error_code krb5_db2_put_policy ( krb5_context kcontext,
207 osa_policy_ent_t policy );
209 krb5_error_code krb5_db2_iter_policy ( krb5_context kcontext,
211 osa_adb_iter_policy_func func,
214 krb5_error_code krb5_db2_delete_policy ( krb5_context kcontext,
217 void krb5_db2_free_policy( krb5_context kcontext,
218 osa_policy_ent_t entry );
220 /* Thread-safety wrapper slapped on top of original implementation. */
221 extern k5_mutex_t *krb5_db2_mutex;
225 krb5_db2_lockout_check_policy(krb5_context context,
226 krb5_db_entry *entry,
227 krb5_timestamp stamp);
230 krb5_db2_lockout_audit(krb5_context context,
231 krb5_db_entry *entry,
232 krb5_timestamp stamp,
233 krb5_error_code status);
237 krb5_db2_invoke(krb5_context context,
239 const krb5_data *req,
242 #endif /* KRB5_KDB_DB2_H */