1
0
mirror of https://github.com/samba-team/samba.git synced 2024-12-22 13:34:15 +03:00

KCC: rename is_repsFrom_implied to get_dsa_for_implied_replica, simplify

KCC.is_repsFrom_implied() did more than it sounded like -- it returned
a tuple of (implied, dsa), where the dsa was None if and only if implied
was False, and a DSA object if implied was True. Thus the implied flag
was strictly reduntant and the only caller really only wanted the DSA.
Now it just gets the DSA, or None.

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Garming Sam <garming@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
This commit is contained in:
Douglas Bagnall 2015-04-28 11:20:30 +12:00 committed by Andrew Bartlett
parent fa22921ed4
commit 733d6ea6fa

View File

@ -870,14 +870,19 @@ class KCC(object):
if t_repsFrom.is_modified():
DEBUG_FN("modify_repsFrom(): %s" % t_repsFrom)
def is_repsFrom_implied(self, n_rep, cn_conn):
"""Given a NC replica and NTDS Connection, determine if the connection
implies a repsFrom tuple should be present from the source DSA listed
in the connection to the naming context
def get_dsa_for_implied_replica(self, n_rep, cn_conn):
"""If a connection imply a replica, find the relevant DSA
Given a NC replica and NTDS Connection, determine if the
connection implies a repsFrom tuple should be present from the
source DSA listed in the connection to the naming context. If
it should be, return the DSA; otherwise return None.
Based on part of MS-ADTS 6.2.2.5
:param n_rep: NC replica
:param conn: NTDS Connection
::returns (True || False), source DSA:
:param cn_conn: NTDS Connection
:return: source DSA or None
"""
#XXX different conditions for "implies" than MS-ADTS 6.2.2
@ -888,16 +893,15 @@ class KCC(object):
# cn!options does not contain NTDSCONN_OPT_RODC_TOPOLOGY.
# cn!fromServer references an nTDSDSA object.
s_dsa = None
if not cn_conn.is_enabled() or cn_conn.is_rodc_topology():
return None
if cn_conn.is_enabled() and not cn_conn.is_rodc_topology():
s_dnstr = cn_conn.get_from_dnstr()
if s_dnstr is not None:
s_dsa = self.get_dsa(s_dnstr)
# No DSA matching this source DN string?
if s_dsa is None:
return False, None
return None
# To imply a repsFrom tuple is needed, each of these
# must be True:
@ -911,7 +915,7 @@ class KCC(object):
s_rep = s_dsa.get_current_replica(n_rep.nc_dnstr)
if s_rep is None or not s_rep.is_present():
return False, None
return None
# To imply a repsFrom tuple is needed, each of these
# must be True:
@ -932,9 +936,8 @@ class KCC(object):
cn_conn.transport_dnstr.find("CN=IP") == 0)
if implied:
return True, s_dsa
else:
return False, None
return s_dsa
return None
def translate_ntdsconn(self, current_dsa=None):
"""Adjust repsFrom to match NTDSConnections
@ -1074,8 +1077,8 @@ class KCC(object):
# repsFrom is not already present
for cn_conn in current_dsa.connect_table.values():
implied, s_dsa = self.is_repsFrom_implied(n_rep, cn_conn)
if not implied:
s_dsa = self.get_dsa_for_implied_replica(n_rep, cn_conn)
if s_dsa is None:
continue
# Loop thru the existing repsFrom tupples (if any) and