Path: blob/main/crypto/krb5/src/plugins/kdb/db2/policy_db.h
34914 views
/* -*- mode: c; c-basic-offset: 4; indent-tabs-mode: nil -*- */1/*2* Data Types for policy and principal information that3* exists in the respective databases.4*5* $Header$6*7* This file was originally created with rpcgen.8* It has been hacked up since then.9*/1011#ifndef __ADB_H__12#define __ADB_H__13#include <sys/types.h>14#include <errno.h>15#include <krb5.h>16#include <kdb.h>17/* Okay, this is a bit obscure. The libdb2 configure script doesn't18detect it, but on Tru64 5.1, netinet/in.h causes sys/bittypes.h to19be included, and that has a typedef for u_int32_t. Because the20configure script doesn't detect it, it causes db-config.h to have a21#define for u_int32_t, so including db.h and then netinet/in.h22causes compilation to fail.2324Since gssrpc/types.h includes netinet/in.h, including that first25will cause the typedef to be seen before the macro definition,26which still isn't quite right, but is close enough for now.2728A better fix might be for db.h to include netinet/in.h if that's29where we find u_int32_t. */30#include <gssrpc/types.h>31#include <gssrpc/xdr.h>32#include <db.h>33#include "adb_err.h"34#include <com_err.h>3536/* DB2 uses EFTYPE to indicate a database file of the wrong format, and falls37* back to EINVAL if the platform does not define EFTYPE. */38#ifdef EFTYPE39#define IS_EFTYPE(e) ((e) == EFTYPE || (e) == EINVAL)40#else41#define IS_EFTYPE(e) ((e) == EINVAL)42#endif4344typedef long osa_adb_ret_t;4546#define OSA_ADB_POLICY_DB_MAGIC 0x12345A004748#define OSA_ADB_POLICY_VERSION_MASK 0x12345D0049#define OSA_ADB_POLICY_VERSION_1 0x12345D0150#define OSA_ADB_POLICY_VERSION_2 0x12345D0251#define OSA_ADB_POLICY_VERSION_3 0x12345D0352535455typedef struct _osa_adb_db_lock_ent_t {56FILE *lockfile;57char *filename;58int refcnt, lockmode, lockcnt;59krb5_context context;60} osa_adb_lock_ent, *osa_adb_lock_t;6162typedef struct _osa_adb_db_ent_t {63int magic;64DB *db;65HASHINFO info;66BTREEINFO btinfo;67char *filename;68osa_adb_lock_t lock;69int opencnt;70} osa_adb_db_ent, *osa_adb_db_t, *osa_adb_princ_t, *osa_adb_policy_t;7172/*73* Return Code (the rest are in adb_err.h)74*/7576#define OSA_ADB_OK 07778/*79* Functions80*/8182krb5_error_code osa_adb_create_db(char *filename, char *lockfile, int magic);83krb5_error_code osa_adb_destroy_db(char *filename, char *lockfile, int magic);84krb5_error_code osa_adb_init_db(osa_adb_db_t *dbp, char *filename,85char *lockfile, int magic);86krb5_error_code osa_adb_fini_db(osa_adb_db_t db, int magic);87krb5_error_code osa_adb_get_lock(osa_adb_db_t db, int mode);88krb5_error_code osa_adb_release_lock(osa_adb_db_t db);89krb5_error_code osa_adb_open_and_lock(osa_adb_princ_t db, int locktype);90krb5_error_code osa_adb_close_and_unlock(osa_adb_princ_t db);91krb5_error_code osa_adb_create_policy(osa_adb_policy_t db,92osa_policy_ent_t entry);93krb5_error_code osa_adb_destroy_policy(osa_adb_policy_t db,94char * name);95krb5_error_code osa_adb_get_policy(osa_adb_policy_t db, char *name,96osa_policy_ent_t *entry);97krb5_error_code osa_adb_put_policy(osa_adb_policy_t db,98osa_policy_ent_t entry);99krb5_error_code osa_adb_iter_policy(osa_adb_policy_t db,100osa_adb_iter_policy_func func,101void * data);102void osa_free_policy_ent(osa_policy_ent_t val);103104bool_t xdr_osa_policy_ent_rec(XDR *xdrs, osa_policy_ent_t objp);105106#endif /* __ADB_H__ */107108109