xref: /titanic_41/usr/src/lib/krb5/kadm5/adb.h (revision 8eea8e29cc4374d1ee24c25a07f45af132db3499)
1 /*
2  * Copyright 2002 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      char	*filename;
73      osa_adb_lock_t lock;
74 } osa_adb_db_ent, *osa_adb_db_t, *osa_adb_princ_t, *osa_adb_policy_t;
75 
76 /* an osa_pw_hist_ent stores all the key_datas for a single password */
77 typedef struct _osa_pw_hist_t {
78      int n_key_data;
79      krb5_key_data *key_data;
80 } osa_pw_hist_ent, *osa_pw_hist_t;
81 
82 typedef struct _osa_princ_ent_t {
83     int				version;
84     char			*policy;
85     long			aux_attributes;
86     unsigned int		old_key_len;
87     unsigned int		old_key_next;
88     krb5_kvno			admin_history_kvno;
89     osa_pw_hist_ent		*old_keys;
90 } osa_princ_ent_rec, *osa_princ_ent_t;
91 
92 typedef struct _osa_policy_ent_t {
93     int		version;
94     char	*name;
95     rpc_u_int32	pw_min_life;
96     rpc_u_int32	pw_max_life;
97     rpc_u_int32	pw_min_length;
98     rpc_u_int32	pw_min_classes;
99     rpc_u_int32	pw_history_num;
100     rpc_u_int32	policy_refcnt;
101 } osa_policy_ent_rec, *osa_policy_ent_t;
102 
103 typedef	void	(*osa_adb_iter_princ_func) (void *, osa_princ_ent_t);
104 typedef	void	(*osa_adb_iter_policy_func) (void *, osa_policy_ent_t);
105 
106 
107 /*
108  * Return Code (the rest are in adb_err.h)
109  */
110 
111 #define OSA_ADB_OK		0
112 
113 /*
114  * xdr functions
115  */
116 bool_t		xdr_osa_princ_ent_rec(XDR *xdrs, osa_princ_ent_t objp);
117 bool_t		xdr_osa_policy_ent_rec(XDR *xdrs, osa_policy_ent_t objp);
118 
119 /*
120  * Functions
121  */
122 
123 osa_adb_ret_t	osa_adb_create_db(char *filename, char *lockfile, int magic);
124 osa_adb_ret_t	osa_adb_destroy_db(char *filename, char *lockfile, int magic);
125 osa_adb_ret_t	osa_adb_init_db(osa_adb_db_t *dbp, char *filename,
126 				char *lockfile, int magic);
127 osa_adb_ret_t	osa_adb_fini_db(osa_adb_db_t db, int magic);
128 osa_adb_ret_t	osa_adb_get_lock(osa_adb_db_t db, int mode);
129 osa_adb_ret_t	osa_adb_release_lock(osa_adb_db_t db);
130 osa_adb_ret_t	osa_adb_open_and_lock(osa_adb_princ_t db, int locktype);
131 osa_adb_ret_t	osa_adb_close_and_unlock(osa_adb_princ_t db);
132 
133 osa_adb_ret_t	osa_adb_create_policy_db(kadm5_config_params *params);
134 osa_adb_ret_t	osa_adb_destroy_policy_db(kadm5_config_params *params);
135 osa_adb_ret_t	osa_adb_open_princ(osa_adb_princ_t *db, char *filename);
136 osa_adb_ret_t	osa_adb_open_policy(osa_adb_policy_t *db,
137 				    kadm5_config_params *rparams);
138 osa_adb_ret_t	osa_adb_close_princ(osa_adb_princ_t db);
139 osa_adb_ret_t	osa_adb_close_policy(osa_adb_policy_t db);
140 osa_adb_ret_t	osa_adb_create_princ(osa_adb_princ_t db,
141 				 osa_princ_ent_t entry);
142 osa_adb_ret_t	osa_adb_create_policy(osa_adb_policy_t db,
143 				      osa_policy_ent_t entry);
144 osa_adb_ret_t	osa_adb_destroy_princ(osa_adb_princ_t db,
145 				      kadm5_princ_t name);
146 osa_adb_ret_t	osa_adb_destroy_policy(osa_adb_policy_t db,
147 				       kadm5_policy_t name);
148 osa_adb_ret_t	osa_adb_get_princ(osa_adb_princ_t db,
149 				  kadm5_princ_t name,
150 				  osa_princ_ent_t *entry);
151 osa_adb_ret_t	osa_adb_get_policy(osa_adb_policy_t db,
152 				   kadm5_policy_t name,
153 				   osa_policy_ent_t *entry);
154 osa_adb_ret_t	osa_adb_put_princ(osa_adb_princ_t db,
155 				  osa_princ_ent_t entry);
156 osa_adb_ret_t	osa_adb_put_policy(osa_adb_policy_t db,
157 				   osa_policy_ent_t entry);
158 osa_adb_ret_t	osa_adb_iter_policy(osa_adb_policy_t db,
159 				    osa_adb_iter_policy_func func,
160 				    void * data);
161 osa_adb_ret_t	osa_adb_iter_princ(osa_adb_princ_t db,
162 				       osa_adb_iter_princ_func func,
163 				       void *data);
164 void		osa_free_policy_ent(osa_policy_ent_t val);
165 void		osa_free_princ_ent(osa_princ_ent_t val);
166 #endif /* __ADB_H__ */
167