summaryrefslogtreecommitdiff
path: root/source4/dsdb/schema
diff options
context:
space:
mode:
authorAndrew Bartlett <abartlet@samba.org>2012-08-22 22:08:36 +1000
committerAndrew Bartlett <abartlet@samba.org>2012-08-23 15:02:25 +0200
commitd1eac79690d0fe8f8a5a78bcb83a6b4783279e27 (patch)
treee330820d20cb00bc4035cbb30e1ad32ba5344f85 /source4/dsdb/schema
parenta58ac39a5ae97b3aebfde10466798b41baccaacf (diff)
downloadsamba-d1eac79690d0fe8f8a5a78bcb83a6b4783279e27.tar.gz
samba-d1eac79690d0fe8f8a5a78bcb83a6b4783279e27.tar.bz2
samba-d1eac79690d0fe8f8a5a78bcb83a6b4783279e27.zip
s4-dsdb: Do not use a possibly-old loadparm context in schema reload
The loadparm context on the schema DB might have gone away already. Pre-cache the schema refresh interval at load time to avoid worrying about this. Andrew Bartlett
Diffstat (limited to 'source4/dsdb/schema')
-rw-r--r--source4/dsdb/schema/schema.h1
-rw-r--r--source4/dsdb/schema/schema_init.c26
2 files changed, 15 insertions, 12 deletions
diff --git a/source4/dsdb/schema/schema.h b/source4/dsdb/schema/schema.h
index 81ac129d5e..eb288e6bf9 100644
--- a/source4/dsdb/schema/schema.h
+++ b/source4/dsdb/schema/schema.h
@@ -247,6 +247,7 @@ struct dsdb_schema {
bool refresh_in_progress;
time_t ts_last_change;
time_t last_refresh;
+ time_t refresh_interval;
/* This 'opaque' is stored in the metadata and is used to check if the currently
* loaded schema needs a reload because another process has signaled that it has been
* requested to reload the schema (either due through DRS or via the schemaUpdateNow).
diff --git a/source4/dsdb/schema/schema_init.c b/source4/dsdb/schema/schema_init.c
index 8385ac2def..752d4f57dd 100644
--- a/source4/dsdb/schema/schema_init.c
+++ b/source4/dsdb/schema/schema_init.c
@@ -39,6 +39,7 @@ struct dsdb_schema *dsdb_new_schema(TALLOC_CTX *mem_ctx)
if (!schema) {
return NULL;
}
+ schema->refresh_interval = 120;
return schema;
}
@@ -93,6 +94,8 @@ struct dsdb_schema *dsdb_schema_copy_shallow(TALLOC_CTX *mem_ctx,
}
schema_copy->num_attributes = schema->num_attributes;
+ schema_copy->refresh_interval = schema->refresh_interval;
+
/* rebuild indexes */
ret = dsdb_setup_sorted_accessors(ldb, schema_copy);
if (ret != LDB_SUCCESS) {
@@ -840,7 +843,7 @@ int dsdb_schema_from_ldb_results(TALLOC_CTX *mem_ctx, struct ldb_context *ldb,
const struct ldb_val *info_val;
struct ldb_val info_val_default;
struct dsdb_schema *schema;
- struct loadparm_context *lp_ctx = NULL;
+ void *lp_opaque = ldb_get_opaque(ldb, "loadparm");
int ret;
TALLOC_CTX *tmp_ctx = talloc_new(mem_ctx);
@@ -856,6 +859,16 @@ int dsdb_schema_from_ldb_results(TALLOC_CTX *mem_ctx, struct ldb_context *ldb,
return ldb_operr(ldb);
}
+ if (lp_opaque) {
+ struct loadparm_context *lp_ctx = talloc_get_type_abort(lp_opaque, struct loadparm_context);
+ schema->refresh_interval = lpcfg_parm_int(lp_ctx, NULL, "dsdb", "schema_reload_interval", schema->refresh_interval);
+ lp_ctx = talloc_get_type(ldb_get_opaque(ldb, "loadparm"),
+ struct loadparm_context);
+ schema->fsmo.update_allowed = lpcfg_parm_bool(lp_ctx, NULL,
+ "dsdb", "schema update allowed",
+ false);
+ }
+
schema->base_dn = talloc_steal(schema, schema_res->msgs[0]->dn);
prefix_val = ldb_msg_find_ldb_val(schema_res->msgs[0], "prefixMap");
@@ -903,17 +916,6 @@ int dsdb_schema_from_ldb_results(TALLOC_CTX *mem_ctx, struct ldb_context *ldb,
schema->fsmo.we_are_master = false;
}
- lp_ctx = talloc_get_type(ldb_get_opaque(ldb, "loadparm"),
- struct loadparm_context);
- if (lp_ctx) {
- bool allowed = lpcfg_parm_bool(lp_ctx, NULL,
- "dsdb", "schema update allowed",
- false);
- schema->fsmo.update_allowed = allowed;
- } else {
- schema->fsmo.update_allowed = false;
- }
-
DEBUG(5, ("schema_fsmo_init: we are master[%s] updates allowed[%s]\n",
(schema->fsmo.we_are_master?"yes":"no"),
(schema->fsmo.update_allowed?"yes":"no")));