17c478bd9Sstevel@tonic-gate /* 27c478bd9Sstevel@tonic-gate * lib/kdb/kdb_db2.h 37c478bd9Sstevel@tonic-gate * 47c478bd9Sstevel@tonic-gate * Copyright 1997 by the Massachusetts Institute of Technology. 57c478bd9Sstevel@tonic-gate * All Rights Reserved. 67c478bd9Sstevel@tonic-gate * 77c478bd9Sstevel@tonic-gate * Export of this software from the United States of America may 87c478bd9Sstevel@tonic-gate * require a specific license from the United States Government. 97c478bd9Sstevel@tonic-gate * It is the responsibility of any person or organization contemplating 107c478bd9Sstevel@tonic-gate * export to obtain such a license before exporting. 11*1da57d55SToomas Soome * 127c478bd9Sstevel@tonic-gate * WITHIN THAT CONSTRAINT, permission to use, copy, modify, and 137c478bd9Sstevel@tonic-gate * distribute this software and its documentation for any purpose and 147c478bd9Sstevel@tonic-gate * without fee is hereby granted, provided that the above copyright 157c478bd9Sstevel@tonic-gate * notice appear in all copies and that both that copyright notice and 167c478bd9Sstevel@tonic-gate * this permission notice appear in supporting documentation, and that 177c478bd9Sstevel@tonic-gate * the name of M.I.T. not be used in advertising or publicity pertaining 187c478bd9Sstevel@tonic-gate * to distribution of the software without specific, written prior 197c478bd9Sstevel@tonic-gate * permission. Furthermore if you modify this software you must label 207c478bd9Sstevel@tonic-gate * your software as modified software and not distribute it in such a 217c478bd9Sstevel@tonic-gate * fashion that it might be confused with the original M.I.T. software. 227c478bd9Sstevel@tonic-gate * M.I.T. makes no representations about the suitability of 237c478bd9Sstevel@tonic-gate * this software for any purpose. It is provided "as is" without express 247c478bd9Sstevel@tonic-gate * or implied warranty. 25*1da57d55SToomas Soome * 267c478bd9Sstevel@tonic-gate * 277c478bd9Sstevel@tonic-gate * KDC Database backend definitions for Berkely DB. 287c478bd9Sstevel@tonic-gate */ 297c478bd9Sstevel@tonic-gate #ifndef KRB5_KDB_DB2_H 3054925bf6Swillf #define KRB5_KDB_DB2_H 317c478bd9Sstevel@tonic-gate 3254925bf6Swillf #include "policy_db.h" 337c478bd9Sstevel@tonic-gate 347c478bd9Sstevel@tonic-gate typedef struct _krb5_db2_context { 357c478bd9Sstevel@tonic-gate krb5_boolean db_inited; /* Context initialized */ 367c478bd9Sstevel@tonic-gate char * db_name; /* Name of database */ 377c478bd9Sstevel@tonic-gate DB * db; /* DB handle */ 387c478bd9Sstevel@tonic-gate krb5_boolean hashfirst; /* Try hash database type first */ 397c478bd9Sstevel@tonic-gate char * db_lf_name; /* Name of lock file */ 407c478bd9Sstevel@tonic-gate int db_lf_file; /* File descriptor of lock file */ 417c478bd9Sstevel@tonic-gate time_t db_lf_time; /* Time last updated */ 427c478bd9Sstevel@tonic-gate int db_locks_held; /* Number of times locked */ 437c478bd9Sstevel@tonic-gate int db_lock_mode; /* Last lock mode, e.g. greatest*/ 447c478bd9Sstevel@tonic-gate krb5_boolean db_nb_locks; /* [Non]Blocking lock modes */ 457c478bd9Sstevel@tonic-gate krb5_keyblock *db_master_key; /* Master key of database */ 4654925bf6Swillf osa_adb_policy_t policy_db; 4754925bf6Swillf krb5_boolean tempdb; 487c478bd9Sstevel@tonic-gate } krb5_db2_context; 497c478bd9Sstevel@tonic-gate 507c478bd9Sstevel@tonic-gate #define KRB5_DB2_MAX_RETRY 5 517c478bd9Sstevel@tonic-gate 527c478bd9Sstevel@tonic-gate #define KDB2_LOCK_EXT ".ok" 5354925bf6Swillf #define KDB2_TEMP_LOCK_EXT "~.ok" 547c478bd9Sstevel@tonic-gate 55*1da57d55SToomas Soome krb5_error_code krb5_db2_db_init 56505d05c7Sgtb (krb5_context); 57*1da57d55SToomas Soome krb5_error_code krb5_db2_db_fini 58505d05c7Sgtb (krb5_context); 59*1da57d55SToomas Soome krb5_error_code krb5_db2_db_get_age 60505d05c7Sgtb (krb5_context, 617c478bd9Sstevel@tonic-gate char *, 62505d05c7Sgtb time_t * ); 63*1da57d55SToomas Soome krb5_error_code krb5_db2_db_create 64505d05c7Sgtb (krb5_context, 657c478bd9Sstevel@tonic-gate char *, 66505d05c7Sgtb krb5_int32); 67*1da57d55SToomas Soome krb5_error_code krb5_db2_db_destroy 68505d05c7Sgtb (krb5_context, 69505d05c7Sgtb char * ); 70*1da57d55SToomas Soome krb5_error_code krb5_db2_db_rename 71505d05c7Sgtb (krb5_context, 727c478bd9Sstevel@tonic-gate char *, 73505d05c7Sgtb char * ); 74*1da57d55SToomas Soome krb5_error_code krb5_db2_db_get_principal 75505d05c7Sgtb (krb5_context, 767c478bd9Sstevel@tonic-gate krb5_const_principal, 777c478bd9Sstevel@tonic-gate krb5_db_entry *, 787c478bd9Sstevel@tonic-gate int *, 79505d05c7Sgtb krb5_boolean * ); 80*1da57d55SToomas Soome krb5_error_code krb5_db2_db_free_principal 81505d05c7Sgtb (krb5_context, 827c478bd9Sstevel@tonic-gate krb5_db_entry *, 83505d05c7Sgtb int ); 84*1da57d55SToomas Soome krb5_error_code krb5_db2_db_put_principal 85505d05c7Sgtb (krb5_context, 8654925bf6Swillf krb5_db_entry *, 8754925bf6Swillf int *, 8854925bf6Swillf char **db_args 8954925bf6Swillf ); 9056a424ccSmp krb5_error_code krb5_db2_db_iterate_ext 9156a424ccSmp (krb5_context, 9256a424ccSmp krb5_error_code (*) (krb5_pointer, 9356a424ccSmp krb5_db_entry *), 9456a424ccSmp krb5_pointer, int, int ); 952dd2efa5Swillf /* Solaris Kerberos: adding support for db_args */ 967c478bd9Sstevel@tonic-gate krb5_error_code krb5_db2_db_iterate 9754925bf6Swillf (krb5_context,char *, 98505d05c7Sgtb krb5_error_code (*) (krb5_pointer, 99505d05c7Sgtb krb5_db_entry *), 1002dd2efa5Swillf krb5_pointer, 1012dd2efa5Swillf char **db_args ); 102*1da57d55SToomas Soome krb5_error_code krb5_db2_db_set_nonblocking 103505d05c7Sgtb (krb5_context, 1047c478bd9Sstevel@tonic-gate krb5_boolean, 105505d05c7Sgtb krb5_boolean * ); 1067c478bd9Sstevel@tonic-gate krb5_boolean krb5_db2_db_set_lockmode 107505d05c7Sgtb (krb5_context, 108505d05c7Sgtb krb5_boolean ); 109*1da57d55SToomas Soome krb5_error_code krb5_db2_db_open_database 110505d05c7Sgtb (krb5_context); 111*1da57d55SToomas Soome krb5_error_code krb5_db2_db_close_database 112505d05c7Sgtb (krb5_context); 1137c478bd9Sstevel@tonic-gate 114*1da57d55SToomas Soome krb5_error_code 115*1da57d55SToomas Soome krb5_db2_set_master_key_ext ( krb5_context kcontext, 116*1da57d55SToomas Soome char *pwd, 11754925bf6Swillf krb5_keyblock *key); 11854925bf6Swillf 11954925bf6Swillf krb5_error_code 12054925bf6Swillf krb5_db2_db_set_mkey( krb5_context context, 12154925bf6Swillf krb5_keyblock *key); 12254925bf6Swillf 12354925bf6Swillf krb5_error_code 12454925bf6Swillf krb5_db2_db_get_mkey( krb5_context context, 12554925bf6Swillf krb5_keyblock **key); 12654925bf6Swillf 12754925bf6Swillf krb5_error_code 12854925bf6Swillf krb5_db2_db_put_principal( krb5_context context, 12954925bf6Swillf krb5_db_entry *entries, 13054925bf6Swillf register int *nentries, 13154925bf6Swillf char **db_args); 13254925bf6Swillf 13354925bf6Swillf krb5_error_code 13454925bf6Swillf krb5_db2_db_delete_principal(krb5_context context, 13554925bf6Swillf krb5_const_principal searchfor, 13654925bf6Swillf int *nentries); 13754925bf6Swillf 13854925bf6Swillf krb5_error_code krb5_db2_lib_init(void); 13954925bf6Swillf 14054925bf6Swillf krb5_error_code krb5_db2_lib_cleanup(void); 14154925bf6Swillf 142*1da57d55SToomas Soome krb5_error_code 14354925bf6Swillf krb5_db2_db_unlock(krb5_context); 14454925bf6Swillf 14554925bf6Swillf krb5_error_code 14654925bf6Swillf krb5_db2_promote_db(krb5_context kcontext, 14754925bf6Swillf char *conf_section, 14854925bf6Swillf char **db_args); 14954925bf6Swillf 150*1da57d55SToomas Soome krb5_error_code 151*1da57d55SToomas Soome krb5_db2_db_set_option ( krb5_context kcontext, 152*1da57d55SToomas Soome int option, 15354925bf6Swillf void *value ); 15454925bf6Swillf 15554925bf6Swillf krb5_error_code 15654925bf6Swillf krb5_db2_db_lock( krb5_context context, 15754925bf6Swillf int in_mode); 15854925bf6Swillf 15954925bf6Swillf 160*1da57d55SToomas Soome krb5_error_code 16154925bf6Swillf krb5_db2_open( krb5_context kcontext, 16254925bf6Swillf char *conf_section, 16354925bf6Swillf char **db_args, 16454925bf6Swillf int mode ); 16554925bf6Swillf 16654925bf6Swillf krb5_error_code krb5_db2_create( krb5_context kcontext, 16754925bf6Swillf char *conf_section, 16854925bf6Swillf char **db_args ); 16954925bf6Swillf 17054925bf6Swillf krb5_error_code krb5_db2_destroy( krb5_context kcontext, 17154925bf6Swillf char *conf_section, 17254925bf6Swillf char **db_args ); 17354925bf6Swillf 17454925bf6Swillf const char * krb5_db2_err2str( krb5_context kcontext, 17554925bf6Swillf long err_code ); 17654925bf6Swillf 177*1da57d55SToomas Soome void * 178*1da57d55SToomas Soome krb5_db2_alloc( krb5_context kcontext, 179*1da57d55SToomas Soome void *ptr, 18054925bf6Swillf size_t size ); 18154925bf6Swillf 182*1da57d55SToomas Soome void 183*1da57d55SToomas Soome krb5_db2_free( krb5_context kcontext, 18454925bf6Swillf void *ptr ); 18554925bf6Swillf 1867c64d375Smp const char * 1877c64d375Smp krb5_db2_errcode_2_string(krb5_context kcontext, 1887c64d375Smp long err_code); 18954925bf6Swillf 1907c64d375Smp void 1917c64d375Smp krb5_db2_release_errcode_string(krb5_context kcontext, 1927c64d375Smp const char *msg); 19354925bf6Swillf 19454925bf6Swillf 19554925bf6Swillf 19654925bf6Swillf /* policy management functions */ 19754925bf6Swillf krb5_error_code 19854925bf6Swillf krb5_db2_create_policy(krb5_context context, osa_policy_ent_t entry); 19954925bf6Swillf 20054925bf6Swillf krb5_error_code krb5_db2_get_policy ( krb5_context kcontext, 20154925bf6Swillf char *name, 20254925bf6Swillf osa_policy_ent_t *policy, 20354925bf6Swillf int *cnt); 20454925bf6Swillf 20554925bf6Swillf krb5_error_code krb5_db2_put_policy ( krb5_context kcontext, 20654925bf6Swillf osa_policy_ent_t policy ); 20754925bf6Swillf 20854925bf6Swillf krb5_error_code krb5_db2_iter_policy ( krb5_context kcontext, 20954925bf6Swillf char *match_entry, 21054925bf6Swillf osa_adb_iter_policy_func func, 21154925bf6Swillf void *data ); 21254925bf6Swillf 21354925bf6Swillf krb5_error_code krb5_db2_delete_policy ( krb5_context kcontext, 21454925bf6Swillf char *policy ); 21554925bf6Swillf 21654925bf6Swillf void krb5_db2_free_policy( krb5_context kcontext, 21754925bf6Swillf osa_policy_ent_t entry ); 21854925bf6Swillf 2197c478bd9Sstevel@tonic-gate #endif /* KRB5_KDB_DB2_H */ 220