[PATCH] fix for Bug 9945

Christian Ambach ambi at samba.org
Tue Sep 13 13:14:36 UTC 2016


Hi list,

attached are proposed patches to fix BZ 9945.

Please review.

Cheers,
Christian

-------------- next part --------------
From 001efe0a04df9fb7b56485c64cd9bd1fb5ba9a74 Mon Sep 17 00:00:00 2001
From: Christian Ambach <ambi at samba.org>
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 <ambi at samba.org>
---
 source4/param/pyparam.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/source4/param/pyparam.c b/source4/param/pyparam.c
index 6a55999..60c4645 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 abeb0b1942a1d55a4d30ac3c0ef6d96800bfaf9c Mon Sep 17 00:00:00 2001
From: Christian Ambach <ambi at samba.org>
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 <ambi at samba.org>
---
 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 3fbbe1f31df482bbbdf7ff61cc7e26208c82fd13 Mon Sep 17 00:00:00 2001
From: Christian Ambach <ambi at samba.org>
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 <ambi at samba.org>
---
 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 6c8afae..07fc05a 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 61e4751f4aa8676bf4af7aa187bd56be478e1043 Mon Sep 17 00:00:00 2001
From: Christian Ambach <ambi at samba.org>
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 <ambi at samba.org>
---
 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 d1a1b08..a50a409 100644
--- a/python/samba/join.py
+++ b/python/samba/join.py
@@ -402,7 +402,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)
@@ -868,7 +868,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 f80a3866612944ef0f87ba028dfc56f59395f046 Mon Sep 17 00:00:00 2001
From: Christian Ambach <ambi at samba.org>
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 <ambi at samba.org>
---
 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

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: OpenPGP digital signature
URL: <http://lists.samba.org/pipermail/samba-technical/attachments/20160913/43209d78/signature.sig>


More information about the samba-technical mailing list