From 673ca5145c9c120cdb522096fd625662407f6f3d Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Fri, 16 Jan 2009 15:05:15 +0100 Subject: Find default smb.conf path correctly, when it was not specified on the command-line. --- source4/param/loadparm.c | 14 ++++++++++---- source4/param/param.h | 1 + source4/param/pyparam.c | 13 ++++++++++++- 3 files changed, 23 insertions(+), 5 deletions(-) (limited to 'source4/param') diff --git a/source4/param/loadparm.c b/source4/param/loadparm.c index 2d9af33325..c1a012474b 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 ba0dbfd0fa..3d257be062 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 0061eadc54..42775908ea 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; -- cgit