17c478bd9Sstevel@tonic-gate /*
2*1da57d55SToomas Soome  * WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING
37c478bd9Sstevel@tonic-gate  *
47c478bd9Sstevel@tonic-gate  *	Openvision retains the copyright to derivative works of
57c478bd9Sstevel@tonic-gate  *	this source code.  Do *NOT* create a derivative of this
67c478bd9Sstevel@tonic-gate  *	source code before consulting with your legal department.
77c478bd9Sstevel@tonic-gate  *	Do *NOT* integrate *ANY* of this source code into another
87c478bd9Sstevel@tonic-gate  *	product before consulting with your legal department.
97c478bd9Sstevel@tonic-gate  *
107c478bd9Sstevel@tonic-gate  *	For further information, read the top-level Openvision
117c478bd9Sstevel@tonic-gate  *	copyright which is contained in the top-level MIT Kerberos
127c478bd9Sstevel@tonic-gate  *	copyright.
137c478bd9Sstevel@tonic-gate  *
147c478bd9Sstevel@tonic-gate  * WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING
157c478bd9Sstevel@tonic-gate  *
167c478bd9Sstevel@tonic-gate  */
177c478bd9Sstevel@tonic-gate 
187c478bd9Sstevel@tonic-gate 
197c478bd9Sstevel@tonic-gate /*
207c478bd9Sstevel@tonic-gate  * Copyright 1993 OpenVision Technologies, Inc., All Rights Reserved
217c478bd9Sstevel@tonic-gate  *
227c478bd9Sstevel@tonic-gate  */
237c478bd9Sstevel@tonic-gate 
247c478bd9Sstevel@tonic-gate #ifndef __KADM5_ADMIN_INTERNAL_H__
257c478bd9Sstevel@tonic-gate #define __KADM5_ADMIN_INTERNAL_H__
267c478bd9Sstevel@tonic-gate 
277c478bd9Sstevel@tonic-gate #include <kadm5/admin.h>
287c478bd9Sstevel@tonic-gate 
297c478bd9Sstevel@tonic-gate #ifdef DEBUG
307c478bd9Sstevel@tonic-gate #define ADMIN_LOG(a, b, c) syslog(a, b, c);
317c478bd9Sstevel@tonic-gate #define ADMIN_LOGO(a, b) syslog(a, b);
327c478bd9Sstevel@tonic-gate #else
337c478bd9Sstevel@tonic-gate #define ADMIN_LOG(a, b, c)
347c478bd9Sstevel@tonic-gate #define ADMIN_LOGO(a, b)
357c478bd9Sstevel@tonic-gate #endif
367c478bd9Sstevel@tonic-gate 
377c478bd9Sstevel@tonic-gate #define KADM5_SERVER_HANDLE_MAGIC	0x12345800
387c478bd9Sstevel@tonic-gate 
397c478bd9Sstevel@tonic-gate #define GENERIC_CHECK_HANDLE(handle, old_api_version, new_api_version) \
407c478bd9Sstevel@tonic-gate { \
417c478bd9Sstevel@tonic-gate 	kadm5_server_handle_t srvr = \
427c478bd9Sstevel@tonic-gate 	     (kadm5_server_handle_t) handle; \
437c478bd9Sstevel@tonic-gate  \
447c478bd9Sstevel@tonic-gate 	if (! srvr) \
457c478bd9Sstevel@tonic-gate 		return KADM5_BAD_SERVER_HANDLE; \
467c478bd9Sstevel@tonic-gate 	if (srvr->magic_number != KADM5_SERVER_HANDLE_MAGIC) \
477c478bd9Sstevel@tonic-gate 		return KADM5_BAD_SERVER_HANDLE; \
487c478bd9Sstevel@tonic-gate 	if ((srvr->struct_version & KADM5_MASK_BITS) != \
497c478bd9Sstevel@tonic-gate 	    KADM5_STRUCT_VERSION_MASK) \
507c478bd9Sstevel@tonic-gate 		return KADM5_BAD_STRUCT_VERSION; \
517c478bd9Sstevel@tonic-gate 	if (srvr->struct_version < KADM5_STRUCT_VERSION_1) \
527c478bd9Sstevel@tonic-gate 		return KADM5_OLD_STRUCT_VERSION; \
537c478bd9Sstevel@tonic-gate 	if (srvr->struct_version > KADM5_STRUCT_VERSION_1) \
547c478bd9Sstevel@tonic-gate 		return KADM5_NEW_STRUCT_VERSION; \
557c478bd9Sstevel@tonic-gate 	if ((srvr->api_version & KADM5_MASK_BITS) != \
567c478bd9Sstevel@tonic-gate 	    KADM5_API_VERSION_MASK) \
577c478bd9Sstevel@tonic-gate 		return KADM5_BAD_API_VERSION; \
587c478bd9Sstevel@tonic-gate 	if (srvr->api_version < KADM5_API_VERSION_1) \
597c478bd9Sstevel@tonic-gate 		return old_api_version; \
607c478bd9Sstevel@tonic-gate 	if (srvr->api_version > KADM5_API_VERSION_2) \
617c478bd9Sstevel@tonic-gate 		return new_api_version; \
627c478bd9Sstevel@tonic-gate }
637c478bd9Sstevel@tonic-gate 
647c478bd9Sstevel@tonic-gate /*
657c478bd9Sstevel@tonic-gate  * _KADM5_CHECK_HANDLE calls the function _kadm5_check_handle and
667c478bd9Sstevel@tonic-gate  * returns any non-zero error code that function returns.
677c478bd9Sstevel@tonic-gate  * _kadm5_check_handle, in client_handle.c and server_handle.c, exists
687c478bd9Sstevel@tonic-gate  * in both the server- and client- side libraries.  In each library,
697c478bd9Sstevel@tonic-gate  * it calls CHECK_HANDLE, which is defined by the appropriate
707c478bd9Sstevel@tonic-gate  * _internal.h header file to call GENERIC_CHECK_HANDLE as well as
717c478bd9Sstevel@tonic-gate  * CLIENT_CHECK_HANDLE and SERVER_CHECK_HANDLE.
727c478bd9Sstevel@tonic-gate  *
737c478bd9Sstevel@tonic-gate  * _KADM5_CHECK_HANDLE should be used by a function that needs to
747c478bd9Sstevel@tonic-gate  * check the handle but wants to be the same code in both the client
757c478bd9Sstevel@tonic-gate  * and server library; it makes a function call to the right handle
767c478bd9Sstevel@tonic-gate  * checker.  Code that only exists in one library can call the
777c478bd9Sstevel@tonic-gate  * CHECK_HANDLE macro, which inlines the test instead of making
787c478bd9Sstevel@tonic-gate  * another function call.
797c478bd9Sstevel@tonic-gate  *
807c478bd9Sstevel@tonic-gate  * Got that?
817c478bd9Sstevel@tonic-gate  */
827c478bd9Sstevel@tonic-gate #define _KADM5_CHECK_HANDLE(handle) \
8356a424ccSmp { int ecode; if ((ecode = _kadm5_check_handle((void *)handle))) return ecode;}
847c478bd9Sstevel@tonic-gate 
8556a424ccSmp int         _kadm5_check_handle(void *handle);
867c478bd9Sstevel@tonic-gate kadm5_ret_t _kadm5_chpass_principal_util(void *server_handle,
877c478bd9Sstevel@tonic-gate 					 void *lhandle,
887c478bd9Sstevel@tonic-gate 					 krb5_principal princ,
89*1da57d55SToomas Soome 					 char *new_pw,
907c478bd9Sstevel@tonic-gate 					 char **ret_pw,
917c478bd9Sstevel@tonic-gate 					 char *msg_ret,
9256a424ccSmp 					 unsigned int msg_len);
937c478bd9Sstevel@tonic-gate 
947c478bd9Sstevel@tonic-gate /* this is needed by the alt_prof code I stole.  The functions
957c478bd9Sstevel@tonic-gate    maybe shouldn't be named krb5_*, but they are. */
967c478bd9Sstevel@tonic-gate 
977c478bd9Sstevel@tonic-gate krb5_error_code
987c478bd9Sstevel@tonic-gate krb5_string_to_keysalts(char *string, const char *tupleseps,
997c478bd9Sstevel@tonic-gate 			const char *ksaltseps, krb5_boolean dups,
1007c478bd9Sstevel@tonic-gate 			krb5_key_salt_tuple **ksaltp, krb5_int32 *nksaltp);
1017c478bd9Sstevel@tonic-gate 
1027c478bd9Sstevel@tonic-gate krb5_error_code
1037c478bd9Sstevel@tonic-gate krb5_string_to_flags(char* string, const char* positive, const char* negative,
1047c478bd9Sstevel@tonic-gate 		     krb5_flags *flagsp);
1057c478bd9Sstevel@tonic-gate 
1067c478bd9Sstevel@tonic-gate #endif /* __KADM5_ADMIN_INTERNAL_H__ */
107