private.h revision 55682
1/*
2 * Copyright (c) 1997-1999 Kungliga Tekniska H�gskolan
3 * (Royal Institute of Technology, Stockholm, Sweden).
4 * All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:
9 *
10 * 1. Redistributions of source code must retain the above copyright
11 *    notice, this list of conditions and the following disclaimer.
12 *
13 * 2. Redistributions in binary form must reproduce the above copyright
14 *    notice, this list of conditions and the following disclaimer in the
15 *    documentation and/or other materials provided with the distribution.
16 *
17 * 3. Neither the name of the Institute nor the names of its contributors
18 *    may be used to endorse or promote products derived from this software
19 *    without specific prior written permission.
20 *
21 * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
22 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 * ARE DISCLAIMED.  IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
25 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31 * SUCH DAMAGE.
32 */
33
34/* $Id: private.h,v 1.10 1999/12/04 23:09:34 assar Exp $ */
35
36#ifndef __kadm5_private_h__
37#define __kadm5_private_h__
38
39struct kadm_func {
40    kadm5_ret_t (*chpass_principal) (void *, krb5_principal, char*);
41    kadm5_ret_t (*create_principal) (void*, kadm5_principal_ent_t,
42				     u_int32_t, char*);
43    kadm5_ret_t (*delete_principal) (void*, krb5_principal);
44    kadm5_ret_t (*destroy) (void*);
45    kadm5_ret_t (*flush) (void*);
46    kadm5_ret_t (*get_principal) (void*, krb5_principal,
47				  kadm5_principal_ent_t, u_int32_t);
48    kadm5_ret_t (*get_principals) (void*, const char*, char***, int*);
49    kadm5_ret_t (*get_privs) (void*, u_int32_t*);
50    kadm5_ret_t (*modify_principal) (void*, kadm5_principal_ent_t, u_int32_t);
51    kadm5_ret_t (*randkey_principal) (void*, krb5_principal,
52				      krb5_keyblock**, int*);
53    kadm5_ret_t (*rename_principal) (void*, krb5_principal, krb5_principal);
54};
55
56/* XXX should be integrated */
57typedef struct kadm5_common_context {
58    krb5_context context;
59    krb5_boolean my_context;
60    struct kadm_func funcs;
61    void *data;
62}kadm5_common_context;
63
64typedef struct kadm5_log_peer {
65    int fd;
66    char *name;
67    krb5_auth_context ac;
68    struct kadm5_log_peer *next;
69} kadm5_log_peer;
70
71typedef struct kadm5_log_context {
72    char *log_file;
73    int log_fd;
74    u_int32_t version;
75    struct sockaddr_un socket_name;
76    int socket_fd;
77} kadm5_log_context;
78
79typedef struct kadm5_server_context {
80    krb5_context context;
81    krb5_boolean my_context;
82    struct kadm_func funcs;
83    /* */
84    kadm5_config_params config;
85    HDB *db;
86    krb5_principal caller;
87    unsigned acl_flags;
88    kadm5_log_context log_context;
89}kadm5_server_context;
90
91typedef struct kadm5_client_context {
92    krb5_context context;
93    krb5_boolean my_context;
94    struct kadm_func funcs;
95    /* */
96    krb5_auth_context ac;
97    char *realm;
98    char *admin_server;
99    int kadmind_port;
100    int sock;
101}kadm5_client_context;
102
103enum kadm_ops {
104    kadm_get,
105    kadm_delete,
106    kadm_create,
107    kadm_rename,
108    kadm_chpass,
109    kadm_modify,
110    kadm_randkey,
111    kadm_get_privs,
112    kadm_get_princs
113};
114
115#define KADMIN_APPL_VERSION "KADM0.1"
116#define KADMIN_OLD_APPL_VERSION "KADM0.0"
117
118#define KADM5_LOG_SIGNAL HDB_DB_DIR "/signal"
119
120kadm5_ret_t _kadm5_privs_to_string (u_int32_t, char*, size_t);
121
122kadm5_ret_t _kadm5_string_to_privs (const char*, u_int32_t*);
123
124HDB *_kadm5_s_get_db (void *);
125
126kadm5_ret_t
127_kadm5_acl_check_permission __P((
128	kadm5_server_context *context,
129	unsigned op));
130
131kadm5_ret_t
132_kadm5_acl_init __P((kadm5_server_context *context));
133
134kadm5_ret_t
135_kadm5_c_init_context __P((
136	kadm5_client_context **ctx,
137	kadm5_config_params *params,
138	krb5_context context));
139
140kadm5_ret_t
141_kadm5_client_recv __P((
142	kadm5_client_context *context,
143	krb5_data *reply));
144
145kadm5_ret_t
146_kadm5_client_send __P((
147	kadm5_client_context *context,
148	krb5_storage *sp));
149
150kadm5_ret_t
151_kadm5_error_code __P((kadm5_ret_t code));
152
153kadm5_ret_t
154_kadm5_s_init_context __P((
155	kadm5_server_context **ctx,
156	kadm5_config_params *params,
157	krb5_context context));
158
159kadm5_ret_t
160_kadm5_set_keys __P((
161	kadm5_server_context *context,
162	hdb_entry *ent,
163	const char *password));
164
165kadm5_ret_t
166_kadm5_set_keys2 __P((
167	hdb_entry *ent,
168	int16_t n_key_data,
169	krb5_key_data *key_data));
170
171kadm5_ret_t
172_kadm5_set_keys_randomly __P((kadm5_server_context *context,
173			      hdb_entry *ent,
174			      krb5_keyblock **new_keys,
175			      int *n_keys));
176
177kadm5_ret_t
178_kadm5_set_modifier __P((
179	kadm5_server_context *context,
180	hdb_entry *ent));
181
182kadm5_ret_t
183_kadm5_setup_entry __P((
184	hdb_entry *ent,
185	u_int32_t mask,
186	kadm5_principal_ent_t princ,
187	u_int32_t princ_mask,
188	kadm5_principal_ent_t def,
189	u_int32_t def_mask));
190
191kadm5_ret_t
192kadm5_log_get_version (int fd,
193		       u_int32_t *ver);
194
195kadm5_ret_t
196kadm5_log_init (kadm5_server_context *context);
197
198kadm5_ret_t
199kadm5_log_create (kadm5_server_context *context,
200		  hdb_entry *ent);
201
202kadm5_ret_t
203kadm5_log_delete (kadm5_server_context *context,
204		  krb5_principal princ);
205
206kadm5_ret_t
207kadm5_log_rename (kadm5_server_context *context,
208		  krb5_principal source,
209		  hdb_entry *ent);
210
211kadm5_ret_t
212kadm5_log_modify (kadm5_server_context *context,
213		  hdb_entry *ent,
214		  u_int32_t mask);
215
216kadm5_ret_t
217kadm5_log_end (kadm5_server_context *context);
218
219kadm5_ret_t
220kadm5_log_foreach (kadm5_server_context *context,
221		   void (*func)(kadm5_server_context *server_context,
222				u_int32_t ver,
223				time_t timestamp,
224				enum kadm_ops op,
225				u_int32_t len,
226				krb5_storage *sp));
227
228kadm5_ret_t
229kadm5_log_replay_create (kadm5_server_context *context,
230			 u_int32_t ver,
231			 u_int32_t len,
232			 krb5_storage *sp);
233
234kadm5_ret_t
235kadm5_log_replay_delete (kadm5_server_context *context,
236			 u_int32_t ver,
237			 u_int32_t len,
238			 krb5_storage *sp);
239
240kadm5_ret_t
241kadm5_log_replay_rename (kadm5_server_context *context,
242			 u_int32_t ver,
243			 u_int32_t len,
244			 krb5_storage *sp);
245
246kadm5_ret_t
247kadm5_log_replay_modify (kadm5_server_context *context,
248			 u_int32_t ver,
249			 u_int32_t len,
250			 krb5_storage *sp);
251
252kadm5_ret_t
253kadm5_log_replay (kadm5_server_context *context,
254		  enum kadm_ops op,
255		  u_int32_t ver,
256		  u_int32_t len,
257		  krb5_storage *sp);
258
259krb5_storage *
260kadm5_log_goto_end (int fd);
261
262kadm5_ret_t
263kadm5_log_previous (krb5_storage *sp,
264		    u_int32_t *ver,
265		    time_t *timestamp,
266		    enum kadm_ops *op,
267		    u_int32_t *len);
268
269kadm5_ret_t
270_kadm5_marshal_params __P((krb5_context context,
271			   kadm5_config_params *params,
272			   krb5_data *out));
273
274kadm5_ret_t
275_kadm5_unmarshal_params __P((krb5_context context,
276			     krb5_data *in,
277			     kadm5_config_params *params));
278
279
280
281#endif /* __kadm5_private_h__ */
282