summaryrefslogtreecommitdiff
path: root/python
AgeCommit message (Collapse)AuthorFilesLines
2021-06-10python: remove obsolete samba_external directoryDouglas Bagnall1-4/+0
It seems this was once meant to contain third-party python libraries that we hoped would already be on the system, of which there was only ever one candidate, dnspython, which we moved then stopped bundling years ago. The ancestor of this directory, 'source4/scripting/python/samba_external/' was unused since 4bbc3ff037026c72f3249f59c1b5af69a6ad6d69 (2010) and the current location has never done anything. Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Jeremy Allison <jra@samba.org>
2021-06-10samba-tool domain: improve error message when `patch` failsDouglas Bagnall1-1/+2
The old message confused even the wisest among us: https://lists.samba.org/archive/samba/2021-May/236021.html and while /user/bin/patch might be overly specific, it should point people in the right direction. Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Jeremy Allison <jra@samba.org>
2021-06-09samba-tool: gpo admxload mkdir -pDavid Mulder1-1/+1
Ensure all directories in the path are created, otherwise admx upload fails 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): Wed Jun 9 22:26:42 UTC 2021 on sn-devel-184
2021-06-09gpo: Apply Group Policy GNOME SettingsDavid Mulder1-2/+427
Signed-off-by: David Mulder <dmulder@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org> Autobuild-User(master): Jeremy Allison <jra@samba.org> Autobuild-Date(master): Wed Jun 9 17:44:25 UTC 2021 on sn-devel-184
2021-06-09gpo: Test Group Policy GNOME SettingDavid Mulder2-0/+390
Signed-off-by: David Mulder <dmulder@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
2021-06-02selftest: Add test of NDR marshalling from python, starting with wbintAndrew Bartlett3-0/+148
These patches are to address an issue unpacking a very large winbind.wbint_Principals array (100,000). We need the NDR_TOKEN_MAX_LIST_SIZE value exposed as otherwise a well-meaning incrase of this value would invalidate the test. BUG: https://bugzilla.samba.org/show_bug.cgi?id=14710 Signed-off-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
2021-06-02samba-tool dns zoneoptions: timestamp manipulation optionsDouglas Bagnall2-3/+649
There was a bug in Samba before 4.9 that marked all records intended to be static with a current timestamp, and all records intended to be dynamic with a zero timestamp. This was exactly the opposite of correct behaviour. It follows that a domain which has been upgraded past 4.9, but on which aging is not enabled, records intended to be static will have a timestamp from before the upgrade date (unless their nodes have suffered a DNS update, which due to another bug, will change the timestmap). The following command will make these truly static: $ samba-tool dns zoneoptions --mark-old-records-static=2018-07-23 -U... where '2018-07-23' should be replaced by the approximate date of the upgrade beyond 4.9. It seems riskier making blanket conversions of static records into dynamic records, but there are sometimes useful patterns in the names given to machines that we can exploit. For example, if there is a group of machines with names like 'desktop-123' that are all supposed to using dynamic DNS, the adminstrator can go $ samba-tool dns zoneoptions --mark-records-dynamic-regex='desktop-\d+' and there's a --mark-records-static-regex for symmetry. These options are deliberately long and cumbersome to type, so people have a chance to think before they get to the end. We also introduce a '--dry-run' (or '-n') option so they can inspect the likely results before going ahead. *NOTE* ageing will still not work properly after this commit, due to other bugs that will be fixed in other commits. Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2021-06-02pytest:samba-tool dns: more robust clean-upDouglas Bagnall1-4/+1
If setUp() fails (and here we have a big .setUp), .tearDown is not run, and that can leave the zone undeleted, breaking all the other tests who expect to be able to recreate it. Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2021-06-02samba-tool dns: remove unused importsDouglas Bagnall1-4/+0
Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2021-06-02samba-tool dns: move dns_record_match to dnsserver.pyDouglas Bagnall3-83/+99
This function is used here and in tests, but the tests should not be importing things from netcmd.dns, which is really supposed to be UI code. So we move to a common place. the only difference is the function raises DNSParseError instead of CommandError, and netcmd.dns has to catch and wrap that. Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2021-05-28pytest:segfault: Add test for assigning to an inline arrayJoseph Sutton1-0/+8
BUG: https://bugzilla.samba.org/show_bug.cgi?id=14065 Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Andreas Schneider <asn@samba.org>
2021-05-19python: Make credentials cache test run against WindowsJoseph Sutton1-1/+4
Windows, unlike Samba, requires the service principal name to be set when requesting a ticket to that service. Additionally, default_realm from the libdefaults section of krb5.conf should be set so that the correct realm is used. Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Autobuild-User(master): Jeremy Allison <jra@samba.org> Autobuild-Date(master): Wed May 19 02:22:01 UTC 2021 on sn-devel-184
2021-05-19python: Fix ticket timestamp conversion when local timezone is not UTCJoseph Sutton1-4/+19
Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
2021-05-19python: Add SMB credentials cache testJoseph Sutton2-0/+109
Test that we can use a credentials cache with a user's service ticket obtained with our Python code to connect to a service through SMB. Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
2021-05-19python: Add RPC credentials cache testJoseph Sutton2-0/+78
Test that we can use a credentials cache with a user's service ticket obtained with our Python code to connect to a service through RPC. Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
2021-05-19python: Add LDAP credentials cache testJoseph Sutton2-0/+95
Test that we can use a credentials cache with a user's service ticket obtained with our Python code to connect to a service through LDAP. Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
2021-05-19python: Add credentials cache testJoseph Sutton4-4/+133
Test that we can use a credentials cache with a user's service ticket obtained with our Python code to connect to a service using the normal credentials system backed on to MIT/Heimdal Kerberos 5 libraries. This will allow us to validate the output of the MIT/Heimdal libraries in the future. Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
2021-05-19krb5: Add Python functions to create a credentials cache containing a ↵Joseph Sutton1-4/+163
service ticket This is a FILE: format credentials cache readable by the MIT/Heimdal Kerberos libraries. This allows us to glue the Python ASN1 Kerberos system to the MIT/Heimdal one. Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
2021-05-19librpc: Test parsing a Kerberos 5 credentials cache with ndrdumpJoseph Sutton1-0/+37
This is the format used by the FILE: credentials cache type. Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
2021-05-19Revert "s4-test: fixed ndrdump test for top level build"Joseph Sutton1-7/+1
This essentially reverts commit b84c0a9ed6d556eb2d3797d606edcd03f9766606, but the datapath is now in the source4 directory. Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
2021-05-17samba-tool:testparm: Display nicer parameter dump error messagesJoseph Sutton1-2/+10
Now we catch errors for unknown sections or parameters and turn them into CommandErrors. BUG: https://bugzilla.samba.org/show_bug.cgi?id=14143 Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz> Reviewed-by: Rowland Penny <rpenny@samba.org> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2021-05-17samba-tool:testparm: Test error handling for unknown sections and parametersJoseph Sutton1-0/+28
BUG: https://bugzilla.samba.org/show_bug.cgi?id=14143 Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz> Reviewed-by: Rowland Penny <rpenny@samba.org> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2021-05-17samba-tool:testparm: Fix error with --section-nameJoseph Sutton1-1/+1
Pass the correct parameters into LoadparmService.dump() so that --section-name works properly. BUG: https://bugzilla.samba.org/show_bug.cgi?id=14143 Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz> Reviewed-by: Rowland Penny <rpenny@samba.org> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2021-05-17samba-tool:testparm: Test that --section-name works without --parameter-nameJoseph Sutton1-1/+39
BUG: https://bugzilla.samba.org/show_bug.cgi?id=14143 Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz> Reviewed-by: Rowland Penny <rpenny@samba.org> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2021-04-29gpo: Correct name of files gpoDavid Mulder1-1/+1
This is important, since having the incorrect name will prevent policies from removing correctly on an unapply, or when the policy is deleted from AD. Signed-off-by: David Mulder <dmulder@suse.com> Reviewed-by: Jeremy Allison <jra@samba.org> Autobuild-User(master): Jeremy Allison <jra@samba.org> Autobuild-Date(master): Thu Apr 29 22:27:20 UTC 2021 on sn-devel-184
2021-04-28tests: Use --configfile instead of -sAndreas Schneider3-11/+23
We should use long options in tests to make clear what we are trying to do. Also the -s short option will be removed for --configfile later. Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2021-04-28python/hostconfig: remove 'from __future__ import absolute_import'Douglas Bagnall1-1/+0
obsolete in Python 3. Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2021-04-28python: remove all 'from __future__ import division'Douglas Bagnall4-4/+0
This made '//' and '/' in Python 2 behave as in Python 3. Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2021-04-28python: remove all 'from __future__ import print_function'Douglas Bagnall48-57/+2
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-04-26samba-tool group listmembers: always list objects which can not expireBjörn Baumbach1-2/+5
Otherwise for example contacts wouldn't be listed when the --hide-expired option is used. Contacts typically do not have the accountExpires attribute. BUG: https://bugzilla.samba.org/show_bug.cgi?id=14692 Signed-off-by: Björn Baumbach <bb@sernet.de> Reviewed-by: Rowland penny <rpenny@samba.org> Autobuild-User(master): Björn Baumbach <bb@sernet.de> Autobuild-Date(master): Mon Apr 26 13:21:43 UTC 2021 on sn-devel-184
2021-04-21samba-tool: Use s3 net join for member joinDavid Mulder1-4/+39
The s4 member join code has been broken for some time. Modify samba-tool to instead use the working s3 member join code. Signed-off-by: David Mulder <dmulder@samba.org> Reviewed-by: Andrew Bartlett <abartlet@samba.org> Autobuild-User(master): David Mulder <dmulder@samba.org> Autobuild-Date(master): Wed Apr 21 21:40:13 UTC 2021 on sn-devel-184
2021-04-21python: glue function for detecting if selftest is enabledDavid Mulder2-0/+13
Signed-off-by: David Mulder <dmulder@samba.org> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2021-04-21python: Test s3 net join and leaveDavid Mulder1-0/+80
Signed-off-by: David Mulder <dmulder@samba.org> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2021-04-21samba-tool: add dns zoneoptions for aging controlDouglas Bagnall2-0/+143
This adds a subcommand for altering zone parameters. At the moment the only options are related to record aging (a.k.a scavenging). The code is structured to make it easy to add more integer or boolean options, but it is not clear that this would be useful; many other parameters are not used or would only have deleterious effects. 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 Apr 21 10:04:14 UTC 2021 on sn-devel-184
2021-04-21libcli: Fix parsing access flags from multiple tablesVolker Lendecke1-2/+3
We have to look at all available mappings for parsing sddl for each special flag set. "GW" and "FX" come from two different tables, but the previous code settled on one table and then expected both "GW" and "FX" to come from that same table. Change the code to look at all tables per special flag set. Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org> Autobuild-User(master): Jeremy Allison <jra@samba.org> Autobuild-Date(master): Wed Apr 21 00:04:36 UTC 2021 on sn-devel-184
2021-04-20torture: Show sddl_decode() failure for "GWFX" access maskVolker Lendecke1-0/+6
Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
2021-04-20gpo: Open ssh config to write bytesDavid Mulder1-1/+1
Reopening the existing config file fails because we fail to open to write bytes. Signed-off-by: David Mulder <dmulder@suse.com> Reviewed-by: Andreas Schneider <asn@samba.org>
2021-04-19torture: Move sddl tests to pythonVolker Lendecke1-0/+180
This kind of test is better hosted in python than in C. More lines, but the ones in source4/libcli/security/tests/sddl.c were preeetty long... Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
2021-04-13python:tests:samba_tool: create temporary files under $SELFTEST_TMPDIRStefan Metzmacher4-4/+4
Tests should not create files in the build nor the source directory! Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Andreas Schneider <asn@samba.org>
2021-04-12tests python krb5: MS-KILE client principal look-upGary Lockyer3-1/+843
Tests of [MS-KILE]: Kerberos Protocol Extensions section 3.3.5.6.1 Client Principal Lookup Signed-off-by: Gary Lockyer <gary@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Isaac Boukris <iboukris@samba.org> Autobuild-User(master): Andrew Bartlett <abartlet@samba.org> Autobuild-Date(master): Mon Apr 12 00:38:26 UTC 2021 on sn-devel-184
2021-04-08pytests/dns_forwarder: remove unused importDouglas Bagnall1-1/+0
Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Andreas Schneider <asn@samba.org> Autobuild-User(master): Douglas Bagnall <dbagnall@samba.org> Autobuild-Date(master): Thu Apr 8 23:03:52 UTC 2021 on sn-devel-184
2021-04-08samba-tool dns: use dnsserver.flag_from_string()Douglas Bagnall1-25/+5
Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Andreas Schneider <asn@samba.org>
2021-04-08samba-tool dns: use dnsserver.record_from_stringDouglas Bagnall1-46/+6
Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Andreas Schneider <asn@samba.org>
2021-04-08pytests/dns: use dnsserver.record_from_stringDouglas Bagnall3-15/+16
not netcmd.dns.data_to_dns_record, which is a UI function. The only practical difference is it will raise DNSParseError, not CommandError. Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Andreas Schneider <asn@samba.org>
2021-04-08pytests/dns: import dnsserver.TXTRecord directlyDouglas Bagnall2-2/+4
Not through samba-tool, which should not be used as a library. Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Andreas Schneider <asn@samba.org>
2021-04-08pytest/dcerpc/dnsserver.py: use dnsserver.flag_from_stringDouglas Bagnall1-9/+6
Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Andreas Schneider <asn@samba.org>
2021-04-08pytest/dcerpcdnsserver: use record_from_string helperDouglas Bagnall1-28/+3
Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Andreas Schneider <asn@samba.org>
2021-04-08py/dnsserver add flag from string functionDouglas Bagnall1-0/+8
Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Andreas Schneider <asn@samba.org>
2021-04-08py/dnsserver: add record_from_string helper functionDouglas Bagnall1-0/+32
Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Andreas Schneider <asn@samba.org>
2021-04-08py/dnsserver: add .from_string() methodsDouglas Bagnall1-0/+71
The logic to parse DNS value strings (e.g. "example.com 10" for an MX, which needs to be split on the space) is repeated at least in samba-tool dns and tests/dcerpc/dnsserver.py. Here we bring it together so we can do it once. The sep= keyword allows callers to separate on all runs of whitespace (the default, as samba-tool dns does) or, using sep='', to separate on true spaces only. Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Andreas Schneider <asn@samba.org>