Use function pointer trampoline for easier dual use (without radiation-hardening capability).

git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@3948 ec53bebd-3082-4978-b11e-865c3cabbd6b
This commit is contained in:
Johan Danielsson
1997-11-11 21:21:47 +00:00
parent a00258bda6
commit 7d293dc9fb
8 changed files with 159 additions and 65 deletions

View File

@@ -11,8 +11,8 @@ idir = $(top_builddir)/include/kadm5
inc_DATA = kadm5_err.h
COMMON_SOURCES = \
acl.c chpass_c.c chpass_s.c context_s.c create_c.c \
create_s.c delete_c.c delete_s.c destroy_c.c \
acl.c chpass_c.c chpass_s.c common_glue.c context_s.c \
create_c.c create_s.c delete_c.c delete_s.c destroy_c.c \
destroy_s.c ent_setup.c error.c flush.c free.c \
get_c.c get_s.c get_princs_c.c get_princs_s.c \
init_c.c init_s.c kadm5_err.c \

View File

@@ -38,8 +38,43 @@
#include "kadm5_locl.h"
/* $Id$ */
RCSID("$Id$");
#define __CALL(FUNC) kadm5 ## _c_ ## FUNC
kadm5_ret_t
kadm5_init_with_password(char *client_name,
char *pass,
char *service_name,
kadm5_config_params *realm_params,
unsigned long struct_version,
unsigned long api_version,
void **server_handle)
{
return kadm5_c_init_with_password(client_name,
pass,
service_name,
realm_params,
struct_version,
api_version,
server_handle);
}
kadm5_ret_t
kadm5_init_with_password_ctx(krb5_context context,
char *client_name,
char *pass,
char *service_name,
kadm5_config_params *realm_params,
unsigned long struct_version,
unsigned long api_version,
void **server_handle)
{
return kadm5_c_init_with_password_ctx(context,
client_name,
pass,
service_name,
realm_params,
struct_version,
api_version,
server_handle);
}
#include "common_glue.c"

View File

@@ -36,20 +36,18 @@
* SUCH DAMAGE.
*/
#include "kadm5_locl.h"
RCSID("$Id$");
/* this file is included by client_glue.c, and server_glue.c */
#ifndef __CALL
#error Must define __CALL
#endif
#define __CALL(F, P) (*((kadm5_common_context*)server_handle)->funcs.F)P;
kadm5_ret_t
kadm5_chpass_principal(void *server_handle,
krb5_principal princ,
char *password)
{
return __CALL(chpass_principal(server_handle, princ, password));
return __CALL(chpass_principal, (server_handle, princ, password));
}
kadm5_ret_t
@@ -58,26 +56,26 @@ kadm5_create_principal(void *server_handle,
u_int32_t mask,
char *password)
{
return __CALL(create_principal(server_handle, princ, mask, password));
return __CALL(create_principal, (server_handle, princ, mask, password));
}
kadm5_ret_t
kadm5_delete_principal(void *server_handle,
krb5_principal princ)
{
return __CALL(delete_principal(server_handle, princ));
return __CALL(delete_principal, (server_handle, princ));
}
kadm5_ret_t
kadm5_destroy (void *server_handle)
{
return __CALL(destroy(server_handle));
return __CALL(destroy, (server_handle));
}
kadm5_ret_t
kadm5_flush (void *server_handle)
{
return __CALL(flush(server_handle));
return __CALL(flush, (server_handle));
}
kadm5_ret_t
@@ -86,45 +84,7 @@ kadm5_get_principal(void *server_handle,
kadm5_principal_ent_t out,
u_int32_t mask)
{
return __CALL(get_principal(server_handle, princ, out, mask));
}
kadm5_ret_t
kadm5_init_with_password(char *client_name,
char *pass,
char *service_name,
kadm5_config_params *realm_params,
unsigned long struct_version,
unsigned long api_version,
void **server_handle)
{
return __CALL(init_with_password(client_name,
pass,
service_name,
realm_params,
struct_version,
api_version,
server_handle));
}
kadm5_ret_t
kadm5_init_with_password_ctx(krb5_context context,
char *client_name,
char *pass,
char *service_name,
kadm5_config_params *realm_params,
unsigned long struct_version,
unsigned long api_version,
void **server_handle)
{
return __CALL(init_with_password_ctx(context,
client_name,
pass,
service_name,
realm_params,
struct_version,
api_version,
server_handle));
return __CALL(get_principal, (server_handle, princ, out, mask));
}
kadm5_ret_t
@@ -132,7 +92,7 @@ kadm5_modify_principal(void *server_handle,
kadm5_principal_ent_t princ,
u_int32_t mask)
{
return __CALL(modify_principal(server_handle, princ, mask));
return __CALL(modify_principal, (server_handle, princ, mask));
}
kadm5_ret_t
@@ -141,7 +101,7 @@ kadm5_randkey_principal(void *server_handle,
krb5_keyblock **new_keys,
int *n_keys)
{
return __CALL(randkey_principal(server_handle, princ, new_keys, n_keys));
return __CALL(randkey_principal, (server_handle, princ, new_keys, n_keys));
}
kadm5_ret_t
@@ -149,7 +109,7 @@ kadm5_rename_principal(void *server_handle,
krb5_principal source,
krb5_principal target)
{
return __CALL(rename_principal(server_handle, source, target));
return __CALL(rename_principal, (server_handle, source, target));
}
kadm5_ret_t
@@ -158,12 +118,12 @@ kadm5_get_principals(void *server_handle,
char ***princs,
int *count)
{
return __CALL(get_principals(server_handle, exp, princs, count));
return __CALL(get_principals, (server_handle, exp, princs, count));
}
kadm5_ret_t
kadm5_get_privs(void *server_handle,
u_int32_t *privs)
{
return __CALL(get_privs(server_handle, privs));
return __CALL(get_privs, (server_handle, privs));
}

View File

@@ -40,6 +40,24 @@
RCSID("$Id$");
static void
set_funcs(kadm5_server_context *c)
{
#define SET(C, F) (C)->funcs.F = kadm5 ## _s_ ## F
SET(c, chpass_principal);
SET(c, chpass_principal);
SET(c, create_principal);
SET(c, delete_principal);
SET(c, destroy);
SET(c, flush);
SET(c, get_principal);
SET(c, get_principals);
SET(c, get_privs);
SET(c, modify_principal);
SET(c, randkey_principal);
SET(c, rename_principal);
};
kadm5_ret_t
_kadm5_s_init_context(kadm5_server_context **ctx,
kadm5_config_params *params,
@@ -49,6 +67,7 @@ _kadm5_s_init_context(kadm5_server_context **ctx,
if(*ctx == NULL)
return ENOMEM;
memset(*ctx, 0, sizeof(**ctx));
set_funcs(*ctx);
(*ctx)->context = context;
initialize_kadm5_error_table(&context->et_list);
#if 0

View File

@@ -48,7 +48,6 @@ kadm5_s_destroy(void *server_handle)
ret = context->db->destroy(context->context, context->db);
if(context->my_context)
krb5_free_context(context->context);
free(context->config.realm);
return ret;
}

View File

@@ -44,6 +44,24 @@
RCSID("$Id$");
static void
set_funcs(kadm5_client_context *c)
{
#define SET(C, F) (C)->funcs.F = kadm5 ## _c_ ## F
SET(c, chpass_principal);
SET(c, chpass_principal);
SET(c, create_principal);
SET(c, delete_principal);
SET(c, destroy);
SET(c, flush);
SET(c, get_principal);
SET(c, get_principals);
SET(c, get_privs);
SET(c, modify_principal);
SET(c, randkey_principal);
SET(c, rename_principal);
};
kadm5_ret_t
_kadm5_c_init_context(kadm5_client_context **ctx,
kadm5_config_params *params,
@@ -53,6 +71,7 @@ _kadm5_c_init_context(kadm5_client_context **ctx,
if(*ctx == NULL)
return ENOMEM;
memset(*ctx, 0, sizeof(**ctx));
set_funcs(*ctx);
(*ctx)->context = context;
if(params->mask & KADM5_CONFIG_REALM)
(*ctx)->realm = strdup(params->realm);

View File

@@ -62,10 +62,36 @@
#include <roken.h>
#include <parse_units.h>
struct kadm_func {
kadm5_ret_t (*chpass_principal) (void *, krb5_principal, char*);
kadm5_ret_t (*create_principal) (void*, kadm5_principal_ent_t,
u_int32_t, char*);
kadm5_ret_t (*delete_principal) (void*, krb5_principal);
kadm5_ret_t (*destroy) (void*);
kadm5_ret_t (*flush) (void*);
kadm5_ret_t (*get_principal) (void*, krb5_principal,
kadm5_principal_ent_t, u_int32_t);
kadm5_ret_t (*get_principals) (void*, const char*, char***, int*);
kadm5_ret_t (*get_privs) (void*, u_int32_t*);
kadm5_ret_t (*modify_principal) (void*, kadm5_principal_ent_t, u_int32_t);
kadm5_ret_t (*randkey_principal) (void*, krb5_principal,
krb5_keyblock**, int*);
kadm5_ret_t (*rename_principal) (void*, krb5_principal, krb5_principal);
};
/* XXX should be integrated */
typedef struct kadm5_common_context {
krb5_context context;
krb5_boolean my_context;
struct kadm_func funcs;
void *data;
}kadm5_common_context;
typedef struct kadm5_server_context {
krb5_context context;
krb5_boolean my_context;
kadm5_config_params config;
struct kadm_func funcs;
/* */
HDB *db;
krb5_principal caller;
unsigned acl_flags;
@@ -75,7 +101,8 @@ typedef struct kadm5_server_context {
typedef struct kadm5_client_context {
krb5_context context;
krb5_boolean my_context;
kadm5_config_params config;
struct kadm_func funcs;
/* */
krb5_auth_context ac;
char *realm;
char *admin_server;

View File

@@ -38,8 +38,43 @@
#include "kadm5_locl.h"
/* $Id$ */
RCSID("$Id$");
#define __CALL(FUNC) kadm5 ## _s_ ## FUNC
kadm5_ret_t
kadm5_init_with_password(char *client_name,
char *pass,
char *service_name,
kadm5_config_params *realm_params,
unsigned long struct_version,
unsigned long api_version,
void **server_handle)
{
return kadm5_s_init_with_password(client_name,
pass,
service_name,
realm_params,
struct_version,
api_version,
server_handle);
}
kadm5_ret_t
kadm5_init_with_password_ctx(krb5_context context,
char *client_name,
char *pass,
char *service_name,
kadm5_config_params *realm_params,
unsigned long struct_version,
unsigned long api_version,
void **server_handle)
{
return kadm5_s_init_with_password_ctx(context,
client_name,
pass,
service_name,
realm_params,
struct_version,
api_version,
server_handle);
}
#include "common_glue.c"