diff options
author | Andrew Tridgell <tridge@samba.org> | 2006-09-22 23:21:36 +0000 |
---|---|---|
committer | Gerald (Jerry) Carter <jerry@samba.org> | 2007-10-10 14:19:15 -0500 |
commit | 6c86ed60fc6111f3f0091e5dadbc70b39d6cfb93 (patch) | |
tree | 95d165e591f0f1198298c0408cdc2cbd34d09df2 /source4/lib/ldb | |
parent | 266ba2222b7eebe426db626acd6fcd109eef429a (diff) | |
download | samba-6c86ed60fc6111f3f0091e5dadbc70b39d6cfb93.tar.gz samba-6c86ed60fc6111f3f0091e5dadbc70b39d6cfb93.tar.bz2 samba-6c86ed60fc6111f3f0091e5dadbc70b39d6cfb93.zip |
r18830: ensure backends aren't added twice (needed for samba3)
(This used to be commit 54b864b491d8a10c28833d28b764262503a72e91)
Diffstat (limited to 'source4/lib/ldb')
-rw-r--r-- | source4/lib/ldb/common/ldb.c | 32 |
1 files changed, 19 insertions, 13 deletions
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 |