1
0
mirror of https://github.com/samba-team/samba.git synced 2025-08-03 04:22:09 +03:00

samba-tool ldapcmp: use shorter names in cmp_attrs

This simplifies a fix in the next commit.

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
This commit is contained in:
Douglas Bagnall
2022-08-18 11:34:53 +12:00
committed by Douglas Bagnall
parent 4959d07b96
commit c26a8f6a41

View File

@ -587,10 +587,14 @@ class LDAPObject(object):
for x in self.attributes: for x in self.attributes:
if x.upper() in self.ignore_attributes or x.upper() in missing_attrs: if x.upper() in self.ignore_attributes or x.upper() in missing_attrs:
continue continue
if isinstance(self.attributes[x], list) and isinstance(other.attributes[x], list): ours = self.attributes[x]
self.attributes[x] = sorted(self.attributes[x]) theirs = other.attributes[x]
other.attributes[x] = sorted(other.attributes[x])
if self.attributes[x] != other.attributes[x]: if isinstance(ours, list) and isinstance(theirs, list):
ours = sorted(ours)
theirs = sorted(theirs)
if ours != theirs:
p = None p = None
q = None q = None
m = None m = None
@ -598,14 +602,14 @@ class LDAPObject(object):
# First check if the difference can be fixed but shunting the first part # First check if the difference can be fixed but shunting the first part
# of the DomainHostName e.g. 'mysamba4.test.local' => 'mysamba4' # of the DomainHostName e.g. 'mysamba4.test.local' => 'mysamba4'
if x.upper() in self.other_attributes: if x.upper() in self.other_attributes:
p = [self.con.domain_name.split(".")[0] == j for j in self.attributes[x]] p = [self.con.domain_name.split(".")[0] == j for j in ours]
q = [other.con.domain_name.split(".")[0] == j for j in other.attributes[x]] q = [other.con.domain_name.split(".")[0] == j for j in theirs]
if p == q: if p == q:
continue continue
# Attribute values that are list that contain DN based values that may differ # Attribute values that are list that contain DN based values that may differ
elif x.upper() in self.dn_attributes: elif x.upper() in self.dn_attributes:
m = self.attributes[x] m = ours
n = other.attributes[x] n = theirs
p = [self.fix_dn(j) for j in m] p = [self.fix_dn(j) for j in m]
q = [other.fix_dn(j) for j in n] q = [other.fix_dn(j) for j in n]
if p == q: if p == q:
@ -615,8 +619,8 @@ class LDAPObject(object):
m = p m = p
n = q n = q
if not p and not q: if not p and not q:
m = self.attributes[x] m = ours
n = other.attributes[x] n = theirs
p = [self.fix_domain_name(j) for j in m] p = [self.fix_domain_name(j) for j in m]
q = [other.fix_domain_name(j) for j in n] q = [other.fix_domain_name(j) for j in n]
if p == q: if p == q:
@ -627,8 +631,8 @@ class LDAPObject(object):
m = p m = p
n = q n = q
if not p and not q: if not p and not q:
m = self.attributes[x] m = ours
n = other.attributes[x] n = theirs
p = [self.fix_server_name(j) for j in m] p = [self.fix_server_name(j) for j in m]
q = [other.fix_server_name(j) for j in n] q = [other.fix_server_name(j) for j in n]
if p == q: if p == q:
@ -639,8 +643,8 @@ class LDAPObject(object):
m = p m = p
n = q n = q
if not p and not q: if not p and not q:
m = self.attributes[x] m = ours
n = other.attributes[x] n = theirs
p = [self.fix_domain_netbios(j) for j in m] p = [self.fix_domain_netbios(j) for j in m]
q = [other.fix_domain_netbios(j) for j in n] q = [other.fix_domain_netbios(j) for j in n]
if p == q: if p == q:
@ -652,7 +656,7 @@ class LDAPObject(object):
if p and q: if p and q:
res += 8 * " " + x + " => \n%s\n%s" % (p, q) + "\n" res += 8 * " " + x + " => \n%s\n%s" % (p, q) + "\n"
else: else:
res += 8 * " " + x + " => \n%s\n%s" % (self.attributes[x], other.attributes[x]) + "\n" res += 8 * " " + x + " => \n%s\n%s" % (ours, theirs) + "\n"
self.df_value_attrs.append(x) self.df_value_attrs.append(x)
# #
if missing_attrs: if missing_attrs: