summaryrefslogtreecommitdiff
path: root/python
Commit message (Collapse)AuthorAgeFilesLines
* selftest: add central dns forwarderVolker Lendecke2019-01-151-0/+156
| | | | | | | | | This is a small DNS server that has hard redirects to the different domain controllers based on domain names. This is required because future commits will avoid calling into libresolv's code which resolv_wrapper takes care of. Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* netcmd: Change domain backup commands to use s3 SMB Py bindingsTim Beale2019-01-141-2/+6
| | | | | | | | | | | | This means we can now backup a DC that has SMBv1 disabled. BUG: https://bugzilla.samba.org/show_bug.cgi?id=13676 Signed-off-by: Tim Beale <timbeale@catalyst.net.nz> Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Autobuild-User(master): Tim Beale <timbeale@samba.org> Autobuild-Date(master): Mon Jan 14 06:49:09 CET 2019 on sn-devel-144
* tests: Change ntaclsbackup tests over to use s3 Py bindingsTim Beale2019-01-141-2/+2
| | | | | | | BUG: https://bugzilla.samba.org/show_bug.cgi?id=13676 Signed-off-by: Tim Beale <timbeale@catalyst.net.nz> Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
* python: use 'et' as format for ParseTuple with python2Noel Power2019-01-131-2/+6
| | | | | Signed-off-by: Noel Power <noel.power@suse.com> Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
* python: Add new compat PYARG_STR_UNI formatNoel Power2019-01-131-0/+10
| | | | | | | | | | | In python2 PYARG_STR_UNI evaluates to et which allows str type (e.g bytes) pass through unencoded and accepts unicode objects encoded as utf8 In python3 PYARG_STR_UNI evaluates to es which allows str type encoded as named/specified encoding Signed-off-by: Noel Power <noel.power@suse.com> Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
* python: Fix memory leak with ParseTuple (using 'es' format)Noel Power2019-01-131-7/+15
| | | | | Signed-off-by: Noel Power <noel.power@suse.com> Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
* py:dcerpc/raw_protocol: add tests to demonstrate how security context ↵Stefan Metzmacher2019-01-121-0/+967
| | | | | | | | | | | | | | | | | | | | | | multiplexing works Important things are this: - It's not required to use the bind time feature negotiation in order to use it, it's only a hint for the client, but nothing is really negotiated, unlike the request multiplexing with the DCERPC_PFC_FLAG_CONC_MPX. - There's special handling related to AUTH_LEVEL_CONNECT and requests without auth trailer - An security context is identified by the unique tuple of auth_type, auth_level and auth_context_id (all together!), not just the auth_context_id. - There's a limit of 2049 explicit authentication contexts. BUG: https://bugzilla.samba.org/show_bug.cgi?id=7113 BUG: https://bugzilla.samba.org/show_bug.cgi?id=11892 Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* py:dcerpc/raw_testcase: add assertEqualsStrLower()Stefan Metzmacher2019-01-121-0/+3
| | | | | | | | BUG: https://bugzilla.samba.org/show_bug.cgi?id=7113 BUG: https://bugzilla.samba.org/show_bug.cgi?id=11892 Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* py:dcerpc/raw_protocol: demonstrate that \\pipe\lsarpc returns \\pipe\lsass ↵Stefan Metzmacher2019-01-121-2/+4
| | | | | | | | | | as secondary_address BUG: https://bugzilla.samba.org/show_bug.cgi?id=7113 BUG: https://bugzilla.samba.org/show_bug.cgi?id=11892 Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* py:dcerpc/raw_protocol: add test_assoc_group_fail3()Stefan Metzmacher2019-01-121-0/+45
| | | | | | | | | | | This demonstrates that assoc groups are only shared on the same transport (endpoint). BUG: https://bugzilla.samba.org/show_bug.cgi?id=7113 BUG: https://bugzilla.samba.org/show_bug.cgi?id=11892 Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* py:dcerpc/raw_protocol: add test_assoc_group_ok2 to check assoc groups over ↵Stefan Metzmacher2019-01-121-0/+31
| | | | | | | | | | ncacn_np BUG: https://bugzilla.samba.org/show_bug.cgi?id=7113 BUG: https://bugzilla.samba.org/show_bug.cgi?id=11892 Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* py:dcerpc/raw_protocol: enable tests with the ↵Stefan Metzmacher2019-01-121-9/+3
| | | | | | | | | | DCERPC_PFC_FLAG_SUPPORT_HEADER_SIGN bit BUG: https://bugzilla.samba.org/show_bug.cgi?id=7113 BUG: https://bugzilla.samba.org/show_bug.cgi?id=11892 Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* py:dcerpc/raw_protocol: consistently call self.recv_pdu(timeout=0.01) after ↵Stefan Metzmacher2019-01-121-1/+3
| | | | | | | | | | | | | | auth3 When we don't expect a FAULT, we should wait a little bit to check there's no response to auth3 request. This reduces the raw_procol test from 45s down to 35s total runtime against Windows. BUG: https://bugzilla.samba.org/show_bug.cgi?id=7113 BUG: https://bugzilla.samba.org/show_bug.cgi?id=11892 Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* py:dcerpc/raw_protocol: add tests for delayed header signing activationStefan Metzmacher2019-01-121-0/+186
| | | | | | | | BUG: https://bugzilla.samba.org/show_bug.cgi?id=7113 BUG: https://bugzilla.samba.org/show_bug.cgi?id=11892 Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* py:dcerpc/raw_testcase: add pfc_flags_2nd and use_auth3 options to ↵Stefan Metzmacher2019-01-121-2/+17
| | | | | | | | | | | | | do_generic_bind() This makes it more flexible and allows to write complex tests in an easier fashion. BUG: https://bugzilla.samba.org/show_bug.cgi?id=7113 BUG: https://bugzilla.samba.org/show_bug.cgi?id=11892 Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* selftest: Improve an error messageVolker Lendecke2019-01-111-1/+2
| | | | | | | | Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Autobuild-User(master): Douglas Bagnall <dbagnall@samba.org> Autobuild-Date(master): Fri Jan 11 06:01:01 CET 2019 on sn-devel-144
* netcmd: Fix broken samba-tool gpo commandsTim Beale2019-01-101-0/+1
| | | | | | | | | | | | | | | | | | | | | | samba-tool gpo create|fetch|backup commands throw exceptions due to a missing Python import: ERROR(<class 'NameError'>): uncaught exception - name 'tempfile' is not defined File "bin/python/samba/netcmd/__init__.py", line 184, in _run return self.run(*args, **kwargs) File "bin/python/samba/netcmd/gpo.py", line 980, in run tmpdir, gpodir = self.construct_tmpdir(tmpdir, gpo) File "bin/python/samba/netcmd/gpo.py", line 386, in construct_tmpdir tmpdir = tempfile.mkdtemp() Introduced by commit e3320b6d3df7a0c7b refactor. 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): Thu Jan 10 16:21:23 CET 2019 on sn-devel-144
* s3:libsmb: Revert SMB Py bindings name back to libsmb_samba_internalTim Beale2019-01-094-4/+4
| | | | | | | | | | | | | | | | | | In order to make it clear that the APIs in these Python bindings are unstable and should not be used by external consumers, this patch changes the name of the Python bindings back to libsmb_samba_internal. To make the Python code that uses these bindings (i.e. samba-tool, etc) look a little cleaner, we can just change the module name as we import it, e.g. from samba.samba3 import libsmb_samba_internal as libsmb Signed-off-by: Tim Beale <timbeale@catalyst.net.nz> Reviewed-by: Stefan Metzmacher <metze@samba.org> Autobuild-User(master): Stefan Metzmacher <metze@samba.org> Autobuild-Date(master): Wed Jan 9 14:30:31 CET 2019 on sn-devel-144
* netcmd/user: python[3]-gpgme unsupported and replaced by python[3]-gpgJoe Guo2019-01-091-25/+61
| | | | | | | | | | | | python[3]-gpgme is deprecated since ubuntu 1804 and debian 9. use python[3]-gpg instead, and adapt the API. BUG: https://bugzilla.samba.org/show_bug.cgi?id=13728 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> Reviewed-by: Stefan Metzmacher <metze@samba.org>
* traffic_replay: use packets per second as primary scaleDouglas Bagnall2019-01-081-6/+14
| | | | | | | | The old -S/--scale-traffic is relative to the original model, which made its relationship to true traffic volumes quite opaque Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
* traffic: assert json equality in learner testDouglas Bagnall2019-01-081-0/+6
| | | | | Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
* traffic tests: use TestCaseInTempdir.mktemp()Douglas Bagnall2019-01-083-45/+6
| | | | | Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
* python/tests: add TestCaseInTempdir.mktemp()Douglas Bagnall2019-01-081-1/+16
| | | | | | | | | | | | | | | | | This gives you a name of a temporary file within the test case's tempdir. Use it like this: with self.mktemp() as filename: self.check_run("samba-tool foo --output %s" % filename) self.assertStringsEqual(open(filename).read(), expected) and filename will flick out of existence when the with block ends. This is based on an idea used in the traffic_runner tests, which will soon be adapted to use this method. Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
* traffic_replay: --old-scale to mimic the old traffic_replayDouglas Bagnall2019-01-082-0/+14
| | | | | | | | | traffic_replay had a broken sense of traffic scale. That is fixed, but in order to compare old and new tests, it helps to be able to approximate the old behaviour. Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
* traffic: add option to reanimate dying conversationsDouglas Bagnall2019-01-083-4/+39
| | | | | | | | | | | | | | | The traffic model is generated from a window in time, which makes conversations appear to start and stop unnaturally at the window boundaries. When the window is short compared to the traffic replay time and the true expected conversation length, this has a significant distorting effect, leading to more conversations than would be expected to generate a given number of packets. To offset this slightly we add the --conversation-persistence option which tries to convert apparent death into a longish wait. Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
* traffic: Conversation.add_short_packet is discerning about packetsDouglas Bagnall2019-01-081-1/+4
| | | | | | | If the packets really wouldn't do anything, we might as well not add them. Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
* traffic: remove useless branch in stats reportDouglas Bagnall2019-01-081-25/+12
| | | | | | | | | This completes the work of 68c64c634ad7576b2ab5ef838c203320afd90f44, but differs from that in that it makes no actual change because isatty was not being called so was always evaluated as true. Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
* traffic: generate more statistics in replayDouglas Bagnall2019-01-081-30/+69
| | | | | | | | | | | | | | | | | | | | | Add more "header" values indicating the progress of the run as a whole. The new fields are: Max sleep miss - the longest sleep() oversleep. Indicates client load. Maximum lag - the longest gap between a planned packet time and its actual time. Start lag - the longest gap between intended and actual conversation start. Planned conversations - how many conversations we meant to have. Planned packets - how many "packets" we thought we were making. Not all "packets" result in actual operations or packets. Unfinished conversations - how many conversations had not finished when they were killed. Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
* traffic: avoid bare except: clausesDouglas Bagnall2019-01-081-2/+2
| | | | | Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
* traffic: simplify tests for badpassword_frequencyDouglas Bagnall2019-01-081-3/+4
| | | | | | | x <= 0 will fail one or both of the other test clauses. Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
* traffic: assign context domain at startDouglas Bagnall2019-01-081-7/+1
| | | | | Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
* traffic: traffic_replay --latency-timeout to control final waitDouglas Bagnall2019-01-081-1/+2
| | | | | | | | | Conversations that haven't finished within some acceptable margin of on-time can be said to have failed. This is where you specify that margin. Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
* traffic_replay: --stop-on-any-error option to not ignore client troubleDouglas Bagnall2019-01-081-0/+3
| | | | | | | | Sometimes you want to know if any client is crashing for any reason. In those times use --stop-on-any-error for an early exit. Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
* traffic: evoke OS error codes by name, not numberDouglas Bagnall2019-01-081-2/+3
| | | | | Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
* traffic: reinitialise RNG in each childDouglas Bagnall2019-01-081-2/+8
| | | | | | | Otherwise they all replay using the same random sequence. Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
* traffic: avoid generating conversations without packetsDouglas Bagnall2019-01-081-0/+28
| | | | | | | | | | | | Some "packets" don't generate any actual traffic. If we have a conversation consisting only of those, we can avoid forking a client for it. This *slightly* increases the load over that which would be generated otherwise for a given traffic rate, but that's OK. Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
* traffic: rework conversation generation to better use memoryDouglas Bagnall2019-01-081-149/+173
| | | | | | | | Use less memory altogether and don't allocated shared mutable before the fork. Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
* traffic: generate sparser descriptions of conversationsDouglas Bagnall2019-01-082-9/+3
| | | | | | | | | | | | | Rather than building all the packets at this point, we stick to the barest details of the packets (which is all the model gives us anyway). The advantage is that will take a lot less memory, which matters because this process forks into many clients that were sharing and mutate the conversation list. Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
* traffic: new version of model with packet_rate, version numberDouglas Bagnall2019-01-088-94/+202
| | | | | Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
* traffic: fix hash non-determinism when loading JSONDouglas Bagnall2019-01-081-0/+2
| | | | | Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Tim Beale <timbeale@samba.org>
* traffic: Conversation gets given id, list of short packetsDouglas Bagnall2019-01-081-8/+8
| | | | | Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
* traffic: rename packet_rate -> replay_speed for accuracy and roomDouglas Bagnall2019-01-081-5/+6
| | | | | | | | We are soon going to have a self.packet_rate, and replay_speed is more accurate in this case. Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
* traffic: initialise conversation specific lists after the forkDouglas Bagnall2019-01-081-12/+12
| | | | | Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
* traffic: split is_a_real_packet() function out of classDouglas Bagnall2019-01-081-17/+21
| | | | | | | | So we can use it to determine whether a packet should be a Packet before making the leap. Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
* traffic: give Packet __slots__ for reduced memoryDouglas Bagnall2019-01-081-1/+10
| | | | | Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
* traffic: make random_colour_print more deterministic, silent on demandDouglas Bagnall2019-01-081-9/+21
| | | | | Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
* traffic: use namedtuple for ConversationAccounts namespace classDouglas Bagnall2019-01-081-9/+10
| | | | | | | Saving memory, which reduces fork overhead. Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
* traffic: fix mk_masked_dir doc and commentsDouglas Bagnall2019-01-081-1/+2
| | | | | Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
* traffic: Packet.from_line classmethod uses cls varDouglas Bagnall2019-01-081-3/+3
| | | | | Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
* traffic_learner: return an error codeDouglas Bagnall2019-01-081-5/+2
| | | | | | | And use it in tests, rather than expecting exact strings. Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>