summaryrefslogtreecommitdiff
path: root/source4/param
diff options
context:
space:
mode:
authorGarming Sam <garming@catalyst.net.nz>2013-12-27 17:09:35 +1300
committerAndrew Bartlett <abartlet@samba.org>2014-01-28 17:26:36 +1300
commite465634eec1ce8ec22948b193f98861199ca59e7 (patch)
treec9166e2328b3285e385990bd80423be9c80aa08b /source4/param
parenta3162686f8b2b080c1d4fd2acbf881798f888dd7 (diff)
downloadsamba-e465634eec1ce8ec22948b193f98861199ca59e7.tar.gz
s4-testparm: modify dumping of parameters to use the lib/param code to have more consistent output
In making this change, it also fixes a bug where attempting to dump a parameter would immediately cause an error (due to a lack of string conversion). Signed-off-by: Garming Sam <garming@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Jelmer Vernooij <jelmer@samba.org>
Diffstat (limited to 'source4/param')
-rw-r--r--source4/param/pyparam.c37
1 files changed, 37 insertions, 0 deletions
diff --git a/source4/param/pyparam.c b/source4/param/pyparam.c
index 9874006bfaa..303a2096c62 100644
--- a/source4/param/pyparam.c
+++ b/source4/param/pyparam.c
@@ -288,6 +288,41 @@ static PyObject *py_lp_dump(PyObject *self, PyObject *args)
Py_RETURN_NONE;
}
+static PyObject *py_lp_dump_a_parameter(PyObject *self, PyObject *args)
+{
+ PyObject *py_stream;
+ char *param_name;
+ char *section_name = NULL;
+ FILE *f;
+ struct loadparm_context *lp_ctx = PyLoadparmContext_AsLoadparmContext(self);
+ struct loadparm_service *service;
+
+ if (!PyArg_ParseTuple(args, "Os|z", &py_stream, &param_name, &section_name))
+ return NULL;
+
+ f = PyFile_AsFile(py_stream);
+ if (f == NULL) {
+ return NULL;
+ }
+
+ if (section_name != NULL && strwicmp(section_name, GLOBAL_NAME) &&
+ strwicmp(section_name, GLOBAL_NAME2)) {
+ /* it's a share parameter */
+ service = lpcfg_service(lp_ctx, section_name);
+ if (service == NULL) {
+ Py_RETURN_NONE;
+ }
+ } else {
+ /* it's global */
+ service = NULL;
+ }
+
+ lpcfg_dump_a_parameter(lp_ctx, service, param_name, f);
+
+ Py_RETURN_NONE;
+
+}
+
static PyObject *py_samdb_url(PyObject *self)
{
struct loadparm_context *lp_ctx = PyLoadparmContext_AsLoadparmContext(self);
@@ -323,6 +358,8 @@ static PyMethodDef py_lp_ctx_methods[] = {
"Get the server role." },
{ "dump", (PyCFunction)py_lp_dump, METH_VARARGS,
"S.dump(stream, show_defaults=False)" },
+ { "dump_a_parameter", (PyCFunction)py_lp_dump_a_parameter, METH_VARARGS,
+ "S.dump_a_parameter(stream, name, service_name)" },
{ "samdb_url", (PyCFunction)py_samdb_url, METH_NOARGS,
"S.samdb_url() -> string\n"
"Returns the current URL for sam.ldb." },