1 /* -*- mode: c; c-basic-offset: 4; indent-tabs-mode: nil -*- */ 2 /* 3 * Data Types for policy and principal information that 4 * exists in the respective databases. 5 * 6 * $Header$ 7 * 8 * This file was originally created with rpcgen. 9 * It has been hacked up since then. 10 */ 11 12 #ifndef __ADB_H__ 13 #define __ADB_H__ 14 #include <sys/types.h> 15 #include <errno.h> 16 #include <krb5.h> 17 #include <kdb.h> 18 /* Okay, this is a bit obscure. The libdb2 configure script doesn't 19 detect it, but on Tru64 5.1, netinet/in.h causes sys/bittypes.h to 20 be included, and that has a typedef for u_int32_t. Because the 21 configure script doesn't detect it, it causes db-config.h to have a 22 #define for u_int32_t, so including db.h and then netinet/in.h 23 causes compilation to fail. 24 25 Since gssrpc/types.h includes netinet/in.h, including that first 26 will cause the typedef to be seen before the macro definition, 27 which still isn't quite right, but is close enough for now. 28 29 A better fix might be for db.h to include netinet/in.h if that's 30 where we find u_int32_t. */ 31 #include <gssrpc/types.h> 32 #include <gssrpc/xdr.h> 33 #include <db.h> 34 #include "adb_err.h" 35 #include <com_err.h> 36 37 /* DB2 uses EFTYPE to indicate a database file of the wrong format, and falls 38 * back to EINVAL if the platform does not define EFTYPE. */ 39 #ifdef EFTYPE 40 #define IS_EFTYPE(e) ((e) == EFTYPE || (e) == EINVAL) 41 #else 42 #define IS_EFTYPE(e) ((e) == EINVAL) 43 #endif 44 45 typedef long osa_adb_ret_t; 46 47 #define OSA_ADB_POLICY_DB_MAGIC 0x12345A00 48 49 #define OSA_ADB_POLICY_VERSION_MASK 0x12345D00 50 #define OSA_ADB_POLICY_VERSION_1 0x12345D01 51 #define OSA_ADB_POLICY_VERSION_2 0x12345D02 52 #define OSA_ADB_POLICY_VERSION_3 0x12345D03 53 54 55 56 typedef struct _osa_adb_db_lock_ent_t { 57 FILE *lockfile; 58 char *filename; 59 int refcnt, lockmode, lockcnt; 60 krb5_context context; 61 } osa_adb_lock_ent, *osa_adb_lock_t; 62 63 typedef struct _osa_adb_db_ent_t { 64 int magic; 65 DB *db; 66 HASHINFO info; 67 BTREEINFO btinfo; 68 char *filename; 69 osa_adb_lock_t lock; 70 int opencnt; 71 } osa_adb_db_ent, *osa_adb_db_t, *osa_adb_princ_t, *osa_adb_policy_t; 72 73 /* 74 * Return Code (the rest are in adb_err.h) 75 */ 76 77 #define OSA_ADB_OK 0 78 79 /* 80 * Functions 81 */ 82 83 krb5_error_code osa_adb_create_db(char *filename, char *lockfile, int magic); 84 krb5_error_code osa_adb_destroy_db(char *filename, char *lockfile, int magic); 85 krb5_error_code osa_adb_init_db(osa_adb_db_t *dbp, char *filename, 86 char *lockfile, int magic); 87 krb5_error_code osa_adb_fini_db(osa_adb_db_t db, int magic); 88 krb5_error_code osa_adb_get_lock(osa_adb_db_t db, int mode); 89 krb5_error_code osa_adb_release_lock(osa_adb_db_t db); 90 krb5_error_code osa_adb_open_and_lock(osa_adb_princ_t db, int locktype); 91 krb5_error_code osa_adb_close_and_unlock(osa_adb_princ_t db); 92 krb5_error_code osa_adb_create_policy(osa_adb_policy_t db, 93 osa_policy_ent_t entry); 94 krb5_error_code osa_adb_destroy_policy(osa_adb_policy_t db, 95 char * name); 96 krb5_error_code osa_adb_get_policy(osa_adb_policy_t db, char *name, 97 osa_policy_ent_t *entry); 98 krb5_error_code osa_adb_put_policy(osa_adb_policy_t db, 99 osa_policy_ent_t entry); 100 krb5_error_code osa_adb_iter_policy(osa_adb_policy_t db, 101 osa_adb_iter_policy_func func, 102 void * data); 103 void osa_free_policy_ent(osa_policy_ent_t val); 104 105 bool_t xdr_osa_policy_ent_rec(XDR *xdrs, osa_policy_ent_t objp); 106 107 #endif /* __ADB_H__ */ 108