summaryrefslogtreecommitdiffstats
path: root/src/lib/kadm5/admin_internal.h
blob: d73837e6797e24c00022805fb15d2687dd5fb588 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
/*
 * Copyright 1993 OpenVision Technologies, Inc., All Rights Reserved
 *
 * $Header$
 */

#ifndef __KADM5_ADMIN_INTERNAL_H__
#define __KADM5_ADMIN_INTERNAL_H__

#include <kadm5/admin.h>

#define KADM5_SERVER_HANDLE_MAGIC	0x12345800

#define GENERIC_CHECK_HANDLE(handle, old_api_version, new_api_version) \
{ \
	kadm5_server_handle_t srvr = \
	     (kadm5_server_handle_t) handle; \
 \
	if (! srvr) \
		return KADM5_BAD_SERVER_HANDLE; \
	if (srvr->magic_number != KADM5_SERVER_HANDLE_MAGIC) \
		return KADM5_BAD_SERVER_HANDLE; \
	if ((srvr->struct_version & KADM5_MASK_BITS) != \
	    KADM5_STRUCT_VERSION_MASK) \
		return KADM5_BAD_STRUCT_VERSION; \
	if (srvr->struct_version < KADM5_STRUCT_VERSION_1) \
		return KADM5_OLD_STRUCT_VERSION; \
	if (srvr->struct_version > KADM5_STRUCT_VERSION_1) \
		return KADM5_NEW_STRUCT_VERSION; \
	if ((srvr->api_version & KADM5_MASK_BITS) != \
	    KADM5_API_VERSION_MASK) \
		return KADM5_BAD_API_VERSION; \
	if (srvr->api_version < KADM5_API_VERSION_1) \
		return old_api_version; \
	if (srvr->api_version > KADM5_API_VERSION_2) \
		return new_api_version; \
}

/*
 * _KADM5_CHECK_HANDLE calls the function _kadm5_check_handle and
 * returns any non-zero error code that function returns.
 * _kadm5_check_handle, in client_handle.c and server_handle.c, exists
 * in both the server- and client- side libraries.  In each library,
 * it calls CHECK_HANDLE, which is defined by the appropriate
 * _internal.h header file to call GENERIC_CHECK_HANDLE as well as
 * CLIENT_CHECK_HANDLE and SERVER_CHECK_HANDLE.
 *
 * _KADM5_CHECK_HANDLE should be used by a function that needs to
 * check the handle but wants to be the same code in both the client
 * and server library; it makes a function call to the right handle
 * checker.  Code that only exists in one library can call the
 * CHECK_HANDLE macro, which inlines the test instead of making
 * another function call.
 *
 * Got that?
 */
#define _KADM5_CHECK_HANDLE(handle) \
{ int code; if (code = _kadm5_check_handle((void *)handle)) return code; }

kadm5_ret_t _kadm5_chpass_principal_util(void *server_handle,
					 void *lhandle,
					 krb5_principal princ,
					 char *new_pw, 
					 char **ret_pw,
					 char *msg_ret);

/* this is needed by the alt_prof code I stole.  The functions
   maybe shouldn't be named krb5_*, but they are. */

krb5_error_code
krb5_string_to_keysalts(char *string, const char *tupleseps,
			const char *ksaltseps, krb5_boolean dups,
			krb5_key_salt_tuple **ksaltp, krb5_int32 *nksaltp);

krb5_error_code
krb5_string_to_flags(char* string, const char* positive, const char* negative,
		     krb5_flags *flagsp);

#endif /* __KADM5_ADMIN_INTERNAL_H__ */