1 /* -*- mode: c; c-basic-offset: 4; indent-tabs-mode: nil -*- */ 2 /* 3 * Copyright 1993 OpenVision Technologies, Inc., All Rights Reserved 4 * 5 */ 6 7 #ifndef __KADM5_ADMIN_INTERNAL_H__ 8 #define __KADM5_ADMIN_INTERNAL_H__ 9 10 #include <kadm5/admin.h> 11 12 #define KADM5_SERVER_HANDLE_MAGIC 0x12345800 13 14 #define CHECK_VERSIONS(struct_version, api_version, old_api_err, new_api_err) \ 15 { \ 16 if ((struct_version & KADM5_MASK_BITS) != KADM5_STRUCT_VERSION_MASK) \ 17 return KADM5_BAD_STRUCT_VERSION; \ 18 if (struct_version < KADM5_STRUCT_VERSION_1) \ 19 return KADM5_OLD_STRUCT_VERSION; \ 20 if (struct_version > KADM5_STRUCT_VERSION_1) \ 21 return KADM5_NEW_STRUCT_VERSION; \ 22 if ((api_version & KADM5_MASK_BITS) != KADM5_API_VERSION_MASK) \ 23 return KADM5_BAD_API_VERSION; \ 24 if (api_version < KADM5_API_VERSION_2) \ 25 return old_api_err; \ 26 if (api_version > KADM5_API_VERSION_4) \ 27 return new_api_err; \ 28 } 29 30 #define GENERIC_CHECK_HANDLE(handle, old_api_err, new_api_err) \ 31 { \ 32 kadm5_server_handle_t srvr = handle; \ 33 \ 34 if (srvr == NULL) \ 35 return KADM5_BAD_SERVER_HANDLE; \ 36 if (srvr->magic_number != KADM5_SERVER_HANDLE_MAGIC) \ 37 return KADM5_BAD_SERVER_HANDLE; \ 38 CHECK_VERSIONS(srvr->struct_version, srvr->api_version, \ 39 old_api_err, new_api_err); \ 40 } 41 42 /* 43 * _KADM5_CHECK_HANDLE calls the function _kadm5_check_handle and 44 * returns any non-zero error code that function returns. 45 * _kadm5_check_handle, in client_handle.c and server_handle.c, exists 46 * in both the server- and client- side libraries. In each library, 47 * it calls CHECK_HANDLE, which is defined by the appropriate 48 * _internal.h header file to call GENERIC_CHECK_HANDLE as well as 49 * CLIENT_CHECK_HANDLE and SERVER_CHECK_HANDLE. 50 * 51 * _KADM5_CHECK_HANDLE should be used by a function that needs to 52 * check the handle but wants to be the same code in both the client 53 * and server library; it makes a function call to the right handle 54 * checker. Code that only exists in one library can call the 55 * CHECK_HANDLE macro, which inlines the test instead of making 56 * another function call. 57 * 58 * Got that? 59 */ 60 #define _KADM5_CHECK_HANDLE(handle) \ 61 { int ecode; if ((ecode = _kadm5_check_handle((void *)handle))) return ecode;} 62 63 int _kadm5_check_handle(void *handle); 64 kadm5_ret_t _kadm5_chpass_principal_util(void *server_handle, 65 void *lhandle, 66 krb5_principal princ, 67 char *new_pw, 68 char **ret_pw, 69 char *msg_ret, 70 unsigned int msg_len); 71 72 /* this is needed by the alt_prof code I stole. The functions 73 maybe shouldn't be named krb5_*, but they are. */ 74 75 krb5_error_code 76 krb5_string_to_keysalts(const char *string, const char *tupleseps, 77 const char *ksaltseps, krb5_boolean dups, 78 krb5_key_salt_tuple **ksaltp, krb5_int32 *nksaltp); 79 80 #endif /* __KADM5_ADMIN_INTERNAL_H__ */ 81