summaryrefslogtreecommitdiff
path: root/source4
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2010-11-29 13:25:59 +1100
committerAndrew Tridgell <tridge@samba.org>2010-11-29 18:04:42 +1100
commit33d178767b425510448435748bdd780402106ded (patch)
tree0ba21861705712cff9c76c6760ee5d0c2ebd2bd8 /source4
parentb20ce4392e2d00c3edff8b4b8f329cf22341ea76 (diff)
downloadsamba-33d178767b425510448435748bdd780402106ded.tar.gz
samba-33d178767b425510448435748bdd780402106ded.tar.bz2
samba-33d178767b425510448435748bdd780402106ded.zip
s4-loadparm: use loadparm_init_global() instead of loadparm_init()
this prevents us having two lp_ctx contexts in these tools which leads to bizarre behaviour Pair-Programmed-With: Andrew Bartlett <abartlet@samba.org>
Diffstat (limited to 'source4')
-rw-r--r--source4/kdc/mit_samba.c2
-rw-r--r--source4/lib/cmdline/popt_common.c2
-rw-r--r--source4/param/pyparam.c2
-rw-r--r--source4/param/pyparam_util.c35
4 files changed, 17 insertions, 24 deletions
diff --git a/source4/kdc/mit_samba.c b/source4/kdc/mit_samba.c
index 956ccd394e..3d5888c460 100644
--- a/source4/kdc/mit_samba.c
+++ b/source4/kdc/mit_samba.c
@@ -70,7 +70,7 @@ static int mit_samba_context_init(struct mit_samba_context **_ctx)
ret = ENOMEM;
goto done;
}
- base_ctx.lp_ctx = loadparm_init(ctx);
+ base_ctx.lp_ctx = loadparm_init_global(false);
if (!base_ctx.lp_ctx) {
ret = ENOMEM;
goto done;
diff --git a/source4/lib/cmdline/popt_common.c b/source4/lib/cmdline/popt_common.c
index 7d9e65d55f..76c6fb23a1 100644
--- a/source4/lib/cmdline/popt_common.c
+++ b/source4/lib/cmdline/popt_common.c
@@ -83,7 +83,7 @@ static void popt_samba_callback(poptContext con,
pname++;
if (reason == POPT_CALLBACK_REASON_PRE) {
- cmdline_lp_ctx = loadparm_init(talloc_autofree_context());
+ cmdline_lp_ctx = loadparm_init_global(false);
/* Hook for 'almost the first thing to do in a samba program' here */
/* setup for panics */
diff --git a/source4/param/pyparam.c b/source4/param/pyparam.c
index cb7169e68d..be29c724f1 100644
--- a/source4/param/pyparam.c
+++ b/source4/param/pyparam.c
@@ -330,7 +330,7 @@ static PyObject *py_lp_ctx_new(PyTypeObject *type, PyObject *args, PyObject *kwa
PyErr_NoMemory();
return NULL;
}
- ret->ptr = loadparm_init(ret->talloc_ctx);
+ ret->ptr = loadparm_init_global(false);
return (PyObject *)ret;
}
diff --git a/source4/param/pyparam_util.c b/source4/param/pyparam_util.c
index 474dd31504..57a9b1b772 100644
--- a/source4/param/pyparam_util.c
+++ b/source4/param/pyparam_util.c
@@ -22,33 +22,30 @@
#include "param/param.h"
#include "param/loadparm.h"
#include "lib/talloc/pytalloc.h"
+#include "lib/cmdline/popt_common.h"
#define PyLoadparmContext_AsLoadparmContext(obj) py_talloc_get_type(obj, struct loadparm_context)
_PUBLIC_ struct loadparm_context *lpcfg_from_py_object(TALLOC_CTX *mem_ctx, PyObject *py_obj)
{
- struct loadparm_context *lp_ctx;
+ struct loadparm_context *lp_ctx;
PyObject *param_mod;
PyTypeObject *lp_type;
bool is_lpobj;
- if (PyString_Check(py_obj)) {
- lp_ctx = loadparm_init(mem_ctx);
- if (!lpcfg_load(lp_ctx, PyString_AsString(py_obj))) {
- talloc_free(lp_ctx);
+ if (PyString_Check(py_obj)) {
+ lp_ctx = loadparm_init_global(false);
+ if (!lpcfg_load(lp_ctx, PyString_AsString(py_obj))) {
PyErr_Format(PyExc_RuntimeError, "Unable to load %s",
- PyString_AsString(py_obj));
- return NULL;
- }
- return lp_ctx;
- }
+ PyString_AsString(py_obj));
+ return NULL;
+ }
+ return lp_ctx;
+ }
- if (py_obj == Py_None) {
- lp_ctx = loadparm_init(mem_ctx);
- /* We're not checking that loading the file succeeded *on purpose */
- lpcfg_load_default(lp_ctx);
- return lp_ctx;
- }
+ if (py_obj == Py_None) {
+ return loadparm_init_global(true);
+ }
param_mod = PyImport_ImportModule("samba.param");
if (param_mod == NULL) {
@@ -74,11 +71,7 @@ _PUBLIC_ struct loadparm_context *lpcfg_from_py_object(TALLOC_CTX *mem_ctx, PyOb
struct loadparm_context *py_default_loadparm_context(TALLOC_CTX *mem_ctx)
{
- struct loadparm_context *ret;
- ret = loadparm_init(mem_ctx);
- if (!lpcfg_load_default(ret))
- return NULL;
- return ret;
+ return loadparm_init_global(true);
}