From 3e8e44e4bcc5a79699be0925d93a9a8db1c6e622 Mon Sep 17 00:00:00 2001 From: Christian Ambach Date: Tue, 13 Sep 2016 10:48:03 +0200 Subject: [PATCH 1/5] s4:param add log_level function to retrieve log level in Python code Signed-off-by: Christian Ambach Reviewed-by: Andrew Bartlett (cherry picked from commit 7ba50a200924119ac1a66759e4c1419ece03ba41) --- source4/param/pyparam.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/source4/param/pyparam.c b/source4/param/pyparam.c index fde91e5..29fb9c4 100644 --- a/source4/param/pyparam.c +++ b/source4/param/pyparam.c @@ -322,6 +322,13 @@ static PyObject *py_lp_dump_a_parameter(PyObject *self, PyObject *args) } +static PyObject *py_lp_log_level(PyObject *self, PyObject *unused) +{ + int ret = DEBUGLEVEL_CLASS[DBGC_CLASS]; + return PyInt_FromLong(ret); +} + + static PyObject *py_samdb_url(PyObject *self, PyObject *unused) { struct loadparm_context *lp_ctx = PyLoadparmContext_AsLoadparmContext(self); @@ -357,6 +364,8 @@ static PyMethodDef py_lp_ctx_methods[] = { "Get the server role." }, { "dump", py_lp_dump, METH_VARARGS, "S.dump(stream, show_defaults=False)" }, + { "log_level", py_lp_log_level, METH_NOARGS, + "S.log_level() -> int\n Get the active log level" }, { "dump_a_parameter", py_lp_dump_a_parameter, METH_VARARGS, "S.dump_a_parameter(stream, name, service_name)" }, { "samdb_url", py_samdb_url, METH_NOARGS, -- 1.9.1 From 4d13f14bbaf96d4ca67b8a406d93bd442e230ae4 Mon Sep 17 00:00:00 2001 From: Christian Ambach Date: Tue, 13 Sep 2016 11:22:38 +0200 Subject: [PATCH 2/5] tests/param add a test for LoadParm.log_level Signed-off-by: Christian Ambach Reviewed-by: Andrew Bartlett (cherry picked from commit fa56dbf6706872c5287eab082bb6ba7b5bd3ccd2) --- python/samba/tests/param.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/python/samba/tests/param.py b/python/samba/tests/param.py index f539eba..684c17c 100644 --- a/python/samba/tests/param.py +++ b/python/samba/tests/param.py @@ -55,3 +55,9 @@ class LoadParmTestCase(samba.tests.TestCase): samba_lp = param.LoadParm() samba_lp.load_default() self.assertRaises(KeyError, samba_lp.__getitem__, "nonexistent") + + def test_log_level(self): + samba_lp = param.LoadParm() + samba_lp.set("log level", "5 auth:4") + self.assertEquals(5, samba_lp.log_level()) + -- 1.9.1 From 9d4e1ee45a9651519303642c77daed76b655abcd Mon Sep 17 00:00:00 2001 From: Christian Ambach Date: Tue, 13 Sep 2016 10:49:47 +0200 Subject: [PATCH 3/5] python/drs_utils: do not attempt to parse log level, use parsed value The log level parameter can contain debug class specific entries. Do not attempt to parse this as int, but use the values that the debugging system already parsed BUG: https://bugzilla.samba.org/show_bug.cgi?id=9945 Signed-off-by: Christian Ambach Reviewed-by: Andrew Bartlett (cherry picked from commit dd25aa129b6d799853312134628402f77b492eab) --- python/samba/drs_utils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/python/samba/drs_utils.py b/python/samba/drs_utils.py index 87c9a86..d0f9434 100644 --- a/python/samba/drs_utils.py +++ b/python/samba/drs_utils.py @@ -44,7 +44,7 @@ def drsuapi_connect(server, lp, creds): """ binding_options = "seal" - if int(lp.get("log level")) >= 5: + if lp.log_level() >= 5: binding_options += ",print" binding_string = "ncacn_ip_tcp:%s[%s]" % (server, binding_options) try: -- 1.9.1 From ebd5115fa219d09d9340e8567a583dd4a0715d5b Mon Sep 17 00:00:00 2001 From: Christian Ambach Date: Tue, 13 Sep 2016 10:49:47 +0200 Subject: [PATCH 4/5] python/join: do not attempt to parse log level, use parsed value The log level parameter can contain debug class specific entries. Do not attempt to parse this as int, but use the values that the debugging system already parsed BUG: https://bugzilla.samba.org/show_bug.cgi?id=9945 Signed-off-by: Christian Ambach Reviewed-by: Andrew Bartlett (cherry picked from commit 92178f02bd09277f783eb68b476cfd1452c7f9ef) --- python/samba/join.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/python/samba/join.py b/python/samba/join.py index 6df337c..18630a1 100644 --- a/python/samba/join.py +++ b/python/samba/join.py @@ -373,7 +373,7 @@ class dc_join(object): def drsuapi_connect(ctx): '''make a DRSUAPI connection to the naming master''' binding_options = "seal" - if int(ctx.lp.get("log level")) >= 4: + if ctx.lp.log_level() >= 4: binding_options += ",print" binding_string = "ncacn_ip_tcp:%s[%s]" % (ctx.server, binding_options) ctx.drsuapi = drsuapi.drsuapi(binding_string, ctx.lp, ctx.creds) @@ -810,7 +810,7 @@ class dc_join(object): repl_creds = ctx.creds binding_options = "seal" - if int(ctx.lp.get("log level")) >= 5: + if ctx.lp.log_level() >= 5: binding_options += ",print" repl = drs_utils.drs_Replicate( "ncacn_ip_tcp:%s[%s]" % (ctx.server, binding_options), -- 1.9.1 From 85c79bbc75bf8abd5b3268d443f802141229b173 Mon Sep 17 00:00:00 2001 From: Christian Ambach Date: Tue, 13 Sep 2016 10:49:47 +0200 Subject: [PATCH 5/5] s4:samba_spnupdate: do not attempt to parse log level, use parsed value The log level parameter can contain debug class specific entries. Do not attempt to parse this as int, but use the values that the debugging system already parsed BUG: https://bugzilla.samba.org/show_bug.cgi?id=9945 Signed-off-by: Christian Ambach Reviewed-by: Andrew Bartlett Autobuild-User(master): Christian Ambach Autobuild-Date(master): Wed Sep 14 23:15:18 CEST 2016 on sn-devel-144 (cherry picked from commit 064d24032398c8896da15246be81fdd4b1588e18) --- source4/scripting/bin/samba_spnupdate | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source4/scripting/bin/samba_spnupdate b/source4/scripting/bin/samba_spnupdate index 977de68..c83e575 100755 --- a/source4/scripting/bin/samba_spnupdate +++ b/source4/scripting/bin/samba_spnupdate @@ -219,7 +219,7 @@ def call_rodc_update(d): server = cldap_ret.pdc_dns_name try: binding_options = "seal" - if int(lp.get("log level")) >= 5: + if lp.log_level() >= 5: binding_options += ",print" drs = drsuapi.drsuapi('ncacn_ip_tcp:%s[%s]' % (server, binding_options), lp, creds) (drs_handle, supported_extensions) = drs_utils.drs_DsBind(drs) -- 1.9.1