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

samba-tool ldapcmp: do not assume common attributes

This has caused numerous reports of

ERROR(<class 'KeyError'>): uncaught exception - 'serverReferenceBL'
  File /usr/lib/python3/dist-packages/samba/netcmd/__init__.py, line 185, in _run
    return self.run(*args, **kwargs)
  File /usr/lib/python3/dist-packages/samba/netcmd/ldapcmp.py, line 957, in run
    if b1.diff(b2):
  File /usr/lib/python3/dist-packages/samba/netcmd/ldapcmp.py, line 781, in diff
    if object1 == object2:
  File /usr/lib/python3/dist-packages/samba/netcmd/ldapcmp.py, line 549, in __eq__
    return self.cmp_attrs(other)
  File /usr/lib/python3/dist-packages/samba/netcmd/ldapcmp.py, line 590, in cmp_attrs
    if isinstance(self.attributes[x], list) and isinstance(other.attributes[x], list):

because other does not have attribute 'x'.

It is better to assume other.attributes[x] is None, which will compare
as unequal to whatever self.attributes[x] is, showing up as a diff
rather than a crash.

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:38:35 +12:00
committed by Douglas Bagnall
parent c26a8f6a41
commit b13c121fcb

View File

@ -588,7 +588,7 @@ class LDAPObject(object):
if x.upper() in self.ignore_attributes or x.upper() in missing_attrs:
continue
ours = self.attributes[x]
theirs = other.attributes[x]
theirs = other.attributes.get(x)
if isinstance(ours, list) and isinstance(theirs, list):
ours = sorted(ours)