xref: /illumos-gate/usr/src/lib/krb5/plugins/kdb/db2/policy_db.h (revision 8119dad84d6416f13557b0ba8e2aaf9064cbcfd3)
1 /*
2  * Data Types for policy and principal information that
3  * 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  */
10 
11 #ifndef __ADB_H__
12 #define __ADB_H__
13 
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 /* Solaris Kerberos: gssrpc not supported */
32 #if 0 /************** Begin IFDEF'ed OUT *******************************/
33 #include <gssrpc/types.h>
34 #include <gssrpc/xdr.h>
35 #else
36 #include <rpc/types.h>
37 #include <rpc/xdr.h>
38 #endif /**************** END IFDEF'ed OUT *******************************/
39 #include <db.h>
40 #include <kdb/adb_err.h>
41 #include <com_err.h>
42 
43 typedef	long		osa_adb_ret_t;
44 
45 #define OSA_ADB_POLICY_DB_MAGIC	0x12345A00
46 
47 #define OSA_ADB_POLICY_VERSION_MASK	0x12345D00
48 #define OSA_ADB_POLICY_VERSION_1	0x12345D01
49 
50 
51 
52 typedef struct _osa_adb_db_lock_ent_t {
53      FILE     *lockfile;
54      char     *filename;
55      int      refcnt, lockmode, lockcnt;
56      krb5_context context;
57 } osa_adb_lock_ent, *osa_adb_lock_t;
58 
59 typedef struct _osa_adb_db_ent_t {
60      int        magic;
61      DB         *db;
62      HASHINFO   info;
63      BTREEINFO  btinfo;
64      char       *filename;
65      osa_adb_lock_t lock;
66      int        opencnt;
67 } osa_adb_db_ent, *osa_adb_db_t, *osa_adb_princ_t, *osa_adb_policy_t;
68 
69 /*
70  * Return Code (the rest are in adb_err.h)
71  */
72 
73 #define OSA_ADB_OK		0
74 
75 /*
76  * Functions
77  */
78 
79 krb5_error_code	osa_adb_create_db(char *filename, char *lockfile, int magic);
80 krb5_error_code	osa_adb_destroy_db(char *filename, char *lockfile, int magic);
81 krb5_error_code   osa_adb_rename_db(char *filefrom, char *lockfrom,
82 				  char *fileto, char *lockto, int magic);
83 krb5_error_code	osa_adb_init_db(osa_adb_db_t *dbp, char *filename,
84 				char *lockfile, int magic);
85 krb5_error_code	osa_adb_fini_db(osa_adb_db_t db, int magic);
86 krb5_error_code	osa_adb_get_lock(osa_adb_db_t db, int mode);
87 krb5_error_code	osa_adb_release_lock(osa_adb_db_t db);
88 krb5_error_code osa_adb_open_and_lock(osa_adb_princ_t db, int locktype);
89 krb5_error_code osa_adb_close_and_unlock(osa_adb_princ_t db);
90 krb5_error_code	osa_adb_close_policy(osa_adb_policy_t db);
91 krb5_error_code	osa_adb_create_policy(osa_adb_policy_t db,
92 				      osa_policy_ent_t entry);
93 krb5_error_code	osa_adb_destroy_policy(osa_adb_policy_t db,
94 				       char * name);
95 krb5_error_code	osa_adb_get_policy(osa_adb_policy_t db,
96 				   char * name,
97 				   osa_policy_ent_t *entry,
98 				   int *cnt);
99 krb5_error_code	osa_adb_put_policy(osa_adb_policy_t db,
100 				   osa_policy_ent_t entry);
101 krb5_error_code	osa_adb_iter_policy(osa_adb_policy_t db,
102 				    osa_adb_iter_policy_func func,
103 				    void * data);
104 void		osa_free_policy_ent(osa_policy_ent_t val);
105 
106 bool_t  xdr_osa_policy_ent_rec(XDR *xdrs, osa_policy_ent_t objp);
107 
108 #endif /* __ADB_H__ */
109