From 72c6645760e7e568933f6b0359a8a4284d9117ac Mon Sep 17 00:00:00 2001 From: Garming Sam Date: Fri, 3 Jan 2014 11:36:08 +1300 Subject: s4-param: add error messages for failure to dump a parameter Signed-off-by: Garming Sam Reviewed-by: Andrew Bartlett Reviewed-by: Jelmer Vernooij --- source4/param/pyparam.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) (limited to 'source4/param') diff --git a/source4/param/pyparam.c b/source4/param/pyparam.c index 345cd9d44c4..e780c2ece8c 100644 --- a/source4/param/pyparam.c +++ b/source4/param/pyparam.c @@ -291,10 +291,11 @@ static PyObject *py_lp_dump_a_parameter(PyObject *self, PyObject *args) { PyObject *py_stream; char *param_name; - char *section_name = NULL; + const char *section_name = NULL; FILE *f; struct loadparm_context *lp_ctx = PyLoadparmContext_AsLoadparmContext(self); struct loadparm_service *service; + bool ret; if (!PyArg_ParseTuple(args, "Os|z", &py_stream, ¶m_name, §ion_name)) return NULL; @@ -309,14 +310,21 @@ static PyObject *py_lp_dump_a_parameter(PyObject *self, PyObject *args) /* it's a share parameter */ service = lpcfg_service(lp_ctx, section_name); if (service == NULL) { - Py_RETURN_NONE; + PyErr_Format(PyExc_RuntimeError, "Unknown section %s", section_name); + return NULL; } } else { /* it's global */ service = NULL; + section_name = "global"; } - lpcfg_dump_a_parameter(lp_ctx, service, param_name, f); + ret = lpcfg_dump_a_parameter(lp_ctx, service, param_name, f); + + if (!ret) { + PyErr_Format(PyExc_RuntimeError, "Parameter %s unknown for section %s", param_name, section_name); + return NULL; + } Py_RETURN_NONE; -- cgit