154925bf6Swillf #ifndef _KRB5_KDB5_H_ 254925bf6Swillf #define _KRB5_KDB5_H_ 354925bf6Swillf 454925bf6Swillf #pragma ident "%Z%%M% %I% %E% SMI" 554925bf6Swillf 654925bf6Swillf #if HAVE_UNISTD_H 754925bf6Swillf #include <unistd.h> 854925bf6Swillf #endif 954925bf6Swillf 1054925bf6Swillf #include <errno.h> 1154925bf6Swillf #include <utime.h> 1254925bf6Swillf #include <utime.h> 1354925bf6Swillf #include <k5-int.h> 1454925bf6Swillf #include "kdb.h" 1554925bf6Swillf 1654925bf6Swillf #define KDB_MAX_DB_NAME 128 1754925bf6Swillf #define KDB_REALM_SECTION "realms" 1854925bf6Swillf #define KDB_MODULE_POINTER "database_module" 1954925bf6Swillf #define KDB_MODULE_DEF_SECTION "dbdefaults" 2054925bf6Swillf #define KDB_MODULE_SECTION "dbmodules" 2154925bf6Swillf #define KDB_LIB_POINTER "db_library" 2254925bf6Swillf #define KDB_DATABASE_CONF_FILE DEFAULT_SECURE_PROFILE_PATH 2354925bf6Swillf #define KDB_DATABASE_ENV_PROF KDC_PROFILE_ENV 2454925bf6Swillf 2554925bf6Swillf #define KRB5_DB_GET_DB_CONTEXT(kcontext) (((kdb5_dal_handle*) (kcontext)->db_context)->db_context) 2654925bf6Swillf #define KRB5_DB_GET_PROFILE(kcontext) ((kcontext)->profile) 2754925bf6Swillf #define KRB5_DB_GET_REALM(kcontext) ((kcontext)->default_realm) 2854925bf6Swillf 2954925bf6Swillf typedef struct _kdb_vftabl{ 3054925bf6Swillf short int maj_ver; 3154925bf6Swillf short int min_ver; 3254925bf6Swillf int iprop_supported; 3354925bf6Swillf 3454925bf6Swillf krb5_error_code (*init_library)(); 3554925bf6Swillf krb5_error_code (*fini_library)(); 3654925bf6Swillf krb5_error_code (*init_module) (krb5_context kcontext, 3754925bf6Swillf char * conf_section, 3854925bf6Swillf char ** db_args, 3954925bf6Swillf int mode); 4054925bf6Swillf 4154925bf6Swillf krb5_error_code (*fini_module) (krb5_context kcontext); 4254925bf6Swillf 4354925bf6Swillf krb5_error_code (*db_create) (krb5_context kcontext, 4454925bf6Swillf char * conf_section, 4554925bf6Swillf char ** db_args); 4654925bf6Swillf 4754925bf6Swillf krb5_error_code (*db_destroy) (krb5_context kcontext, 4854925bf6Swillf char *conf_section, 4954925bf6Swillf char ** db_args); 5054925bf6Swillf 5154925bf6Swillf krb5_error_code (*db_get_age) (krb5_context kcontext, 5254925bf6Swillf char *db_name, 5354925bf6Swillf time_t *age); 5454925bf6Swillf 5554925bf6Swillf krb5_error_code (*db_set_option) (krb5_context kcontext, 5654925bf6Swillf int option, 5754925bf6Swillf void *value); 5854925bf6Swillf 5954925bf6Swillf krb5_error_code (*db_lock) (krb5_context kcontext, 6054925bf6Swillf int mode); 6154925bf6Swillf 6254925bf6Swillf krb5_error_code (*db_unlock) (krb5_context kcontext); 6354925bf6Swillf 6454925bf6Swillf krb5_error_code (*db_get_principal) (krb5_context kcontext, 6554925bf6Swillf krb5_const_principal search_for, 6654925bf6Swillf krb5_db_entry *entries, 6754925bf6Swillf int *nentries, 6854925bf6Swillf krb5_boolean *more); 6954925bf6Swillf 7054925bf6Swillf krb5_error_code (*db_get_principal_nolock) (krb5_context kcontext, 7154925bf6Swillf krb5_const_principal search_for, 7254925bf6Swillf krb5_db_entry *entries, 7354925bf6Swillf int *nentries, 7454925bf6Swillf krb5_boolean *more); 7554925bf6Swillf 7654925bf6Swillf krb5_error_code (*db_free_principal) (krb5_context kcontext, 7754925bf6Swillf krb5_db_entry *entry, 7854925bf6Swillf int count); 7954925bf6Swillf 8054925bf6Swillf krb5_error_code (*db_put_principal) (krb5_context kcontext, 8154925bf6Swillf krb5_db_entry *entries, 8254925bf6Swillf int *nentries, 8354925bf6Swillf char **db_args); 8454925bf6Swillf 8554925bf6Swillf krb5_error_code (*db_delete_principal) (krb5_context kcontext, 8654925bf6Swillf krb5_const_principal search_for, 8754925bf6Swillf int *nentries); 8854925bf6Swillf 89*2dd2efa5Swillf /* Solaris Kerberos: adding support for db_args */ 9054925bf6Swillf krb5_error_code (*db_iterate) (krb5_context kcontext, 9154925bf6Swillf char *match_entry, 9254925bf6Swillf int (*func) (krb5_pointer, krb5_db_entry *), 93*2dd2efa5Swillf krb5_pointer func_arg, 94*2dd2efa5Swillf char **db_args); 9554925bf6Swillf 9654925bf6Swillf krb5_error_code (*db_create_policy) (krb5_context kcontext, 9754925bf6Swillf osa_policy_ent_t policy); 9854925bf6Swillf 9954925bf6Swillf krb5_error_code (*db_get_policy) (krb5_context kcontext, 10054925bf6Swillf char *name, 10154925bf6Swillf osa_policy_ent_t *policy, 10254925bf6Swillf int *cnt); 10354925bf6Swillf 10454925bf6Swillf krb5_error_code (*db_put_policy) (krb5_context kcontext, 10554925bf6Swillf osa_policy_ent_t policy); 10654925bf6Swillf 10754925bf6Swillf krb5_error_code (*db_iter_policy) (krb5_context kcontext, 10854925bf6Swillf char *match_entry, 10954925bf6Swillf osa_adb_iter_policy_func func, 11054925bf6Swillf void *data); 11154925bf6Swillf 11254925bf6Swillf 11354925bf6Swillf krb5_error_code (*db_delete_policy) (krb5_context kcontext, 11454925bf6Swillf char *policy); 11554925bf6Swillf 11654925bf6Swillf void (*db_free_policy) (krb5_context kcontext, 11754925bf6Swillf osa_policy_ent_t val); 11854925bf6Swillf 11954925bf6Swillf krb5_error_code (*db_supported_realms) (krb5_context kcontext, 12054925bf6Swillf char **realms); 12154925bf6Swillf 12254925bf6Swillf krb5_error_code (*db_free_supported_realms) (krb5_context kcontext, 12354925bf6Swillf char **realms); 12454925bf6Swillf 12554925bf6Swillf 12654925bf6Swillf const char * (*errcode_2_string) (krb5_context kcontext, 12754925bf6Swillf long err_code); 12854925bf6Swillf void (*release_errcode_string) (krb5_context kcontext, const char *msg); 12954925bf6Swillf 13054925bf6Swillf void * (*db_alloc) (krb5_context kcontext, void *ptr, size_t size); 13154925bf6Swillf void (*db_free) (krb5_context kcontext, void *ptr); 13254925bf6Swillf 13354925bf6Swillf 13454925bf6Swillf 13554925bf6Swillf /* optional functions */ 13654925bf6Swillf krb5_error_code (*set_master_key) (krb5_context kcontext, 13754925bf6Swillf char *pwd, 13854925bf6Swillf krb5_keyblock *key); 13954925bf6Swillf 14054925bf6Swillf krb5_error_code (*get_master_key) (krb5_context kcontext, 14154925bf6Swillf krb5_keyblock **key); 14254925bf6Swillf 14354925bf6Swillf 14454925bf6Swillf krb5_error_code (*setup_master_key_name) (krb5_context kcontext, 14554925bf6Swillf char *keyname, 14654925bf6Swillf char *realm, 14754925bf6Swillf char **fullname, 14854925bf6Swillf krb5_principal *principal); 14954925bf6Swillf 15054925bf6Swillf krb5_error_code (*store_master_key) (krb5_context kcontext, 15154925bf6Swillf char *db_arg, 15254925bf6Swillf krb5_principal mname, 15354925bf6Swillf krb5_keyblock *key, 15454925bf6Swillf char *master_pwd); 15554925bf6Swillf 15654925bf6Swillf krb5_error_code (*fetch_master_key) (krb5_context kcontext, 15754925bf6Swillf krb5_principal mname, 15854925bf6Swillf krb5_keyblock *key, 15954925bf6Swillf int *kvno, 16054925bf6Swillf char *db_args); 16154925bf6Swillf 16254925bf6Swillf krb5_error_code (*verify_master_key) (krb5_context kcontext, 16354925bf6Swillf krb5_principal mprinc, 16454925bf6Swillf krb5_keyblock *mkey); 16554925bf6Swillf 16654925bf6Swillf krb5_error_code (*dbe_search_enctype) (krb5_context kcontext, 16754925bf6Swillf krb5_db_entry *dbentp, 16854925bf6Swillf krb5_int32 *start, 16954925bf6Swillf krb5_int32 ktype, 17054925bf6Swillf krb5_int32 stype, 17154925bf6Swillf krb5_int32 kvno, 17254925bf6Swillf krb5_key_data **kdatap); 17354925bf6Swillf 17454925bf6Swillf 17554925bf6Swillf krb5_error_code 17654925bf6Swillf (*db_change_pwd) (krb5_context context, 17754925bf6Swillf krb5_keyblock * master_key, 17854925bf6Swillf krb5_key_salt_tuple * ks_tuple, 17954925bf6Swillf int ks_tuple_count, 18054925bf6Swillf char * passwd, 18154925bf6Swillf int new_kvno, 18254925bf6Swillf krb5_boolean keepold, 18354925bf6Swillf krb5_db_entry * db_entry); 18454925bf6Swillf 18554925bf6Swillf /* Promote a temporary database to be the live one. */ 18654925bf6Swillf krb5_error_code (*promote_db) (krb5_context context, 18754925bf6Swillf char *conf_section, 18854925bf6Swillf char **db_args); 18954925bf6Swillf 19054925bf6Swillf } kdb_vftabl; 19154925bf6Swillf 19254925bf6Swillf typedef struct _db_library { 19354925bf6Swillf char name[KDB_MAX_DB_NAME]; 19454925bf6Swillf int reference_cnt; 19554925bf6Swillf struct plugin_dir_handle dl_dir_handle; 19654925bf6Swillf kdb_vftabl vftabl; 19754925bf6Swillf struct _db_library *next, *prev; 19854925bf6Swillf } *db_library; 19954925bf6Swillf 20054925bf6Swillf typedef struct _kdb5_dal_handle 20154925bf6Swillf { 20254925bf6Swillf /* Helps us to change db_library without affecting modules to some 20354925bf6Swillf extent. */ 20454925bf6Swillf void *db_context; 20554925bf6Swillf db_library lib_handle; 20654925bf6Swillf } kdb5_dal_handle; 20754925bf6Swillf 20854925bf6Swillf #endif /* end of _KRB5_KDB5_H_ */ 209