summaryrefslogtreecommitdiff
path: root/python/samba/netcmd/ldapcmp.py
Commit message (Collapse)AuthorAgeFilesLines
* python:netcmd: Decode return value of find_netbios() from bytes into stringAndreas Schneider2023-03-141-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | ERROR(<class 'TypeError'>): uncaught exception - replace() argument 1 must be str, not bytes File "bin/python/samba/netcmd/__init__.py", line 230, in _run return self.run(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^ File "bin/python/samba/netcmd/ldapcmp.py", line 966, in run if b1.diff(b2): ^^^^^^^^^^^ File "bin/python/samba/netcmd/ldapcmp.py", line 790, in diff if object1 == object2: ^^^^^^^^^^^^^^^^^^ File "bin/python/samba/netcmd/ldapcmp.py", line 557, in __eq__ return self.cmp_attrs(other) ^^^^^^^^^^^^^^^^^^^^^ File "bin/python/samba/netcmd/ldapcmp.py", line 656, in cmp_attrs p = [self.fix_domain_netbios(j) for j in m] ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "bin/python/samba/netcmd/ldapcmp.py", line 656, in <listcomp> p = [self.fix_domain_netbios(j) for j in m] ^^^^^^^^^^^^^^^^^^^^^^^^^^ File "bin/python/samba/netcmd/ldapcmp.py", line 542, in fix_domain_netbios res = res.replace(self.con.domain_netbios.lower(), self.con.domain_netbios.upper()) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ BUGS: https://bugzilla.samba.org/show_bug.cgi?id=15330 Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
* samba-tool ldapcmp: use CommandError on auth failureDouglas Bagnall2022-09-061-2/+7
| | | | | Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
* samba-tool ldapcmp: use CommandError, not assertionDouglas Bagnall2022-09-061-1/+4
| | | | | Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
* samba-tool ldapcmp: do not assume common attributesDouglas Bagnall2022-09-061-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | 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>
* samba-tool ldapcmp: use shorter names in cmp_attrsDouglas Bagnall2022-09-061-15/+19
| | | | | | | 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>
* samba-tool ldapcmp: use ValueError, not ExceptionDouglas Bagnall2022-09-061-1/+1
| | | | | Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
* python: Don't use deprecated escape sequencesJoseph Sutton2022-06-141-1/+1
| | | | | | | | Certain escape sequences are not valid in Python string literals, and will eventually result in a SyntaxError. Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Andreas Schneider <asn@samba.org>
* python: Remove redundant assignmentsJoseph Sutton2022-05-101-5/+2
| | | | Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz> Reviewed-by: Andreas Schneider <asn@samba.org>
* python: use raw string for regex with escapeDouglas Bagnall2020-02-071-3/+3
| | | | | | | | | | | | | | | | Python regards 'GPT\.INI$' as a string containing an invalid escape sequence '\.', which is ignored (i.e. treated as the literal sequence of those 2 characters), but only after Python has grumbled to itself, and to you if you enabled DeprecationWarnings. The proper thing to do here is use r-strings, like r'GPT\.INI$', which tell Python that all backslashes are literal. Alternatively (as we do once in this patch), the backslash can itself be escaped ('\\'). There are more problems of this nature in the build scripts. Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Noel Power <npower@samba.org>
* ldapcmp: ignore 'schemaInfo' if two domains are comparedStefan Metzmacher2019-04-111-1/+1
| | | | | | | | BUG: https://bugzilla.samba.org/show_bug.cgi?id=13799 Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Garming Sam <garming@catalyst.net.nz>
* samba-tool ldapcmp: print DNs on predictable orderDouglas Bagnall2018-11-211-2/+2
| | | | | | | Rather than unstable hash order. Ideally we'd do them in proper DN order. Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
* netcmd/ldapcmp: make code pythonicJoe Guo2018-11-211-11/+6
| | | | | | Signed-off-by: Joe Guo <joeg@catalyst.net.nz> Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
* netcmd/ldapcmp: promote re object to globalJoe Guo2018-11-211-7/+5
| | | | | | | | Then we can reuse the re obj. Signed-off-by: Joe Guo <joeg@catalyst.net.nz> Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
* netcmd/ldapcmp: use set instead of list to compare attrsJoe Guo2018-11-211-31/+22
| | | | | | | | This will simplify the logic and improve performance. Signed-off-by: Joe Guo <joeg@catalyst.net.nz> Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
* netcmd/ldapcmp: fix wrong way for string copyJoe Guo2018-11-211-4/+4
| | | | | | | | | | | Two mistakes here: - res[:-1] will copy but lost the last char - string is immutable in python, there is no need to copy it explicitly Signed-off-by: Joe Guo <joeg@catalyst.net.nz> Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
* netcmd/ldapcmp: pass --skip-missing-dn to LDAPBaseJoe Guo2018-11-211-2/+2
| | | | | | | | | | | | | This option has default value False, and was actually not passed down from cli to LDAPBase. However, LDAPBase.__init__ has default value True for it. After the change, a few tests using ldapcmp are affected. Add --skip-missing-dn explicitly to keep the behavior consistent, otherwise test will fail. Signed-off-by: Joe Guo <joeg@catalyst.net.nz> Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
* netcmd/ldapcmp: avoid modifying data while looping on dictJoe Guo2018-11-211-5/+7
| | | | | | | | | Just define another dict for return value, seems no need to modify original dict. Signed-off-by: Joe Guo <joeg@catalyst.net.nz> Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
* netcmd/ldapcmp: rm unused global var summaryJoe Guo2018-11-211-6/+0
| | | | | | Signed-off-by: Joe Guo <joeg@catalyst.net.nz> Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
* netcmd/ldapcmp: use set instead of list to find missing DNsJoe Guo2018-11-211-49/+30
| | | | | | | | This simplify the logic and improve performance a lot. Signed-off-by: Joe Guo <joeg@catalyst.net.nz> Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
* netcmd/ldapcmp: avoid list comprehension in for loopJoe Guo2018-11-211-2/+6
| | | | | | | | | The list comprehension will repeat for each item. For large database, this make the command freeze. Signed-off-by: Joe Guo <joeg@catalyst.net.nz> Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
* netcmd/ldapcmp: add choices arg to --view optionJoe Guo2018-11-211-3/+1
| | | | | | | | So we don't need to validate ourselves. Signed-off-by: Joe Guo <joeg@catalyst.net.nz> Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
* netcmd/ldapcmp: add choices arg to --scope optionJoe Guo2018-11-211-3/+1
| | | | | | | | So we don't need to validate ourselves. Signed-off-by: Joe Guo <joeg@catalyst.net.nz> Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
* netcmd/ldapcmp: rename __eq__ to diffJoe Guo2018-11-211-2/+2
| | | | | | | | | | This method actually changed both objects and print info. __eq__ is not a proper name and is not designed for this case. Rename to diff. Signed-off-by: Joe Guo <joeg@catalyst.net.nz> Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
* netcmd/ldapcmp: fix typo for BundleJoe Guo2018-11-211-4/+4
| | | | | | | | Bundel -> Bundle Signed-off-by: Joe Guo <joeg@catalyst.net.nz> Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
* samba-tool ldapcmp: use ValueError, not obsolete StandardErrorDouglas Bagnall2018-10-251-1/+1
| | | | | | | The error is in the value, and StandardError is not in Python 3 Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Noel Power <npower@samba.org>
* samba_tool: Enclose iterator with listNoel Power2018-10-231-1/+1
| | | | | | | | | Really strange bug caused by map being updated while being iterated. This caused keys to be skipped and inconsistent and incorrect results from ldapcmp. Signed-off-by: Noel Power <noel.power@suse.com> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
* python/samba: misc use of str for ldb.bytesNoel Power2018-10-231-2/+2
| | | | | Signed-off-by: Noel Power <noel.power@suse.com> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
* PEP8: fix E127: continuation line over-indented for visual indentJoe Guo2018-09-061-2/+2
| | | | | | Signed-off-by: Joe Guo <joeg@catalyst.net.nz> Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
* PEP8: fix E125: continuation line with same indent as next logical lineJoe Guo2018-09-061-2/+2
| | | | | | Signed-off-by: Joe Guo <joeg@catalyst.net.nz> Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
* PEP8: add spaces after operatorsDouglas Bagnall2018-08-241-5/+5
| | | | | Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
* PEP8: fix E713: test for membership should be 'not in'Joe Guo2018-08-241-3/+3
| | | | | | Signed-off-by: Joe Guo <joeg@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
* PEP8: fix E302: expected 2 blank lines, found 1Joe Guo2018-08-241-0/+3
| | | | | | Signed-off-by: Joe Guo <joeg@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
* PEP8: fix E261: at least two spaces before inline commentJoe Guo2018-08-241-2/+2
| | | | | | Signed-off-by: Joe Guo <joeg@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
* PEP8: fix E231: missing whitespace after ','Joe Guo2018-08-241-6/+6
| | | | | | Signed-off-by: Joe Guo <joeg@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
* PEP8: fix E226: missing whitespace around arithmetic operatorJoe Guo2018-08-241-33/+33
| | | | | | Signed-off-by: Joe Guo <joeg@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
* PEP8: fix E225: missing whitespace around operatorJoe Guo2018-08-241-2/+2
| | | | | | Signed-off-by: Joe Guo <joeg@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
* PEP8: fix E222: multiple spaces after operatorJoe Guo2018-08-241-1/+1
| | | | | | Signed-off-by: Joe Guo <joeg@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
* PEP8: fix E202: whitespace before ')'Joe Guo2018-08-241-25/+25
| | | | | | Signed-off-by: Joe Guo <joeg@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
* PEP8: fix E201: whitespace after '('Joe Guo2018-08-241-28/+28
| | | | | | Signed-off-by: Joe Guo <joeg@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
* PEP8: fix E128: continuation line under-indented for visual indentJoe Guo2018-08-241-24/+24
| | | | | | Signed-off-by: Joe Guo <joeg@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
* PEP8: fix E123: closing bracket does not match indentation of opening ↵Joe Guo2018-08-241-2/+2
| | | | | | | | bracket's line Signed-off-by: Joe Guo <joeg@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
* PEP8: fix E122: continuation line missing indentation or outdentedJoe Guo2018-08-241-2/+2
| | | | | | Signed-off-by: Joe Guo <joeg@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
* PEP8: fix E111: indentation is not a multiple of fourJoe Guo2018-08-241-1/+1
| | | | | | Signed-off-by: Joe Guo <joeg@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
* samba-tool ldapcmp: remove duplicate takes_optiongroups attributeDouglas Bagnall2018-03-211-6/+0
| | | | | Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
* samba-tool: convert 'except X, (tuple)' to 'except X as e'Noel Power2018-02-281-4/+8
| | | | | | | | | In addition to converting the except line another line is also added for each except to extract the tuple contents. Signed-off-by: Noel Power <noel.power@suse.com> Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
* samba-tool: convert 'except X, e' to 'except X as e' for all XDouglas Bagnall2018-02-151-1/+1
| | | | | | | This is needed for Python 3 and is compatible with python 2.6 Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
* ldapcmp: Improve the difference checker of ldapcmp for 2012 R2Garming Sam2017-12-211-1/+8
| | | | | | | | | | There are a number of new attributes which may be considered DNs. Signed-off-by: Garming Sam <garming@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org> Autobuild-User(master): Garming Sam <garming@samba.org> Autobuild-Date(master): Thu Dec 21 03:41:19 CET 2017 on sn-devel-144
* ldapcmp: Add otherWellKnownObjects to ignore when using --twoGarming Sam2017-12-201-6/+11
| | | | | | | wellKnownObjects already exists in this list. Signed-off-by: Garming Sam <garming@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
* samba-tool/ldapcmp: ignore differences of whenChangedStefan Metzmacher2016-08-081-1/+1
| | | | | | | | | | | | | This is implicitly replicated, but may diverge on updates of non-replicated attributes. BUG: https://bugzilla.samba.org/show_bug.cgi?id=12129 Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Ralph Boehme <slow@samba.org> Autobuild-User(master): Ralph Böhme <slow@samba.org> Autobuild-Date(master): Mon Aug 8 17:34:24 CEST 2016 on sn-devel-144
* samba-tool/ldapcmp: update the list of non replicated attributesStefan Metzmacher2014-09-021-13/+49
| | | | | | | | | | Bug: https://bugzilla.samba.org/show_bug.cgi?id=10788 Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Andrew Bartlett <abartlet@samba.org> Autobuild-User(master): Andrew Bartlett <abartlet@samba.org> Autobuild-Date(master): Tue Sep 2 03:49:49 CEST 2014 on sn-devel-104