command-line.
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,
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.
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;
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;
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()
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):
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):