switch to new plugin handler
This commit is contained in:
150
kdc/windc.c
150
kdc/windc.c
@@ -33,41 +33,38 @@
|
|||||||
|
|
||||||
#include "kdc_locl.h"
|
#include "kdc_locl.h"
|
||||||
|
|
||||||
static krb5plugin_windc_ftable *windcft;
|
static int have_plugin = 0;
|
||||||
static void *windcctx;
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Pick the first WINDC module that we find.
|
* Pick the first WINDC module that we find.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
static krb5_error_code KRB5_LIB_CALL
|
||||||
|
load(krb5_context context, const void *plug, void *plugctx, void *userctx)
|
||||||
|
{
|
||||||
|
have_plugin = 1;
|
||||||
|
return KRB5_PLUGIN_NO_HANDLE;
|
||||||
|
}
|
||||||
|
|
||||||
krb5_error_code
|
krb5_error_code
|
||||||
krb5_kdc_windc_init(krb5_context context)
|
krb5_kdc_windc_init(krb5_context context)
|
||||||
{
|
{
|
||||||
#if 0
|
(void)_krb5_plugin_run_f(context, "krb5", "windc",
|
||||||
struct krb5_plugin *list = NULL, *e;
|
KRB5_WINDC_PLUGIN_MINOR, 0, NULL, load);
|
||||||
krb5_error_code ret;
|
|
||||||
|
|
||||||
ret = _krb5_plugin_find(context, PLUGIN_TYPE_DATA, "windc", &list);
|
|
||||||
if(ret != 0 || list == NULL)
|
|
||||||
return 0;
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
for (e = list; e != NULL; e = _krb5_plugin_get_next(e)) {
|
struct generate_uc {
|
||||||
|
hdb_entry_ex *client;
|
||||||
|
krb5_pac *pac;
|
||||||
|
};
|
||||||
|
|
||||||
windcft = _krb5_plugin_get_symbol(e);
|
static krb5_error_code KRB5_LIB_CALL
|
||||||
if (windcft->minor_version < KRB5_WINDC_PLUGIN_MINOR)
|
generate(krb5_context context, const void *plug, void *plugctx, void *userctx)
|
||||||
continue;
|
{
|
||||||
|
krb5plugin_windc_ftable *ft = (krb5plugin_windc_ftable *)plug;
|
||||||
(*windcft->init)(context, &windcctx);
|
struct generate_uc *uc = (struct generate_uc *)userctx;
|
||||||
break;
|
return ft->pac_generate((void *)plug, context, uc->client, uc->pac);
|
||||||
}
|
|
||||||
_krb5_plugin_free(list);
|
|
||||||
if (e == NULL) {
|
|
||||||
krb5_set_error_message(context, ENOENT, "Did not find any WINDC plugin");
|
|
||||||
windcft = NULL;
|
|
||||||
return ENOENT;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -76,10 +73,44 @@ _kdc_pac_generate(krb5_context context,
|
|||||||
hdb_entry_ex *client,
|
hdb_entry_ex *client,
|
||||||
krb5_pac *pac)
|
krb5_pac *pac)
|
||||||
{
|
{
|
||||||
*pac = NULL;
|
struct generate_uc uc;
|
||||||
if (windcft == NULL)
|
|
||||||
|
if (!have_plugin)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
uc.client = client;
|
||||||
|
uc.pac = pac;
|
||||||
|
|
||||||
|
(void)_krb5_plugin_run_f(context, "krb5", "windc",
|
||||||
|
KRB5_WINDC_PLUGIN_MINOR, 0, &uc, generate);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
struct verify_uc {
|
||||||
|
krb5_principal client_principal;
|
||||||
|
krb5_principal delegated_proxy_principal;
|
||||||
|
hdb_entry_ex *client;
|
||||||
|
hdb_entry_ex *server;
|
||||||
|
hdb_entry_ex *krbtgt;
|
||||||
|
krb5_pac *pac;
|
||||||
|
int *verified;
|
||||||
|
};
|
||||||
|
|
||||||
|
static krb5_error_code KRB5_LIB_CALL
|
||||||
|
verify(krb5_context context, const void *plug, void *plugctx, void *userctx)
|
||||||
|
{
|
||||||
|
krb5plugin_windc_ftable *ft = (krb5plugin_windc_ftable *)plug;
|
||||||
|
struct verify_uc *uc = (struct verify_uc *)userctx;
|
||||||
|
krb5_error_code ret;
|
||||||
|
|
||||||
|
ret = ft->pac_verify((void *)plug, context,
|
||||||
|
uc->client_principal,
|
||||||
|
uc->delegated_proxy_principal,
|
||||||
|
uc->client, uc->server, uc->krbtgt, uc->pac);
|
||||||
|
if (ret == 0)
|
||||||
|
(*uc->verified) = 1;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
return (windcft->pac_generate)(windcctx, context, client, pac);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
krb5_error_code
|
krb5_error_code
|
||||||
@@ -92,20 +123,47 @@ _kdc_pac_verify(krb5_context context,
|
|||||||
krb5_pac *pac,
|
krb5_pac *pac,
|
||||||
int *verified)
|
int *verified)
|
||||||
{
|
{
|
||||||
krb5_error_code ret;
|
struct verify_uc uc;
|
||||||
|
|
||||||
if (windcft == NULL)
|
if (!have_plugin)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
ret = windcft->pac_verify(windcctx, context,
|
uc.client_principal = client_principal;
|
||||||
client_principal,
|
uc.delegated_proxy_principal = delegated_proxy_principal;
|
||||||
delegated_proxy_principal,
|
uc.client = client;
|
||||||
client, server, krbtgt, pac);
|
uc.server = server;
|
||||||
if (ret == 0)
|
uc.krbtgt = krbtgt;
|
||||||
*verified = 1;
|
uc.pac = pac;
|
||||||
return ret;
|
uc.verified = verified;
|
||||||
|
|
||||||
|
(void)_krb5_plugin_run_f(context, "krb5", "windc",
|
||||||
|
KRB5_WINDC_PLUGIN_MINOR, 0, &uc, verify);
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
struct check_uc {
|
||||||
|
krb5_kdc_configuration *config;
|
||||||
|
hdb_entry_ex *client_ex;
|
||||||
|
const char *client_name;
|
||||||
|
hdb_entry_ex *server_ex;
|
||||||
|
const char *server_name;
|
||||||
|
KDC_REQ *req;
|
||||||
|
METHOD_DATA *method_data;
|
||||||
|
};
|
||||||
|
|
||||||
|
static krb5_error_code KRB5_LIB_CALL
|
||||||
|
check(krb5_context context, const void *plug, void *plugctx, void *userctx)
|
||||||
|
{
|
||||||
|
krb5plugin_windc_ftable *ft = (krb5plugin_windc_ftable *)plug;
|
||||||
|
struct check_uc *uc = (struct check_uc *)userctx;
|
||||||
|
|
||||||
|
return ft->client_access((void *)plug, context, uc->config,
|
||||||
|
uc->client_ex, uc->client_name,
|
||||||
|
uc->server_ex, uc->server_name,
|
||||||
|
uc->req, uc->method_data);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
krb5_error_code
|
krb5_error_code
|
||||||
_kdc_check_access(krb5_context context,
|
_kdc_check_access(krb5_context context,
|
||||||
krb5_kdc_configuration *config,
|
krb5_kdc_configuration *config,
|
||||||
@@ -114,15 +172,23 @@ _kdc_check_access(krb5_context context,
|
|||||||
KDC_REQ *req,
|
KDC_REQ *req,
|
||||||
METHOD_DATA *method_data)
|
METHOD_DATA *method_data)
|
||||||
{
|
{
|
||||||
if (windcft == NULL)
|
struct check_uc uc;
|
||||||
|
|
||||||
|
if (!have_plugin)
|
||||||
return kdc_check_flags(context, config,
|
return kdc_check_flags(context, config,
|
||||||
client_ex, client_name,
|
client_ex, client_name,
|
||||||
server_ex, server_name,
|
server_ex, server_name,
|
||||||
req->msg_type == krb_as_req);
|
req->msg_type == krb_as_req);
|
||||||
|
|
||||||
return (windcft->client_access)(windcctx,
|
uc.config = config;
|
||||||
context, config,
|
uc.client_ex = client_ex;
|
||||||
client_ex, client_name,
|
uc.client_name = client_name;
|
||||||
server_ex, server_name,
|
uc.server_ex = server_ex;
|
||||||
req, method_data);
|
uc.server_name = server_name;
|
||||||
|
uc.req = req;
|
||||||
|
uc.method_data = method_data;
|
||||||
|
|
||||||
|
return _krb5_plugin_run_f(context, "krb5", "windc",
|
||||||
|
KRB5_WINDC_PLUGIN_MINOR, 0, &uc, check);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user