add support for hdb methods (aka back-ends). include ldap.
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@8119 ec53bebd-3082-4978-b11e-865c3cabbd6b
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 1997, 1998, 1999 Kungliga Tekniska H<>gskolan
|
* Copyright (c) 1997 - 2000 Kungliga Tekniska H<>gskolan
|
||||||
* (Royal Institute of Technology, Stockholm, Sweden).
|
* (Royal Institute of Technology, Stockholm, Sweden).
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
*
|
*
|
||||||
@@ -35,6 +35,31 @@
|
|||||||
|
|
||||||
RCSID("$Id$");
|
RCSID("$Id$");
|
||||||
|
|
||||||
|
struct hdb_method {
|
||||||
|
const char *prefix;
|
||||||
|
krb5_error_code (*create)(krb5_context, HDB **, const char *filename);
|
||||||
|
};
|
||||||
|
|
||||||
|
static struct hdb_method methods[] = {
|
||||||
|
#if HAVE_DB_H
|
||||||
|
{"db:", hdb_db_create},
|
||||||
|
#endif
|
||||||
|
#if HDB_NDBM_H
|
||||||
|
{"ndbm:", hdb_ndbm_create},
|
||||||
|
#endif
|
||||||
|
#if OPENLDAP
|
||||||
|
{"ldap:", hdb_ldap_create},
|
||||||
|
#endif
|
||||||
|
#if HAVE_DB_H
|
||||||
|
{"", hdb_db_create},
|
||||||
|
#elif HAVE_NDBM_H
|
||||||
|
{"", hdb_ndbm_create},
|
||||||
|
#elif OPENLDAP
|
||||||
|
{"", hdb_ldap_create},
|
||||||
|
#endif
|
||||||
|
{NULL, NULL}
|
||||||
|
};
|
||||||
|
|
||||||
krb5_error_code
|
krb5_error_code
|
||||||
hdb_next_enctype2key(krb5_context context,
|
hdb_next_enctype2key(krb5_context context,
|
||||||
hdb_entry *e,
|
hdb_entry *e,
|
||||||
@@ -281,21 +306,38 @@ hdb_init_db(krb5_context context, HDB *db)
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* find the relevant method for `filename', returning a pointer to the
|
||||||
|
* rest in `rest'.
|
||||||
|
* return NULL if there's no such method.
|
||||||
|
*/
|
||||||
|
|
||||||
|
static const struct hdb_method *
|
||||||
|
find_method (const char *filename, const char **rest)
|
||||||
|
{
|
||||||
|
const struct hdb_method *h;
|
||||||
|
|
||||||
|
for (h = methods; h->prefix != NULL; ++h)
|
||||||
|
if (strncmp (filename, h->prefix, strlen(h->prefix)) == 0) {
|
||||||
|
*rest = filename + strlen(h->prefix);
|
||||||
|
return h;
|
||||||
|
}
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
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)
|
||||||
{
|
{
|
||||||
krb5_error_code ret = 0;
|
const struct hdb_method *h;
|
||||||
|
const char *residual;
|
||||||
|
|
||||||
if(filename == NULL)
|
if(filename == NULL)
|
||||||
filename = HDB_DEFAULT_DB;
|
filename = HDB_DEFAULT_DB;
|
||||||
initialize_hdb_error_table_r(&context->et_list);
|
initialize_hdb_error_table_r(&context->et_list);
|
||||||
#ifdef HAVE_DB_H
|
h = find_method (filename, &residual);
|
||||||
ret = hdb_db_create(context, db, filename);
|
if (h == NULL)
|
||||||
#elif HAVE_NDBM_H
|
krb5_errx(context, 1, "No database support! (hdb_create)");
|
||||||
ret = hdb_ndbm_create(context, db, filename);
|
return (*h->create)(context, db, residual);
|
||||||
#else
|
|
||||||
krb5_errx(context, 1, "No database support! (hdb_create)");
|
|
||||||
#endif
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
krb5_error_code
|
krb5_error_code
|
||||||
|
Reference in New Issue
Block a user