Update hdb's use of the plugin interface
The various _krb5_plugin_* functions are gone, replace this with the new world order. Signed-off-by: Love Hornquist Astrand <lha@h5l.org>
This commit is contained in:

committed by
Love Hornquist Astrand

parent
3cf3708950
commit
4787ea76a9
@@ -476,42 +476,43 @@ _hdb_keytab2hdb_entry(krb5_context context,
|
|||||||
* use O_CREAT to tell the backend to create the file.
|
* use O_CREAT to tell the backend to create the file.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
struct cb_s {
|
||||||
|
const char *residual;
|
||||||
|
const char *filename;
|
||||||
|
const struct hdb_method *h;
|
||||||
|
};
|
||||||
|
|
||||||
|
static krb5_error_code KRB5_LIB_CALL
|
||||||
|
callback(krb5_context context, const void *plug, void *plugctx, void *userctx)
|
||||||
|
{
|
||||||
|
struct cb_s *cb_ctx = (struct cb_s *)userctx;
|
||||||
|
|
||||||
|
if (strncmp (cb_ctx->filename, cb_ctx->h->prefix, strlen(cb_ctx->h->prefix)) == 0) {
|
||||||
|
cb_ctx->residual = cb_ctx->filename + strlen(cb_ctx->h->prefix);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
return KRB5_PLUGIN_NO_HANDLE;
|
||||||
|
}
|
||||||
|
|
||||||
krb5_error_code
|
krb5_error_code
|
||||||
hdb_create(krb5_context context, HDB **db, const char *filename)
|
hdb_create(krb5_context context, HDB **db, const char *filename)
|
||||||
{
|
{
|
||||||
const struct hdb_method *h;
|
struct cb_s cb_ctx;
|
||||||
const char *residual;
|
|
||||||
krb5_error_code ret;
|
|
||||||
struct krb5_plugin *list = NULL, *e;
|
|
||||||
|
|
||||||
if(filename == NULL)
|
if (filename == NULL)
|
||||||
filename = HDB_DEFAULT_DB;
|
filename = HDB_DEFAULT_DB;
|
||||||
krb5_add_et_list(context, initialize_hdb_error_table_r);
|
cb_ctx.h = find_method (filename, &cb_ctx.residual);
|
||||||
h = find_method (filename, &residual);
|
cb_ctx.filename = filename;
|
||||||
|
|
||||||
if (h == NULL) {
|
if (cb_ctx.h == NULL) {
|
||||||
ret = _krb5_plugin_find(context, PLUGIN_TYPE_DATA, "hdb", &list);
|
(void)_krb5_plugin_run_f(context, "krb5", "hdb",
|
||||||
if(ret == 0 && list != NULL) {
|
HDB_INTERFACE_VERSION, 0, &cb_ctx, callback);
|
||||||
for (e = list; e != NULL; e = _krb5_plugin_get_next(e)) {
|
|
||||||
h = _krb5_plugin_get_symbol(e);
|
|
||||||
if (strncmp (filename, h->prefix, strlen(h->prefix)) == 0
|
|
||||||
&& h->interface_version == HDB_INTERFACE_VERSION) {
|
|
||||||
residual = filename + strlen(h->prefix);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (e == NULL) {
|
|
||||||
h = NULL;
|
|
||||||
_krb5_plugin_free(list);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef HAVE_DLOPEN
|
#ifdef HAVE_DLOPEN
|
||||||
if (h == NULL)
|
if (cb_ctx.h == NULL)
|
||||||
h = find_dynamic_method (context, filename, &residual);
|
cb_ctx.h = find_dynamic_method (context, cb_ctx.filename, &cb_ctx.residual);
|
||||||
#endif
|
#endif
|
||||||
if (h == NULL)
|
if (cb_ctx.h == NULL)
|
||||||
krb5_errx(context, 1, "No database support for %s", filename);
|
krb5_errx(context, 1, "No database support for %s", cb_ctx.filename);
|
||||||
return (*h->create)(context, db, residual);
|
return (*cb_ctx.h->create)(context, db, cb_ctx.residual);
|
||||||
}
|
}
|
||||||
|
@@ -263,9 +263,12 @@ typedef struct HDB {
|
|||||||
krb5_error_code (*hdb_check_s4u2self)(krb5_context, struct HDB *, hdb_entry_ex *, krb5_const_principal);
|
krb5_error_code (*hdb_check_s4u2self)(krb5_context, struct HDB *, hdb_entry_ex *, krb5_const_principal);
|
||||||
}HDB;
|
}HDB;
|
||||||
|
|
||||||
#define HDB_INTERFACE_VERSION 7
|
#define HDB_INTERFACE_VERSION 8
|
||||||
|
|
||||||
struct hdb_so_method {
|
struct hdb_so_method {
|
||||||
|
int minor_version;
|
||||||
|
krb5_error_code (KRB5_LIB_CALL *init)(krb5_context, void **);
|
||||||
|
void (KRB5_LIB_CALL *fini)(void *);
|
||||||
int version;
|
int version;
|
||||||
const char *prefix;
|
const char *prefix;
|
||||||
krb5_error_code (*create)(krb5_context, HDB **, const char *filename);
|
krb5_error_code (*create)(krb5_context, HDB **, const char *filename);
|
||||||
|
Reference in New Issue
Block a user