summaryrefslogtreecommitdiff
path: root/python/samba/kcc
AgeCommit message (Collapse)AuthorFilesLines
2025-08-07samba_kcc: log when msDS-HasInstantiatedNCs is not BinaryDnDouglas Bagnall1-3/+10
Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Gary Lockyer <gary@catalyst.net.nz>
2025-08-07samba_kcc: use dsdb_dn_guess()Douglas Bagnall2-12/+12
We also remove a bit of .decode()ing, which now happens automatically. Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Gary Lockyer <gary@catalyst.net.nz>
2023-12-15python: pep257: docstring should use double quotesRob van der Linde1-27/+27
Signed-off-by: Rob van der Linde <rob@catalyst.net.nz> Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2023-08-30python: Fix spellingJoseph Sutton1-2/+2
Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2023-08-08python:samba:kcc: Fix log message formattingJoseph Sutton1-2/+2
Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2023-06-23python:samba:kcc: Fix code spellingAndreas Schneider4-21/+21
Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2022-05-10kcc: Don't reuse outer loop variable for inner loopJoseph Sutton1-3/+3
Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz> Reviewed-by: Andreas Schneider <asn@samba.org>
2021-04-28python: remove all 'from __future__ import print_function'Douglas Bagnall2-2/+0
This made Python 2's print behave like Python 3's print(). In some cases, where we had: from __future__ import print_function """Intended module documentation...""" this will have the side effect of making the intended module documentation work as the actual module documentation (i.e. becoming __doc__), because it is once again the first statement in the module. Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2021-03-17kcc: use py3 compatible sort in rarely visited branchDouglas Bagnall1-2/+2
This won't have worked for some time, but nobody has complained, because nobody uses DS_NTDSSETTINGS_OPT_IS_RAND_BH_SELECTION_DISABLED Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Jeremy Allison <jra@samba.org>
2020-10-02python2 reduction: Merge remaining compat code into commonDavid Mulder1-2/+2
The remaining compat code (get_string, get_bytes, cmp) are useful helper routines which we should simply merge into common (especially since there is some duplication here). Signed-off-by: David Mulder <dmulder@suse.com> Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Autobuild-User(master): David Mulder <dmulder@samba.org> Autobuild-Date(master): Fri Oct 2 14:49:36 UTC 2020 on sn-devel-184
2020-10-02python: Move dsdb_Dn to samdbDavid Mulder2-3/+2
The import dsdb needed for dsdb_Dn causes import errors when trying to import get_bytes/get_string in some places. Signed-off-by: David Mulder <dmulder@suse.com> Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
2019-12-18samba_kcc: avoid ValueError when local connections are less than 2Björn Baumbach1-0/+5
Signed-off-by: Björn Baumbach <bb@sernet.de> Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Autobuild-User(master): Björn Baumbach <bb@sernet.de> Autobuild-Date(master): Wed Dec 18 11:37:53 UTC 2019 on sn-devel-184
2019-09-24kcc_utils.py: avoid inefficient string concatenationsBjörn Jacke1-103/+92
Signed-off-by: Bjoern Jacke <bjacke@samba.org> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2019-01-19python/kcc lib: cope with differently formed repsToFromDouglas Bagnall1-5/+16
samba-tool visualise reuses these libraries to parse reps from other DCs, and Windows sometimes sends more data than we are expecting Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2018-12-10python/samba/kcc: PY3 fix some str versus ldb.bytes comparisonsNoel Power1-3/+3
Signed-off-by: Noel Power <noel.power@suse.com> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2018-11-01python/kcc/graph: import KCCError, which is used somewhereDouglas Bagnall1-0/+1
Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Noel Power <noel.power@suse.com>
2018-10-25python/kcc: use compat.cmp_fn (PY3)Douglas Bagnall1-2/+2
Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Noel Power <npower@samba.org>
2018-09-03python/samba: changes needed for samba.tests.samba_tool.visualize PY2/PY3Noel Power1-1/+1
Signed-off-by: Noel Power <noel.power@suse.com> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2018-08-24PEP8: fix E713: test for membership should be 'not in'Joe Guo2-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>
2018-08-24PEP8: fix E305: expected 2 blank lines after class or function definition, ↵Joe Guo2-0/+2
found 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>
2018-08-24PEP8: fix E265: block comment should start with '# 'Joe Guo4-7/+7
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>
2018-08-24PEP8: fix E226: missing whitespace around arithmetic operatorJoe Guo1-9/+9
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>
2018-08-24PEP8: fix E123: closing bracket does not match indentation of opening ↵Joe Guo1-1/+1
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>
2018-07-13python/samba/kcc: md5 needs to be passed bytes in py3Noel Power1-1/+3
Signed-off-by: Noel Power <noel.power@suse.com> Reviewed-by: Andreas Schneider <asn@samba.org> Signed-off-by: Joe Guo <joeg@catalyst.net.nz> Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
2018-06-10python/kcc/graph_utils: short-cut edge failure test without edgesDouglas Bagnall1-0/+3
Otherwise we get an exception because itertools.combinations is asked to find combinations with negative size. Instead we assert the graph is connected as-is, which in this case is the same as asserting there are no vertices. Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2018-05-31python kcc/graph_utils: don't debug in colourDouglas Bagnall1-5/+3
this was somewhat useful during the initial development, but is wrong for a library Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2018-05-31kcc graph verifiers: improve messagesDouglas Bagnall1-10/+15
Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2018-05-31kcc graph verifier: use __doc__ description for error explanationDouglas Bagnall2-5/+5
Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2018-05-31kcc graphs: site edges in colour, labeled with DNsDouglas Bagnall3-7/+13
This makes it easy to see where the site edges objects are, and what sites they refer too. Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2018-05-31kcc.graph_utils: shift debug noise out of verify()Douglas Bagnall2-30/+24
Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2018-05-05samba_kcc: remove an unused variableDouglas Bagnall1-2/+0
Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Gary Lockyer <gary@catalyst.net.nz>
2018-04-30python: Bulk conversion callers of ldb.Dn second paramNoel Power1-1/+1
Convert second param passed to ldb.Dn to be unicode so py2 & py3 code will work Signed-off-by: Noel Power <noel.power@suse.com> Reviewed-by: Alexander Bokovoy <ab@samba.org>
2018-04-30python/samba: bulk conversion of caller to dsdb_Dn 2nd param.Noel Power2-7/+7
Convert second param to dsdb_Dn to be unicode so py2 & py3 code will work Signed-off-by: Noel Power <noel.power@suse.com> Reviewed-by: Alexander Bokovoy <ab@samba.org>
2018-04-13kcc/graph: add __hash__ to InternalEdge for py3Joe Guo1-0/+5
In py3, if a class defines `__eq__()` but not `__hash__()`, its instances will not be usable as items in hashable collections, e.g.: set. Add `__hash__()` to InternalEdge, so it can be added to a set in py3. 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>
2018-04-13kcc: fix sort for py3Joe Guo2-19/+4
py2: list.sort(cmp=None, key=None, reverse=False) sorted(iterable[, cmp[, key[, reverse]]]) py3: list.sort(key=None, reverse=False) sorted(iterable, *, key=None, reverse=False) The `cmp` arg was removed in py3, make use of `key` arg to work around. 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>
2018-04-13kcc/kcc_utils: fix divide for py3Joe Guo1-1/+1
`/` will return float other than int in py3. Use `//` to keep consistent with py2. 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>
2018-04-13kcc/kcc_utils: convert dict.keys to listJoe Guo1-1/+1
In py3, `dict.keys()` will return a iterator not a list. Convert it to list to support both py2 and py3. 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>
2018-04-13kcc/graph_utils: port string.translate for py3Joe Guo1-1/+1
In py3, `str.translate` removed the second positional argument `deletechars`, which means you can not use it to delete chars from str. Use `replace` for this case. 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>
2018-03-23samba python libs: convert print func to be py2/py3 compatibleNoel Power1-3/+4
Signed-off-by: Noel Power <noel.power@suse.com> Reviewed-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
2018-03-21kcc_utils: Use lower name in automatic sites coveredGarming Sam1-1/+1
This allows easier testing, as well as some consistency in the DNS record creation. Signed-off-by: Garming Sam <garming@catalyst.net.nz> Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
2018-03-21kcc_utils: Prevent multiple sites attached to a sitelink covering a siteGarming Sam1-3/+34
This avoids trivial duplicates in a similar manner as mentioned in: https://blogs.technet.microsoft.com/askds/2011/04/29/sites-sites-everywhere/ It prefers the largest sites then the earliest alphabetically, so that only a single site ever covers an uncovered site (within a site link). Note that this isn't applicable over multiple site links (like Windows presumably) and is only a simple mechanism to avoid excessive registering. DCs within the site will also still register for each. Signed-off-by: Garming Sam <garming@catalyst.net.nz> Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
2018-03-21kcc_utils: Keep a count of the DCs in each siteGarming Sam1-2/+3
This is useful for ranking which sites are preferable within the same site link. Signed-off-by: Garming Sam <garming@catalyst.net.nz> Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
2018-03-21kcc_utils: Add a routine for automatic site coverageGarming Sam1-0/+80
This allows double-coverage if two links exist with the same cost. Administrators should only connect an DC-less site via a single site link. This also allows unnecessary coverage by all sites in the adjoining site link (to be resolved in the later patches). Signed-off-by: Garming Sam <garming@catalyst.net.nz> Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
2018-02-28samba python libs: convert 'except X, (tuple)' to 'except X as e'Noel Power3-29/+58
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>
2018-02-15samba python libs: convert 'except X, e' to 'except X as e'Douglas Bagnall4-7/+7
Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2018-01-13samba_kcc: do not commit new nTDSConnection, if we are rodcAndrej Gessel1-3/+3
Traceback (most recent call last): /usr/local/samba/sbin/samba_kcc: File "/usr/local/samba/sbin/samba_kcc", line 337, in <module> /usr/local/samba/sbin/samba_kcc: attempt_live_connections=opts.attempt_live_connections) /usr/local/samba/sbin/samba_kcc: File "/usr/local/samba/lib/python2.7/site-packages/samba/kcc/__init__.py", line 2644, in run /usr/local/samba/sbin/samba_kcc: all_connected = self.intersite(ping) /usr/local/samba/sbin/samba_kcc: File "/usr/local/samba/lib/python2.7/site-packages/samba/kcc/__init__.py", line 1883, in intersite /usr/local/samba/sbin/samba_kcc: all_connected = self.create_intersite_connections() /usr/local/samba/sbin/samba_kcc: File "/usr/local/samba/lib/python2.7/site-packages/samba/kcc/__init__.py", line 1817, in create_intersite_connections /usr/local/samba/sbin/samba_kcc: part, True) /usr/local/samba/sbin/samba_kcc: File "/usr/local/samba/lib/python2.7/site-packages/samba/kcc/__init__.py", line 1769, in create_connections /usr/local/samba/sbin/samba_kcc: partial_ok, detect_failed) /usr/local/samba/sbin/samba_kcc: File "/usr/local/samba/lib/python2.7/site-packages/samba/kcc/__init__.py", line 1594, in create_connection /usr/local/samba/sbin/samba_kcc: lbh.commit_connections(self.samdb) /usr/local/samba/sbin/samba_kcc: File "/usr/local/samba/lib/python2.7/site-packages/samba/kcc/kcc_utils.py", line 827, in commit_connections /usr/local/samba/sbin/samba_kcc: connect.commit_added(samdb, ro) /usr/local/samba/sbin/samba_kcc: File "/usr/local/samba/lib/python2.7/site-packages/samba/kcc/kcc_utils.py", line 1123, in commit_added /usr/local/samba/sbin/samba_kcc: (self.dnstr, estr)) /usr/local/samba/sbin/samba_kcc: samba.kcc.kcc_utils.KCCError: Could not add nTDSConnection for (CN=862f0429-c72c-4a81-ae9a-96820bb2f96d,CN=NTDS Settings, CN=BUILDHOST,CN=Servers,CN=Testsite,CN=Sites,CN=Configuration,DC=samdom,DC=com) - (Invalid LDB reply type 1) ../source4/dsdb/kcc/kcc_periodic.c:693: Failed samba_kcc - NT_STATUS_ACCESS_DENIED Signed-off-by: Andrej Gessel <Andrej.Gessel@janztec.com> Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org> Autobuild-User(master): Karolin Seeger <kseeger@samba.org> Autobuild-Date(master): Sat Jan 13 22:01:49 CET 2018 on sn-devel-144
2018-01-13samba_kcc: simplify NCReplica.set_instantiated_flags()Douglas Bagnall1-5/+2
Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2018-01-13samba_kcc: simplify NCReplica constructorDouglas Bagnall2-6/+5
There is nothing to be gained from setting the dn and guid separately except subtle bugs. Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2018-01-13samba_kcc: clarify readonly logging, removing now unused functionDouglas Bagnall2-6/+3
The unused function was somewhat misnamed. Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2018-01-13samba_kcc: remove unused functionsDouglas Bagnall1-15/+0
Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>