kdc: rename windc to kdc plugin
authorLuke Howard <lukeh@padl.com>
Mon, 3 Jan 2022 00:10:18 +0000 (11:10 +1100)
committerLuke Howard <lukeh@padl.com>
Mon, 3 Jan 2022 05:17:01 +0000 (16:17 +1100)
Rename the "windc" plugin API to the more general "kdc" plugin API, for two
reasons: the Heimdal KDC uses the Windows PAC even when not emulating a domain
controller, and the plugin API has accreted methods that are not specific to
emulating a domain controller (such as referral_policy and finalize_reply).

13 files changed:
include/Makefile.am
kdc/Makefile.am
kdc/NTMakefile
kdc/config.c
kdc/headers.h
kdc/kdc-plugin.c [moved from kdc/windc.c with 84% similarity]
kdc/kdc-plugin.h [moved from kdc/windc_plugin.h with 68% similarity]
kdc/libkdc-exports.def
kdc/misc.c
kdc/version-script.map
tests/plugin/Makefile.am
tests/plugin/check-pac.in
tests/plugin/kdc_test_plugin.c [moved from tests/plugin/windc.c with 78% similarity]

index 16dd2250c20cfa21c06a372936399c67667233bc..7f9286f30a0a33eb3fe04418a4919bf2bfb8058d 100644 (file)
@@ -111,7 +111,7 @@ CLEANFILES =                        \
        vis.h                   \
        wind.h                  \
        wind_err.h              \
-       windc_plugin.h          \
+       kdc-plugin.h            \
        xdbm.h
 
 DISTCLEANFILES =       \
index 1e46c9c1bd9a90f5c6f2456eb636bc14604313b5..c4bed6e02ed83b17f2eb7931ec0beebd1910699b 100644 (file)
@@ -129,7 +129,7 @@ libkdc_la_SOURCES =                 \
        token_validator.c       \
        csr_authorizer.c        \
        process.c               \
-       windc.c                 \
+       kdc-plugin.c            \
        gss_preauth.c
 
 KDC_PROTOS = $(srcdir)/kdc-protos.h $(srcdir)/kdc-private.h
@@ -239,7 +239,7 @@ include_HEADERS = kdc.h $(srcdir)/kdc-protos.h
 noinst_HEADERS = $(srcdir)/kdc-private.h
 
 krb5dir = $(includedir)/krb5
-krb5_HEADERS = windc_plugin.h token_validator_plugin.h csr_authorizer_plugin.h
+krb5_HEADERS = kdc-plugin.h token_validator_plugin.h csr_authorizer_plugin.h
 
 build_HEADERZ = $(krb5_HEADERS) # XXX
 
index 79dc739bc6d69f359c90e4ec397a44cba0154651..9c1810eb0a4d72b6673758323ba26a5a79b684e6 100644 (file)
@@ -51,7 +51,7 @@ INCFILES=\
        $(INCDIR)\kdc.h         \
        $(INCDIR)\kdc-protos.h  \
        $(INCDIR)\kdc-private.h \
-       $(INCDIR)\krb5\windc_plugin.h
+       $(INCDIR)\krb5\kdc-plugin.h
 
 all:: $(INCFILES) $(LIBKDC) $(BINPROGRAMS) $(SBINPROGRAMS) $(LIBEXECPROGRAMS)
 
@@ -109,7 +109,7 @@ LIBKDC_OBJS=\
        $(OBJ)\token_validator.obj      \
        $(OBJ)\csr_authorizer.obj       \
        $(OBJ)\process.obj              \
-       $(OBJ)\windc.obj                \
+       $(OBJ)\kdc-plugin.obj           \
        $(OBJ)\gss_preauth.obj
 
 LIBKDC_LIBS=\
@@ -150,7 +150,7 @@ libkdc_la_SOURCES =                 \
        token_validator.c       \
        csr_authorizer.c        \
        process.c               \
-       windc.c                 \
+       kdc-plugin.c            \
        gss_preauth.c
 
 $(OBJ)\kdc-protos.h: $(libkdc_la_SOURCES)
index 507cb195af3f30cde5b74c143603002b8732a697..e217b9dadfa5dc0f5fd8ac14af4ced0397873343 100644 (file)
@@ -309,7 +309,7 @@ configure(krb5_context context, int argc, char **argv, int *optidx)
        krb5_enctype_disable(context, ETYPE_DES_PCBC_NONE);
     }
 
-    krb5_kdc_windc_init(context);
+    krb5_kdc_plugin_init(context);
 
     krb5_kdc_pkinit_config(context, config);
 
index 6f4d56ae95cb64f8afa9c755cd10a3a95e0d952a..57b2071a792e91a8e07a3df2c9075e695b9c69fb 100644 (file)
 #include <heimntlm.h>
 #endif
 #include <kdc.h>
-#include <windc_plugin.h>
+#include <kdc-plugin.h>
 
 #include <heimbase.h>
 
similarity index 84%
rename from kdc/windc.c
rename to kdc/kdc-plugin.c
index e9ee9963659de5829c17ce3d719fffa340831d6c..569ae580c1af4c4c81293d5a710b9956fc007ba0 100644 (file)
 static int have_plugin = 0;
 
 /*
- * Pick the first WINDC module that we find.
+ * Pick the first KDC plugin module that we find.
  */
 
-static const char *windc_plugin_deps[] = {
+static const char *kdc_plugin_deps[] = {
     "kdc",
     "krb5",
     "hdb",
     NULL
 };
 
-static struct heim_plugin_data windc_plugin_data = {
+static struct heim_plugin_data kdc_plugin_data = {
     "krb5",
-    "windc",
-    KRB5_WINDC_PLUGIN_MINOR,
-    windc_plugin_deps,
+    "kdc",
+    KRB5_KDC_PLUGIN_MINOR,
+    kdc_plugin_deps,
     kdc_get_instance
 };
 
@@ -62,9 +62,9 @@ load(krb5_context context, const void *plug, void *plugctx, void *userctx)
 }
 
 krb5_error_code
-krb5_kdc_windc_init(krb5_context context)
+krb5_kdc_plugin_init(krb5_context context)
 {
-    (void)_krb5_plugin_run_f(context, &windc_plugin_data, 0, NULL, load);
+    (void)_krb5_plugin_run_f(context, &kdc_plugin_data, 0, NULL, load);
 
     return 0;
 }
@@ -80,7 +80,7 @@ struct generate_uc {
 static krb5_error_code KRB5_LIB_CALL
 generate(krb5_context context, const void *plug, void *plugctx, void *userctx)
 {
-    krb5plugin_windc_ftable *ft = (krb5plugin_windc_ftable *)plug;
+    krb5plugin_kdc_ftable *ft = (krb5plugin_kdc_ftable *)plug;
     struct generate_uc *uc = (struct generate_uc *)userctx;    
 
     if (ft->pac_generate == NULL)
@@ -120,7 +120,7 @@ _kdc_pac_generate(krb5_context context,
        uc.pac = pac;
        uc.pac_attributes = pac_attributes;
 
-       ret = _krb5_plugin_run_f(context, &windc_plugin_data,
+       ret = _krb5_plugin_run_f(context, &kdc_plugin_data,
                                 0, &uc, generate);
        if (ret != KRB5_PLUGIN_NO_HANDLE)
            return ret;
@@ -145,7 +145,7 @@ struct verify_uc {
 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;
+    krb5plugin_kdc_ftable *ft = (krb5plugin_kdc_ftable *)plug;
     struct verify_uc *uc = (struct verify_uc *)userctx;
     krb5_error_code ret;
 
@@ -180,14 +180,14 @@ _kdc_pac_verify(krb5_context context,
     uc.krbtgt = krbtgt;
     uc.pac = pac;
 
-    return _krb5_plugin_run_f(context, &windc_plugin_data,
+    return _krb5_plugin_run_f(context, &kdc_plugin_data,
                             0, &uc, verify);
 }
 
 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;
+    krb5plugin_kdc_ftable *ft = (krb5plugin_kdc_ftable *)plug;
 
     if (ft->client_access == NULL)
        return KRB5_PLUGIN_NO_HANDLE;
@@ -200,7 +200,7 @@ _kdc_check_access(astgs_request_t r)
     krb5_error_code ret = KRB5_PLUGIN_NO_HANDLE;
 
     if (have_plugin) {
-        ret = _krb5_plugin_run_f(r->context, &windc_plugin_data,
+        ret = _krb5_plugin_run_f(r->context, &kdc_plugin_data,
                                  0, r, check);
     }
 
@@ -213,7 +213,7 @@ _kdc_check_access(astgs_request_t r)
 static krb5_error_code KRB5_LIB_CALL
 referral_policy(krb5_context context, const void *plug, void *plugctx, void *userctx)
 {
-    krb5plugin_windc_ftable *ft = (krb5plugin_windc_ftable *)plug;
+    krb5plugin_kdc_ftable *ft = (krb5plugin_kdc_ftable *)plug;
 
     if (ft->referral_policy == NULL)
        return KRB5_PLUGIN_NO_HANDLE;
@@ -226,7 +226,7 @@ _kdc_referral_policy(astgs_request_t r)
     krb5_error_code ret = KRB5_PLUGIN_NO_HANDLE;
 
     if (have_plugin)
-        ret = _krb5_plugin_run_f(r->context, &windc_plugin_data, 0, r, referral_policy);
+        ret = _krb5_plugin_run_f(r->context, &kdc_plugin_data, 0, r, referral_policy);
 
     return ret;
 }
@@ -234,7 +234,7 @@ _kdc_referral_policy(astgs_request_t r)
 static krb5_error_code KRB5_LIB_CALL
 finalize_reply(krb5_context context, const void *plug, void *plugctx, void *userctx)
 {
-    krb5plugin_windc_ftable *ft = (krb5plugin_windc_ftable *)plug;
+    krb5plugin_kdc_ftable *ft = (krb5plugin_kdc_ftable *)plug;
 
     if (ft->finalize_reply == NULL)
        return KRB5_PLUGIN_NO_HANDLE;
@@ -247,7 +247,7 @@ _kdc_finalize_reply(astgs_request_t r)
     krb5_error_code ret = KRB5_PLUGIN_NO_HANDLE;
 
     if (have_plugin)
-        ret = _krb5_plugin_run_f(r->context, &windc_plugin_data, 0, r, finalize_reply);
+        ret = _krb5_plugin_run_f(r->context, &kdc_plugin_data, 0, r, finalize_reply);
 
     if (ret == KRB5_PLUGIN_NO_HANDLE)
         ret = 0;
@@ -258,7 +258,7 @@ _kdc_finalize_reply(astgs_request_t r)
 static krb5_error_code KRB5_LIB_CALL
 audit(krb5_context context, const void *plug, void *plugctx, void *userctx)
 {
-    krb5plugin_windc_ftable *ft = (krb5plugin_windc_ftable *)plug;
+    krb5plugin_kdc_ftable *ft = (krb5plugin_kdc_ftable *)plug;
 
     if (ft->audit == NULL)
        return KRB5_PLUGIN_NO_HANDLE;
@@ -266,12 +266,12 @@ audit(krb5_context context, const void *plug, void *plugctx, void *userctx)
 }
 
 krb5_error_code
-_kdc_windc_audit(astgs_request_t r)
+_kdc_plugin_audit(astgs_request_t r)
 {
     krb5_error_code ret = KRB5_PLUGIN_NO_HANDLE;
 
     if (have_plugin)
-        ret = _krb5_plugin_run_f(r->context, &windc_plugin_data, 0, r, audit);
+        ret = _krb5_plugin_run_f(r->context, &kdc_plugin_data, 0, r, audit);
 
     if (ret == KRB5_PLUGIN_NO_HANDLE)
         ret = 0;
similarity index 68%
rename from kdc/windc_plugin.h
rename to kdc/kdc-plugin.h
index 433344e15da0e8cce3e790650e4569618da09d9c..b6b08898f84e1dae7447333292b64c31d45d0539 100644 (file)
@@ -33,8 +33,8 @@
 
 /* $Id$ */
 
-#ifndef HEIMDAL_KDC_WINDC_PLUGIN_H
-#define HEIMDAL_KDC_WINDC_PLUGIN_H 1
+#ifndef HEIMDAL_KDC_KDC_PLUGIN_H
+#define HEIMDAL_KDC_KDC_PLUGIN_H 1
 
 #include <krb5.h>
 #include <kdc.h>
@@ -47,12 +47,12 @@ struct hdb_entry_ex;
  */
 
 typedef krb5_error_code
-(KRB5_CALLCONV *krb5plugin_windc_pac_generate)(void *, krb5_context,
-                                              struct hdb_entry_ex *, /* client */
-                                              struct hdb_entry_ex *, /* server */
-                                              const krb5_keyblock *, /* pk_replykey */
-                                              uint64_t,              /* pac_attributes */
-                                              krb5_pac *);
+(KRB5_CALLCONV *krb5plugin_kdc_pac_generate)(void *, krb5_context,
+                                            struct hdb_entry_ex *, /* client */
+                                            struct hdb_entry_ex *, /* server */
+                                            const krb5_keyblock *, /* pk_replykey */
+                                            uint64_t,        /* pac_attributes */
+                                            krb5_pac *);
 
 /*
  * Verify the PAC KDC signatures by fetching the appropriate TGS key
@@ -61,13 +61,13 @@ typedef krb5_error_code
  */
 
 typedef krb5_error_code
-(KRB5_CALLCONV *krb5plugin_windc_pac_verify)(void *, krb5_context,
-                              const krb5_principal, /* new ticket client */
-                              const krb5_principal, /* delegation proxy */
-                              struct hdb_entry_ex *,/* client */
-                              struct hdb_entry_ex *,/* server */
-                              struct hdb_entry_ex *,/* krbtgt */
-                              krb5_pac *);
+(KRB5_CALLCONV *krb5plugin_kdc_pac_verify)(void *, krb5_context,
+                                          const krb5_principal, /* new ticket client */
+                                          const krb5_principal, /* delegation proxy */
+                                          struct hdb_entry_ex *,/* client */
+                                          struct hdb_entry_ex *,/* server */
+                                          struct hdb_entry_ex *,/* krbtgt */
+                                          krb5_pac *);
 
 /*
  * Authorize the client principal's access to the Authentication Service (AS).
@@ -75,7 +75,7 @@ typedef krb5_error_code
  */
 
 typedef krb5_error_code
-(KRB5_CALLCONV *krb5plugin_windc_client_access)(void *, astgs_request_t);
+(KRB5_CALLCONV *krb5plugin_kdc_client_access)(void *, astgs_request_t);
 
 /*
  * A referral policy plugin can either rewrite the server principal
@@ -89,14 +89,14 @@ typedef krb5_error_code
  */
 
 typedef krb5_error_code
-(KRB5_CALLCONV *krb5plugin_windc_referral_policy)(void *, astgs_request_t r);
+(KRB5_CALLCONV *krb5plugin_kdc_referral_policy)(void *, astgs_request_t);
 
 /*
  * Update the AS or TGS reply immediately prior to encoding.
  */
 
 typedef krb5_error_code
-(KRB5_CALLCONV *krb5plugin_windc_finalize_reply)(void *, astgs_request_t r);
+(KRB5_CALLCONV *krb5plugin_kdc_finalize_reply)(void *, astgs_request_t);
 
 /*
  * Audit an AS or TGS request. This function is called after encoding the
@@ -107,21 +107,21 @@ typedef krb5_error_code
  */
 
 typedef krb5_error_code
-(KRB5_CALLCONV *krb5plugin_windc_audit)(void *, astgs_request_t r);
+(KRB5_CALLCONV *krb5plugin_kdc_audit)(void *, astgs_request_t);
 
-#define KRB5_WINDC_PLUGIN_MINOR                        8
-#define KRB5_WINDC_PLUGING_MINOR KRB5_WINDC_PLUGIN_MINOR
+#define KRB5_KDC_PLUGIN_MINOR          8
+#define KRB5_KDC_PLUGING_MINOR         KRB5_KDC_PLUGIN_MINOR
 
-typedef struct krb5plugin_windc_ftable {
+typedef struct krb5plugin_kdc_ftable {
     int                        minor_version;
     krb5_error_code    (KRB5_CALLCONV *init)(krb5_context, void **);
     void               (KRB5_CALLCONV *fini)(void *);
-    krb5plugin_windc_pac_generate      pac_generate;
-    krb5plugin_windc_pac_verify                pac_verify;
-    krb5plugin_windc_client_access     client_access;
-    krb5plugin_windc_referral_policy   referral_policy;
-    krb5plugin_windc_finalize_reply    finalize_reply;
-    krb5plugin_windc_audit             audit;
-} krb5plugin_windc_ftable;
-
-#endif /* HEIMDAL_KDC_WINDC_PLUGIN_H */
+    krb5plugin_kdc_pac_generate                pac_generate;
+    krb5plugin_kdc_pac_verify          pac_verify;
+    krb5plugin_kdc_client_access       client_access;
+    krb5plugin_kdc_referral_policy     referral_policy;
+    krb5plugin_kdc_finalize_reply      finalize_reply;
+    krb5plugin_kdc_audit               audit;
+} krb5plugin_kdc_ftable;
+
+#endif /* HEIMDAL_KDC_KDC_PLUGIN_H */
index c7efb182614e4c12572fb46d0080be25326ddc71..6fca11d38eff660c32dadfaaf851448df469959e 100644 (file)
@@ -7,7 +7,7 @@ EXPORTS
        kdc_log_msg_va
        kdc_openlog
        kdc_validate_token
-       krb5_kdc_windc_init
+       krb5_kdc_plugin_init
        krb5_kdc_get_config
        krb5_kdc_pkinit_config
        krb5_kdc_set_dbinfo
index 296557300062fce3cde5eed7e96679ae2f60249e..8dbed3aa9f94c3f592710054787861a0cf8c835b 100644 (file)
@@ -343,7 +343,7 @@ _kdc_include_pac_p(astgs_request_t r)
 }
 
 /*
- * Notify the HDB backend and windc plugin of the audited event.
+ * Notify the HDB backend and KDC plugin of the audited event.
  */
 
 krb5_error_code
@@ -352,7 +352,7 @@ _kdc_audit_request(astgs_request_t r)
     krb5_error_code ret;
     struct HDB *hdb;
 
-    ret = _kdc_windc_audit(r);
+    ret = _kdc_plugin_audit(r);
     if (ret == 0 &&
        (hdb = r->clientdb ? r->clientdb : r->config->db[0]) &&
        hdb->hdb_audit)
index ae0cef858b0a56c9cc102b2f1897af2e0caf0e32..c878e4bb4e101b937fe559cd6d2e5eec89359419 100644 (file)
@@ -11,7 +11,7 @@ HEIMDAL_KDC_1.0 {
                kdc_openlog;
                kdc_check_flags;
                kdc_validate_token;
-               krb5_kdc_windc_init;
+               krb5_kdc_plugin_init;
                krb5_kdc_get_config;
                krb5_kdc_pkinit_config;
                krb5_kdc_set_dbinfo;
index 3fb1a2324b9b4adfe90f568273a73d5db44c74fd..5dd43ccb04da3b8f3abb92373313b29ed183655f 100644 (file)
@@ -29,10 +29,10 @@ krb5.conf: krb5.conf.in Makefile
        $(do_subst) < $(srcdir)/krb5.conf.in > krb5.conf.tmp
        mv krb5.conf.tmp krb5.conf
 
-lib_LTLIBRARIES = windc.la
+lib_LTLIBRARIES = kdc_test_plugin.la
 
-windc_la_SOURCES = windc.c
-windc_la_LDFLAGS = -module
+kdc_test_plugin_la_SOURCES = kdc_test_plugin.c
+kdc_test_plugin_la_LDFLAGS = -module
 
 CLEANFILES= \
        $(TESTS) \
index 60ec21a31f360b73592c88950613c26d76bc387a..025a9745485d3add3bbb5e6e5a508e6088197c7f 100644 (file)
@@ -115,8 +115,8 @@ trap "kill ${kdcpid}; echo signal killing kdc; exit 1;" EXIT
 
 ec=0
 
-echo "Check that WINDC module was loaded "
-grep "windc init" messages.log >/dev/null || \
+echo "Check that KDC plugin module was loaded "
+grep "kdc plugin init" messages.log >/dev/null || \
        { ec=1 ; eval "${testfailed}"; }
 
 echo "Getting client initial tickets"; > messages.log
similarity index 78%
rename from tests/plugin/windc.c
rename to tests/plugin/kdc_test_plugin.c
index 6d275f9a94e13c35859a18d902b7370bd8350810..786030427c3e4287d7052ed0593a26be67573f52 100644 (file)
@@ -3,18 +3,18 @@
 #include <hdb.h>
 #include <hx509.h>
 #include <kdc.h>
-#include <windc_plugin.h>
+#include <kdc-plugin.h>
 
 static krb5_error_code KRB5_CALLCONV
-windc_init(krb5_context context, void **ctx)
+init(krb5_context context, void **ctx)
 {
-    krb5_warnx(context, "windc init");
+    krb5_warnx(context, "kdc plugin init");
     *ctx = NULL;
     return 0;
 }
 
 static void KRB5_CALLCONV
-windc_fini(void *ctx)
+fini(void *ctx)
 {
 }
 
@@ -123,10 +123,10 @@ audit(void *ctx, astgs_request_t r)
     return 0;
 }
 
-static krb5plugin_windc_ftable windc = {
-    KRB5_WINDC_PLUGING_MINOR,
-    windc_init,
-    windc_fini,
+static krb5plugin_kdc_ftable kdc_plugin = {
+    KRB5_KDC_PLUGING_MINOR,
+    init,
+    fini,
     pac_generate,
     pac_verify,
     client_access,
@@ -135,18 +135,18 @@ static krb5plugin_windc_ftable windc = {
     audit
 };
 
-static const krb5plugin_windc_ftable *const windc_plugins[] = {
-    &windc
+static const krb5plugin_kdc_ftable *const kdc_plugins[] = {
+    &kdc_plugin
 };
 
 krb5_error_code KRB5_CALLCONV
-windc_plugin_load(krb5_context context,
-                      krb5_get_instance_func_t *get_instance,
-                      size_t *num_plugins,
-                      const krb5plugin_windc_ftable *const **plugins);
+kdc_plugin_load(krb5_context context,
+               krb5_get_instance_func_t *get_instance,
+               size_t *num_plugins,
+               const krb5plugin_kdc_ftable *const **plugins);
 
 static uintptr_t KRB5_CALLCONV
-windc_get_instance(const char *libname)
+kdc_plugin_get_instance(const char *libname)
 {
     if (strcmp(libname, "hdb") == 0)
        return hdb_get_instance(libname);
@@ -157,14 +157,14 @@ windc_get_instance(const char *libname)
 }
 
 krb5_error_code KRB5_CALLCONV
-windc_plugin_load(krb5_context context,
-                 krb5_get_instance_func_t *get_instance,
-                 size_t *num_plugins,
-                 const krb5plugin_windc_ftable *const **plugins)
+kdc_plugin_load(krb5_context context,
+               krb5_get_instance_func_t *get_instance,
+               size_t *num_plugins,
+               const krb5plugin_kdc_ftable *const **plugins)
 {
-    *get_instance = windc_get_instance;
-    *num_plugins = sizeof(windc_plugins) / sizeof(windc_plugins[0]);
-    *plugins = windc_plugins;
+    *get_instance = kdc_plugin_get_instance;
+    *num_plugins = sizeof(kdc_plugins) / sizeof(kdc_plugins[0]);
+    *plugins = kdc_plugins;
 
     return 0;
 }