xref: /titanic_41/usr/src/lib/krb5/kadm5/server_internal.h (revision 99ebb4ca412cb0a19d77a3899a87c055b9c30fa8)
1 /*
2  * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
3  * Use is subject to license terms.
4  */
5 #pragma ident	"%Z%%M%	%I%	%E% SMI"
6 
7 /*
8  * WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING
9  *
10  *	Openvision retains the copyright to derivative works of
11  *	this source code.  Do *NOT* create a derivative of this
12  *	source code before consulting with your legal department.
13  *	Do *NOT* integrate *ANY* of this source code into another
14  *	product before consulting with your legal department.
15  *
16  *	For further information, read the top-level Openvision
17  *	copyright which is contained in the top-level MIT Kerberos
18  *	copyright.
19  *
20  * WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING
21  *
22  */
23 
24 
25 /*
26  * Copyright 1993 OpenVision Technologies, Inc., All Rights Reserved
27  *
28  * $Header: /cvs/krbdev/krb5/src/lib/kadm5/server_internal.h,v 1.31 2001/07/08 12:24:56 epeisach Exp $
29  */
30 
31 /*
32  * This header file is used internally by the Admin API server
33  * libraries and Admin server.  IF YOU THINK YOU NEED TO USE THIS FILE
34  * FOR ANYTHING, YOU'RE ALMOST CERTAINLY WRONG.
35  */
36 
37 #ifndef __KADM5_SERVER_INTERNAL_H__
38 #define __KADM5_SERVER_INTERNAL_H__
39 
40 #ifdef HAVE_MEMORY_H
41 #include    <memory.h>
42 #endif
43 #include    <stdlib.h>
44 #include    "k5-int.h"
45 #include    <krb5/kdb.h>
46 #include    <kadm5/admin.h>
47 #include    "admin_internal.h"
48 #include    "adb.h"
49 
50 typedef struct _kadm5_server_handle_t {
51 	krb5_ui_4	magic_number;
52 	krb5_ui_4	struct_version;
53 	krb5_ui_4	api_version;
54 	krb5_context	context;
55 	krb5_principal	current_caller;
56 	kadm5_config_params  params;
57 	struct _kadm5_server_handle_t *lhandle;
58 	osa_adb_policy_t policy_db;
59 	krb5_keyblock	master_keyblock;
60 } kadm5_server_handle_rec, *kadm5_server_handle_t;
61 
62 kadm5_ret_t    adb_policy_init(kadm5_server_handle_t handle);
63 kadm5_ret_t    adb_policy_close(kadm5_server_handle_t handle);
64 kadm5_ret_t    passwd_check(kadm5_server_handle_t handle,
65 			    char *pass, int use_policy,
66 			    kadm5_policy_ent_t policy,
67 			    krb5_principal principal);
68 kadm5_ret_t    principal_exists(krb5_principal principal);
69 krb5_error_code	    kdb_init_master(kadm5_server_handle_t handle,
70 				    char *r, int from_keyboard);
71 krb5_error_code	    kdb_init_hist(kadm5_server_handle_t handle,
72 				  char *r);
73 krb5_error_code     kdb_get_entry(kadm5_server_handle_t handle,
74 				  krb5_principal principal, krb5_db_entry *kdb,
75 				  osa_princ_ent_rec *adb);
76 krb5_error_code     kdb_free_entry(kadm5_server_handle_t handle,
77 				   krb5_db_entry *kdb, osa_princ_ent_rec *adb);
78 krb5_error_code     kdb_put_entry(kadm5_server_handle_t handle,
79 				  krb5_db_entry *kdb, osa_princ_ent_rec *adb);
80 krb5_error_code     kdb_delete_entry(kadm5_server_handle_t handle,
81 				     krb5_principal name);
82 krb5_error_code     kdb_iter_entry(kadm5_server_handle_t handle,
83 				   void (*iter_fct)(void *, krb5_principal),
84 				   void *data);
85 
86 int		    init_dict(kadm5_config_params *);
87 int		    find_word(const char *word);
88 void		    destroy_dict(void);
89 
90 /* XXX this ought to be in libkrb5.a, but isn't */
91 kadm5_ret_t krb5_copy_key_data_contents(krb5_context context,
92 					krb5_key_data *from,
93 					krb5_key_data *to);
94 kadm5_ret_t krb5_free_key_data_contents(krb5_context context,
95 					krb5_key_data *key);
96 
97 /*
98  * *Warning*
99  * *Warning*	    This is going to break if we
100  * *Warning*	    ever go multi-threaded
101  * *Warning*
102  */
103 extern	krb5_principal	current_caller;
104 
105 /*
106  * Why is this (or something similar) not defined *anywhere* in krb5?
107  */
108 #define KSUCCESS	0
109 #define WORD_NOT_FOUND	1
110 
111 /*
112  * all the various mask bits or'd together
113  */
114 
115 #define	ALL_PRINC_MASK \
116  (KADM5_PRINCIPAL | KADM5_PRINC_EXPIRE_TIME | KADM5_PW_EXPIRATION | \
117   KADM5_LAST_PWD_CHANGE | KADM5_ATTRIBUTES | KADM5_MAX_LIFE | \
118   KADM5_MOD_TIME | KADM5_MOD_NAME | KADM5_KVNO | KADM5_MKVNO | \
119   KADM5_AUX_ATTRIBUTES | KADM5_POLICY_CLR | KADM5_POLICY | \
120   KADM5_MAX_RLIFE | KADM5_TL_DATA | KADM5_KEY_DATA)
121 
122 #define ALL_POLICY_MASK \
123  (KADM5_POLICY | KADM5_PW_MAX_LIFE | KADM5_PW_MIN_LIFE | \
124   KADM5_PW_MIN_LENGTH | KADM5_PW_MIN_CLASSES | KADM5_PW_HISTORY_NUM | \
125   KADM5_REF_COUNT)
126 
127 #define SERVER_CHECK_HANDLE(handle) \
128 { \
129 	kadm5_server_handle_t srvr = \
130 	     (kadm5_server_handle_t) handle; \
131  \
132 	if (! srvr->current_caller) \
133 		return KADM5_BAD_SERVER_HANDLE; \
134 	if (! srvr->lhandle) \
135 	        return KADM5_BAD_SERVER_HANDLE; \
136 }
137 
138 #define CHECK_HANDLE(handle) \
139      GENERIC_CHECK_HANDLE(handle, KADM5_OLD_SERVER_API_VERSION, \
140 			  KADM5_NEW_SERVER_API_VERSION) \
141      SERVER_CHECK_HANDLE(handle)
142 
143 #endif /* __KADM5_SERVER_INTERNAL_H__ */
144