summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--source4/param/param.i99
-rw-r--r--source4/param/param.py2
-rw-r--r--source4/param/param_wrap.c215
-rw-r--r--source4/param/tests/bindings.py17
-rw-r--r--source4/scripting/python/misc.i2
-rw-r--r--source4/scripting/python/samba/provision.py66
-rwxr-xr-xsource4/setup/provision.py12
7 files changed, 375 insertions, 38 deletions
diff --git a/source4/param/param.i b/source4/param/param.i
index 3d5deba5ff..dca2496f94 100644
--- a/source4/param/param.i
+++ b/source4/param/param.i
@@ -24,6 +24,7 @@
#include "includes.h"
#include "param/param.h"
+#include "param/loadparm.h"
typedef struct param_context param;
typedef struct loadparm_context loadparm_context;
@@ -57,6 +58,104 @@ typedef struct loadparm_context {
bool is_mydomain(const char *domain) { return lp_is_mydomain($self, domain); }
bool is_myname(const char *name) { return lp_is_myname($self, name); }
int use(struct param_context *param) { return param_use($self, param); }
+ bool set(const char *parm_name, const char *parm_value) {
+ return lp_set_cmdline($self, parm_name, parm_value);
+ }
+
+ PyObject *get(const char *param_name, const char *service_name)
+ {
+ struct parm_struct *parm = NULL;
+ void *parm_ptr = NULL;
+ int i;
+
+ if (service_name != NULL) {
+ struct loadparm_service *service;
+ /* its a share parameter */
+ service = lp_service($self, service_name);
+ if (service == NULL) {
+ return Py_None;
+ }
+ if (strchr(param_name, ':')) {
+ /* its a parametric option on a share */
+ const char *type = talloc_strndup($self,
+ param_name,
+ strcspn(param_name, ":"));
+ const char *option = strchr(param_name, ':') + 1;
+ const char *value;
+ if (type == NULL || option == NULL) {
+ return Py_None;
+ }
+ value = lp_get_parametric($self, service, type, option);
+ if (value == NULL) {
+ return Py_None;
+ }
+ return PyString_FromString(value);
+ }
+
+ parm = lp_parm_struct(param_name);
+ if (parm == NULL || parm->class == P_GLOBAL) {
+ return Py_None;
+ }
+ parm_ptr = lp_parm_ptr($self, service, parm);
+ } else if (strchr(param_name, ':')) {
+ /* its a global parametric option */
+ const char *type = talloc_strndup($self,
+ param_name, strcspn(param_name, ":"));
+ const char *option = strchr(param_name, ':') + 1;
+ const char *value;
+ if (type == NULL || option == NULL) {
+ return Py_None;
+ }
+ value = lp_get_parametric($self, NULL, type, option);
+ if (value == NULL)
+ return Py_None;
+ return PyString_FromString(value);
+ } else {
+ /* its a global parameter */
+ parm = lp_parm_struct(param_name);
+ if (parm == NULL) {
+ return Py_None;
+ }
+ parm_ptr = lp_parm_ptr($self, NULL, parm);
+ }
+
+ if (parm == NULL || parm_ptr == NULL) {
+ return Py_None;
+ }
+
+ /* construct and return the right type of python object */
+ switch (parm->type) {
+ case P_STRING:
+ case P_USTRING:
+ return PyString_FromString(*(char **)parm_ptr);
+ case P_BOOL:
+ return PyBool_FromLong(*(bool *)parm_ptr);
+ case P_INTEGER:
+ case P_OCTAL:
+ case P_BYTES:
+ return PyLong_FromLong(*(int *)parm_ptr);
+ case P_ENUM:
+ for (i=0; parm->enum_list[i].name; i++) {
+ if (*(int *)parm_ptr == parm->enum_list[i].value) {
+ return PyString_FromString(parm->enum_list[i].name);
+ }
+ }
+ return Py_None;
+ case P_LIST:
+ {
+ int i;
+ const char **strlist = *(const char ***)parm_ptr;
+ PyObject *pylist = PyList_New(str_list_length(strlist));
+ for (i = 0; strlist[i]; i++)
+ PyList_SetItem(pylist, i,
+ PyString_FromString(strlist[i]));
+ return pylist;
+ }
+
+ break;
+ }
+ return Py_None;
+ }
}
} loadparm_context;
diff --git a/source4/param/param.py b/source4/param/param.py
index bd5965aa17..291459b9b6 100644
--- a/source4/param/param.py
+++ b/source4/param/param.py
@@ -70,6 +70,8 @@ LoadParm.configfile = new_instancemethod(_param.LoadParm_configfile,None,LoadPar
LoadParm.is_mydomain = new_instancemethod(_param.LoadParm_is_mydomain,None,LoadParm)
LoadParm.is_myname = new_instancemethod(_param.LoadParm_is_myname,None,LoadParm)
LoadParm.use = new_instancemethod(_param.LoadParm_use,None,LoadParm)
+LoadParm.set = new_instancemethod(_param.LoadParm_set,None,LoadParm)
+LoadParm.get = new_instancemethod(_param.LoadParm_get,None,LoadParm)
LoadParm_swigregister = _param.LoadParm_swigregister
LoadParm_swigregister(LoadParm)
diff --git a/source4/param/param_wrap.c b/source4/param/param_wrap.c
index ab54bca381..e66d8a2043 100644
--- a/source4/param/param_wrap.c
+++ b/source4/param/param_wrap.c
@@ -2517,6 +2517,7 @@ static swig_module_info swig_module = {swig_types, 15, 0, 0, 0, 0};
#include "includes.h"
#include "param/param.h"
+#include "param/loadparm.h"
typedef struct param_context param;
typedef struct loadparm_context loadparm_context;
@@ -2641,6 +2642,102 @@ SWIG_FromCharPtr(const char *cptr)
SWIGINTERN bool loadparm_context_is_mydomain(loadparm_context *self,char const *domain){ return lp_is_mydomain(self, domain); }
SWIGINTERN bool loadparm_context_is_myname(loadparm_context *self,char const *name){ return lp_is_myname(self, name); }
SWIGINTERN int loadparm_context_use(loadparm_context *self,struct param_context *param){ return param_use(self, param); }
+SWIGINTERN bool loadparm_context_set(loadparm_context *self,char const *parm_name,char const *parm_value){
+ return lp_set_cmdline(self, parm_name, parm_value);
+ }
+SWIGINTERN PyObject *loadparm_context_get(loadparm_context *self,char const *param_name,char const *service_name){
+ struct parm_struct *parm = NULL;
+ void *parm_ptr = NULL;
+ int i;
+
+ if (service_name != NULL) {
+ struct loadparm_service *service;
+ /* its a share parameter */
+ service = lp_service(self, service_name);
+ if (service == NULL) {
+ return Py_None;
+ }
+ if (strchr(param_name, ':')) {
+ /* its a parametric option on a share */
+ const char *type = talloc_strndup(self,
+ param_name,
+ strcspn(param_name, ":"));
+ const char *option = strchr(param_name, ':') + 1;
+ const char *value;
+ if (type == NULL || option == NULL) {
+ return Py_None;
+ }
+ value = lp_get_parametric(self, service, type, option);
+ if (value == NULL) {
+ return Py_None;
+ }
+ return PyString_FromString(value);
+ }
+
+ parm = lp_parm_struct(param_name);
+ if (parm == NULL || parm->class == P_GLOBAL) {
+ return Py_None;
+ }
+ parm_ptr = lp_parm_ptr(self, service, parm);
+ } else if (strchr(param_name, ':')) {
+ /* its a global parametric option */
+ const char *type = talloc_strndup(self,
+ param_name, strcspn(param_name, ":"));
+ const char *option = strchr(param_name, ':') + 1;
+ const char *value;
+ if (type == NULL || option == NULL) {
+ return Py_None;
+ }
+ value = lp_get_parametric(self, NULL, type, option);
+ if (value == NULL)
+ return Py_None;
+ return PyString_FromString(value);
+ } else {
+ /* its a global parameter */
+ parm = lp_parm_struct(param_name);
+ if (parm == NULL) {
+ return Py_None;
+ }
+ parm_ptr = lp_parm_ptr(self, NULL, parm);
+ }
+
+ if (parm == NULL || parm_ptr == NULL) {
+ return Py_None;
+ }
+
+ /* construct and return the right type of python object */
+ switch (parm->type) {
+ case P_STRING:
+ case P_USTRING:
+ return PyString_FromString(*(char **)parm_ptr);
+ case P_BOOL:
+ return PyBool_FromLong(*(bool *)parm_ptr);
+ case P_INTEGER:
+ case P_OCTAL:
+ case P_BYTES:
+ return PyLong_FromLong(*(int *)parm_ptr);
+ case P_ENUM:
+ for (i=0; parm->enum_list[i].name; i++) {
+ if (*(int *)parm_ptr == parm->enum_list[i].value) {
+ return PyString_FromString(parm->enum_list[i].name);
+ }
+ }
+ return Py_None;
+ case P_LIST:
+ {
+ int i;
+ const char **strlist = *(const char ***)parm_ptr;
+ PyObject *pylist = PyList_New(str_list_length(strlist));
+ for (i = 0; strlist[i]; i++)
+ PyList_SetItem(pylist, i,
+ PyString_FromString(strlist[i]));
+ return pylist;
+ }
+
+ break;
+ }
+ return Py_None;
+ }
SWIGINTERN void delete_loadparm_context(loadparm_context *self){ talloc_free(self); }
SWIGINTERN char const *loadparm_service_volume_label(loadparm_service *self){ return volume_label(self); }
SWIGINTERN char const *loadparm_service_printername(loadparm_service *self){ return lp_printername(self); }
@@ -2954,6 +3051,122 @@ fail:
}
+SWIGINTERN PyObject *_wrap_LoadParm_set(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) {
+ PyObject *resultobj = 0;
+ loadparm_context *arg1 = (loadparm_context *) 0 ;
+ char *arg2 = (char *) 0 ;
+ char *arg3 = (char *) 0 ;
+ bool result;
+ void *argp1 = 0 ;
+ int res1 = 0 ;
+ int res2 ;
+ char *buf2 = 0 ;
+ int alloc2 = 0 ;
+ int res3 ;
+ char *buf3 = 0 ;
+ int alloc3 = 0 ;
+ PyObject * obj0 = 0 ;
+ PyObject * obj1 = 0 ;
+ PyObject * obj2 = 0 ;
+ char * kwnames[] = {
+ (char *) "self",(char *) "parm_name",(char *) "parm_value", NULL
+ };
+
+ {
+ arg1 = loadparm_init(NULL);
+ }
+ if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"|OOO:LoadParm_set",kwnames,&obj0,&obj1,&obj2)) SWIG_fail;
+ if (obj0) {
+ res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_loadparm_context, 0 | 0 );
+ if (!SWIG_IsOK(res1)) {
+ SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "LoadParm_set" "', argument " "1"" of type '" "loadparm_context *""'");
+ }
+ arg1 = (loadparm_context *)(argp1);
+ }
+ if (obj1) {
+ res2 = SWIG_AsCharPtrAndSize(obj1, &buf2, NULL, &alloc2);
+ if (!SWIG_IsOK(res2)) {
+ SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "LoadParm_set" "', argument " "2"" of type '" "char const *""'");
+ }
+ arg2 = (char *)(buf2);
+ }
+ if (obj2) {
+ res3 = SWIG_AsCharPtrAndSize(obj2, &buf3, NULL, &alloc3);
+ if (!SWIG_IsOK(res3)) {
+ SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "LoadParm_set" "', argument " "3"" of type '" "char const *""'");
+ }
+ arg3 = (char *)(buf3);
+ }
+ result = (bool)loadparm_context_set(arg1,(char const *)arg2,(char const *)arg3);
+ resultobj = SWIG_From_bool((bool)(result));
+ if (alloc2 == SWIG_NEWOBJ) free((char*)buf2);
+ if (alloc3 == SWIG_NEWOBJ) free((char*)buf3);
+ return resultobj;
+fail:
+ if (alloc2 == SWIG_NEWOBJ) free((char*)buf2);
+ if (alloc3 == SWIG_NEWOBJ) free((char*)buf3);
+ return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_LoadParm_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) {
+ PyObject *resultobj = 0;
+ loadparm_context *arg1 = (loadparm_context *) 0 ;
+ char *arg2 = (char *) 0 ;
+ char *arg3 = (char *) 0 ;
+ PyObject *result = 0 ;
+ void *argp1 = 0 ;
+ int res1 = 0 ;
+ int res2 ;
+ char *buf2 = 0 ;
+ int alloc2 = 0 ;
+ int res3 ;
+ char *buf3 = 0 ;
+ int alloc3 = 0 ;
+ PyObject * obj0 = 0 ;
+ PyObject * obj1 = 0 ;
+ PyObject * obj2 = 0 ;
+ char * kwnames[] = {
+ (char *) "self",(char *) "param_name",(char *) "service_name", NULL
+ };
+
+ {
+ arg1 = loadparm_init(NULL);
+ }
+ if (!PyArg_ParseTupleAndKeywords(args,kwargs,(char *)"|OOO:LoadParm_get",kwnames,&obj0,&obj1,&obj2)) SWIG_fail;
+ if (obj0) {
+ res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_loadparm_context, 0 | 0 );
+ if (!SWIG_IsOK(res1)) {
+ SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "LoadParm_get" "', argument " "1"" of type '" "loadparm_context *""'");
+ }
+ arg1 = (loadparm_context *)(argp1);
+ }
+ if (obj1) {
+ res2 = SWIG_AsCharPtrAndSize(obj1, &buf2, NULL, &alloc2);
+ if (!SWIG_IsOK(res2)) {
+ SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "LoadParm_get" "', argument " "2"" of type '" "char const *""'");
+ }
+ arg2 = (char *)(buf2);
+ }
+ if (obj2) {
+ res3 = SWIG_AsCharPtrAndSize(obj2, &buf3, NULL, &alloc3);
+ if (!SWIG_IsOK(res3)) {
+ SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "LoadParm_get" "', argument " "3"" of type '" "char const *""'");
+ }
+ arg3 = (char *)(buf3);
+ }
+ result = (PyObject *)loadparm_context_get(arg1,(char const *)arg2,(char const *)arg3);
+ resultobj = result;
+ if (alloc2 == SWIG_NEWOBJ) free((char*)buf2);
+ if (alloc3 == SWIG_NEWOBJ) free((char*)buf3);
+ return resultobj;
+fail:
+ if (alloc2 == SWIG_NEWOBJ) free((char*)buf2);
+ if (alloc3 == SWIG_NEWOBJ) free((char*)buf3);
+ return NULL;
+}
+
+
SWIGINTERN PyObject *_wrap_delete_LoadParm(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *kwargs) {
PyObject *resultobj = 0;
loadparm_context *arg1 = (loadparm_context *) 0 ;
@@ -3658,6 +3871,8 @@ static PyMethodDef SwigMethods[] = {
{ (char *)"LoadParm_is_mydomain", (PyCFunction) _wrap_LoadParm_is_mydomain, METH_VARARGS | METH_KEYWORDS, NULL},
{ (char *)"LoadParm_is_myname", (PyCFunction) _wrap_LoadParm_is_myname, METH_VARARGS | METH_KEYWORDS, NULL},
{ (char *)"LoadParm_use", (PyCFunction) _wrap_LoadParm_use, METH_VARARGS | METH_KEYWORDS, NULL},
+ { (char *)"LoadParm_set", (PyCFunction) _wrap_LoadParm_set, METH_VARARGS | METH_KEYWORDS, NULL},
+ { (char *)"LoadParm_get", (PyCFunction) _wrap_LoadParm_get, METH_VARARGS | METH_KEYWORDS, NULL},
{ (char *)"delete_LoadParm", (PyCFunction) _wrap_delete_LoadParm, METH_VARARGS | METH_KEYWORDS, NULL},
{ (char *)"LoadParm_swigregister", LoadParm_swigregister, METH_VARARGS, NULL},
{ (char *)"LoadParm_swiginit", LoadParm_swiginit, METH_VARARGS, NULL},
diff --git a/source4/param/tests/bindings.py b/source4/param/tests/bindings.py
index 0bdd28a619..9ea1c00daf 100644
--- a/source4/param/tests/bindings.py
+++ b/source4/param/tests/bindings.py
@@ -29,6 +29,23 @@ class LoadParmTestCase(unittest.TestCase):
file = param.LoadParm()
self.assertEquals(0, len(file))
+ def test_set_workgroup(self):
+ file = param.LoadParm()
+ file.set("workgroup", "bla")
+ self.assertEquals("BLA", file.get("workgroup"))
+
+ def test_is_mydomain(self):
+ file = param.LoadParm()
+ file.set("workgroup", "bla")
+ self.assertTrue(file.is_mydomain("BLA"))
+ self.assertFalse(file.is_mydomain("FOOBAR"))
+
+ def test_is_myname(self):
+ file = param.LoadParm()
+ file.set("netbios name", "bla")
+ self.assertTrue(file.is_myname("BLA"))
+ self.assertFalse(file.is_myname("FOOBAR"))
+
class ParamTestCase(unittest.TestCase):
def test_init(self):
diff --git a/source4/scripting/python/misc.i b/source4/scripting/python/misc.i
index eda0db2c3d..a0519644b8 100644
--- a/source4/scripting/python/misc.i
+++ b/source4/scripting/python/misc.i
@@ -32,7 +32,7 @@
%import "../../auth/credentials/credentials.i"
%import "../../param/param.i"
%import "../../libcli/security/security.i"
-%import "../../libcli/util/errors.i";
+%import "../../libcli/util/errors.i"
%rename(random_password) generate_random_str;
char *generate_random_str(TALLOC_CTX *mem_ctx, size_t len);
diff --git a/source4/scripting/python/samba/provision.py b/source4/scripting/python/samba/provision.py
index 7d7b85c13e..d88b8501ba 100644
--- a/source4/scripting/python/samba/provision.py
+++ b/source4/scripting/python/samba/provision.py
@@ -122,13 +122,13 @@ class ProvisionSettings(object):
if not valid_netbios_name(self.netbiosname):
raise InvalidNetbiosName(self.netbiosname)
- if lp.get_string("workgroup").upper() != self.domain.upper():
+ if lp.get("workgroup").upper() != self.domain.upper():
raise Error("workgroup '%s' in smb.conf must match chosen domain '%s'\n",
- lp.get_string("workgroup"), self.domain)
+ lp.get("workgroup"), self.domain)
- if lp.get_string("realm").upper() != self.realm.upper():
+ if lp.get("realm").upper() != self.realm.upper():
raise Error("realm '%s' in smb.conf must match chosen realm '%s'\n" %
- (lp.get_string("realm"), self.realm))
+ (lp.get("realm"), self.realm))
class ProvisionPaths:
@@ -154,10 +154,10 @@ class ProvisionPaths:
def install_ok(lp, session_info, credentials):
"""Check whether the current install seems ok."""
- if lp.get_string("realm") == "":
+ if lp.get("realm") == "":
return False
- ldb = Ldb(lp.get_string("sam database"), session_info=session_info,
- credentials=credentials)
+ ldb = Ldb(lp.get("sam database"), session_info=session_info,
+ credentials=credentials, lp=lp)
if len(ldb.search("(cn=Administrator)")) != 1:
return False
return True
@@ -195,14 +195,16 @@ def ldb_delete(ldb):
ldb.connect(ldb.filename)
-def open_ldb(session_info, credentials, dbname):
+def open_ldb(session_info, credentials, lp, dbname):
assert session_info is not None
try:
- return Ldb(dbname, session_info=session_info, credentials=credentials)
+ return Ldb(dbname, session_info=session_info, credentials=credentials,
+ lp=lp)
except LdbError, e:
print e
os.unlink(dbname)
- return Ldb(dbname, session_info=session_info, credentials=credentials)
+ return Ldb(dbname, session_info=session_info, credentials=credentials,
+ lp=lp)
def setup_add_ldif(setup_dir, ldif, subobj, ldb):
@@ -228,10 +230,10 @@ def setup_modify_ldif(setup_dir, ldif, subobj, ldb):
ldb.modify(msg)
-def setup_ldb(setup_dir, ldif, session_info, credentials, subobj, dbname,
+def setup_ldb(setup_dir, ldif, session_info, credentials, subobj, lp, dbname,
erase=True):
assert dbname is not None
- ldb = open_ldb(session_info, credentials, dbname)
+ ldb = open_ldb(session_info, credentials, lp, dbname)
assert ldb is not None
ldb.transaction_start()
try:
@@ -277,10 +279,10 @@ def provision_default_paths(lp, subobj):
:param subobj: Object
"""
paths = ProvisionPaths()
- private_dir = lp.get_string("private dir")
+ private_dir = lp.get("private dir")
paths.shareconf = os.path.join(private_dir, "share.ldb")
- paths.samdb = lp.get_string("sam database") or os.path.join(private_dir, "samdb.ldb")
- paths.secrets = lp.get_string("secrets database") or os.path.join(private_dir, "secrets.ldb")
+ paths.samdb = lp.get("sam database") or os.path.join(private_dir, "samdb.ldb")
+ paths.secrets = lp.get("secrets database") or os.path.join(private_dir, "secrets.ldb")
paths.templates = os.path.join(private_dir, "templates.ldb")
paths.keytab = os.path.join(private_dir, "secrets.keytab")
paths.dns = os.path.join(private_dir, subobj.dnsdomain + ".zone")
@@ -329,22 +331,22 @@ def setup_name_mappings(subobj, ldb):
ldb.setup_name_mapping(subobj.domaindn, sid + "-520", subobj.wheel)
-def provision_become_dc(setup_dir, subobj, message, paths, session_info,
+def provision_become_dc(setup_dir, subobj, message, paths, lp, session_info,
credentials):
assert session_info is not None
subobj.fix(paths)
message("Setting up templates into %s" % paths.templates)
setup_ldb(setup_dir, "provision_templates.ldif", session_info,
- credentials, subobj, paths.templates)
+ credentials, subobj, lp, paths.templates)
# Also wipes the database
message("Setting up %s partitions" % paths.samdb)
setup_ldb(setup_dir, "provision_partitions.ldif", session_info,
- credentials, subobj, paths.samdb)
+ credentials, subobj, lp, paths.samdb)
samdb = SamDB(paths.samdb, session_info=session_info,
- credentials=credentials)
+ credentials=credentials, lp=lp)
ldb.transaction_start()
try:
message("Setting up %s attributes" % paths.samdb)
@@ -366,9 +368,9 @@ def provision_become_dc(setup_dir, subobj, message, paths, session_info,
message("Setting up %s" % paths.secrets)
setup_ldb(setup_dir, "secrets_init.ldif", session_info, credentials,
- subobj, paths.secrets)
+ subobj, lp, paths.secrets)
- setup_ldb(setup_dir, "secrets.ldif", session_info, credentials, subobj,
+ setup_ldb(setup_dir, "secrets.ldif", session_info, credentials, subobj, lp,
paths.secrets, False)
@@ -401,11 +403,11 @@ def provision(lp, setup_dir, subobj, message, blank, paths, session_info,
# only install a new shares config db if there is none
if not os.path.exists(paths.shareconf):
message("Setting up share.ldb")
- setup_ldb(setup_dir, "share.ldif", session_info, credentials, subobj, paths.shareconf)
+ setup_ldb(setup_dir, "share.ldif", session_info, credentials, subobj, lp, paths.shareconf)
message("Setting up %s" % paths.secrets)
- setup_ldb(setup_dir, "secrets_init.ldif", session_info, credentials, subobj, paths.secrets)
- setup_ldb(setup_dir, "secrets.ldif", session_info, credentials, subobj, paths.secrets, False)
+ setup_ldb(setup_dir, "secrets_init.ldif", session_info, credentials, subobj, lp, paths.secrets)
+ setup_ldb(setup_dir, "secrets.ldif", session_info, credentials, subobj, lp, paths.secrets, False)
message("Setting up registry")
reg = registry.Registry()
@@ -414,13 +416,13 @@ def provision(lp, setup_dir, subobj, message, blank, paths, session_info,
#reg.apply_patchfile(os.path.join(setup_dir, "provision.reg"))
message("Setting up templates into %s" % paths.templates)
- setup_ldb(setup_dir, "provision_templates.ldif", session_info, credentials, subobj, paths.templates)
+ setup_ldb(setup_dir, "provision_templates.ldif", session_info, credentials, subobj, lp, paths.templates)
message("Setting up sam.ldb partitions")
setup_ldb(setup_dir, "provision_partitions.ldif", session_info,
- credentials, subobj, paths.samdb)
+ credentials, subobj, lp, paths.samdb)
- samdb = open_ldb(session_info, credentials, paths.samdb)
+ samdb = open_ldb(session_info, credentials, lp, paths.samdb)
samdb.transaction_start()
try:
message("Setting up sam.ldb attributes")
@@ -439,7 +441,8 @@ def provision(lp, setup_dir, subobj, message, blank, paths, session_info,
message("Pre-loading the Samba 4 and AD schema")
- samdb = SamDB(paths.samdb, session_info, credentials)
+ samdb = SamDB(paths.samdb, session_info=session_info,
+ credentials=credentials, lp=lp)
samdb.set_domain_sid(subobj.domainsid)
load_schema(setup_dir, subobj, samdb)
@@ -531,7 +534,8 @@ def provision_dns(setup_dir, subobj, message, paths, session_info, credentials):
"""Write out a DNS zone file, from the info in the current database."""
message("Setting up DNS zone: %s" % subobj.dnsdomain)
# connect to the sam
- ldb = SamDB(paths.samdb, session_info=session_info, credentials=credentials)
+ ldb = SamDB(paths.samdb, session_info=session_info, credentials=credentials,
+ lp=lp)
# These values may have changed, due to an incoming SamSync,
# or may not have been specified, so fetch them from the database
@@ -576,8 +580,8 @@ def provision_ldapbase(setup_dir, subobj, message, paths):
def provision_guess(lp):
"""guess reasonably default options for provisioning."""
- subobj = ProvisionSettings(realm=lp.get_string("realm").upper(),
- domain=lp.get_string("workgroup"),
+ subobj = ProvisionSettings(realm=lp.get("realm").upper(),
+ domain=lp.get("workgroup"),
hostname=hostname(),
hostip=hostip())
diff --git a/source4/setup/provision.py b/source4/setup/provision.py
index 5a92ac7e8e..d00cb15ebd 100755
--- a/source4/setup/provision.py
+++ b/source4/setup/provision.py
@@ -115,11 +115,11 @@ if opts.realm is None or opts.domain is None or opts.host_name is None:
sys.exit(1)
# cope with an initially blank smb.conf
-lp = param.ParamFile()
-lp.read(opts.configfile)
-lp.set_string("realm", opts.realm)
-lp.set_string("workgroup", opts.domain)
-lp.set_string("server role", opts.server_role)
+lp = param.LoadParm()
+lp.load(opts.configfile)
+lp.set("realm", opts.realm)
+lp.set("workgroup", opts.domain)
+lp.set("server role", opts.server_role)
subobj = provision_guess(lp)
subobj.domain_guid = opts.domain_guid
@@ -162,7 +162,7 @@ if opts.ldap_base:
message("Please install the LDIF located in %s, %s and into your LDAP server, and re-run with --ldap-backend=ldap://my.ldap.server" % (paths.ldap_basedn_ldif, paths.ldap_config_basedn_ldif, paths.ldap_schema_basedn_ldif))
elif opts.partitions_only:
provision_become_dc(setup_dir, subobj, message, False,
- paths, system_session(), creds)
+ paths, lp, system_session(), creds)
else:
provision(lp, setup_dir, subobj, message, opts.blank, paths,
system_session(), creds, opts.ldap_backend)