hdb: Use db type preference from ./configure

Use the HDB backend type from the --with-db-type-preference=... option
to ./configure to make the default HDB backend more stable.
This commit is contained in:
Nicolas Williams
2020-10-02 19:49:19 -05:00
parent 93ada1fbf6
commit 8c7900c40b
2 changed files with 13 additions and 0 deletions

View File

@@ -7,6 +7,7 @@ AM_CPPFLAGS += $(INCLUDE_openldap) -DHDB_DB_DIR=\"$(DIR_hdbdir)\"
AM_CPPFLAGS += -I$(srcdir)/../krb5
AM_CPPFLAGS += $(INCLUDE_sqlite3)
AM_CPPFLAGS += $(INCLUDE_libintl)
AM_CPPFLAGS += -DHDB_DEFAULT_DB_TYPE=\"$(db_type):\"
if HAVE_DBHEADER
AM_CPPFLAGS += -I$(DBHEADER)
endif

View File

@@ -802,7 +802,19 @@ hdb_create(krb5_context context, HDB **db, const char *filename)
*db = NULL;
}
}
#ifdef HDB_DEFAULT_DB_TYPE
if (cb_ctx.h == NULL || cb_ctx.h->prefix == NULL) {
/*
* If still we've not picked a backend, use a build configuration time
* default.
*/
for (cb_ctx.h = methods; cb_ctx.h->prefix != NULL; cb_ctx.h++)
if (strcmp(cb_ctx.h->prefix, HDB_DEFAULT_DB_TYPE) == 0)
break;
}
#endif
if (cb_ctx.h == NULL || cb_ctx.h->prefix == NULL)
/* Last resort default */
cb_ctx.h = &default_dbmethod;
if (cb_ctx.h == NULL || cb_ctx.h->prefix == NULL) {
krb5_set_error_message(context, ENOTSUP,