[SCM] Samba Shared Repository - branch master updated - 673ca5145c9c120cdb522096fd625662407f6f3d

Jelmer Vernooij jelmer at samba.org
Fri Jan 16 14:05:58 GMT 2009


The branch, master has been updated
       via  673ca5145c9c120cdb522096fd625662407f6f3d (commit)
      from  0d7ca8e89e37d1aa07a4c8fad6a24ac41ceb4855 (commit)

http://gitweb.samba.org/?p=samba.git;a=shortlog;h=master


- Log -----------------------------------------------------------------
commit 673ca5145c9c120cdb522096fd625662407f6f3d
Author: Jelmer Vernooij <jelmer at samba.org>
Date:   Fri Jan 16 15:05:15 2009 +0100

    Find default smb.conf path correctly, when it was not specified on the
    command-line.

-----------------------------------------------------------------------

Summary of changes:
 source4/param/loadparm.c                    |   14 ++++++++++----
 source4/param/param.h                       |    1 +
 source4/param/pyparam.c                     |   13 ++++++++++++-
 source4/scripting/python/samba/provision.py |    8 ++++++++
 4 files changed, 31 insertions(+), 5 deletions(-)


Changeset truncated at 500 lines:

diff --git a/source4/param/loadparm.c b/source4/param/loadparm.c
index 2d9af33..c1a0124 100644
--- a/source4/param/loadparm.c
+++ b/source4/param/loadparm.c
@@ -2427,13 +2427,19 @@ const char *lp_configfile(struct loadparm_context *lp_ctx)
 	return lp_ctx->szConfigFile;
 }
 
-bool lp_load_default(struct loadparm_context *lp_ctx)
+const char *lp_default_path(void)
 {
-    const char *path;
     if (getenv("SMB_CONF_PATH"))
-        path = getenv("SMB_CONF_PATH");
+        return getenv("SMB_CONF_PATH");
     else
-        path = dyn_CONFIGFILE;
+        return dyn_CONFIGFILE;
+}
+
+bool lp_load_default(struct loadparm_context *lp_ctx)
+{
+    const char *path;
+
+    path = lp_default_path();
 
     if (!file_exist(path)) {
 	    /* We allow the default smb.conf file to not exist, 
diff --git a/source4/param/param.h b/source4/param/param.h
index ba0dbfd..3d257be 100644
--- a/source4/param/param.h
+++ b/source4/param/param.h
@@ -279,6 +279,7 @@ void lp_killunused(struct loadparm_context *lp_ctx,
 struct loadparm_context *loadparm_init(TALLOC_CTX *mem_ctx);
 const char *lp_configfile(struct loadparm_context *lp_ctx);
 bool lp_load_default(struct loadparm_context *lp_ctx);
+const char *lp_default_path(void);
 
 /**
  * Load the services array from the services file.
diff --git a/source4/param/pyparam.c b/source4/param/pyparam.c
index 0061ead..4277590 100644
--- a/source4/param/pyparam.c
+++ b/source4/param/pyparam.c
@@ -358,6 +358,17 @@ struct loadparm_context *py_default_loadparm_context(TALLOC_CTX *mem_ctx)
     return ret;
 }
 
+static PyObject *py_default_path(PyObject *self)
+{
+    return PyString_FromString(lp_default_path());
+}
+
+static PyMethodDef pyparam_methods[] = {
+    { "default_path", (PyCFunction)py_default_path, METH_NOARGS, 
+        "Returns the default smb.conf path." },
+    { NULL }
+};
+
 void initparam(void)
 {
 	PyObject *m;
@@ -365,7 +376,7 @@ void initparam(void)
 	if (PyType_Ready(&PyLoadparmContext) < 0)
 		return;
 
-	m = Py_InitModule3("param", NULL, "Parsing and writing Samba configuration files.");
+	m = Py_InitModule3("param", pyparam_methods, "Parsing and writing Samba configuration files.");
 	if (m == NULL)
 		return;
 
diff --git a/source4/scripting/python/samba/provision.py b/source4/scripting/python/samba/provision.py
index 6becc78..70bd8ac 100644
--- a/source4/scripting/python/samba/provision.py
+++ b/source4/scripting/python/samba/provision.py
@@ -344,6 +344,9 @@ def guess_names(lp=None, hostname=None, domain=None, dnsdomain=None, serverrole=
 
 def make_smbconf(smbconf, setup_path, hostname, domain, realm, serverrole, 
                  targetdir):
+    """Create a new smb.conf file based on a couple of basic settings.
+    """
+    assert smbconf is not None
     if hostname is None:
         hostname = socket.gethostname().split(".")[0].lower()
 
@@ -947,6 +950,8 @@ def provision(setup_dir, message, session_info,
         if (not os.path.exists(os.path.join(targetdir, "etc"))):
             os.makedirs(os.path.join(targetdir, "etc"))
         smbconf = os.path.join(targetdir, "etc", "smb.conf")
+    elif smbconf is None:
+        smbconf = param.default_path()
 
     # only install a new smb.conf if there isn't one there already
     if not os.path.exists(smbconf):
@@ -1178,6 +1183,9 @@ def provision_backend(setup_dir=None, message=None,
         if (not os.path.exists(os.path.join(targetdir, "etc"))):
             os.makedirs(os.path.join(targetdir, "etc"))
         smbconf = os.path.join(targetdir, "etc", "smb.conf")
+    elif smbconf is None:
+        smbconf = param.default_path()
+        assert smbconf is not None
 
     # only install a new smb.conf if there isn't one there already
     if not os.path.exists(smbconf):


-- 
Samba Shared Repository


More information about the samba-cvs mailing list