xref: /titanic_41/usr/src/lib/krb5/kadm5/adb.h (revision aa59c4cb15a6ac5d4e585dadf7a055b580abf579)
1 /*
2  * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
3  * Use is subject to license terms.
4  */
5 
6 #pragma ident	"%Z%%M%	%I%	%E% SMI"
7 
8 /*
9  * WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING
10  *
11  *	Openvision retains the copyright to derivative works of
12  *	this source code.  Do *NOT* create a derivative of this
13  *	source code before consulting with your legal department.
14  *	Do *NOT* integrate *ANY* of this source code into another
15  *	product before consulting with your legal department.
16  *
17  *	For further information, read the top-level Openvision
18  *	copyright which is contained in the top-level MIT Kerberos
19  *	copyright.
20  *
21  * WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING
22  *
23  */
24 
25 
26 /*
27  * Data Types for policys, and principal information that
28  * exist in the respective databases.
29  *
30  * $Header: /cvs/krbdev/krb5/src/lib/kadm5/adb.h,v 1.21 1998/02/14 02:34:09 tlyu Exp $
31  *
32  * This file was originally created with rpcgen.
33  * It has been hacked up since then.
34  */
35 
36 #ifndef __ADB_H__
37 #define __ADB_H__
38 #include <sys/types.h>
39 #include <rpc/types.h>	/* SUNWresync121 - no need to change to gssrpc/ */
40 #include "k5-int.h"
41 #include <krb5/kdb.h>
42 #include <db.h>
43 #include <kadm5/admin.h>
44 #include <kadm5/adb_err.h>
45 #include <com_err.h>
46 
47 typedef	long		osa_adb_ret_t;
48 
49 #define OSA_ADB_POLICY_DB_MAGIC	0x12345A00
50 #define OSA_ADB_PRINC_DB_MAGIC	0x12345B00
51 
52 #define OSA_ADB_SHARED		0x7001
53 #define OSA_ADB_EXCLUSIVE	0x7002
54 #define OSA_ADB_PERMANENT	0x7003
55 
56 #define OSA_ADB_PRINC_VERSION_MASK	0x12345C00
57 #define OSA_ADB_PRINC_VERSION_1		0x12345C01
58 #define OSA_ADB_POLICY_VERSION_MASK	0x12345D00
59 #define OSA_ADB_POLICY_VERSION_1	0x12345D01
60 
61 typedef struct _osa_adb_db_lock_ent_t {
62      FILE	*lockfile;
63      char	*filename;
64      int	refcnt, lockmode, lockcnt;
65      krb5_context context;
66 } osa_adb_lock_ent, *osa_adb_lock_t;
67 
68 typedef struct _osa_adb_db_ent_t {
69      int	magic;
70      DB		*db;
71      HASHINFO	info;
72      BTREEINFO	btinfo;
73      char	*filename;
74      osa_adb_lock_t lock;
75      int	opencnt;
76 } osa_adb_db_ent, *osa_adb_db_t, *osa_adb_princ_t, *osa_adb_policy_t;
77 
78 /* an osa_pw_hist_ent stores all the key_datas for a single password */
79 typedef struct _osa_pw_hist_t {
80      int n_key_data;
81      krb5_key_data *key_data;
82 } osa_pw_hist_ent, *osa_pw_hist_t;
83 
84 typedef struct _osa_princ_ent_t {
85     int				version;
86     char			*policy;
87     long			aux_attributes;
88     unsigned int		old_key_len;
89     unsigned int		old_key_next;
90     krb5_kvno			admin_history_kvno;
91     osa_pw_hist_ent		*old_keys;
92 } osa_princ_ent_rec, *osa_princ_ent_t;
93 
94 typedef struct _osa_policy_ent_t {
95     int		version;
96     char	*name;
97     uint32_t	pw_min_life;
98     uint32_t	pw_max_life;
99     uint32_t	pw_min_length;
100     uint32_t	pw_min_classes;
101     uint32_t	pw_history_num;
102     uint32_t	policy_refcnt;
103 } osa_policy_ent_rec, *osa_policy_ent_t;
104 
105 typedef	void	(*osa_adb_iter_princ_func) (void *, osa_princ_ent_t);
106 typedef	void	(*osa_adb_iter_policy_func) (void *, osa_policy_ent_t);
107 
108 
109 /*
110  * Return Code (the rest are in adb_err.h)
111  */
112 
113 #define OSA_ADB_OK		0
114 
115 /*
116  * xdr functions
117  */
118 bool_t		xdr_osa_princ_ent_rec(XDR *xdrs, osa_princ_ent_t objp);
119 bool_t		xdr_osa_policy_ent_rec(XDR *xdrs, osa_policy_ent_t objp);
120 bool_t		xdr_osa_pw_hist_ent(XDR *xdrs, osa_pw_hist_ent *objp);
121 bool_t          xdr_krb5_key_data(XDR *xdrs, krb5_key_data *objp);
122 
123 /*
124  * Functions
125  */
126 
127 osa_adb_ret_t	osa_adb_create_db(char *filename, char *lockfile, int magic);
128 osa_adb_ret_t	osa_adb_destroy_db(char *filename, char *lockfile, int magic);
129 osa_adb_ret_t   osa_adb_rename_db(char *filefrom, char *lockfrom,
130 				  char *fileto, char *lockto, int magic);
131 osa_adb_ret_t   osa_adb_rename_policy_db(kadm5_config_params *fromparams,
132 					 kadm5_config_params *toparams);
133 osa_adb_ret_t	osa_adb_init_db(osa_adb_db_t *dbp, char *filename,
134 				char *lockfile, int magic);
135 osa_adb_ret_t	osa_adb_fini_db(osa_adb_db_t db, int magic);
136 osa_adb_ret_t	osa_adb_get_lock(osa_adb_db_t db, int mode);
137 osa_adb_ret_t	osa_adb_release_lock(osa_adb_db_t db);
138 osa_adb_ret_t	osa_adb_open_and_lock(osa_adb_princ_t db, int locktype);
139 osa_adb_ret_t	osa_adb_close_and_unlock(osa_adb_princ_t db);
140 
141 osa_adb_ret_t	osa_adb_create_policy_db(kadm5_config_params *params);
142 osa_adb_ret_t	osa_adb_destroy_policy_db(kadm5_config_params *params);
143 osa_adb_ret_t	osa_adb_open_princ(osa_adb_princ_t *db, char *filename);
144 osa_adb_ret_t	osa_adb_open_policy(osa_adb_policy_t *db,
145 				    kadm5_config_params *rparams);
146 osa_adb_ret_t	osa_adb_close_princ(osa_adb_princ_t db);
147 osa_adb_ret_t	osa_adb_close_policy(osa_adb_policy_t db);
148 osa_adb_ret_t	osa_adb_create_princ(osa_adb_princ_t db,
149 				 osa_princ_ent_t entry);
150 osa_adb_ret_t	osa_adb_create_policy(osa_adb_policy_t db,
151 				      osa_policy_ent_t entry);
152 osa_adb_ret_t	osa_adb_destroy_princ(osa_adb_princ_t db,
153 				      kadm5_princ_t name);
154 osa_adb_ret_t	osa_adb_destroy_policy(osa_adb_policy_t db,
155 				       kadm5_policy_t name);
156 osa_adb_ret_t	osa_adb_get_princ(osa_adb_princ_t db,
157 				  kadm5_princ_t name,
158 				  osa_princ_ent_t *entry);
159 osa_adb_ret_t	osa_adb_get_policy(osa_adb_policy_t db,
160 				   kadm5_policy_t name,
161 				   osa_policy_ent_t *entry);
162 osa_adb_ret_t	osa_adb_put_princ(osa_adb_princ_t db,
163 				  osa_princ_ent_t entry);
164 osa_adb_ret_t	osa_adb_put_policy(osa_adb_policy_t db,
165 				   osa_policy_ent_t entry);
166 osa_adb_ret_t	osa_adb_iter_policy(osa_adb_policy_t db,
167 				    osa_adb_iter_policy_func func,
168 				    void * data);
169 osa_adb_ret_t	osa_adb_iter_princ(osa_adb_princ_t db,
170 				       osa_adb_iter_princ_func func,
171 				       void *data);
172 void		osa_free_policy_ent(osa_policy_ent_t val);
173 void		osa_free_princ_ent(osa_princ_ent_t val);
174 #endif /* __ADB_H__ */
175