diff options
author | Simo Sorce <idra@samba.org> | 2005-07-12 12:04:54 +0000 |
---|---|---|
committer | Gerald (Jerry) Carter <jerry@samba.org> | 2007-10-10 13:20:13 -0500 |
commit | c9b0e86a436b5b169a4c33bd25eac379cb622b17 (patch) | |
tree | 7b3662e7b11aa57a7624e46b369858262dc1bfae /source4/lib/ldb/ldb_tdb | |
parent | adb7fd18e5e58bc466bdd31d68423e5f958a1d5d (diff) | |
download | samba-c9b0e86a436b5b169a4c33bd25eac379cb622b17.tar.gz samba-c9b0e86a436b5b169a4c33bd25eac379cb622b17.tar.bz2 samba-c9b0e86a436b5b169a4c33bd25eac379cb622b17.zip |
r8373: New wildcard matching code.
This code applies correct ldap standard wildcard matching code
removes WILDCARD matching from tdb @ATTRIBUTES, that's now handled independently
adds some more tests for wildcard matching
fixes dn comparison code in ldb_match
(This used to be commit 4eb5863042011988d85092d7dde3d809aa15bd59)
Diffstat (limited to 'source4/lib/ldb/ldb_tdb')
-rw-r--r-- | source4/lib/ldb/ldb_tdb/ldb_cache.c | 10 | ||||
-rw-r--r-- | source4/lib/ldb/ldb_tdb/ldb_index.c | 11 | ||||
-rw-r--r-- | source4/lib/ldb/ldb_tdb/ldb_search.c | 30 |
3 files changed, 6 insertions, 45 deletions
diff --git a/source4/lib/ldb/ldb_tdb/ldb_cache.c b/source4/lib/ldb/ldb_tdb/ldb_cache.c index 0b7ddad5db..be76f7085b 100644 --- a/source4/lib/ldb/ldb_tdb/ldb_cache.c +++ b/source4/lib/ldb/ldb_tdb/ldb_cache.c @@ -39,9 +39,8 @@ #define LTDB_FLAG_CASE_INSENSITIVE (1<<0) #define LTDB_FLAG_INTEGER (1<<1) -#define LTDB_FLAG_WILDCARD (1<<2) -#define LTDB_FLAG_HIDDEN (1<<3) -#define LTDB_FLAG_OBJECTCLASS (1<<4) +#define LTDB_FLAG_HIDDEN (1<<2) +#define LTDB_FLAG_OBJECTCLASS (1<<3) /* valid attribute flags */ static const struct { @@ -50,7 +49,6 @@ static const struct { } ltdb_valid_attr_flags[] = { { "CASE_INSENSITIVE", LTDB_FLAG_CASE_INSENSITIVE }, { "INTEGER", LTDB_FLAG_INTEGER }, - { "WILDCARD", LTDB_FLAG_WILDCARD }, { "HIDDEN", LTDB_FLAG_HIDDEN }, { "NONE", 0 }, { NULL, 0 } @@ -138,10 +136,6 @@ static int ltdb_attributes_load(struct ldb_module *module) case 0: syntax = LDB_SYNTAX_OCTET_STRING; break; - case LTDB_FLAG_WILDCARD: - case LTDB_FLAG_WILDCARD | LTDB_FLAG_CASE_INSENSITIVE: - syntax = LDB_SYNTAX_WILDCARD; - break; case LTDB_FLAG_CASE_INSENSITIVE: syntax = LDB_SYNTAX_DIRECTORY_STRING; break; diff --git a/source4/lib/ldb/ldb_tdb/ldb_index.c b/source4/lib/ldb/ldb_tdb/ldb_index.c index a3317a8765..03ad0612d4 100644 --- a/source4/lib/ldb/ldb_tdb/ldb_index.c +++ b/source4/lib/ldb/ldb_tdb/ldb_index.c @@ -188,13 +188,6 @@ static int ltdb_index_dn_simple(struct ldb_module *module, list->count = 0; list->dn = NULL; - /* - if the value is a wildcard then we can't do a match via indexing - */ - if (ltdb_has_wildcard(module, tree->u.simple.attr, &tree->u.simple.value)) { - return -1; - } - /* if the attribute isn't in the list of indexed attributes then this node needs a full search */ if (ldb_msg_find_idx(index_list, tree->u.simple.attr, NULL, LTDB_IDXATTR) == -1) { @@ -581,6 +574,8 @@ static int ltdb_index_dn(struct ldb_module *module, ret = ltdb_index_dn_leaf(module, tree, index_list, list); break; + case LDB_OP_PRESENT: + case LDB_OP_SUBSTRING: case LDB_OP_EXTENDED: /* we can't index with fancy bitops yet */ ret = -1; @@ -638,7 +633,7 @@ static int ldb_index_filter(struct ldb_module *module, struct ldb_parse_tree *tr } ret = 0; - if (ldb_match_message(module->ldb, msg, tree, base, scope) == 1) { + if (ldb_match_msg(module->ldb, msg, tree, base, scope) == 1) { ret = ltdb_add_attr_results(module, msg, attrs, &count, res); } talloc_free(msg); diff --git a/source4/lib/ldb/ldb_tdb/ldb_search.c b/source4/lib/ldb/ldb_tdb/ldb_search.c index e48043da88..3ecb2d9b39 100644 --- a/source4/lib/ldb/ldb_tdb/ldb_search.c +++ b/source4/lib/ldb/ldb_tdb/ldb_search.c @@ -188,34 +188,6 @@ static struct ldb_message *ltdb_pull_attrs(struct ldb_module *module, } - -/* - see if a ldb_val is a wildcard - return 1 if yes, 0 if no -*/ -int ltdb_has_wildcard(struct ldb_module *module, const char *attr_name, - const struct ldb_val *val) -{ - const struct ldb_attrib_handler *h; - - /* all attribute types recognise the "*" wildcard */ - if (val->length == 1 && strncmp((char *)val->data, "*", 1) == 0) { - return 1; - } - - if (strpbrk(val->data, "*?") == NULL) { - return 0; - } - - h = ldb_attrib_handler(module->ldb, attr_name); - if (h->flags & LDB_ATTR_FLAG_WILDCARD) { - return 1; - } - - return 0; -} - - /* search the database for a single simple dn, returning all attributes in a single message @@ -416,7 +388,7 @@ static int search_func(struct tdb_context *tdb, TDB_DATA key, TDB_DATA data, voi } /* see if it matches the given expression */ - if (!ldb_match_message(sinfo->module->ldb, msg, sinfo->tree, + if (!ldb_match_msg(sinfo->module->ldb, msg, sinfo->tree, sinfo->base, sinfo->scope)) { talloc_free(msg); return 0; |