diff options
author | Andrew Tridgell <tridge@samba.org> | 2004-05-07 23:54:41 +0000 |
---|---|---|
committer | Gerald (Jerry) Carter <jerry@samba.org> | 2007-10-10 12:51:47 -0500 |
commit | 265023fafa463c742f89510879acb2a830de8ab9 (patch) | |
tree | 1614be24e20bd5c0bfc9f4a5d657a2b574df2c63 /source4/lib/ldb/ldb_tdb | |
parent | dee25d910e5ed3d07a240cebe8600f4a95c94159 (diff) | |
download | samba-265023fafa463c742f89510879acb2a830de8ab9.tar.gz samba-265023fafa463c742f89510879acb2a830de8ab9.tar.bz2 samba-265023fafa463c742f89510879acb2a830de8ab9.zip |
r574: - another attempt at const cleanliness in ldb
- fixed a problem with searching for values containing an '=' sign
- fixed the semantics of attempting an attribute deletion on an attribute that doesn't exist.
- added some more ldb_msg_*() utilities
(This used to be commit 62b4ec367d170330d837b0f1fe5cd13205a53b59)
Diffstat (limited to 'source4/lib/ldb/ldb_tdb')
-rw-r--r-- | source4/lib/ldb/ldb_tdb/ldb_index.c | 4 | ||||
-rw-r--r-- | source4/lib/ldb/ldb_tdb/ldb_search.c | 12 | ||||
-rw-r--r-- | source4/lib/ldb/ldb_tdb/ldb_tdb.c | 10 |
3 files changed, 16 insertions, 10 deletions
diff --git a/source4/lib/ldb/ldb_tdb/ldb_index.c b/source4/lib/ldb/ldb_tdb/ldb_index.c index 877955a9b7..0e9f3e3c55 100644 --- a/source4/lib/ldb/ldb_tdb/ldb_index.c +++ b/source4/lib/ldb/ldb_tdb/ldb_index.c @@ -496,7 +496,7 @@ static int ldb_index_filter(struct ldb_context *ldb, struct ldb_parse_tree *tree const char *base, enum ldb_scope scope, const struct dn_list *dn_list, - char * const attrs[], struct ldb_message ***res) + const char * const attrs[], struct ldb_message ***res) { int i; unsigned int count = 0; @@ -536,7 +536,7 @@ int ltdb_search_indexed(struct ldb_context *ldb, const char *base, enum ldb_scope scope, struct ldb_parse_tree *tree, - char * const attrs[], struct ldb_message ***res) + const char * const attrs[], struct ldb_message ***res) { struct ltdb_private *ltdb = ldb->private_data; struct dn_list dn_list; diff --git a/source4/lib/ldb/ldb_tdb/ldb_search.c b/source4/lib/ldb/ldb_tdb/ldb_search.c index 5ee4449dee..60eaf3117c 100644 --- a/source4/lib/ldb/ldb_tdb/ldb_search.c +++ b/source4/lib/ldb/ldb_tdb/ldb_search.c @@ -149,7 +149,7 @@ static int msg_add_all_elements(struct ldb_context *ldb, struct ldb_message *ret */ static struct ldb_message *ltdb_pull_attrs(struct ldb_context *ldb, const struct ldb_message *msg, - char * const *attrs) + const char * const *attrs) { struct ldb_message *ret; int i; @@ -304,7 +304,7 @@ int ltdb_search_dn1(struct ldb_context *ldb, const char *dn, struct ldb_message search the database for a single simple dn */ int ltdb_search_dn(struct ldb_context *ldb, char *dn, - char * const attrs[], struct ldb_message ***res) + const char * const attrs[], struct ldb_message ***res) { int ret; struct ldb_message msg, *msg2; @@ -340,7 +340,7 @@ int ltdb_search_dn(struct ldb_context *ldb, char *dn, return 0 on success, -1 on failure */ int ltdb_add_attr_results(struct ldb_context *ldb, struct ldb_message *msg, - char * const attrs[], + const char * const attrs[], unsigned int *count, struct ldb_message ***res) { @@ -378,7 +378,7 @@ struct ltdb_search_info { struct ldb_parse_tree *tree; const char *base; enum ldb_scope scope; - char * const *attrs; + const char * const *attrs; struct ldb_message **msgs; int failures; int count; @@ -458,7 +458,7 @@ static int ltdb_search_full(struct ldb_context *ldb, const char *base, enum ldb_scope scope, struct ldb_parse_tree *tree, - char * const attrs[], struct ldb_message ***res) + const char * const attrs[], struct ldb_message ***res) { struct ltdb_private *ltdb = ldb->private_data; int ret; @@ -491,7 +491,7 @@ static int ltdb_search_full(struct ldb_context *ldb, */ int ltdb_search(struct ldb_context *ldb, const char *base, enum ldb_scope scope, const char *expression, - char * const attrs[], struct ldb_message ***res) + const char * const attrs[], struct ldb_message ***res) { struct ltdb_private *ltdb = ldb->private_data; struct ldb_parse_tree *tree; diff --git a/source4/lib/ldb/ldb_tdb/ldb_tdb.c b/source4/lib/ldb/ldb_tdb/ldb_tdb.c index eb28bc4938..09d1618ffc 100644 --- a/source4/lib/ldb/ldb_tdb/ldb_tdb.c +++ b/source4/lib/ldb/ldb_tdb/ldb_tdb.c @@ -436,10 +436,13 @@ static int msg_delete_element(struct ldb_context *ldb, sizeof(el->values[i])*(el->num_values-(i+1))); } el->num_values--; + if (el->num_values == 0) { + return msg_delete_attribute(ldb, msg, name); + } return 0; } } - + return -1; } @@ -488,7 +491,7 @@ int ltdb_modify_internal(struct ldb_context *ldb, const struct ldb_message *msg) already exists */ ret = find_element(&msg2, msg->elements[i].name); if (ret != -1) { - errno = EEXIST; + ltdb->last_err_string = "Attribute exists"; goto failed; } if (msg_add_element(ldb, &msg2, &msg->elements[i]) != 0) { @@ -500,6 +503,7 @@ int ltdb_modify_internal(struct ldb_context *ldb, const struct ldb_message *msg) /* replace all elements of this attribute name with the elements listed */ if (msg_delete_attribute(ldb, &msg2, msg->elements[i].name) != 0) { + ltdb->last_err_string = "No such attribute"; goto failed; } /* add the replacement element */ @@ -514,6 +518,7 @@ int ltdb_modify_internal(struct ldb_context *ldb, const struct ldb_message *msg) if (msg->elements[i].num_values == 0) { if (msg_delete_attribute(ldb, &msg2, msg->elements[i].name) != 0) { + ltdb->last_err_string = "No such attribute"; goto failed; } break; @@ -523,6 +528,7 @@ int ltdb_modify_internal(struct ldb_context *ldb, const struct ldb_message *msg) &msg2, msg->elements[i].name, &msg->elements[i].values[j]) != 0) { + ltdb->last_err_string = "No such attribute"; goto failed; } } |