[SCM] Samba Shared Repository - branch master updated -
release-4-0-0alpha7-1256-gaf6316d
Jelmer Vernooij
jelmer at samba.org
Thu Apr 23 17:20:19 GMT 2009
The branch, master has been updated
via af6316d1500cfcedd5fd59ed0ddbba9aec9c3756 (commit)
via b6981e79dfb22819f48edcd4041b00f9b8cd7a93 (commit)
via 9b64073cf733588b75c3780f2c18728ff3009500 (commit)
from 90cc5e72ba0cf4b5261be2f2aa9db87bd011fbb0 (commit)
http://gitweb.samba.org/?p=samba.git;a=shortlog;h=master
- Log -----------------------------------------------------------------
commit af6316d1500cfcedd5fd59ed0ddbba9aec9c3756
Author: Jelmer Vernooij <jelmer at samba.org>
Date: Thu Apr 23 18:59:37 2009 +0200
Provide a ldb_global_init() function for compatibility with older versions of LDB
(including the one in Samba 3).
commit b6981e79dfb22819f48edcd4041b00f9b8cd7a93
Author: Jelmer Vernooij <jelmer at samba.org>
Date: Thu Apr 23 14:31:45 2009 +0200
samba3/ldb: Update the ldb_dn API to match that of the Samba 4 LDB:
* ldb_dn_new() now takes an initial DN string
* ldb_dn_string_compose() -> ldb_dn_new_fmt()
* dummy ldb_dn_validate(), since LDB DNs in the current implementation
are always valid if they could be created.
commit 9b64073cf733588b75c3780f2c18728ff3009500
Author: Jelmer Vernooij <jelmer at samba.org>
Date: Thu Apr 23 14:27:59 2009 +0200
ldb/samba3: Support event context argument to ldb_init().
This argument is ignored (Samba3's LDB is synchronous) but having it
there is useful for API compatibility with the LDB used by Samba 4 and
available on some systems.
-----------------------------------------------------------------------
Summary of changes:
source3/groupdb/mapping_ldb.c | 10 +++---
source3/lib/ldb/common/ldb.c | 6 ++--
source3/lib/ldb/common/ldb_dn.c | 53 ++++++++++++++++++++++++++----------
source3/lib/ldb/include/ldb.h | 9 +++++-
source3/lib/ldb/tools/ldbadd.c | 2 +-
source3/lib/ldb/tools/ldbdel.c | 2 +-
source3/lib/ldb/tools/ldbedit.c | 2 +-
source3/lib/ldb/tools/ldbmodify.c | 2 +-
source3/lib/ldb/tools/ldbrename.c | 2 +-
source3/lib/ldb/tools/ldbsearch.c | 2 +-
source3/libads/ldap.c | 22 ++++++++-------
source4/lib/ldb/common/ldb.c | 6 ++++
12 files changed, 77 insertions(+), 41 deletions(-)
Changeset truncated at 500 lines:
diff --git a/source3/groupdb/mapping_ldb.c b/source3/groupdb/mapping_ldb.c
index a162c19..7ad0bbb 100644
--- a/source3/groupdb/mapping_ldb.c
+++ b/source3/groupdb/mapping_ldb.c
@@ -23,7 +23,7 @@
#include "includes.h"
#include "groupdb/mapping.h"
-#include "lib/ldb/include/includes.h"
+#include "lib/ldb/include/ldb.h"
#include "lib/ldb/include/ldb_errors.h"
static struct ldb_context *ldb;
@@ -57,7 +57,7 @@ static bool init_group_mapping(void)
db_path = state_path("group_mapping.ldb");
- ldb = ldb_init(NULL);
+ ldb = ldb_init(NULL, NULL);
if (ldb == NULL) goto failed;
/* Ensure this db is created read/write for root only. */
@@ -133,8 +133,8 @@ static struct ldb_dn *mapping_dn(TALLOC_CTX *mem_ctx, const DOM_SID *sid)
}
/* we split by domain and rid so we can do a subtree search
when we only want one domain */
- return ldb_dn_string_compose(mem_ctx, NULL, "rid=%u,domain=%s",
- rid, string_sid);
+ return ldb_dn_new_fmt(mem_ctx, ldb, "rid=%u,domain=%s",
+ rid, string_sid);
}
/*
@@ -328,7 +328,7 @@ static bool enum_group_mapping(const DOM_SID *domsid, enum lsa_SidType sid_name_
/* we do a subtree search on the domain */
if (domsid != NULL) {
sid_to_fstring(name, domsid);
- basedn = ldb_dn_string_compose(tmp_ctx, NULL, "domain=%s", name);
+ basedn = ldb_dn_new_fmt(tmp_ctx, ldb, "domain=%s", name);
if (basedn == NULL) goto failed;
}
diff --git a/source3/lib/ldb/common/ldb.c b/source3/lib/ldb/common/ldb.c
index cef7373..791c186 100644
--- a/source3/lib/ldb/common/ldb.c
+++ b/source3/lib/ldb/common/ldb.c
@@ -39,7 +39,7 @@
initialise a ldb context
The mem_ctx is optional
*/
-struct ldb_context *ldb_init(void *mem_ctx)
+struct ldb_context *ldb_init(void *mem_ctx, struct tevent_context *tev_ctx)
{
struct ldb_context *ldb = talloc_zero(mem_ctx, struct ldb_context);
int ret;
@@ -166,7 +166,7 @@ static const struct ldb_dn *ldb_set_default_basedn(struct ldb_context *ldb)
}
tmp_ctx = talloc_new(ldb);
- ret = ldb_search(ldb, ldb, &res, ldb_dn_new(tmp_ctx), LDB_SCOPE_BASE,
+ ret = ldb_search(ldb, ldb, &res, ldb_dn_new(tmp_ctx, ldb, NULL), LDB_SCOPE_BASE,
attrs, "(objectClass=*)");
if (ret == LDB_SUCCESS) {
if (res->count == 1) {
@@ -601,7 +601,7 @@ int ldb_build_search_req(struct ldb_request **ret_req,
req->operation = LDB_SEARCH;
if (base == NULL) {
- req->op.search.base = ldb_dn_new(req);
+ req->op.search.base = ldb_dn_new(req, ldb, NULL);
} else {
req->op.search.base = base;
}
diff --git a/source3/lib/ldb/common/ldb_dn.c b/source3/lib/ldb/common/ldb_dn.c
index 7ef3c38..09d5855 100644
--- a/source3/lib/ldb/common/ldb_dn.c
+++ b/source3/lib/ldb/common/ldb_dn.c
@@ -332,21 +332,44 @@ failed:
return dc;
}
-struct ldb_dn *ldb_dn_new(void *mem_ctx)
+struct ldb_dn *ldb_dn_new(void *mem_ctx, struct ldb_context *ldb, const char *text)
{
struct ldb_dn *edn;
- edn = talloc(mem_ctx, struct ldb_dn);
- LDB_DN_NULL_FAILED(edn);
-
- /* Initially there are no components */
- edn->comp_num = 0;
- edn->components = NULL;
+ if (text == NULL) {
+ edn = talloc_zero(mem_ctx, struct ldb_dn);
+ } else {
+ edn = ldb_dn_explode(mem_ctx, text);
+ }
return edn;
+}
-failed:
- return NULL;
+bool ldb_dn_validate(struct ldb_dn *dn)
+{
+ /* This implementation does not do "lazy" evaluation of DN's, so
+ * if a DN can be created it will be valid. */
+ return true;
+}
+
+struct ldb_dn *ldb_dn_new_fmt(void *mem_ctx, struct ldb_context *ldb, const char *new_fmt, ...)
+{
+ char *strdn;
+ va_list ap;
+ struct ldb_dn *dn;
+
+ if ( (! mem_ctx) || (! ldb)) return NULL;
+
+ va_start(ap, new_fmt);
+ strdn = talloc_vasprintf(mem_ctx, new_fmt, ap);
+ if (strdn == NULL)
+ return NULL;
+ va_end(ap);
+
+ dn = ldb_dn_explode(mem_ctx, strdn);
+
+ talloc_free(strdn);
+ return dn;
}
/*
@@ -360,7 +383,7 @@ struct ldb_dn *ldb_dn_explode(void *mem_ctx, const char *dn)
if (dn == NULL) return NULL;
/* Allocate a structure to hold the exploded DN */
- edn = ldb_dn_new(mem_ctx);
+ edn = talloc_zero(mem_ctx, struct ldb_dn);
if (edn == NULL) {
return NULL;
}
@@ -440,7 +463,7 @@ struct ldb_dn *ldb_dn_explode_or_special(void *mem_ctx, const char *dn)
*/
/* Allocate a structure to hold the exploded DN */
- if (!(edn = ldb_dn_new(mem_ctx))) {
+ if (!(edn = talloc_zero(mem_ctx, struct ldb_dn))) {
return NULL;
}
@@ -599,7 +622,7 @@ struct ldb_dn *ldb_dn_casefold(struct ldb_context *ldb, void *mem_ctx, const str
if (edn == NULL) return NULL;
- cedn = ldb_dn_new(mem_ctx);
+ cedn = talloc_zero(mem_ctx, struct ldb_dn);
if (!cedn) {
return NULL;
}
@@ -737,7 +760,7 @@ struct ldb_dn *ldb_dn_copy_partial(void *mem_ctx, const struct ldb_dn *dn, int n
if (dn == NULL) return NULL;
if (num_el <= 0) return NULL;
- newdn = ldb_dn_new(mem_ctx);
+ newdn = talloc_zero(mem_ctx, struct ldb_dn);
LDB_DN_NULL_FAILED(newdn);
newdn->comp_num = num_el;
@@ -814,7 +837,7 @@ struct ldb_dn *ldb_dn_build_child(void *mem_ctx, const char *attr,
newdn = ldb_dn_copy_partial(mem_ctx, base, base->comp_num + 1);
LDB_DN_NULL_FAILED(newdn);
} else {
- newdn = ldb_dn_new(mem_ctx);
+ newdn = talloc_zero(mem_ctx, struct ldb_dn);
LDB_DN_NULL_FAILED(newdn);
newdn->comp_num = 1;
@@ -847,7 +870,7 @@ struct ldb_dn *ldb_dn_compose(void *mem_ctx, const struct ldb_dn *dn1, const str
}
if (dn2 == NULL) {
- newdn = ldb_dn_new(mem_ctx);
+ newdn = talloc_zero(mem_ctx, struct ldb_dn);
LDB_DN_NULL_FAILED(newdn);
newdn->comp_num = dn1->comp_num;
diff --git a/source3/lib/ldb/include/ldb.h b/source3/lib/ldb/include/ldb.h
index 113652a..466e4a2 100644
--- a/source3/lib/ldb/include/ldb.h
+++ b/source3/lib/ldb/include/ldb.h
@@ -795,10 +795,13 @@ int ldb_global_init(void);
\param mem_ctx pointer to a talloc memory context. Pass NULL if there is
no suitable context available.
+ \param ev_ctx Event context. This is here for API compatibility
+ with the Samba 4 version of LDB and ignored in this version of LDB.
+
\return pointer to ldb_context that should be free'd (using talloc_free())
at the end of the program.
*/
-struct ldb_context *ldb_init(void *mem_ctx);
+struct ldb_context *ldb_init(void *mem_ctx, struct tevent_context *ev_ctx);
/**
Connect to a database.
@@ -1275,7 +1278,9 @@ int ldb_attrib_add_handlers(struct ldb_context *ldb,
int ldb_dn_is_special(const struct ldb_dn *dn);
int ldb_dn_check_special(const struct ldb_dn *dn, const char *check);
char *ldb_dn_escape_value(void *mem_ctx, struct ldb_val value);
-struct ldb_dn *ldb_dn_new(void *mem_ctx);
+struct ldb_dn *ldb_dn_new(TALLOC_CTX *mem_ctx, struct ldb_context *ldb, const char *dn);
+bool ldb_dn_validate(struct ldb_dn *dn);
+struct ldb_dn *ldb_dn_new_fmt(void *mem_ctx, struct ldb_context *ldb, const char *new_fmt, ...);
struct ldb_dn *ldb_dn_explode(void *mem_ctx, const char *dn);
struct ldb_dn *ldb_dn_explode_or_special(void *mem_ctx, const char *dn);
char *ldb_dn_linearize(void *mem_ctx, const struct ldb_dn *edn);
diff --git a/source3/lib/ldb/tools/ldbadd.c b/source3/lib/ldb/tools/ldbadd.c
index 155395e..c23a13a 100644
--- a/source3/lib/ldb/tools/ldbadd.c
+++ b/source3/lib/ldb/tools/ldbadd.c
@@ -90,7 +90,7 @@ int main(int argc, const char **argv)
ldb_global_init();
- ldb = ldb_init(NULL);
+ ldb = ldb_init(NULL, NULL);
options = ldb_cmdline_process(ldb, argc, argv, usage);
diff --git a/source3/lib/ldb/tools/ldbdel.c b/source3/lib/ldb/tools/ldbdel.c
index c58a82a..bdd1b60 100644
--- a/source3/lib/ldb/tools/ldbdel.c
+++ b/source3/lib/ldb/tools/ldbdel.c
@@ -80,7 +80,7 @@ int main(int argc, const char **argv)
ldb_global_init();
- ldb = ldb_init(NULL);
+ ldb = ldb_init(NULL, NULL);
options = ldb_cmdline_process(ldb, argc, argv, usage);
diff --git a/source3/lib/ldb/tools/ldbedit.c b/source3/lib/ldb/tools/ldbedit.c
index a33e6ae..6b9eaec 100644
--- a/source3/lib/ldb/tools/ldbedit.c
+++ b/source3/lib/ldb/tools/ldbedit.c
@@ -282,7 +282,7 @@ int main(int argc, const char **argv)
ldb_global_init();
- ldb = ldb_init(NULL);
+ ldb = ldb_init(NULL, NULL);
options = ldb_cmdline_process(ldb, argc, argv, usage);
diff --git a/source3/lib/ldb/tools/ldbmodify.c b/source3/lib/ldb/tools/ldbmodify.c
index f12387a..e3552b4 100644
--- a/source3/lib/ldb/tools/ldbmodify.c
+++ b/source3/lib/ldb/tools/ldbmodify.c
@@ -92,7 +92,7 @@ int main(int argc, const char **argv)
ldb_global_init();
- ldb = ldb_init(NULL);
+ ldb = ldb_init(NULL, NULL);
options = ldb_cmdline_process(ldb, argc, argv, usage);
diff --git a/source3/lib/ldb/tools/ldbrename.c b/source3/lib/ldb/tools/ldbrename.c
index d6c3a4a..d66d4b9 100644
--- a/source3/lib/ldb/tools/ldbrename.c
+++ b/source3/lib/ldb/tools/ldbrename.c
@@ -59,7 +59,7 @@ int main(int argc, const char **argv)
ldb_global_init();
- ldb = ldb_init(NULL);
+ ldb = ldb_init(NULL, NULL);
options = ldb_cmdline_process(ldb, argc, argv, usage);
diff --git a/source3/lib/ldb/tools/ldbsearch.c b/source3/lib/ldb/tools/ldbsearch.c
index e5cec0f..f1c88d5 100644
--- a/source3/lib/ldb/tools/ldbsearch.c
+++ b/source3/lib/ldb/tools/ldbsearch.c
@@ -279,7 +279,7 @@ int main(int argc, const char **argv)
ldb_global_init();
- ldb = ldb_init(NULL);
+ ldb = ldb_init(NULL, NULL);
options = ldb_cmdline_process(ldb, argc, argv, usage);
diff --git a/source3/libads/ldap.c b/source3/libads/ldap.c
index cc72d81..588c0a1 100644
--- a/source3/libads/ldap.c
+++ b/source3/libads/ldap.c
@@ -22,7 +22,7 @@
*/
#include "includes.h"
-#include "lib/ldb/include/includes.h"
+#include "lib/ldb/include/ldb.h"
#ifdef HAVE_LDAP
@@ -3858,34 +3858,36 @@ ADS_STATUS ads_check_ou_dn(TALLOC_CTX *mem_ctx,
struct ldb_dn *name_dn = NULL;
const char *name = NULL;
char *ou_string = NULL;
+ struct ldb_context *ldb = ldb_init(mem_ctx, NULL);
- name_dn = ldb_dn_explode(mem_ctx, *account_ou);
- if (name_dn) {
+ name_dn = ldb_dn_new(mem_ctx, ldb, *account_ou);
+ if (name_dn && ldb_dn_validate(name_dn)) {
+ talloc_free(ldb);
return ADS_SUCCESS;
}
ou_string = ads_ou_string(ads, *account_ou);
if (!ou_string) {
+ talloc_free(ldb);
return ADS_ERROR_LDAP(LDAP_INVALID_DN_SYNTAX);
}
- name = talloc_asprintf(mem_ctx, "%s,%s", ou_string,
- ads->config.bind_path);
+ name_dn = ldb_dn_new_fmt(mem_ctx, ldb, "%s,%s", ou_string,
+ ads->config.bind_path);
SAFE_FREE(ou_string);
- if (!name) {
- return ADS_ERROR_LDAP(LDAP_NO_MEMORY);
- }
- name_dn = ldb_dn_explode(mem_ctx, name);
- if (!name_dn) {
+ if (!name_dn || !ldb_dn_validate(name_dn)) {
+ talloc_free(ldb);
return ADS_ERROR_LDAP(LDAP_INVALID_DN_SYNTAX);
}
*account_ou = talloc_strdup(mem_ctx, name);
if (!*account_ou) {
+ talloc_free(ldb);
return ADS_ERROR_LDAP(LDAP_NO_MEMORY);
}
+ talloc_free(ldb);
return ADS_SUCCESS;
}
diff --git a/source4/lib/ldb/common/ldb.c b/source4/lib/ldb/common/ldb.c
index 86ce206..64ad683 100644
--- a/source4/lib/ldb/common/ldb.c
+++ b/source4/lib/ldb/common/ldb.c
@@ -1430,3 +1430,9 @@ void *ldb_get_opaque(struct ldb_context *ldb, const char *name)
}
return NULL;
}
+
+int ldb_global_init(void)
+{
+ /* Provided for compatibility with some older versions of ldb */
+ return 0;
+}
--
Samba Shared Repository
More information about the samba-cvs
mailing list