mirror of
https://github.com/samba-team/samba.git
synced 2025-12-13 16:23:50 +03:00
lib/smbconf: add delete_global_parameter method to SMBConf
Add a delete_global_parameter method wrapping smbconf_delete_global_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:
committed by
Jeremy Allison
parent
64a36f5bf0
commit
cc26fe829c
@@ -500,6 +500,24 @@ static PyObject *obj_delete_parameter(py_SMBConf_Object * self, PyObject * args)
|
||||
Py_RETURN_NONE;
|
||||
}
|
||||
|
||||
static PyObject *obj_delete_global_parameter(py_SMBConf_Object * self,
|
||||
PyObject * args)
|
||||
{
|
||||
sbcErr err;
|
||||
char *param_name = NULL;
|
||||
|
||||
if (!PyArg_ParseTuple(args, "s", ¶m_name)) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
err = smbconf_delete_global_parameter(self->conf_ctx, param_name);
|
||||
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"
|
||||
@@ -561,6 +579,10 @@ PyDoc_STRVAR(obj_delete_parameter_doc,
|
||||
"delete_parameter(str, str) -> None\n"
|
||||
"Delete a single configuration parameter.\n");
|
||||
|
||||
PyDoc_STRVAR(obj_delete_global_parameter_doc,
|
||||
"delete_parameter(str, str) -> None\n"
|
||||
"Delete a single global configuration parameter.\n");
|
||||
|
||||
static PyMethodDef py_smbconf_obj_methods[] = {
|
||||
{ "requires_messaging", (PyCFunction) obj_requires_messaging,
|
||||
METH_NOARGS, obj_requires_messaging_doc },
|
||||
@@ -586,6 +608,8 @@ static PyMethodDef py_smbconf_obj_methods[] = {
|
||||
obj_delete_share_doc },
|
||||
{ "delete_parameter", (PyCFunction) obj_delete_parameter, METH_VARARGS,
|
||||
obj_delete_parameter_doc },
|
||||
{ "delete_global_parameter", (PyCFunction) obj_delete_global_parameter,
|
||||
METH_VARARGS, obj_delete_global_parameter_doc },
|
||||
{ 0 },
|
||||
};
|
||||
|
||||
|
||||
@@ -234,6 +234,31 @@ class SMBConfTests(samba.tests.TestCase):
|
||||
),
|
||||
)
|
||||
|
||||
def test_delete_global_parameter(self):
|
||||
sconf = self.s3smbconf.init_reg(None)
|
||||
sconf.drop()
|
||||
sconf.set_global_parameter("workgroup", "EXAMPLE")
|
||||
sconf.set_global_parameter("client min protocol", "NT1")
|
||||
sconf.set_global_parameter("server min protocol", "SMB2")
|
||||
|
||||
s1 = sconf.get_share("global")
|
||||
self.assertEqual(
|
||||
s1,
|
||||
(
|
||||
"global",
|
||||
[
|
||||
("workgroup", "EXAMPLE"),
|
||||
("client min protocol", "NT1"),
|
||||
("server min protocol", "SMB2"),
|
||||
],
|
||||
),
|
||||
)
|
||||
|
||||
sconf.delete_global_parameter("server min protocol")
|
||||
sconf.delete_global_parameter("client min protocol")
|
||||
s1 = sconf.get_share("global")
|
||||
self.assertEqual(s1, ("global", [("workgroup", "EXAMPLE")]))
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
import unittest
|
||||
|
||||
Reference in New Issue
Block a user