[PATCH] small KCC fixes
Kamen Mazdrashki
kamenim at samba.org
Mon Apr 21 18:08:24 MDT 2014
Hi Jelmer, Andrew,
Could you please review a patch of small fixes for Python KCC
implementation.
Since it is more that just one commit, I've pushed it to gerrit:
https://gerrit.samba.org/#/q/status:open+project:samba+branch:master+topic:kcc-small-fixes,n,z
Starting from:
https://gerrit.samba.org/#/c/229/
Also attached to this mail for console-lovers :)
Cheers,
Kamen
-------------- next part --------------
From 287bae01eb563d3028108c05f48823b5740b1270 Mon Sep 17 00:00:00 2001
From: Kamen Mazdrashki <kamenim at samba.org>
Date: Mon, 21 Apr 2014 14:32:48 +0200
Subject: [PATCH 1/6] s4:KCC: Use dsdb.DS_DOMAIN_FUNCTION_2008 constant for
DS-Behavior comparisons
DS_BEHAVIOR_WIN2008 was used so far which is a leftover from previous
KCC implementation in "C"
Change-Id: Id9b6551073c0b17cc27e086faa315b01305f39a5
Signed-off-by: Kamen Mazdrashki <kamenim at samba.org>
---
python/samba/kcc_utils.py | 2 +-
source4/scripting/bin/samba_kcc | 8 ++++----
2 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/python/samba/kcc_utils.py b/python/samba/kcc_utils.py
index 57c3187..2692e45 100644
--- a/python/samba/kcc_utils.py
+++ b/python/samba/kcc_utils.py
@@ -502,7 +502,7 @@ class DirectoryServiceAgent(object):
"""Is dsa at minimum windows level greater than or equal to (version)
:param version: Windows version to test against
- (e.g. DS_BEHAVIOR_WIN2008)
+ (e.g. DS_DOMAIN_FUNCTION_2008)
"""
if self.dsa_behavior >= version:
return True
diff --git a/source4/scripting/bin/samba_kcc b/source4/scripting/bin/samba_kcc
index e3d38c9..6301e49 100755
--- a/source4/scripting/bin/samba_kcc
+++ b/source4/scripting/bin/samba_kcc
@@ -1009,10 +1009,10 @@ class KCC(object):
# IF AmIRODC() and cr!nCName corresponds to default NC then
# Let dsaobj be the nTDSDSA object of the dc
- # IF dsaobj.msDS-Behavior-Version < DS_BEHAVIOR_WIN2008
+ # IF dsaobj.msDS-Behavior-Version < DS_DOMAIN_FUNCTION_2008
# Skip dc
if self.my_dsa.is_ro() and part.is_default():
- if not dsa.is_minimum_behavior(DS_BEHAVIOR_WIN2008):
+ if not dsa.is_minimum_behavior(dsdb.DS_DOMAIN_FUNCTION_2008):
continue
# IF t!name != "IP" and the parent object of dc has no value for
@@ -1651,7 +1651,7 @@ class KCC(object):
# an RODC, at least one writable domain controller in
# the domain must be running Windows Server 2008
if ro and not partial and nc_x.nc_type == NCType.domain:
- if not dc_s.is_minimum_behavior(DS_BEHAVIOR_WIN2008):
+ if not dc_s.is_minimum_behavior(dsdb.DS_DOMAIN_FUNCTION_2008):
continue
# If we haven't been told to turn off stale connection
@@ -1724,7 +1724,7 @@ class KCC(object):
# is no minimum windows behavior for those since GCs
# have always been present.
if ro and not partial and nc_x.nc_type == NCType.domain:
- if not dc_s.is_minimum_behavior(DS_BEHAVIOR_WIN2008):
+ if not dc_s.is_minimum_behavior(dsdb.DS_DOMAIN_FUNCTION_2008):
continue
# If we haven't been told to turn off stale connection
--
1.8.3.2
From 5d593ec48049d7f55063692110e6c5b42638751b Mon Sep 17 00:00:00 2001
From: Kamen Mazdrashki <kamenim at samba.org>
Date: Mon, 21 Apr 2014 14:43:51 +0200
Subject: [PATCH 2/6] s4:kcc_utils: Propagate 'samdb' into
load_connection_transport() method
so it is actually able to make samdb.search-es
Change-Id: I8491fd215710a53fbb41d607381f89afb5267464
Signed-off-by: Kamen Mazdrashki <kamenim at samba.org>
---
python/samba/kcc_utils.py | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/python/samba/kcc_utils.py b/python/samba/kcc_utils.py
index 2692e45..dd0e17a 100644
--- a/python/samba/kcc_utils.py
+++ b/python/samba/kcc_utils.py
@@ -903,7 +903,7 @@ class NTDSConnection(object):
if "transportType" in msg:
dsdn = dsdb_Dn(samdb, msg["tranportType"][0])
- self.load_connection_transport(str(dsdn.dn))
+ self.load_connection_transport(samdb, str(dsdn.dn))
if "schedule" in msg:
self.schedule = ndr_unpack(drsblobs.replSchedule, msg["schedule"][0])
@@ -916,7 +916,7 @@ class NTDSConnection(object):
self.from_dnstr = str(dsdn.dn)
assert self.from_dnstr is not None
- def load_connection_transport(self, tdnstr):
+ def load_connection_transport(self, samdb, tdnstr):
"""Given a NTDSConnection object which enumerates a transport
DN, load the transport information for the connection object
--
1.8.3.2
From 38e725c6f0fcaec2f57955c74a7593ff343f4270 Mon Sep 17 00:00:00 2001
From: Kamen Mazdrashki <kamenim at samba.org>
Date: Mon, 21 Apr 2014 17:32:36 +0200
Subject: [PATCH 3/6] s4:samba_kcc: Fix error handling opening export ldif file
Change-Id: If52440272513ef244e33481476da0e884969153c
Signed-off-by: Kamen Mazdrashki <kamenim at samba.org>
---
source4/scripting/bin/samba_kcc | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/source4/scripting/bin/samba_kcc b/source4/scripting/bin/samba_kcc
index 6301e49..d752f45 100755
--- a/source4/scripting/bin/samba_kcc
+++ b/source4/scripting/bin/samba_kcc
@@ -2037,8 +2037,8 @@ class KCC(object):
try:
f = open(ldif_file, "w")
- except (enum, estr):
- logger.error("Unable to open (%s) : %s" % (ldif_file, estr))
+ except IOError as ioerr:
+ logger.error("Unable to open (%s) : %s" % (ldif_file, str(ioerr)))
return 1
try:
--
1.8.3.2
From aa5acfa76eacea430391d723c65832f5f20f9027 Mon Sep 17 00:00:00 2001
From: Kamen Mazdrashki <kamenim at samba.org>
Date: Mon, 21 Apr 2014 17:36:58 +0200
Subject: [PATCH 4/6] s4:samba_kcc: fix reference to DSA object while building
partial replica list
Change-Id: I33209dfd42d8c3af8d80b862ba0022d15385311b
Signed-off-by: Kamen Mazdrashki <kamenim at samba.org>
---
source4/scripting/bin/samba_kcc | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/source4/scripting/bin/samba_kcc b/source4/scripting/bin/samba_kcc
index d752f45..1b20576 100755
--- a/source4/scripting/bin/samba_kcc
+++ b/source4/scripting/bin/samba_kcc
@@ -1683,7 +1683,7 @@ class KCC(object):
# Pull out the NCReplica with the dn that
# matches NC (x) we are examining.
- p_of_x = dsa.current_rep_table[nc_x.nc_dnstr]
+ p_of_x = dc_s.current_rep_table[nc_x.nc_dnstr]
# Replica (p) of NC (x) must be partial
if not p_of_x.is_partial():
--
1.8.3.2
From 141a351d3d63d7f49a217b539c75094224a7a88f Mon Sep 17 00:00:00 2001
From: Kamen Mazdrashki <kamenim at samba.org>
Date: Mon, 21 Apr 2014 17:39:21 +0200
Subject: [PATCH 5/6] s4:kcc_util: fix loading connection transport object -
used to refer to not defined object
Change-Id: If8dc8e8db85f1a882ec73dc83d28fa1b5156de84
Signed-off-by: Kamen Mazdrashki <kamenim at samba.org>
---
python/samba/kcc_utils.py | 1 +
1 file changed, 1 insertion(+)
diff --git a/python/samba/kcc_utils.py b/python/samba/kcc_utils.py
index dd0e17a..ad0f4e5 100644
--- a/python/samba/kcc_utils.py
+++ b/python/samba/kcc_utils.py
@@ -932,6 +932,7 @@ class NTDSConnection(object):
(tdnstr, estr))
if "objectGUID" in res[0]:
+ msg = res[0]
self.transport_dnstr = tdnstr
self.transport_guid = \
misc.GUID(samdb.schema_format_value("objectGUID",
--
1.8.3.2
From a3727986edc3bd55684fa4e4cff46a250fc2f59c Mon Sep 17 00:00:00 2001
From: Kamen Mazdrashki <kamenim at samba.org>
Date: Mon, 21 Apr 2014 17:51:09 +0200
Subject: [PATCH 6/6] s4:samba_kcc: Use 'dburl' passed from command line rather
than lp.samdb_url()
This patch makes '-H, --URL' param to actually work as expected
Change-Id: Ie7f4e9e3fc1f79a938473312e200f36de6886596
Signed-off-by: Kamen Mazdrashki <kamenim at samba.org>
---
source4/scripting/bin/samba_kcc | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/source4/scripting/bin/samba_kcc b/source4/scripting/bin/samba_kcc
index 1b20576..617cad2 100755
--- a/source4/scripting/bin/samba_kcc
+++ b/source4/scripting/bin/samba_kcc
@@ -1910,13 +1910,13 @@ class KCC(object):
# currently importing an ldif for a test run
if self.samdb is None:
try:
- self.samdb = SamDB(url=lp.samdb_url(),
+ self.samdb = SamDB(url=dburl,
session_info=system_session(),
credentials=creds, lp=lp)
except ldb.LdbError, (num, msg):
logger.error("Unable to open sam database %s : %s" %
- (lp.samdb_url(), msg))
+ (dburl, msg))
return 1
try:
@@ -2027,7 +2027,7 @@ class KCC(object):
credentials=creds, lp=lp)
except ldb.LdbError, (enum, estr):
logger.error("Unable to open sam database (%s) : %s" %
- (lp.samdb_url(), estr))
+ (dburl, estr))
return 1
if os.path.exists(ldif_file):
--
1.8.3.2
More information about the samba-technical
mailing list