summaryrefslogtreecommitdiff
path: root/source4/param
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/param
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/param')
-rw-r--r--source4/param/pyparam.c2
-rw-r--r--source4/param/pyparam_util.c35
2 files changed, 15 insertions, 22 deletions
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);
}