xref: /freebsd/crypto/krb5/src/lib/kdb/iprop.x (revision 7f2fe78b9dd5f51c821d771b63d2e096f6fd49e9)
1*7f2fe78bSCy Schubert /*
2*7f2fe78bSCy Schubert  * Copyright 2004 Sun Microsystems, Inc.  All rights reserved.
3*7f2fe78bSCy Schubert  * Use is subject to license terms.
4*7f2fe78bSCy Schubert  */
5*7f2fe78bSCy Schubert 
6*7f2fe78bSCy Schubert /* %#pragma ident	"@(#)iprop.x	1.2	04/02/20 SMI" */
7*7f2fe78bSCy Schubert 
8*7f2fe78bSCy Schubert /*
9*7f2fe78bSCy Schubert  * Main source:
10*7f2fe78bSCy Schubert  * lib/kdb/iprop.x
11*7f2fe78bSCy Schubert  *
12*7f2fe78bSCy Schubert  * Generated files:
13*7f2fe78bSCy Schubert  * lib/kdb/iprop_xdr.c
14*7f2fe78bSCy Schubert  * include/iprop.h
15*7f2fe78bSCy Schubert  * kprop/kpropd_rpc.c (clnt)
16*7f2fe78bSCy Schubert  *
17*7f2fe78bSCy Schubert  * Derived files:
18*7f2fe78bSCy Schubert  * kadmin/server/ipropd_svc.c
19*7f2fe78bSCy Schubert  */
20*7f2fe78bSCy Schubert 
21*7f2fe78bSCy Schubert /*
22*7f2fe78bSCy Schubert  * This file gets fed through the preprocessor to handle RPC_*
23*7f2fe78bSCy Schubert  * symbols, but we don't want it to chew on __GNUC__ in this phase.
24*7f2fe78bSCy Schubert  */
25*7f2fe78bSCy Schubert #undef __GNUC__
26*7f2fe78bSCy Schubert 
27*7f2fe78bSCy Schubert #ifdef RPC_XDR
28*7f2fe78bSCy Schubert /*
29*7f2fe78bSCy Schubert  * Sloppy rpcgen code declares "buf" and rarely uses it.  As it's
30*7f2fe78bSCy Schubert  * generated code, and not presented to code building against the
31*7f2fe78bSCy Schubert  * Kerberos code, it's not a problem we need to fix, so suppress the
32*7f2fe78bSCy Schubert  * complaint.
33*7f2fe78bSCy Schubert  */
34*7f2fe78bSCy Schubert %#ifdef __GNUC__
35*7f2fe78bSCy Schubert %#pragma GCC diagnostic ignored "-Wunused-variable"
36*7f2fe78bSCy Schubert %#endif
37*7f2fe78bSCy Schubert #endif /* RPC_XDR */
38*7f2fe78bSCy Schubert 
39*7f2fe78bSCy Schubert /*
40*7f2fe78bSCy Schubert  * Initial declarations
41*7f2fe78bSCy Schubert  */
42*7f2fe78bSCy Schubert 
43*7f2fe78bSCy Schubert #ifndef RPC_HDR
44*7f2fe78bSCy Schubert typedef short int16_t;
45*7f2fe78bSCy Schubert typedef unsigned short uint16_t;
46*7f2fe78bSCy Schubert typedef int int32_t;
47*7f2fe78bSCy Schubert typedef unsigned int uint32_t;
48*7f2fe78bSCy Schubert /*typedef hyper int64_t;*/
49*7f2fe78bSCy Schubert /*typedef unsigned hyper uint64_t;*/
50*7f2fe78bSCy Schubert #endif  /* !RPC_HDR */
51*7f2fe78bSCy Schubert 
52*7f2fe78bSCy Schubert typedef opaque	 utf8str_t<>;
53*7f2fe78bSCy Schubert 
54*7f2fe78bSCy Schubert /*
55*7f2fe78bSCy Schubert  * Transaction log serial no.
56*7f2fe78bSCy Schubert  */
57*7f2fe78bSCy Schubert typedef uint32_t	kdb_sno_t;
58*7f2fe78bSCy Schubert 
59*7f2fe78bSCy Schubert /* Timestamp */
60*7f2fe78bSCy Schubert struct kdbe_time_t {
61*7f2fe78bSCy Schubert 	uint32_t	seconds;
62*7f2fe78bSCy Schubert 	uint32_t	useconds;
63*7f2fe78bSCy Schubert };
64*7f2fe78bSCy Schubert 
65*7f2fe78bSCy Schubert /* Key Data */
66*7f2fe78bSCy Schubert struct kdbe_key_t {
67*7f2fe78bSCy Schubert 	int32_t		k_ver;	/* Version */
68*7f2fe78bSCy Schubert 	int32_t		k_kvno;	/* Key version no. */
69*7f2fe78bSCy Schubert 	int32_t		k_enctype<>;
70*7f2fe78bSCy Schubert 	utf8str_t	k_contents<>;
71*7f2fe78bSCy Schubert };
72*7f2fe78bSCy Schubert 
73*7f2fe78bSCy Schubert /* Content data */
74*7f2fe78bSCy Schubert struct kdbe_data_t {
75*7f2fe78bSCy Schubert 	int32_t		k_magic;
76*7f2fe78bSCy Schubert 	utf8str_t	k_data;
77*7f2fe78bSCy Schubert };
78*7f2fe78bSCy Schubert 
79*7f2fe78bSCy Schubert /* Principal Data */
80*7f2fe78bSCy Schubert struct kdbe_princ_t {
81*7f2fe78bSCy Schubert 	utf8str_t	k_realm;
82*7f2fe78bSCy Schubert 	kdbe_data_t	k_components<>;
83*7f2fe78bSCy Schubert 	int32_t		k_nametype;
84*7f2fe78bSCy Schubert };
85*7f2fe78bSCy Schubert 
86*7f2fe78bSCy Schubert /* TL data (pre-auth specific data) */
87*7f2fe78bSCy Schubert struct kdbe_tl_t {
88*7f2fe78bSCy Schubert 	int16_t		tl_type;
89*7f2fe78bSCy Schubert 	opaque		tl_data<>;
90*7f2fe78bSCy Schubert };
91*7f2fe78bSCy Schubert 
92*7f2fe78bSCy Schubert /* Structure to store pwd history */
93*7f2fe78bSCy Schubert typedef kdbe_key_t kdbe_pw_hist_t<>;
94*7f2fe78bSCy Schubert 
95*7f2fe78bSCy Schubert /* Basic KDB entry attributes */
96*7f2fe78bSCy Schubert enum kdbe_attr_type_t {
97*7f2fe78bSCy Schubert 	AT_ATTRFLAGS = 0,
98*7f2fe78bSCy Schubert 	AT_MAX_LIFE = 1,
99*7f2fe78bSCy Schubert 	AT_MAX_RENEW_LIFE = 2,
100*7f2fe78bSCy Schubert 	AT_EXP = 3,
101*7f2fe78bSCy Schubert 	AT_PW_EXP = 4,
102*7f2fe78bSCy Schubert 	AT_LAST_SUCCESS = 5,
103*7f2fe78bSCy Schubert 	AT_LAST_FAILED = 6,
104*7f2fe78bSCy Schubert 	AT_FAIL_AUTH_COUNT = 7,
105*7f2fe78bSCy Schubert 	AT_PRINC = 8,
106*7f2fe78bSCy Schubert 	AT_KEYDATA = 9,
107*7f2fe78bSCy Schubert 	AT_TL_DATA = 10,
108*7f2fe78bSCy Schubert 	AT_LEN = 11,
109*7f2fe78bSCy Schubert 	AT_MOD_PRINC = 12,
110*7f2fe78bSCy Schubert 	AT_MOD_TIME = 13,
111*7f2fe78bSCy Schubert 	AT_MOD_WHERE = 14,
112*7f2fe78bSCy Schubert 	AT_PW_LAST_CHANGE = 15,
113*7f2fe78bSCy Schubert 	AT_PW_POLICY = 16,
114*7f2fe78bSCy Schubert 	AT_PW_POLICY_SWITCH = 17,
115*7f2fe78bSCy Schubert 	AT_PW_HIST_KVNO = 18,
116*7f2fe78bSCy Schubert 	AT_PW_HIST = 19
117*7f2fe78bSCy Schubert };
118*7f2fe78bSCy Schubert 
119*7f2fe78bSCy Schubert /* KDB entry, Attribute=value */
120*7f2fe78bSCy Schubert union kdbe_val_t switch (kdbe_attr_type_t av_type) {
121*7f2fe78bSCy Schubert case AT_ATTRFLAGS:
122*7f2fe78bSCy Schubert 	uint32_t	av_attrflags;
123*7f2fe78bSCy Schubert case AT_MAX_LIFE:
124*7f2fe78bSCy Schubert 	uint32_t	av_max_life;
125*7f2fe78bSCy Schubert case AT_MAX_RENEW_LIFE:
126*7f2fe78bSCy Schubert 	uint32_t	av_max_renew_life;
127*7f2fe78bSCy Schubert case AT_EXP:
128*7f2fe78bSCy Schubert 	uint32_t	av_exp;
129*7f2fe78bSCy Schubert case AT_PW_EXP:
130*7f2fe78bSCy Schubert 	uint32_t	av_pw_exp;
131*7f2fe78bSCy Schubert case AT_LAST_SUCCESS:
132*7f2fe78bSCy Schubert 	uint32_t	av_last_success;
133*7f2fe78bSCy Schubert case AT_LAST_FAILED:
134*7f2fe78bSCy Schubert 	uint32_t	av_last_failed;
135*7f2fe78bSCy Schubert case AT_FAIL_AUTH_COUNT:
136*7f2fe78bSCy Schubert 	uint32_t	av_fail_auth_count;
137*7f2fe78bSCy Schubert case AT_PRINC:
138*7f2fe78bSCy Schubert 	kdbe_princ_t	av_princ;
139*7f2fe78bSCy Schubert case AT_KEYDATA:
140*7f2fe78bSCy Schubert 	kdbe_key_t	av_keydata<>;	/* array of keys */
141*7f2fe78bSCy Schubert case AT_TL_DATA:
142*7f2fe78bSCy Schubert 	kdbe_tl_t	av_tldata<>;	/* array of TL data */
143*7f2fe78bSCy Schubert case AT_LEN:
144*7f2fe78bSCy Schubert 	int16_t		av_len;
145*7f2fe78bSCy Schubert case AT_PW_LAST_CHANGE:
146*7f2fe78bSCy Schubert 	uint32_t	av_pw_last_change;
147*7f2fe78bSCy Schubert case AT_MOD_PRINC:
148*7f2fe78bSCy Schubert 	kdbe_princ_t	av_mod_princ;
149*7f2fe78bSCy Schubert case AT_MOD_TIME:
150*7f2fe78bSCy Schubert 	uint32_t	av_mod_time;
151*7f2fe78bSCy Schubert case AT_MOD_WHERE:
152*7f2fe78bSCy Schubert 	utf8str_t	av_mod_where;
153*7f2fe78bSCy Schubert case AT_PW_POLICY:
154*7f2fe78bSCy Schubert 	utf8str_t	av_pw_policy;
155*7f2fe78bSCy Schubert case AT_PW_POLICY_SWITCH:
156*7f2fe78bSCy Schubert 	bool		av_pw_policy_switch;
157*7f2fe78bSCy Schubert case AT_PW_HIST_KVNO:
158*7f2fe78bSCy Schubert 	uint32_t	av_pw_hist_kvno;
159*7f2fe78bSCy Schubert case AT_PW_HIST:
160*7f2fe78bSCy Schubert 	kdbe_pw_hist_t	av_pw_hist<>;	/* array of pw history */
161*7f2fe78bSCy Schubert default:
162*7f2fe78bSCy Schubert 	opaque		av_extension<>;	/* futures */
163*7f2fe78bSCy Schubert };
164*7f2fe78bSCy Schubert 
165*7f2fe78bSCy Schubert typedef kdbe_val_t kdbe_t<>;	    /* Array of attr/val makes a KDB entry */
166*7f2fe78bSCy Schubert 
167*7f2fe78bSCy Schubert /*
168*7f2fe78bSCy Schubert  * Incremental update
169*7f2fe78bSCy Schubert  */
170*7f2fe78bSCy Schubert struct kdb_incr_update_t {
171*7f2fe78bSCy Schubert 	utf8str_t	kdb_princ_name;	/* Principal name */
172*7f2fe78bSCy Schubert 	kdb_sno_t	kdb_entry_sno;	/* Serial # of entry */
173*7f2fe78bSCy Schubert 	kdbe_time_t	kdb_time;	/* Timestamp of update */
174*7f2fe78bSCy Schubert 	kdbe_t		kdb_update; 	/* Attributes modified */
175*7f2fe78bSCy Schubert 	bool		kdb_deleted;	/* Is this update a DELETION ? */
176*7f2fe78bSCy Schubert 	bool		kdb_commit;	/* Is the entry committed or not ? */
177*7f2fe78bSCy Schubert 	utf8str_t	kdb_kdcs_seen_by<>; /* Names of replicass that have */
178*7f2fe78bSCy Schubert 					    /* seen this update - for */
179*7f2fe78bSCy Schubert 					    /* future use */
180*7f2fe78bSCy Schubert 	opaque		kdb_futures<>;	/* futures */
181*7f2fe78bSCy Schubert };
182*7f2fe78bSCy Schubert 
183*7f2fe78bSCy Schubert /*
184*7f2fe78bSCy Schubert  * Update log body
185*7f2fe78bSCy Schubert  */
186*7f2fe78bSCy Schubert typedef kdb_incr_update_t kdb_ulog_t<>;
187*7f2fe78bSCy Schubert 
188*7f2fe78bSCy Schubert enum update_status_t {
189*7f2fe78bSCy Schubert 	UPDATE_OK = 0,
190*7f2fe78bSCy Schubert 	UPDATE_ERROR = 1,
191*7f2fe78bSCy Schubert 	UPDATE_FULL_RESYNC_NEEDED = 2,
192*7f2fe78bSCy Schubert 	UPDATE_BUSY = 3,
193*7f2fe78bSCy Schubert 	UPDATE_NIL = 4,
194*7f2fe78bSCy Schubert 	UPDATE_PERM_DENIED = 5
195*7f2fe78bSCy Schubert };
196*7f2fe78bSCy Schubert 
197*7f2fe78bSCy Schubert struct kdb_last_t {
198*7f2fe78bSCy Schubert 	kdb_sno_t	last_sno;
199*7f2fe78bSCy Schubert 	kdbe_time_t	last_time;
200*7f2fe78bSCy Schubert };
201*7f2fe78bSCy Schubert 
202*7f2fe78bSCy Schubert struct kdb_incr_result_t {
203*7f2fe78bSCy Schubert 	kdb_last_t		lastentry;
204*7f2fe78bSCy Schubert 	kdb_ulog_t		updates;
205*7f2fe78bSCy Schubert 	update_status_t		ret;
206*7f2fe78bSCy Schubert };
207*7f2fe78bSCy Schubert 
208*7f2fe78bSCy Schubert struct kdb_fullresync_result_t {
209*7f2fe78bSCy Schubert 	kdb_last_t		lastentry;
210*7f2fe78bSCy Schubert 	update_status_t 	ret;
211*7f2fe78bSCy Schubert };
212*7f2fe78bSCy Schubert 
213*7f2fe78bSCy Schubert program KRB5_IPROP_PROG {
214*7f2fe78bSCy Schubert 	version KRB5_IPROP_VERS {
215*7f2fe78bSCy Schubert 		/*
216*7f2fe78bSCy Schubert 		 * NULL procedure
217*7f2fe78bSCy Schubert 		 */
218*7f2fe78bSCy Schubert 		void
219*7f2fe78bSCy Schubert 		IPROP_NULL(void) = 0;
220*7f2fe78bSCy Schubert 
221*7f2fe78bSCy Schubert 		/*
222*7f2fe78bSCy Schubert 		 * Keep waiting for and get next incremental update(s)
223*7f2fe78bSCy Schubert 		 *
224*7f2fe78bSCy Schubert 		 * Will return latest kdb_vers on the master (if different),
225*7f2fe78bSCy Schubert 		 * alongwith return value and affected db entries.
226*7f2fe78bSCy Schubert 		 */
227*7f2fe78bSCy Schubert 		kdb_incr_result_t
228*7f2fe78bSCy Schubert 		IPROP_GET_UPDATES(kdb_last_t) = 1;
229*7f2fe78bSCy Schubert 
230*7f2fe78bSCy Schubert 		/*
231*7f2fe78bSCy Schubert 		 * We need to do the full-resync of the db, since the
232*7f2fe78bSCy Schubert 		 * serial nos./timestamps are way out-of-whack
233*7f2fe78bSCy Schubert 		 */
234*7f2fe78bSCy Schubert 		kdb_fullresync_result_t
235*7f2fe78bSCy Schubert 		IPROP_FULL_RESYNC(void) = 2;
236*7f2fe78bSCy Schubert 
237*7f2fe78bSCy Schubert 		/*
238*7f2fe78bSCy Schubert 		 * Full resync with version marker
239*7f2fe78bSCy Schubert 		 */
240*7f2fe78bSCy Schubert 		kdb_fullresync_result_t
241*7f2fe78bSCy Schubert 		IPROP_FULL_RESYNC_EXT(uint32_t) = 3;
242*7f2fe78bSCy Schubert 	} = 1;
243*7f2fe78bSCy Schubert } = 100423;
244