xref: /titanic_44/usr/src/lib/krb5/kadm5/server_internal.h (revision ea8dc4b6d2251b437950c0056bc626b311c73c27)
1 /*
2  * Copyright 2004 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.27 1996/10/21 20:29:58 bjaspan 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 #include    <memory.h>
41 #include    <stdlib.h>
42 #include    "k5-int.h"
43 #include    <krb5/kdb.h>
44 #include    <kadm5/admin.h>
45 #include    "admin_internal.h"
46 #include    "adb.h"
47 
48 typedef struct _kadm5_server_handle_t {
49 	krb5_ui_4	magic_number;
50 	krb5_ui_4	struct_version;
51 	krb5_ui_4	api_version;
52 	krb5_context	context;
53 	krb5_principal	current_caller;
54 	kadm5_config_params  params;
55 	struct _kadm5_server_handle_t *lhandle;
56 	osa_adb_policy_t policy_db;
57 	krb5_keyblock	master_keyblock;
58 } kadm5_server_handle_rec, *kadm5_server_handle_t;
59 
60 kadm5_ret_t    adb_policy_init(kadm5_server_handle_t handle);
61 kadm5_ret_t    adb_policy_close(kadm5_server_handle_t handle);
62 kadm5_ret_t    passwd_check(kadm5_server_handle_t handle,
63 			    char *pass, int use_policy,
64 			    kadm5_policy_ent_t policy,
65 			    krb5_principal principal);
66 kadm5_ret_t    principal_exists(krb5_principal principal);
67 krb5_error_code	    kdb_init_master(kadm5_server_handle_t handle,
68 				    char *r, int from_keyboard);
69 krb5_error_code	    kdb_init_hist(kadm5_server_handle_t handle,
70 				  char *r);
71 krb5_error_code     kdb_get_entry(kadm5_server_handle_t handle,
72 				  krb5_principal principal, krb5_db_entry *kdb,
73 				  osa_princ_ent_rec *adb);
74 krb5_error_code     kdb_free_entry(kadm5_server_handle_t handle,
75 				   krb5_db_entry *kdb, osa_princ_ent_rec *adb);
76 krb5_error_code     kdb_put_entry(kadm5_server_handle_t handle,
77 				  krb5_db_entry *kdb, osa_princ_ent_rec *adb);
78 krb5_error_code     kdb_delete_entry(kadm5_server_handle_t handle,
79 				     krb5_principal name);
80 
81 int		    init_dict(kadm5_config_params *);
82 int		    find_word(const char *word);
83 void		    destroy_dict(void);
84 
85 /*
86  * *Warning*
87  * *Warning*	    This is going to break if we
88  * *Warning*	    ever go multi-threaded
89  * *Warning*
90  */
91 extern	krb5_principal	current_caller;
92 
93 /*
94  * Why is this (or something similar) not defined *anywhere* in krb5?
95  */
96 #define KSUCCESS	0
97 #define WORD_NOT_FOUND	1
98 
99 /*
100  * all the various mask bits or'd together
101  */
102 
103 #define	ALL_PRINC_MASK \
104  (KADM5_PRINCIPAL | KADM5_PRINC_EXPIRE_TIME | KADM5_PW_EXPIRATION | \
105   KADM5_LAST_PWD_CHANGE | KADM5_ATTRIBUTES | KADM5_MAX_LIFE | \
106   KADM5_MOD_TIME | KADM5_MOD_NAME | KADM5_KVNO | KADM5_MKVNO | \
107   KADM5_AUX_ATTRIBUTES | KADM5_POLICY_CLR | KADM5_POLICY | \
108   KADM5_MAX_RLIFE | KADM5_TL_DATA | KADM5_KEY_DATA)
109 
110 #define ALL_POLICY_MASK \
111  (KADM5_POLICY | KADM5_PW_MAX_LIFE | KADM5_PW_MIN_LIFE | \
112   KADM5_PW_MIN_LENGTH | KADM5_PW_MIN_CLASSES | KADM5_PW_HISTORY_NUM | \
113   KADM5_REF_COUNT)
114 
115 #define SERVER_CHECK_HANDLE(handle) \
116 { \
117 	kadm5_server_handle_t srvr = \
118 	     (kadm5_server_handle_t) handle; \
119  \
120 	if (! srvr->current_caller) \
121 		return KADM5_BAD_SERVER_HANDLE; \
122 	if (! srvr->lhandle) \
123 	        return KADM5_BAD_SERVER_HANDLE; \
124 }
125 
126 #define CHECK_HANDLE(handle) \
127      GENERIC_CHECK_HANDLE(handle, KADM5_OLD_SERVER_API_VERSION, \
128 			  KADM5_NEW_SERVER_API_VERSION) \
129      SERVER_CHECK_HANDLE(handle)
130 
131 #endif /* __KADM5_SERVER_INTERNAL_H__ */
132