xref: /titanic_50/usr/src/lib/krb5/plugins/kdb/db2/policy_db.h (revision 54925bf60766fbb4f1f2d7c843721406a7b7a3fb)
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 #pragma ident	"%Z%%M%	%I%	%E% SMI"
15 
16 #include <sys/types.h>
17 #include <errno.h>
18 #include <krb5.h>
19 #include <kdb.h>
20 /* Okay, this is a bit obscure.  The libdb2 configure script doesn't
21    detect it, but on Tru64 5.1, netinet/in.h causes sys/bittypes.h to
22    be included, and that has a typedef for u_int32_t.  Because the
23    configure script doesn't detect it, it causes db-config.h to have a
24    #define for u_int32_t, so including db.h and then netinet/in.h
25    causes compilation to fail.
26 
27    Since gssrpc/types.h includes netinet/in.h, including that first
28    will cause the typedef to be seen before the macro definition,
29    which still isn't quite right, but is close enough for now.
30 
31    A better fix might be for db.h to include netinet/in.h if that's
32    where we find u_int32_t.  */
33 /* Solaris Kerberos: gssrpc not supported */
34 #if 0 /************** Begin IFDEF'ed OUT *******************************/
35 #include <gssrpc/types.h>
36 #include <gssrpc/xdr.h>
37 #else
38 #include <rpc/types.h>
39 #include <rpc/xdr.h>
40 #endif /**************** END IFDEF'ed OUT *******************************/
41 #include <db.h>
42 #include <kdb/adb_err.h>
43 #include <com_err.h>
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 
52 
53 
54 typedef struct _osa_adb_db_lock_ent_t {
55      FILE     *lockfile;
56      char     *filename;
57      int      refcnt, lockmode, lockcnt;
58      krb5_context context;
59 } osa_adb_lock_ent, *osa_adb_lock_t;
60 
61 typedef struct _osa_adb_db_ent_t {
62      int        magic;
63      DB         *db;
64      HASHINFO   info;
65      BTREEINFO  btinfo;
66      char       *filename;
67      osa_adb_lock_t lock;
68      int        opencnt;
69 } osa_adb_db_ent, *osa_adb_db_t, *osa_adb_princ_t, *osa_adb_policy_t;
70 
71 /*
72  * Return Code (the rest are in adb_err.h)
73  */
74 
75 #define OSA_ADB_OK		0
76 
77 /*
78  * Functions
79  */
80 
81 krb5_error_code	osa_adb_create_db(char *filename, char *lockfile, int magic);
82 krb5_error_code	osa_adb_destroy_db(char *filename, char *lockfile, int magic);
83 krb5_error_code   osa_adb_rename_db(char *filefrom, char *lockfrom,
84 				  char *fileto, char *lockto, 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_close_policy(osa_adb_policy_t db);
93 krb5_error_code	osa_adb_create_policy(osa_adb_policy_t db,
94 				      osa_policy_ent_t entry);
95 krb5_error_code	osa_adb_destroy_policy(osa_adb_policy_t db,
96 				       char * name);
97 krb5_error_code	osa_adb_get_policy(osa_adb_policy_t db,
98 				   char * name,
99 				   osa_policy_ent_t *entry,
100 				   int *cnt);
101 krb5_error_code	osa_adb_put_policy(osa_adb_policy_t db,
102 				   osa_policy_ent_t entry);
103 krb5_error_code	osa_adb_iter_policy(osa_adb_policy_t db,
104 				    osa_adb_iter_policy_func func,
105 				    void * data);
106 void		osa_free_policy_ent(osa_policy_ent_t val);
107 
108 bool_t  xdr_osa_policy_ent_rec(XDR *xdrs, osa_policy_ent_t objp);
109 
110 #endif /* __ADB_H__ */
111