mirror of
https://github.com/samba-team/samba.git
synced 2025-01-11 05:18:09 +03:00
lib/smbconf: add set_parameter method to SMBConf
Add a set_parameter method wrapping smbconf_set_parameter. Signed-off-by: John Mulligan <jmulligan@redhat.com> Reviewed-by: Jeremy Allison <jra@samba.org> Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
This commit is contained in:
parent
ff603de514
commit
565d8ae8cd
@ -309,6 +309,25 @@ static PyObject *obj_drop(py_SMBConf_Object * self,
|
||||
Py_RETURN_NONE;
|
||||
}
|
||||
|
||||
static PyObject *obj_set_parameter(py_SMBConf_Object * self, PyObject * args)
|
||||
{
|
||||
sbcErr err;
|
||||
char *servicename = NULL;
|
||||
char *param = NULL;
|
||||
char *val = NULL;
|
||||
|
||||
if (!PyArg_ParseTuple(args, "sss", &servicename, ¶m, &val)) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
err = smbconf_set_parameter(self->conf_ctx, servicename, param, val);
|
||||
if (err != SBC_ERR_OK) {
|
||||
py_raise_SMBConfError(err);
|
||||
return NULL;
|
||||
}
|
||||
Py_RETURN_NONE;
|
||||
}
|
||||
|
||||
PyDoc_STRVAR(obj_requires_messaging_doc,
|
||||
"requires_messaging() -> bool\n"
|
||||
"\n"
|
||||
@ -348,6 +367,11 @@ PyDoc_STRVAR(obj_drop_doc,
|
||||
"drop() -> None\n"
|
||||
"Drop the entire configuration, resetting it to an empty state.\n");
|
||||
|
||||
PyDoc_STRVAR(obj_set_parameter_doc,
|
||||
"set_parameter(str, str, str) -> None\n"
|
||||
"Set a configuration parmeter. Specify service name, parameter name,\n"
|
||||
"and parameter value.\n");
|
||||
|
||||
static PyMethodDef py_smbconf_obj_methods[] = {
|
||||
{ "requires_messaging", (PyCFunction) obj_requires_messaging,
|
||||
METH_NOARGS, obj_requires_messaging_doc },
|
||||
@ -363,6 +387,8 @@ static PyMethodDef py_smbconf_obj_methods[] = {
|
||||
obj_create_share_doc },
|
||||
{ "drop", (PyCFunction) obj_drop, METH_NOARGS,
|
||||
obj_drop_doc },
|
||||
{ "set_parameter", (PyCFunction) obj_set_parameter, METH_VARARGS,
|
||||
obj_set_parameter_doc },
|
||||
{ 0 },
|
||||
};
|
||||
|
||||
|
@ -148,6 +148,18 @@ class SMBConfTests(samba.tests.TestCase):
|
||||
names = sconf.share_names()
|
||||
self.assertEqual(names, [])
|
||||
|
||||
def test_set_parameter(self):
|
||||
sconf = self.s3smbconf.init_reg(None)
|
||||
sconf.drop()
|
||||
sconf.create_share("foobar")
|
||||
sconf.set_parameter("foobar", "path", "/mnt/foobar")
|
||||
sconf.set_parameter("foobar", "browseable", "no")
|
||||
|
||||
s1 = sconf.get_share("foobar")
|
||||
self.assertEqual(
|
||||
s1, ("foobar", [("path", "/mnt/foobar"), ("browseable", "no")])
|
||||
)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
import unittest
|
||||
|
Loading…
Reference in New Issue
Block a user