Previously, if this function was called without an existing stackframe
then uses of talloc_tos in source3/registry trigger a panic. Since we
intend to add patches that allow access to this call with Python
bindings, that will not typically have a talloc_stackframe already, we
add a talloc_stackframe call around the call to
smbconf_init_reg_internal. This hides the use of talloc_tos in the
registry code from higher level code that needs to call smbconf.
Signed-off-by: John Mulligan <jmulligan@redhat.com>
Reviewed-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
sbcErr smbconf_init_reg(TALLOC_CTX *mem_ctx, struct smbconf_ctx **conf_ctx,
const char *path)
{
- return smbconf_init_internal(mem_ctx, conf_ctx, path, &smbconf_ops_reg);
+ /*
+ * this tmp_ctx stackframe is required to initialize the registry backend.
+ * Without it, the calls panics due to the use of talloc_tos in the
+ * source3/registry code.
+ */
+ TALLOC_CTX *tmp_ctx = talloc_stackframe();
+ sbcErr err = smbconf_init_internal(mem_ctx, conf_ctx, path, &smbconf_ops_reg);
+ talloc_free(tmp_ctx);
+ return err;
}