summaryrefslogtreecommitdiffstats
path: root/source4/kdc
diff options
context:
space:
mode:
authorAndrew Bartlett <abartlet@samba.org>2014-01-14 11:23:04 +1300
committerAndrew Bartlett <abartlet@samba.org>2014-01-20 22:26:49 +0100
commite758f4111356fafce5b5c8393648c9ea5c400601 (patch)
treed4dcb698af7373a5f0b4cb0007d753e14c9f7963 /source4/kdc
parent368208069e33a6d9b78a90f7326d5ac1bdd204f7 (diff)
downloadsamba-e758f4111356fafce5b5c8393648c9ea5c400601.tar.gz
samba-e758f4111356fafce5b5c8393648c9ea5c400601.tar.xz
samba-e758f4111356fafce5b5c8393648c9ea5c400601.zip
kdc: Add belts-and-braces check that we fail if the hdb version changes
This checks both if host system run-time Heimdal has changed version, and that the build-time version is supported. Signed-off-by: Andrew Bartlett <abartlet@samba.org> Reviewed-By: Jelmer Vernooij <jelmer@samba.org> Autobuild-User(master): Andrew Bartlett <abartlet@samba.org> Autobuild-Date(master): Mon Jan 20 22:26:49 CET 2014 on sn-devel-104
Diffstat (limited to 'source4/kdc')
-rw-r--r--source4/kdc/hdb-samba4-plugin.c6
-rw-r--r--source4/kdc/hdb-samba4.c5
2 files changed, 11 insertions, 0 deletions
diff --git a/source4/kdc/hdb-samba4-plugin.c b/source4/kdc/hdb-samba4-plugin.c
index cc38a60152..6f76124995 100644
--- a/source4/kdc/hdb-samba4-plugin.c
+++ b/source4/kdc/hdb-samba4-plugin.c
@@ -60,6 +60,8 @@ static krb5_error_code hdb_samba4_create(krb5_context context, struct HDB **db,
if (NT_STATUS_IS_OK(nt_status)) {
return 0;
+ } else if (NT_STATUS_EQUAL(nt_status, NT_STATUS_ERROR_DS_INCOMPATIBLE_VERSION)) {
+ return EINVAL;
} else if (NT_STATUS_EQUAL(nt_status, NT_STATUS_CANT_ACCESS_DOMAIN_INFO)) {
krb5_set_error_message(context, EINVAL, "Failed to open Samba4 LDB at %s", lpcfg_private_path(base_ctx, base_ctx->lp_ctx, "sam.ldb"));
@@ -70,6 +72,10 @@ static krb5_error_code hdb_samba4_create(krb5_context context, struct HDB **db,
return EINVAL;
}
+#if (HDB_INTERFACE_VERSION != 8 && HDB_INTERFACE_VERSION != 7)
+#error "Unsupported Heimdal HDB version"
+#endif
+
#if HDB_INTERFACE_VERSION >= 8
static krb5_error_code hdb_samba4_init(krb5_context context, void **ctx)
{
diff --git a/source4/kdc/hdb-samba4.c b/source4/kdc/hdb-samba4.c
index 6a9e5587bf..4519fb99dc 100644
--- a/source4/kdc/hdb-samba4.c
+++ b/source4/kdc/hdb-samba4.c
@@ -176,6 +176,11 @@ NTSTATUS hdb_samba4_create_kdc(struct samba_kdc_base_context *base_ctx,
struct samba_kdc_db_context *kdc_db_ctx;
NTSTATUS nt_status;
+ if (hdb_interface_version != HDB_INTERFACE_VERSION) {
+ krb5_set_error_message(context, EINVAL, "Heimdal HDB interface version mismatch between build-time and run-time libraries!");
+ return NT_STATUS_ERROR_DS_INCOMPATIBLE_VERSION;
+ }
+
*db = talloc(base_ctx, HDB);
if (!*db) {
krb5_set_error_message(context, ENOMEM, "malloc: out of memory");