From b13c121fcbafc9b84e29e438715727e3e780ff92 Mon Sep 17 00:00:00 2001 From: Douglas Bagnall Date: Thu, 18 Aug 2022 11:38:35 +1200 Subject: [PATCH] samba-tool ldapcmp: do not assume common attributes This has caused numerous reports of ERROR(): 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 Reviewed-by: Andrew Bartlett --- python/samba/netcmd/ldapcmp.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/python/samba/netcmd/ldapcmp.py b/python/samba/netcmd/ldapcmp.py index dc5e86e905d..dd34e0cf015 100644 --- a/python/samba/netcmd/ldapcmp.py +++ b/python/samba/netcmd/ldapcmp.py @@ -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) -- 2.47.3