2N/A/* -*- mode: c; c-basic-offset: 4; indent-tabs-mode: nil -*- */
2N/A/*
2N/A * lib/kdb/kdb_db2.h
2N/A *
2N/A * Copyright 1997 by the Massachusetts Institute of Technology.
2N/A * All Rights Reserved.
2N/A *
2N/A * Export of this software from the United States of America may
2N/A * require a specific license from the United States Government.
2N/A * It is the responsibility of any person or organization contemplating
2N/A * export to obtain such a license before exporting.
2N/A *
2N/A * WITHIN THAT CONSTRAINT, permission to use, copy, modify, and
2N/A * distribute this software and its documentation for any purpose and
2N/A * without fee is hereby granted, provided that the above copyright
2N/A * notice appear in all copies and that both that copyright notice and
2N/A * this permission notice appear in supporting documentation, and that
2N/A * the name of M.I.T. not be used in advertising or publicity pertaining
2N/A * to distribution of the software without specific, written prior
2N/A * permission. Furthermore if you modify this software you must label
2N/A * your software as modified software and not distribute it in such a
2N/A * fashion that it might be confused with the original M.I.T. software.
2N/A * M.I.T. makes no representations about the suitability of
2N/A * this software for any purpose. It is provided "as is" without express
2N/A * or implied warranty.
2N/A *
2N/A *
2N/A * KDC Database backend definitions for Berkely DB.
2N/A */
2N/A#ifndef KRB5_KDB_DB2_H
2N/A#define KRB5_KDB_DB2_H
2N/A
2N/A#include "policy_db.h"
2N/A
2N/Atypedef struct _krb5_db2_context {
2N/A krb5_boolean db_inited; /* Context initialized */
2N/A char * db_name; /* Name of database */
2N/A DB * db; /* DB handle */
2N/A krb5_boolean hashfirst; /* Try hash database type first */
2N/A char * db_lf_name; /* Name of lock file */
2N/A int db_lf_file; /* File descriptor of lock file */
2N/A time_t db_lf_time; /* Time last updated */
2N/A int db_locks_held; /* Number of times locked */
2N/A int db_lock_mode; /* Last lock mode, e.g. greatest*/
2N/A krb5_boolean db_nb_locks; /* [Non]Blocking lock modes */
2N/A krb5_keyblock *db_master_key; /* Master key of database */
2N/A osa_adb_policy_t policy_db;
2N/A krb5_boolean tempdb;
2N/A} krb5_db2_context;
2N/A
2N/A#define KRB5_DB2_MAX_RETRY 5
2N/A
2N/A#define KDB2_LOCK_EXT ".ok"
2N/A#define KDB2_TEMP_LOCK_EXT "~.ok"
2N/A
2N/Akrb5_error_code krb5_db2_db_init(krb5_context);
2N/Akrb5_error_code krb5_db2_db_fini(krb5_context);
2N/Akrb5_error_code krb5_db2_db_get_age(krb5_context, char *, time_t *);
2N/Akrb5_error_code krb5_db2_db_create(krb5_context, char *, krb5_int32);
2N/Akrb5_error_code krb5_db2_db_destroy(krb5_context, char *);
2N/Akrb5_error_code krb5_db2_db_rename(krb5_context, char *, char *, int );
2N/Akrb5_error_code krb5_db2_db_get_principal(krb5_context, krb5_const_principal,
2N/A krb5_db_entry *, int *,
2N/A krb5_boolean *);
2N/Akrb5_error_code krb5_db2_db_free_principal(krb5_context, krb5_db_entry *, int);
2N/Akrb5_error_code krb5_db2_db_put_principal(krb5_context, krb5_db_entry *,
2N/A int *, char **db_args);
2N/Akrb5_error_code krb5_db2_db_iterate_ext(krb5_context,
2N/A krb5_error_code (*)(krb5_pointer,
2N/A krb5_db_entry *),
2N/A krb5_pointer, int, int);
2N/Akrb5_error_code krb5_db2_db_iterate(krb5_context, char *,
2N/A krb5_error_code (*)(krb5_pointer,
2N/A krb5_db_entry *),
2N/A krb5_pointer,
2N/A char **db_args); /* Solaris Kerberos */
2N/Akrb5_error_code krb5_db2_db_set_nonblocking(krb5_context, krb5_boolean,
2N/A krb5_boolean *);
2N/Akrb5_boolean krb5_db2_db_set_lockmode(krb5_context, krb5_boolean);
2N/Akrb5_error_code krb5_db2_db_open_database(krb5_context);
2N/Akrb5_error_code krb5_db2_db_close_database(krb5_context);
2N/A
2N/Akrb5_error_code
2N/Akrb5_db2_set_master_key_ext(krb5_context kcontext, char *pwd,
2N/A krb5_keyblock *key);
2N/A
2N/Akrb5_error_code
2N/Akrb5_db2_db_set_mkey(krb5_context context, krb5_keyblock *key);
2N/A
2N/Akrb5_error_code
2N/Akrb5_db2_db_get_mkey(krb5_context context, krb5_keyblock **key);
2N/A
2N/Akrb5_error_code
2N/Akrb5_db2_db_set_mkey_list(krb5_context context, krb5_keylist_node *keylist);
2N/A
2N/Akrb5_error_code
2N/Akrb5_db2_db_get_mkey_list(krb5_context context, krb5_keylist_node **keylist);
2N/A
2N/Akrb5_error_code
2N/Akrb5_db2_db_put_principal(krb5_context context, krb5_db_entry *entries,
2N/A register int *nentries, char **db_args);
2N/A
2N/Akrb5_error_code
2N/Akrb5_db2_db_delete_principal(krb5_context context,
2N/A krb5_const_principal searchfor, int *nentries);
2N/A
2N/Akrb5_error_code krb5_db2_lib_init(void);
2N/Akrb5_error_code krb5_db2_lib_cleanup(void);
2N/Akrb5_error_code krb5_db2_db_unlock(krb5_context);
2N/A
2N/Akrb5_error_code
2N/Akrb5_db2_promote_db(krb5_context kcontext, char *conf_section, char **db_args);
2N/A
2N/Akrb5_error_code
2N/Akrb5_db2_db_set_option(krb5_context kcontext, int option, void *value );
2N/A
2N/Akrb5_error_code
2N/Akrb5_db2_db_lock(krb5_context context, int in_mode);
2N/A
2N/Akrb5_error_code
2N/Akrb5_db2_open(krb5_context kcontext, char *conf_section, char **db_args,
2N/A int mode);
2N/A
2N/Akrb5_error_code krb5_db2_create(krb5_context kcontext, char *conf_section,
2N/A char **db_args);
2N/A
2N/Akrb5_error_code krb5_db2_destroy(krb5_context kcontext, char *conf_section,
2N/A char **db_args);
2N/A
2N/Aconst char *krb5_db2_err2str(krb5_context kcontext, long err_code);
2N/Avoid *krb5_db2_alloc(krb5_context kcontext, void *ptr, size_t size);
2N/Avoid krb5_db2_free(krb5_context kcontext, void *ptr);
2N/A
2N/A
2N/A/* policy management functions */
2N/Akrb5_error_code
2N/Akrb5_db2_create_policy(krb5_context context, osa_policy_ent_t entry);
2N/A
2N/Akrb5_error_code krb5_db2_get_policy(krb5_context kcontext,
2N/A char *name, osa_policy_ent_t *policy,
2N/A int *cnt);
2N/A
2N/Akrb5_error_code krb5_db2_put_policy(krb5_context kcontext,
2N/A osa_policy_ent_t policy);
2N/A
2N/Akrb5_error_code krb5_db2_iter_policy(krb5_context kcontext, char *match_entry,
2N/A osa_adb_iter_policy_func func,
2N/A void *data);
2N/A
2N/Akrb5_error_code krb5_db2_delete_policy(krb5_context kcontext, char *policy);
2N/A
2N/Avoid krb5_db2_free_policy(krb5_context kcontext, osa_policy_ent_t entry);
2N/A
2N/A/* Thread-safety wrapper slapped on top of original implementation. */
2N/Aextern k5_mutex_t *krb5_db2_mutex;
2N/A
2N/A/* lockout */
2N/Akrb5_error_code
2N/Akrb5_db2_lockout_check_policy(krb5_context context,
2N/A krb5_db_entry *entry,
2N/A krb5_timestamp stamp);
2N/A
2N/Akrb5_error_code
2N/Akrb5_db2_lockout_audit(krb5_context context,
2N/A krb5_db_entry *entry,
2N/A krb5_timestamp stamp,
2N/A krb5_error_code status);
2N/A
2N/A/* methods */
2N/Akrb5_error_code
2N/Akrb5_db2_invoke(krb5_context context,
2N/A unsigned int method,
2N/A const krb5_data *req,
2N/A krb5_data *rep);
2N/A
2N/A#endif /* KRB5_KDB_DB2_H */