1
0
mirror of https://github.com/samba-team/samba.git synced 2025-01-01 21:18:10 +03:00

r19163: pass always a mem_ctx to functions and a ldb_context where needed

It would be nice if someone can merge that to samba4,
otherwise I'll merge that to samba4 on monday

metze
This commit is contained in:
Stefan Metzmacher 2006-10-07 10:24:16 +00:00 committed by Gerald (Jerry) Carter
parent 6091c8152a
commit 6bc42f31ce
5 changed files with 23 additions and 20 deletions

View File

@ -220,7 +220,7 @@ static int ldb_canonicalise_dn(struct ldb_context *ldb, void *mem_ctx,
out->length = 0; out->length = 0;
out->data = NULL; out->data = NULL;
dn = ldb_dn_explode_casefold(ldb, (char *)in->data); dn = ldb_dn_explode_casefold(ldb, mem_ctx, (char *)in->data);
if (dn == NULL) { if (dn == NULL) {
return -1; return -1;
} }
@ -248,10 +248,10 @@ static int ldb_comparison_dn(struct ldb_context *ldb, void *mem_ctx,
struct ldb_dn *dn1 = NULL, *dn2 = NULL; struct ldb_dn *dn1 = NULL, *dn2 = NULL;
int ret; int ret;
dn1 = ldb_dn_explode_casefold(mem_ctx, (char *)v1->data); dn1 = ldb_dn_explode_casefold(ldb, mem_ctx, (char *)v1->data);
if (dn1 == NULL) return -1; if (dn1 == NULL) return -1;
dn2 = ldb_dn_explode_casefold(mem_ctx, (char *)v2->data); dn2 = ldb_dn_explode_casefold(ldb, mem_ctx, (char *)v2->data);
if (dn2 == NULL) { if (dn2 == NULL) {
talloc_free(dn1); talloc_free(dn1);
return -1; return -1;

View File

@ -554,10 +554,10 @@ int ldb_dn_cmp(struct ldb_context *ldb, const char *dn0, const char *dn1)
if (dn0 == NULL || dn1 == NULL) return dn1 - dn0; if (dn0 == NULL || dn1 == NULL) return dn1 - dn0;
edn0 = ldb_dn_explode_casefold(ldb, dn0); edn0 = ldb_dn_explode_casefold(ldb, ldb, dn0);
if (edn0 == NULL) return 1; if (edn0 == NULL) return 1;
edn1 = ldb_dn_explode_casefold(ldb, dn1); edn1 = ldb_dn_explode_casefold(ldb, ldb, dn1);
if (edn1 == NULL) { if (edn1 == NULL) {
talloc_free(edn0); talloc_free(edn0);
return -1; return -1;
@ -575,14 +575,14 @@ int ldb_dn_cmp(struct ldb_context *ldb, const char *dn0, const char *dn1)
casefold a dn. We need to casefold the attribute names, and canonicalize casefold a dn. We need to casefold the attribute names, and canonicalize
attribute values of case insensitive attributes. attribute values of case insensitive attributes.
*/ */
struct ldb_dn *ldb_dn_casefold(struct ldb_context *ldb, const struct ldb_dn *edn) struct ldb_dn *ldb_dn_casefold(struct ldb_context *ldb, void *mem_ctx, const struct ldb_dn *edn)
{ {
struct ldb_dn *cedn; struct ldb_dn *cedn;
int i; int i, ret;
if (edn == NULL) return NULL; if (edn == NULL) return NULL;
cedn = ldb_dn_new(ldb); cedn = ldb_dn_new(mem_ctx);
if (!cedn) { if (!cedn) {
return NULL; return NULL;
} }
@ -598,14 +598,17 @@ struct ldb_dn *ldb_dn_casefold(struct ldb_context *ldb, const struct ldb_dn *edn
struct ldb_dn_component dc; struct ldb_dn_component dc;
const struct ldb_attrib_handler *h; const struct ldb_attrib_handler *h;
dc.name = ldb_attr_casefold(cedn, edn->components[i].name); dc.name = ldb_attr_casefold(cedn->components, edn->components[i].name);
if (!dc.name) { if (!dc.name) {
talloc_free(cedn); talloc_free(cedn);
return NULL; return NULL;
} }
h = ldb_attrib_handler(ldb, dc.name); h = ldb_attrib_handler(ldb, dc.name);
if (h->canonicalise_fn(ldb, cedn, &(edn->components[i].value), &(dc.value)) != 0) { ret = h->canonicalise_fn(ldb, cedn->components,
&(edn->components[i].value),
&(dc.value));
if (ret != 0) {
talloc_free(cedn); talloc_free(cedn);
return NULL; return NULL;
} }
@ -616,7 +619,7 @@ struct ldb_dn *ldb_dn_casefold(struct ldb_context *ldb, const struct ldb_dn *edn
return cedn; return cedn;
} }
struct ldb_dn *ldb_dn_explode_casefold(struct ldb_context *ldb, const char *dn) struct ldb_dn *ldb_dn_explode_casefold(struct ldb_context *ldb, void *mem_ctx, const char *dn)
{ {
struct ldb_dn *edn, *cdn; struct ldb_dn *edn, *cdn;
@ -625,13 +628,13 @@ struct ldb_dn *ldb_dn_explode_casefold(struct ldb_context *ldb, const char *dn)
edn = ldb_dn_explode(ldb, dn); edn = ldb_dn_explode(ldb, dn);
if (edn == NULL) return NULL; if (edn == NULL) return NULL;
cdn = ldb_dn_casefold(ldb, edn); cdn = ldb_dn_casefold(ldb, mem_ctx, edn);
talloc_free(edn); talloc_free(edn);
return cdn; return cdn;
} }
char *ldb_dn_linearize_casefold(struct ldb_context *ldb, const struct ldb_dn *edn) char *ldb_dn_linearize_casefold(struct ldb_context *ldb, void *mem_ctx, const struct ldb_dn *edn)
{ {
struct ldb_dn *cdn; struct ldb_dn *cdn;
char *dn; char *dn;
@ -640,11 +643,11 @@ char *ldb_dn_linearize_casefold(struct ldb_context *ldb, const struct ldb_dn *ed
/* Special DNs */ /* Special DNs */
if (ldb_dn_is_special(edn)) { if (ldb_dn_is_special(edn)) {
dn = talloc_strdup(ldb, (char *)edn->components[0].value.data); dn = talloc_strdup(mem_ctx, (char *)edn->components[0].value.data);
return dn; return dn;
} }
cdn = ldb_dn_casefold(ldb, edn); cdn = ldb_dn_casefold(ldb, mem_ctx, edn);
if (cdn == NULL) return NULL; if (cdn == NULL) return NULL;
dn = ldb_dn_linearize(ldb, cdn); dn = ldb_dn_linearize(ldb, cdn);

View File

@ -149,7 +149,7 @@ static int ldb_match_equality(struct ldb_context *ldb,
int ret; int ret;
if (ldb_attr_dn(tree->u.equality.attr) == 0) { if (ldb_attr_dn(tree->u.equality.attr) == 0) {
valuedn = ldb_dn_explode_casefold(ldb, valuedn = ldb_dn_explode_casefold(ldb, ldb,
(char *)tree->u.equality.value.data); (char *)tree->u.equality.value.data);
if (valuedn == NULL) { if (valuedn == NULL) {
return 0; return 0;

View File

@ -1145,11 +1145,11 @@ struct ldb_dn *ldb_dn_new(void *mem_ctx);
struct ldb_dn *ldb_dn_explode(void *mem_ctx, const char *dn); 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); 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); char *ldb_dn_linearize(void *mem_ctx, const struct ldb_dn *edn);
char *ldb_dn_linearize_casefold(struct ldb_context *ldb, const struct ldb_dn *edn); char *ldb_dn_linearize_casefold(struct ldb_context *ldb, void *mem_ctx, const struct ldb_dn *edn);
int ldb_dn_compare_base(struct ldb_context *ldb, const struct ldb_dn *base, const struct ldb_dn *dn); int ldb_dn_compare_base(struct ldb_context *ldb, const struct ldb_dn *base, const struct ldb_dn *dn);
int ldb_dn_compare(struct ldb_context *ldb, const struct ldb_dn *edn0, const struct ldb_dn *edn1); int ldb_dn_compare(struct ldb_context *ldb, const struct ldb_dn *edn0, const struct ldb_dn *edn1);
struct ldb_dn *ldb_dn_casefold(struct ldb_context *ldb, const struct ldb_dn *edn); struct ldb_dn *ldb_dn_casefold(struct ldb_context *ldb, void *mem_ctx, const struct ldb_dn *edn);
struct ldb_dn *ldb_dn_explode_casefold(struct ldb_context *ldb, const char *dn); struct ldb_dn *ldb_dn_explode_casefold(struct ldb_context *ldb, void *mem_ctx, const char *dn);
struct ldb_dn *ldb_dn_copy_partial(void *mem_ctx, const struct ldb_dn *dn, int num_el); struct ldb_dn *ldb_dn_copy_partial(void *mem_ctx, const struct ldb_dn *dn, int num_el);
struct ldb_dn *ldb_dn_copy(void *mem_ctx, const struct ldb_dn *dn); struct ldb_dn *ldb_dn_copy(void *mem_ctx, const struct ldb_dn *dn);
struct ldb_dn *ldb_dn_get_parent(void *mem_ctx, const struct ldb_dn *dn); struct ldb_dn *ldb_dn_get_parent(void *mem_ctx, const struct ldb_dn *dn);

View File

@ -138,7 +138,7 @@ struct TDB_DATA ltdb_key(struct ldb_module *module, const struct ldb_dn *dn)
the rest the rest
*/ */
dn_folded = ldb_dn_linearize_casefold(ldb, dn); dn_folded = ldb_dn_linearize_casefold(ldb, ldb, dn);
if (!dn_folded) { if (!dn_folded) {
goto failed; goto failed;
} }