summaryrefslogtreecommitdiff
path: root/python/samba
AgeCommit message (Collapse)AuthorFilesLines
2019-03-21selftest: Remove mention of --extra-python from commentAndrew Bartlett1-1/+1
Signed-off-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
2019-03-20py/graph: use 2.6 compatible check for set membershipDouglas Bagnall1-1/+1
It is better this way anyway. Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org> Autobuild-User(master): Andrew Bartlett <abartlet@samba.org> Autobuild-Date(master): Wed Mar 20 06:36:05 UTC 2019 on sn-devel-144
2019-03-14dbcheck: don't check expired tombstone objects by default anymoreStefan Metzmacher2-2/+46
These will be removed anyway and any change on them risks to be an originating update that causes replication problems. BUG: https://bugzilla.samba.org/show_bug.cgi?id=13816 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): Thu Mar 14 03:12:27 UTC 2019 on sn-devel-144
2019-03-14dbcheck: add --selftest-check-expired-tombstones cmdline optionStefan Metzmacher1-1/+6
This will be used by dbcheck tests which operate on static/old provision dumps in the following commits. Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2019-03-14python/samba/netcmd: provide SUPPRESS_HELP via Option classStefan Metzmacher1-0/+1
BUG: https://bugzilla.samba.org/show_bug.cgi?id=13816 Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2019-03-14dbcheck: detect the change after deletion bugStefan Metzmacher1-0/+110
Old versions of 'samba-tool dbcheck' could reanimate deleted objects, when running at the same time as the tombstone garbage collection. When the (deleted) parent of a deleted object (with the DISALLOW_MOVE_ON_DELETE bit in systemFlags), is removed before the object itself, dbcheck moved it in the LostAndFound[Config] subtree of the partition as an originating change. That means that the object will be in tombstone state again for 180 days on the local DC. And other DCs fail to replicate the object as it's already removed completely there and the replication only gives the name and lastKnownParent attributes, because all other attributes should already be known to the other DC. BUG: https://bugzilla.samba.org/show_bug.cgi?id=13816 Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2019-03-14dbcheck: add find_repl_attid() helper functionStefan Metzmacher1-5/+10
BUG: https://bugzilla.samba.org/show_bug.cgi?id=13816 Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2019-03-14dbcheck: don't remove dangling one-way links on already deleted objectsStefan Metzmacher1-0/+13
This would typically happen when the garbage collection removed a parent object before a child object (both with the DISALLOW_MOVE_ON_DELETE bit set in systemFlags), while dbcheck is running at the same time as the garbage collection. In this case the lastKnownParent attributes points a non existing object. BUG: https://bugzilla.samba.org/show_bug.cgi?id=13816 Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2019-03-14dbcheck: don't move already deleted objects to LostAndFoundStefan Metzmacher1-2/+7
This would typically happen when the garbage collection removed a parent object before a child object (both with the DISALLOW_MOVE_ON_DELETE bit set in systemFlags), while dbcheck is running at the same time as the garbage collection. BUG: https://bugzilla.samba.org/show_bug.cgi?id=13816 Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2019-03-14dbcheck: do isDeleted, systemFlags and replPropertyMetaData detection firstStefan Metzmacher1-11/+14
BUG: https://bugzilla.samba.org/show_bug.cgi?id=13816 Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2019-03-14dbcheck: use DSDB_CONTROL_DBCHECK_FIX_LINK_DN_NAME when renaming deleted objectsStefan Metzmacher1-3/+6
We should never do originating updates on deleted objects. BUG: https://bugzilla.samba.org/show_bug.cgi?id=13816 Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2019-03-14tests: Make IPv4 assumption explicitTim Beale2-4/+5
This test is asserting the expected number of *IPv4* addresses, not any interface address (including IPv6). It works currently because the selftest client doesn't have an IPv6 address in its smb.conf. This patch makes the IPv4 assumption explicit by importing interface_ips_v4() from the provision code. We need to tweak this to pass through an 'all_interfaces' flag, otherwise it filters out the loopback IP addresses that the testenv is using. Signed-off-by: Tim Beale <timbeale@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2019-03-12samba-tool domain provision: Fix --interactive module in python3Andrew Bartlett1-0/+1
The prompts were not being printed to the screen because the stream was not being flushed. As reported on the samba mailing list by Adam Xu: https://lists.samba.org/archive/samba/2019-March/221753.html BUG: https://bugzilla.samba.org/show_bug.cgi?id=13828 Signed-off-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Tim Beale <timbeale@catalyst.net.nz>
2019-03-12gpo: Backup a policy folder containing GPE.INIGarming Sam1-0/+6
The GPE.INI file does not appear to be documented anywhere in the protocol specifications and seems to be due to legacy code. It appears that it used to be how the gPCUserExtensionNames and gPCMachineExtensionNames were maintained without the requirement for LDAP. All we do is ignore the parsing of this file and copy it over as binary. BUG: https://bugzilla.samba.org/show_bug.cgi?id=13825 Signed-off-by: Garming Sam <garming@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org> Autobuild-User(master): Andrew Bartlett <abartlet@samba.org> Autobuild-Date(master): Tue Mar 12 01:41:32 UTC 2019 on sn-devel-144
2019-03-12gpo: During restore clobber GPT.INI with a blank versionGarming Sam2-12/+32
Generally speaking, there is not much value to keeping this file. The display name does not ever seem to be used and the version only applies to the original domain or DC it was on. The command line option to revert this behaviour is mostly for the tests or for having a straight 1:1 backup-restore for pure restoration. BUG: https://bugzilla.samba.org/show_bug.cgi?id=13806 Signed-off-by: Garming Sam <garming@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2019-03-12gpo: Parse GPT.INI with Latin-1Garming Sam1-0/+11
For some reason the French version of RSAT turns accents into ISO-8859-1. BUG: https://bugzilla.samba.org/show_bug.cgi?id=13806 Signed-off-by: Garming Sam <garming@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2019-03-12gpo: Add test for saving gPCXXXExtensionNames in backupGarming Sam1-0/+69
The test only checks that the LDAP values are equal before and after. The format and specifics should be up to the implementation -- and be amenable to changes later. As long as the extension doesn't match .SAMBABACKUP or .xml, it won't be detected by the tools. BUG: https://bugzilla.samba.org/show_bug.cgi?id=13627 Signed-off-by: Garming Sam <garming@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2019-03-12gpo: Restore gPCMachineExtensionNames and gPCUserExtensionNamesGarming Sam1-1/+25
After creating a backup and calling 'gpo restore', this makes it so that restoring a GPO will instantly enable it for use. There might be some cases where we might not want to do this, but for now just do it. BUG: https://bugzilla.samba.org/show_bug.cgi?id=13627 Signed-off-by: Garming Sam <garming@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2019-03-12py3: io.open takes a numeric buffering argument at index 2Garming Sam1-1/+1
It's unsure why this doesn't fail generically, but it fails on my machine sometimes... Signed-off-by: Garming Sam <garming@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2019-03-12gpo: Add tests to make sure that an empty gplink worksGarming Sam1-0/+34
BUG: https://bugzilla.samba.org/show_bug.cgi?id=13564 Signed-off-by: Garming Sam <garming@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2019-03-12gpo: Ensure that gplink works when emptyGarming Sam1-1/+5
It appears that RSAT can leave a space in the gPLink field, which we need to handle. BUG: https://bugzilla.samba.org/show_bug.cgi?id=13564 Signed-off-by: Garming Sam <garming@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2019-03-12test/blackbox: py3 compatible print in documentation.Douglas Bagnall1-1/+1
Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2019-03-07subunit/run.py: change shebang to python3Joe Guo1-1/+1
always use explicit python version at current stage. Signed-off-by: Joe Guo <joeg@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Noel Power <npower@samba.org> Autobuild-User(master): Noel Power <npower@samba.org> Autobuild-Date(master): Thu Mar 7 13:03:56 UTC 2019 on sn-devel-144
2019-03-07tests/auto_log_pass_change.py: only care about the last expected message ↵Joe Guo1-39/+16
other than exact messages count The messages count could be different because of racing condition. And we should only care about the last expected one. Signed-off-by: Joe Guo <joeg@catalyst.net.nz> Reviewed-by: Andrew Bartlett abartlet@samba.org Reviewed-by: Noel Power npower@samba.org
2019-03-07subunit/run.py: make iso8601 UTC usage python 2/3 compatibleJoe Guo1-3/+3
In `iso8601/iso8601.py`: if sys.version_info >= (3, 2, 0): UTC = datetime.timezone.utc ... else: class Utc(datetime.tzinfo): ... UTC = Utc() The class `Utc` is only available for python < 3.2.0. Use `UTC` instance instead, which is python 2/3 compatible. Signed-off-by: Joe Guo <joeg@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Noel Power <npower@samba.org>
2019-03-07web_server: Remove the unused Python WSGI web serverGarming Sam1-81/+0
SWAT was removed in Samba 4.1 and there isn't any reason to keep a web server in our codebase. The web server was not turned on by default. The web server plainly does not hold up to modern web server standards and allows for resource exhaustion (and probably generally has bugs). Credit goes to Michael Hanselmann for prompting us to remove this service entirely. Signed-off-by: Garming Sam <garming@catalyst.net.nz> Reviewed-by: Jeremy Allison <jra@samba.org>
2019-03-05tests: Reduce likelihood of auth_log test locking up during CIAaron Haslett1-12/+13
We would sometimes see the auth_log test hang during a CI run. The CI job would eventually fail after consuming a costly 10 hours of CI runtime. We believe the problem is around the test creating multiple instances of the Messaging() context. This is a similar race condition to what was seen in 19f34b2161dee26. Currently a new Messaging() context is created for every test case. By using classmethods instead, the Messaging context is only created once per python test file execution (i.e. creation of the python class, rather than initialization of the python object, which happens for every test-case). This means the test will only create one Messaging() context, which should avoid any race conditions. Changes: + removed msg_ctxs - this wasn't actually used for anything. + use classmethods to setup and tear-down the Messaging() context (and tweak lp initialization accordingly). + fix discardMessages() - the loop wasn't actually discarding any messages previously (this may also have been the cause of the test hanging). Signed-off-by: Aaron Haslett <aaronhaslett@catalyst.net.nz> Signed-off-by: Tim Beale <timbeale@catalyst.net.nz> Reviewed-by: Noel Power <npower@samba.org> Autobuild-User(master): Noel Power <npower@samba.org> Autobuild-Date(master): Tue Mar 5 13:10:43 UTC 2019 on sn-devel-144
2019-03-04tests: Work auth_log CLIENT_IP out from config instead of env varTim Beale2-1/+11
Instead of passing the CLIENT_IP to the auth_log tests, we can just work out the source-IP that the client will use from its smb.conf file. This only works for auth_log_pass_change, but not auth_log.py - the latter still needs to be run on the :local testenv for other reasons, so it doesn't use the client.conf. However, we can still update the base code to use the client.conf IP, as auth_log.py overrides self.remoteAddress anyway. The main advantage of this change is it avoids having hardcoded IP addresses in the selftest framework. Signed-off-by: Tim Beale <timbeale@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2019-03-04tests: Work audit_log CLIENT_IP out from config instead of env varTim Beale4-3/+11
Instead of passing the CLIENT_IP to the audit_log tests, we can just work out the source-IP that the client will use from its smb.conf file. Because the audit_log tests are all run on the non-local testenv, they'll already use the client.conf and the 127.0.0.11 address. The main advantage of this change is it avoids having hardcoded IP addresses in the selftest framework. Signed-off-by: Tim Beale <timbeale@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2019-03-04tests: Remove explicit SOCKET_WRAPPER usage from auth_log testsTim Beale2-2/+19
The auth-logging tests are an odd combination of server and client behaviour. On the one hand we want a IRPC connection to see the auth events being logged on the server. On the other hand, we want the auth events to appear to be happening on a client. Currently we hardcode in the use of a SOCKET_WRAPPER interface to make this happen. We can avoid this explicit socket wrapper usage by using the server smb.conf instead in the one place we actually want to act like the server (creating the IRPC connection). Then we can switch from using the 'ad_dc*:local' testenvs to use 'ad_dc*', in order to act like a client by default. The SERVERCONFFILE environment variable has already been added for the few cases where a test needs explicit access to the server's smb.conf. However, for samba.tests.auth_log, the samlogon test cases are still reliant on being run on the :local testenv, and so we can't switch them over just yet. This is because the samlogon is using the DC's machine creds underneath, which will fail on the non-local testenv. We could create separate machine creds for the client and use those, but this is a non-trivial rework of the test code. Signed-off-by: Tim Beale <timbeale@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2019-03-04tests: Remove redundant credentials from auth_log testsTim Beale3-9/+0
The LDB connection in these tests is to the direct sam.ldb file on disk, so the credentials are not actually needed (and in fact, weren't event initialized correctly). These tests always need to run on the DC itself (i.e. :local testenv) because they use ncalrpc connections. Signed-off-by: Tim Beale <timbeale@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2019-02-21selftest: Confirm new and old SDDL strings differ after a samba-tool dsacl setAndrew Bartlett1-0/+1
Signed-off-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Autobuild-User(master): Andrew Bartlett <abartlet@samba.org> Autobuild-Date(master): Thu Feb 21 05:37:31 CET 2019 on sn-devel-144
2019-02-21selftest: Add test for samba-tool dsacl get, cross-checked with samba-tool ↵Andrew Bartlett1-0/+30
dsacl set Signed-off-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
2019-02-21samba-tool dsacl: Mark old and new descriptor output correctlyAndrew Bartlett1-4/+7
Signed-off-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
2019-02-21Add command "samba-tool dsacl get" This code is very equal to "samba-tool ↵Martin Krämer1-0/+48
dsacl set", except it only prints out the current sddl of an object. Signed-off-by: Martin Krämer <mk.maddin@gmail.com> Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2019-02-21Update dsacl.py - add_ace to handle/verify sddl parameter correctMartin Krämer2-14/+110
Test for samba-tool dsacl set --sddl parmeter Update tests.py - add dsacl (dsacl.py / samba-tool dsacl set) test Signed-off-by: <Martin Krämer mk.maddin@gmail.com> Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2019-02-21dbcheck: skip reverse member link checks when cli option specifiedJoe Guo2-3/+21
currently dbcheck cmd tooks about 1 day to finish on a 100k user database. We can skip member reverse link checks to speed it up dramatically. A new cli option is added to enable the skipping. 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>
2019-02-20s3 winbind auth_log: Tests for logon id logging.Gary Lockyer1-0/+442
Tests to validate that winbind generates a random logon_id and passes it in the netlogon call. This will allow the linking of the windbind authentication requests and the SamLogon request on the DC. Signed-off-by: Gary Lockyer <gary@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2019-02-20auth_log tests: Allow the remote address to be NoneGary Lockyer1-0/+3
Allow self.remoteAddress to be None, remote address filtering is not required for the winbind auth logging tests. Signed-off-by: Gary Lockyer <gary@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2019-02-14s2 decrpc samr: Add tests for QueryDomainInfoGary Lockyer1-0/+55
Add tests for the number of domain users, groups and aliases returned by QueryDomainInfo. These tests revealed that the existing code was not checking the returned elements to ensure they were part of the domain. Signed-off-by: Gary Lockyer <gary@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2019-02-13spelling of associatedDouglas Bagnall1-1/+1
Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2019-02-11tests/user_check_password_script: add a test do disallow the username as ↵Stefan Metzmacher1-9/+25
password Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2019-02-01Tests for segfaults in python bindingsDouglas Bagnall1-0/+126
These tests run in a child process and are regarded as succeeding if they don't die by signal. Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2019-02-01netcmd: Improve error handling of gpo aclcheck as non-adminTim Beale1-0/+4
Reading the nTSecurityDescriptor attribute over LDAP requires admin creds. However, if you don't specify admin creds, then you get an error like this: bin/samba-tool gpo aclcheck ERROR(<class 'KeyError'>): uncaught exception - 'No such element' File "bin/python/samba/netcmd/__init__.py", line 184, in _run return self.run(*args, **kwargs) File "bin/python/samba/netcmd/gpo.py", line 1536, in run ds_sd_ndr = m['nTSecurityDescriptor'][0] This patch adds an explicit check/error message to make the problem clearer. Signed-off-by: Tim Beale <timbeale@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2019-02-01selftest: Move dns_hub.py into selftest directoryTim Beale1-154/+0
As dns_hub.py is now integral to the selftest environments, it seems to make sense for it to live under the selftest/ directory. Signed-off-by: Tim Beale <timbeale@catalyst.net.nz> Reviewed-by: Volker Lendecke <vl@samba.org> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2019-02-01dns_hub: Fix flake8 warningsTim Beale1-5/+5
Signed-off-by: Tim Beale <timbeale@catalyst.net.nz> Reviewed-by: Volker Lendecke <vl@samba.org> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2019-01-29python/tests/dns*: make use of dns.DNS_RCODE/dns.DNS_OPCODEStefan Metzmacher2-4/+4
Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Volker Lendecke <vl@samba.org> Reviewed-by: Andreas Schneider <asn@samba.org>
2019-01-21netcmd: Try to improve domain backup error messageTim Beale1-2/+3
I ran this command as non-root by mistake and didn't find the error message particularly helpful. Tweak the error message so it reminds the user that they should be root. Also display the path we're looking for the sam.ldb file in, to give them more clues. BUG: https://bugzilla.samba.org/show_bug.cgi?id=13676 Signed-off-by: Tim Beale <timbeale@catalyst.net.nz> Reviewed-by: Noel Power <npower@samba.org> Autobuild-User(master): Noel Power <npower@samba.org> Autobuild-Date(master): Mon Jan 21 16:34:06 CET 2019 on sn-devel-144
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>
2019-01-19python/uptodateness: cope with unknown invocation IDDouglas Bagnall1-2/+7
This can happen if a server has been replaced Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>