r10790: allow updating of existing ldb opaque values (thanks to abartlet for
authorAndrew Tridgell <tridge@samba.org>
Fri, 7 Oct 2005 00:40:29 +0000 (00:40 +0000)
committerGerald (Jerry) Carter <jerry@samba.org>
Wed, 10 Oct 2007 18:39:29 +0000 (13:39 -0500)
spotting this)
(This used to be commit ef13569ca94da00cc410318e61505e70f3606674)

source4/lib/ldb/common/ldb.c

index 725044d3f49d7e2dc93eb0ca26fc1f53f17ce2e7..d34ddb4c8ade0a32e283997e4d455574809e2063 100644 (file)
@@ -350,7 +350,17 @@ const char *ldb_errstring(struct ldb_context *ldb)
 */
 int ldb_set_opaque(struct ldb_context *ldb, const char *name, void *value)
 {
-       struct ldb_opaque *o = talloc(ldb, struct ldb_opaque);
+       struct ldb_opaque *o;
+
+       /* allow updating an existing value */
+       for (o=ldb->opaque;o;o=o->next) {
+               if (strcmp(o->name, name) == 0) {
+                       o->value = value;
+                       return LDB_SUCCESS;
+               }
+       }
+
+       o = talloc(ldb, struct ldb_opaque);
        if (o == NULL) {
                ldb_oom(ldb);
                return LDB_ERR_OTHER;