s4:schema_load LDB module - fix a segfault condition on schema refresh
authorMatthias Dieter Wallnöfer <mdw@samba.org>
Sat, 3 Jul 2010 12:33:23 +0000 (14:33 +0200)
committerMatthias Dieter Wallnöfer <mdw@samba.org>
Sat, 3 Jul 2010 13:28:57 +0000 (15:28 +0200)
The schema refresh operation itself starts requests from the top of the LDB
modules stack (see call "dsdb_schema_set_attributes" - search operations).
This doesn't work well when these do perform "dsdb_get_schema" calls. Since the
new schema isn't marked as "refreshed" atm (but in fact it still is - we didn't
terminate the reload/refresh yet) we could perform other calls to
"dsdb_schema_refresh" and run into serious trouble (segfault).

source4/dsdb/samdb/ldb_modules/schema_load.c

index 9d9c9ebcd744ca9124908cddbb5c4ab0e6b6a2f5..30aafdb65e9df239f60af3435329003c83579de1 100644 (file)
@@ -224,6 +224,7 @@ static int dsdb_schema_from_db(struct ldb_module *module, struct ldb_dn *schema_
                goto failed;
        }
 
+       (*schema)->refresh_in_progress = true;
        (*schema)->refresh_fn = dsdb_schema_refresh;
        (*schema)->loaded_from_module = module;
        (*schema)->loaded_usn = current_usn;
@@ -231,6 +232,10 @@ static int dsdb_schema_from_db(struct ldb_module *module, struct ldb_dn *schema_
        /* "dsdb_set_schema()" steals schema into the ldb_context */
        ret = dsdb_set_schema(ldb, (*schema));
 
+       if (*schema != NULL) {
+               (*schema)->refresh_in_progress = false;
+       }
+
        if (ret != LDB_SUCCESS) {
                ldb_debug_set(ldb, LDB_DEBUG_FATAL,
                              "schema_load_init: dsdb_set_schema() failed: %d:%s: %s",