Path: blob/main/crypto/krb5/src/lib/kadm5/admin_internal.h
39537 views
/* -*- mode: c; c-basic-offset: 4; indent-tabs-mode: nil -*- */1/*2* Copyright 1993 OpenVision Technologies, Inc., All Rights Reserved3*4*/56#ifndef __KADM5_ADMIN_INTERNAL_H__7#define __KADM5_ADMIN_INTERNAL_H__89#include <kadm5/admin.h>1011#define KADM5_SERVER_HANDLE_MAGIC 0x123458001213#define CHECK_VERSIONS(struct_version, api_version, old_api_err, new_api_err) \14{ \15if ((struct_version & KADM5_MASK_BITS) != KADM5_STRUCT_VERSION_MASK) \16return KADM5_BAD_STRUCT_VERSION; \17if (struct_version < KADM5_STRUCT_VERSION_1) \18return KADM5_OLD_STRUCT_VERSION; \19if (struct_version > KADM5_STRUCT_VERSION_1) \20return KADM5_NEW_STRUCT_VERSION; \21if ((api_version & KADM5_MASK_BITS) != KADM5_API_VERSION_MASK) \22return KADM5_BAD_API_VERSION; \23if (api_version < KADM5_API_VERSION_2) \24return old_api_err; \25if (api_version > KADM5_API_VERSION_4) \26return new_api_err; \27}2829#define GENERIC_CHECK_HANDLE(handle, old_api_err, new_api_err) \30{ \31kadm5_server_handle_t srvr = handle; \32\33if (srvr == NULL) \34return KADM5_BAD_SERVER_HANDLE; \35if (srvr->magic_number != KADM5_SERVER_HANDLE_MAGIC) \36return KADM5_BAD_SERVER_HANDLE; \37CHECK_VERSIONS(srvr->struct_version, srvr->api_version, \38old_api_err, new_api_err); \39}4041/*42* _KADM5_CHECK_HANDLE calls the function _kadm5_check_handle and43* returns any non-zero error code that function returns.44* _kadm5_check_handle, in client_handle.c and server_handle.c, exists45* in both the server- and client- side libraries. In each library,46* it calls CHECK_HANDLE, which is defined by the appropriate47* _internal.h header file to call GENERIC_CHECK_HANDLE as well as48* CLIENT_CHECK_HANDLE and SERVER_CHECK_HANDLE.49*50* _KADM5_CHECK_HANDLE should be used by a function that needs to51* check the handle but wants to be the same code in both the client52* and server library; it makes a function call to the right handle53* checker. Code that only exists in one library can call the54* CHECK_HANDLE macro, which inlines the test instead of making55* another function call.56*57* Got that?58*/59#define _KADM5_CHECK_HANDLE(handle) \60{ int ecode; if ((ecode = _kadm5_check_handle((void *)handle))) return ecode;}6162int _kadm5_check_handle(void *handle);63kadm5_ret_t _kadm5_chpass_principal_util(void *server_handle,64void *lhandle,65krb5_principal princ,66char *new_pw,67char **ret_pw,68char *msg_ret,69unsigned int msg_len);7071/* this is needed by the alt_prof code I stole. The functions72maybe shouldn't be named krb5_*, but they are. */7374krb5_error_code75krb5_string_to_keysalts(const char *string, const char *tupleseps,76const char *ksaltseps, krb5_boolean dups,77krb5_key_salt_tuple **ksaltp, krb5_int32 *nksaltp);7879#endif /* __KADM5_ADMIN_INTERNAL_H__ */808182