From 6c86ed60fc6111f3f0091e5dadbc70b39d6cfb93 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Fri, 22 Sep 2006 23:21:36 +0000 Subject: r18830: ensure backends aren't added twice (needed for samba3) (This used to be commit 54b864b491d8a10c28833d28b764262503a72e91) --- source4/lib/ldb/common/ldb.c | 32 +++++++++++++++++++------------- 1 file changed, 19 insertions(+), 13 deletions(-) (limited to 'source4/lib/ldb') diff --git a/source4/lib/ldb/common/ldb.c b/source4/lib/ldb/common/ldb.c index 1aae76bad6..760a311383 100644 --- a/source4/lib/ldb/common/ldb.c +++ b/source4/lib/ldb/common/ldb.c @@ -61,6 +61,21 @@ static struct ldb_backend { ldb_connect_fn connect_fn; struct ldb_backend *prev, *next; } *ldb_backends = NULL; + + +static ldb_connect_fn ldb_find_backend(const char *url) +{ + struct ldb_backend *backend; + + for (backend = ldb_backends; backend; backend = backend->next) { + if (strncmp(backend->name, url, strlen(backend->name)) == 0) { + return backend->connect_fn; + } + } + + return NULL; +} + /* register a new ldb backend */ @@ -68,6 +83,10 @@ int ldb_register_backend(const char *url_prefix, ldb_connect_fn connectfn) { struct ldb_backend *backend = talloc(talloc_autofree_context(), struct ldb_backend); + if (ldb_find_backend(url_prefix)) { + return LDB_SUCCESS; + } + /* Maybe check for duplicity here later on? */ backend->name = talloc_strdup(backend, url_prefix); @@ -77,19 +96,6 @@ int ldb_register_backend(const char *url_prefix, ldb_connect_fn connectfn) return LDB_SUCCESS; } -static ldb_connect_fn ldb_find_backend(const char *url) -{ - struct ldb_backend *backend; - - for (backend = ldb_backends; backend; backend = backend->next) { - if (strncmp(backend->name, url, strlen(backend->name)) == 0) { - return backend->connect_fn; - } - } - - return NULL; -} - /* Return the ldb module form of a database. The URL can either be one of the following forms ldb://path -- cgit