summaryrefslogtreecommitdiff
path: root/source4
diff options
context:
space:
mode:
authorKamen Mazdrashki <kamenim@samba.org>2010-08-17 03:58:26 +0300
committerKamen Mazdrashki <kamenim@samba.org>2010-08-19 03:34:01 +0300
commitca809186137e259060032ef61d9d3e93cddad298 (patch)
tree6af2255ab3de7c5a0d36e10f58f7c02c7cec352d /source4
parentb7d1586ccd05a78a4fae512c54fa39dda408e08b (diff)
downloadsamba-ca809186137e259060032ef61d9d3e93cddad298.tar.gz
samba-ca809186137e259060032ef61d9d3e93cddad298.tar.bz2
samba-ca809186137e259060032ef61d9d3e93cddad298.zip
s4-dsdb: Use dsdb_syntax_ctx in *_validate_ldb functions
Diffstat (limited to 'source4')
-rw-r--r--source4/dsdb/samdb/ldb_modules/objectclass_attrs.c6
-rw-r--r--source4/dsdb/schema/schema.h3
-rw-r--r--source4/dsdb/schema/schema_syntax.c94
3 files changed, 41 insertions, 62 deletions
diff --git a/source4/dsdb/samdb/ldb_modules/objectclass_attrs.c b/source4/dsdb/samdb/ldb_modules/objectclass_attrs.c
index 070d8585ae..3c22eed7f8 100644
--- a/source4/dsdb/samdb/ldb_modules/objectclass_attrs.c
+++ b/source4/dsdb/samdb/ldb_modules/objectclass_attrs.c
@@ -79,6 +79,7 @@ static int attr_handler(struct oc_context *ac)
unsigned int i;
int ret;
WERROR werr;
+ struct dsdb_syntax_ctx syntax_ctx;
ldb = ldb_module_get_ctx(ac->module);
@@ -91,6 +92,9 @@ static int attr_handler(struct oc_context *ac)
return ldb_oom(ldb);
}
+ /* initialize syntax checking context */
+ dsdb_syntax_ctx_init(&syntax_ctx, ldb, ac->schema);
+
/* Check if attributes exist in the schema, if the values match,
* if they're not operational and fix the names to the match the schema
* case */
@@ -114,7 +118,7 @@ static int attr_handler(struct oc_context *ac)
}
if (!(msg->elements[i].flags & LDB_FLAG_INTERNAL_DISABLE_VALIDATION)) {
- werr = attr->syntax->validate_ldb(ldb, ac->schema, attr,
+ werr = attr->syntax->validate_ldb(&syntax_ctx, attr,
&msg->elements[i]);
if (!W_ERROR_IS_OK(werr)) {
ldb_asprintf_errstring(ldb, "objectclass_attrs: attribute '%s' on entry '%s' contains at least one invalid value!",
diff --git a/source4/dsdb/schema/schema.h b/source4/dsdb/schema/schema.h
index 2168202d1f..a9b383cb07 100644
--- a/source4/dsdb/schema/schema.h
+++ b/source4/dsdb/schema/schema.h
@@ -57,8 +57,7 @@ struct dsdb_syntax {
const struct ldb_message_element *in,
TALLOC_CTX *mem_ctx,
struct drsuapi_DsReplicaAttribute *out);
- WERROR (*validate_ldb)(struct ldb_context *ldb,
- const struct dsdb_schema *schema,
+ WERROR (*validate_ldb)(const struct dsdb_syntax_ctx *ctx,
const struct dsdb_attribute *attr,
const struct ldb_message_element *in);
};
diff --git a/source4/dsdb/schema/schema_syntax.c b/source4/dsdb/schema/schema_syntax.c
index a6593b4f78..c553e20180 100644
--- a/source4/dsdb/schema/schema_syntax.c
+++ b/source4/dsdb/schema/schema_syntax.c
@@ -88,8 +88,7 @@ static WERROR dsdb_syntax_FOOBAR_ldb_to_drsuapi(struct ldb_context *ldb,
return WERR_FOOBAR;
}
-static WERROR dsdb_syntax_FOOBAR_validate_ldb(struct ldb_context *ldb,
- const struct dsdb_schema *schema,
+static WERROR dsdb_syntax_FOOBAR_validate_ldb(const struct dsdb_syntax_ctx *ctx,
const struct dsdb_attribute *attr,
const struct ldb_message_element *in)
{
@@ -183,8 +182,7 @@ static WERROR dsdb_syntax_BOOL_ldb_to_drsuapi(struct ldb_context *ldb,
return WERR_OK;
}
-static WERROR dsdb_syntax_BOOL_validate_ldb(struct ldb_context *ldb,
- const struct dsdb_schema *schema,
+static WERROR dsdb_syntax_BOOL_validate_ldb(const struct dsdb_syntax_ctx *ctx,
const struct dsdb_attribute *attr,
const struct ldb_message_element *in)
{
@@ -294,8 +292,7 @@ static WERROR dsdb_syntax_INT32_ldb_to_drsuapi(struct ldb_context *ldb,
return WERR_OK;
}
-static WERROR dsdb_syntax_INT32_validate_ldb(struct ldb_context *ldb,
- const struct dsdb_schema *schema,
+static WERROR dsdb_syntax_INT32_validate_ldb(const struct dsdb_syntax_ctx *ctx,
const struct dsdb_attribute *attr,
const struct ldb_message_element *in)
{
@@ -421,8 +418,7 @@ static WERROR dsdb_syntax_INT64_ldb_to_drsuapi(struct ldb_context *ldb,
return WERR_OK;
}
-static WERROR dsdb_syntax_INT64_validate_ldb(struct ldb_context *ldb,
- const struct dsdb_schema *schema,
+static WERROR dsdb_syntax_INT64_validate_ldb(const struct dsdb_syntax_ctx *ctx,
const struct dsdb_attribute *attr,
const struct ldb_message_element *in)
{
@@ -561,8 +557,7 @@ static WERROR dsdb_syntax_NTTIME_UTC_ldb_to_drsuapi(struct ldb_context *ldb,
return WERR_OK;
}
-static WERROR dsdb_syntax_NTTIME_UTC_validate_ldb(struct ldb_context *ldb,
- const struct dsdb_schema *schema,
+static WERROR dsdb_syntax_NTTIME_UTC_validate_ldb(const struct dsdb_syntax_ctx *ctx,
const struct dsdb_attribute *attr,
const struct ldb_message_element *in)
{
@@ -699,8 +694,7 @@ static WERROR dsdb_syntax_NTTIME_ldb_to_drsuapi(struct ldb_context *ldb,
return WERR_OK;
}
-static WERROR dsdb_syntax_NTTIME_validate_ldb(struct ldb_context *ldb,
- const struct dsdb_schema *schema,
+static WERROR dsdb_syntax_NTTIME_validate_ldb(const struct dsdb_syntax_ctx *ctx,
const struct dsdb_attribute *attr,
const struct ldb_message_element *in)
{
@@ -803,8 +797,7 @@ static WERROR dsdb_syntax_DATA_BLOB_ldb_to_drsuapi(struct ldb_context *ldb,
return WERR_OK;
}
-static WERROR dsdb_syntax_DATA_BLOB_validate_one_val(struct ldb_context *ldb,
- const struct dsdb_schema *schema,
+static WERROR dsdb_syntax_DATA_BLOB_validate_one_val(const struct dsdb_syntax_ctx *ctx,
const struct dsdb_attribute *attr,
const struct ldb_val *val)
{
@@ -827,8 +820,7 @@ static WERROR dsdb_syntax_DATA_BLOB_validate_one_val(struct ldb_context *ldb,
return WERR_OK;
}
-static WERROR dsdb_syntax_DATA_BLOB_validate_ldb(struct ldb_context *ldb,
- const struct dsdb_schema *schema,
+static WERROR dsdb_syntax_DATA_BLOB_validate_ldb(const struct dsdb_syntax_ctx *ctx,
const struct dsdb_attribute *attr,
const struct ldb_message_element *in)
{
@@ -844,8 +836,7 @@ static WERROR dsdb_syntax_DATA_BLOB_validate_ldb(struct ldb_context *ldb,
return WERR_DS_INVALID_ATTRIBUTE_SYNTAX;
}
- status = dsdb_syntax_DATA_BLOB_validate_one_val(ldb,
- schema,
+ status = dsdb_syntax_DATA_BLOB_validate_one_val(ctx,
attr,
&in->values[i]);
if (!W_ERROR_IS_OK(status)) {
@@ -1264,7 +1255,7 @@ static WERROR dsdb_syntax_OID_drsuapi_to_ldb(struct ldb_context *ldb,
return werr;
}
-static WERROR dsdb_syntax_OID_ldb_to_drsuapi(struct ldb_context *ldb,
+static WERROR dsdb_syntax_OID_ldb_to_drsuapi(struct ldb_context *ldb,
const struct dsdb_schema *schema,
const struct dsdb_attribute *attr,
const struct ldb_message_element *in,
@@ -1302,8 +1293,7 @@ static WERROR dsdb_syntax_OID_ldb_to_drsuapi(struct ldb_context *ldb,
return _dsdb_syntax_auto_OID_ldb_to_drsuapi(ldb, schema, attr, in, mem_ctx, out);
}
-static WERROR dsdb_syntax_OID_validate_ldb(struct ldb_context *ldb,
- const struct dsdb_schema *schema,
+static WERROR dsdb_syntax_OID_validate_ldb(const struct dsdb_syntax_ctx *ctx,
const struct dsdb_attribute *attr,
const struct ldb_message_element *in)
{
@@ -1320,13 +1310,13 @@ static WERROR dsdb_syntax_OID_validate_ldb(struct ldb_context *ldb,
* TODO: optimize and verify this code
*/
- tmp_ctx = talloc_new(ldb);
+ tmp_ctx = talloc_new(ctx->ldb);
if (tmp_ctx == NULL) {
return WERR_NOMEM;
}
- status = dsdb_syntax_OID_ldb_to_drsuapi(ldb,
- schema,
+ status = dsdb_syntax_OID_ldb_to_drsuapi(ctx->ldb,
+ ctx->schema,
attr,
in,
tmp_ctx,
@@ -1336,8 +1326,8 @@ static WERROR dsdb_syntax_OID_validate_ldb(struct ldb_context *ldb,
return status;
}
- status = dsdb_syntax_OID_drsuapi_to_ldb(ldb,
- schema,
+ status = dsdb_syntax_OID_drsuapi_to_ldb(ctx->ldb,
+ ctx->schema,
attr,
&drs_tmp,
tmp_ctx,
@@ -1431,8 +1421,7 @@ static WERROR dsdb_syntax_UNICODE_ldb_to_drsuapi(struct ldb_context *ldb,
return WERR_OK;
}
-static WERROR dsdb_syntax_UNICODE_validate_one_val(struct ldb_context *ldb,
- const struct dsdb_schema *schema,
+static WERROR dsdb_syntax_UNICODE_validate_one_val(const struct dsdb_syntax_ctx *ctx,
const struct dsdb_attribute *attr,
const struct ldb_val *val)
{
@@ -1444,7 +1433,7 @@ static WERROR dsdb_syntax_UNICODE_validate_one_val(struct ldb_context *ldb,
return WERR_FOOBAR;
}
- ok = convert_string_talloc(ldb,
+ ok = convert_string_talloc(ctx->ldb,
CH_UNIX, CH_UTF16,
val->data,
val->length,
@@ -1470,8 +1459,7 @@ static WERROR dsdb_syntax_UNICODE_validate_one_val(struct ldb_context *ldb,
return WERR_OK;
}
-static WERROR dsdb_syntax_UNICODE_validate_ldb(struct ldb_context *ldb,
- const struct dsdb_schema *schema,
+static WERROR dsdb_syntax_UNICODE_validate_ldb(const struct dsdb_syntax_ctx *ctx,
const struct dsdb_attribute *attr,
const struct ldb_message_element *in)
{
@@ -1487,8 +1475,7 @@ static WERROR dsdb_syntax_UNICODE_validate_ldb(struct ldb_context *ldb,
return WERR_DS_INVALID_ATTRIBUTE_SYNTAX;
}
- status = dsdb_syntax_UNICODE_validate_one_val(ldb,
- schema,
+ status = dsdb_syntax_UNICODE_validate_one_val(ctx,
attr,
&in->values[i]);
if (!W_ERROR_IS_OK(status)) {
@@ -1679,8 +1666,7 @@ static WERROR dsdb_syntax_DN_ldb_to_drsuapi(struct ldb_context *ldb,
return WERR_OK;
}
-static WERROR dsdb_syntax_DN_validate_one_val(struct ldb_context *ldb,
- const struct dsdb_schema *schema,
+static WERROR dsdb_syntax_DN_validate_one_val(const struct dsdb_syntax_ctx *ctx,
const struct dsdb_attribute *attr,
const struct ldb_val *val,
TALLOC_CTX *mem_ctx,
@@ -1706,7 +1692,7 @@ static WERROR dsdb_syntax_DN_validate_one_val(struct ldb_context *ldb,
return WERR_FOOBAR;
}
- dsdb_dn = dsdb_dn_parse(tmp_ctx, ldb, val,
+ dsdb_dn = dsdb_dn_parse(tmp_ctx, ctx->ldb, val,
attr->syntax->ldap_oid);
if (!dsdb_dn) {
talloc_free(tmp_ctx);
@@ -1779,8 +1765,7 @@ static WERROR dsdb_syntax_DN_validate_one_val(struct ldb_context *ldb,
return WERR_OK;
}
-static WERROR dsdb_syntax_DN_validate_ldb(struct ldb_context *ldb,
- const struct dsdb_schema *schema,
+static WERROR dsdb_syntax_DN_validate_ldb(const struct dsdb_syntax_ctx *ctx,
const struct dsdb_attribute *attr,
const struct ldb_message_element *in)
{
@@ -1793,11 +1778,10 @@ static WERROR dsdb_syntax_DN_validate_ldb(struct ldb_context *ldb,
for (i=0; i < in->num_values; i++) {
WERROR status;
struct dsdb_dn *dsdb_dn;
- TALLOC_CTX *tmp_ctx = talloc_new(ldb);
+ TALLOC_CTX *tmp_ctx = talloc_new(ctx->ldb);
W_ERROR_HAVE_NO_MEMORY(tmp_ctx);
- status = dsdb_syntax_DN_validate_one_val(ldb,
- schema,
+ status = dsdb_syntax_DN_validate_one_val(ctx,
attr,
&in->values[i],
tmp_ctx, &dsdb_dn);
@@ -2002,8 +1986,7 @@ static WERROR dsdb_syntax_DN_BINARY_ldb_to_drsuapi(struct ldb_context *ldb,
return WERR_OK;
}
-static WERROR dsdb_syntax_DN_BINARY_validate_ldb(struct ldb_context *ldb,
- const struct dsdb_schema *schema,
+static WERROR dsdb_syntax_DN_BINARY_validate_ldb(const struct dsdb_syntax_ctx *ctx,
const struct dsdb_attribute *attr,
const struct ldb_message_element *in)
{
@@ -2016,11 +1999,10 @@ static WERROR dsdb_syntax_DN_BINARY_validate_ldb(struct ldb_context *ldb,
for (i=0; i < in->num_values; i++) {
WERROR status;
struct dsdb_dn *dsdb_dn;
- TALLOC_CTX *tmp_ctx = talloc_new(ldb);
+ TALLOC_CTX *tmp_ctx = talloc_new(ctx->ldb);
W_ERROR_HAVE_NO_MEMORY(tmp_ctx);
- status = dsdb_syntax_DN_validate_one_val(ldb,
- schema,
+ status = dsdb_syntax_DN_validate_one_val(ctx,
attr,
&in->values[i],
tmp_ctx, &dsdb_dn);
@@ -2034,8 +2016,7 @@ static WERROR dsdb_syntax_DN_BINARY_validate_ldb(struct ldb_context *ldb,
return WERR_DS_INVALID_ATTRIBUTE_SYNTAX;
}
- status = dsdb_syntax_DATA_BLOB_validate_one_val(ldb,
- schema,
+ status = dsdb_syntax_DATA_BLOB_validate_one_val(ctx,
attr,
&dsdb_dn->extra_part);
if (!W_ERROR_IS_OK(status)) {
@@ -2079,8 +2060,7 @@ static WERROR dsdb_syntax_DN_STRING_ldb_to_drsuapi(struct ldb_context *ldb,
out);
}
-static WERROR dsdb_syntax_DN_STRING_validate_ldb(struct ldb_context *ldb,
- const struct dsdb_schema *schema,
+static WERROR dsdb_syntax_DN_STRING_validate_ldb(const struct dsdb_syntax_ctx *ctx,
const struct dsdb_attribute *attr,
const struct ldb_message_element *in)
{
@@ -2093,11 +2073,10 @@ static WERROR dsdb_syntax_DN_STRING_validate_ldb(struct ldb_context *ldb,
for (i=0; i < in->num_values; i++) {
WERROR status;
struct dsdb_dn *dsdb_dn;
- TALLOC_CTX *tmp_ctx = talloc_new(ldb);
+ TALLOC_CTX *tmp_ctx = talloc_new(ctx->ldb);
W_ERROR_HAVE_NO_MEMORY(tmp_ctx);
- status = dsdb_syntax_DN_validate_one_val(ldb,
- schema,
+ status = dsdb_syntax_DN_validate_one_val(ctx,
attr,
&in->values[i],
tmp_ctx, &dsdb_dn);
@@ -2111,8 +2090,7 @@ static WERROR dsdb_syntax_DN_STRING_validate_ldb(struct ldb_context *ldb,
return WERR_DS_INVALID_ATTRIBUTE_SYNTAX;
}
- status = dsdb_syntax_UNICODE_validate_one_val(ldb,
- schema,
+ status = dsdb_syntax_UNICODE_validate_one_val(ctx,
attr,
&dsdb_dn->extra_part);
if (!W_ERROR_IS_OK(status)) {
@@ -2225,13 +2203,11 @@ static WERROR dsdb_syntax_PRESENTATION_ADDRESS_ldb_to_drsuapi(struct ldb_context
return WERR_OK;
}
-static WERROR dsdb_syntax_PRESENTATION_ADDRESS_validate_ldb(struct ldb_context *ldb,
- const struct dsdb_schema *schema,
+static WERROR dsdb_syntax_PRESENTATION_ADDRESS_validate_ldb(const struct dsdb_syntax_ctx *ctx,
const struct dsdb_attribute *attr,
const struct ldb_message_element *in)
{
- return dsdb_syntax_UNICODE_validate_ldb(ldb,
- schema,
+ return dsdb_syntax_UNICODE_validate_ldb(ctx,
attr,
in);
}