xref: /titanic_41/usr/src/lib/krb5/kadm5/admin_internal.h (revision 95efa359b507db290a2484b8f615822b1e06096f)
1 #pragma ident	"%Z%%M%	%I%	%E% SMI"
2 
3 /*
4  * WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING
5  *
6  *	Openvision retains the copyright to derivative works of
7  *	this source code.  Do *NOT* create a derivative of this
8  *	source code before consulting with your legal department.
9  *	Do *NOT* integrate *ANY* of this source code into another
10  *	product before consulting with your legal department.
11  *
12  *	For further information, read the top-level Openvision
13  *	copyright which is contained in the top-level MIT Kerberos
14  *	copyright.
15  *
16  * WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING
17  *
18  */
19 
20 
21 /*
22  * Copyright 1993 OpenVision Technologies, Inc., All Rights Reserved
23  *
24  */
25 
26 #ifndef __KADM5_ADMIN_INTERNAL_H__
27 #define __KADM5_ADMIN_INTERNAL_H__
28 
29 #include <kadm5/admin.h>
30 
31 #ifdef DEBUG
32 #define ADMIN_LOG(a, b, c) syslog(a, b, c);
33 #define ADMIN_LOGO(a, b) syslog(a, b);
34 #else
35 #define ADMIN_LOG(a, b, c)
36 #define ADMIN_LOGO(a, b)
37 #endif
38 
39 #define KADM5_SERVER_HANDLE_MAGIC	0x12345800
40 
41 #define GENERIC_CHECK_HANDLE(handle, old_api_version, new_api_version) \
42 { \
43 	kadm5_server_handle_t srvr = \
44 	     (kadm5_server_handle_t) handle; \
45  \
46 	if (! srvr) \
47 		return KADM5_BAD_SERVER_HANDLE; \
48 	if (srvr->magic_number != KADM5_SERVER_HANDLE_MAGIC) \
49 		return KADM5_BAD_SERVER_HANDLE; \
50 	if ((srvr->struct_version & KADM5_MASK_BITS) != \
51 	    KADM5_STRUCT_VERSION_MASK) \
52 		return KADM5_BAD_STRUCT_VERSION; \
53 	if (srvr->struct_version < KADM5_STRUCT_VERSION_1) \
54 		return KADM5_OLD_STRUCT_VERSION; \
55 	if (srvr->struct_version > KADM5_STRUCT_VERSION_1) \
56 		return KADM5_NEW_STRUCT_VERSION; \
57 	if ((srvr->api_version & KADM5_MASK_BITS) != \
58 	    KADM5_API_VERSION_MASK) \
59 		return KADM5_BAD_API_VERSION; \
60 	if (srvr->api_version < KADM5_API_VERSION_1) \
61 		return old_api_version; \
62 	if (srvr->api_version > KADM5_API_VERSION_2) \
63 		return new_api_version; \
64 }
65 
66 /*
67  * _KADM5_CHECK_HANDLE calls the function _kadm5_check_handle and
68  * returns any non-zero error code that function returns.
69  * _kadm5_check_handle, in client_handle.c and server_handle.c, exists
70  * in both the server- and client- side libraries.  In each library,
71  * it calls CHECK_HANDLE, which is defined by the appropriate
72  * _internal.h header file to call GENERIC_CHECK_HANDLE as well as
73  * CLIENT_CHECK_HANDLE and SERVER_CHECK_HANDLE.
74  *
75  * _KADM5_CHECK_HANDLE should be used by a function that needs to
76  * check the handle but wants to be the same code in both the client
77  * and server library; it makes a function call to the right handle
78  * checker.  Code that only exists in one library can call the
79  * CHECK_HANDLE macro, which inlines the test instead of making
80  * another function call.
81  *
82  * Got that?
83  */
84 #define _KADM5_CHECK_HANDLE(handle) \
85 { int ecode; if ((ecode = _kadm5_check_handle((void *)handle))) return ecode;}
86 
87 int         _kadm5_check_handle(void *handle);
88 kadm5_ret_t _kadm5_chpass_principal_util(void *server_handle,
89 					 void *lhandle,
90 					 krb5_principal princ,
91 					 char *new_pw,
92 					 char **ret_pw,
93 					 char *msg_ret,
94 					 unsigned int msg_len);
95 
96 /* this is needed by the alt_prof code I stole.  The functions
97    maybe shouldn't be named krb5_*, but they are. */
98 
99 krb5_error_code
100 krb5_string_to_keysalts(char *string, const char *tupleseps,
101 			const char *ksaltseps, krb5_boolean dups,
102 			krb5_key_salt_tuple **ksaltp, krb5_int32 *nksaltp);
103 
104 krb5_error_code
105 krb5_string_to_flags(char* string, const char* positive, const char* negative,
106 		     krb5_flags *flagsp);
107 
108 #endif /* __KADM5_ADMIN_INTERNAL_H__ */
109