summaryrefslogtreecommitdiff
path: root/source4/scripting
AgeCommit message (Collapse)AuthorFilesLines
2018-08-24PEP8: fix E201: whitespace after '('Joe 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 E127: continuation line over-indented for visual indentJoe Guo1-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>
2018-08-24PEP8: fix E111: indentation is not a multiple of fourJoe Guo2-31/+31
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-06netcmd: domain backup offline commandAaron Haslett1-97/+0
Unlike the existing 'domain backup online' command, this command allows an admin to back up a local samba installation using the filesystem and the tdbbackup tool instead of using remote protocols. It replaces samba_backup as that tool does not handle sam.ldb and secrets.ldb correctly. Those two databases need to have transactions started on them before their downstream ldb and tdb files are backed up. Signed-off-by: Aaron Haslett <aaronhaslett@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Gary Lockyer <gary@catalyst.net.nz>
2018-07-12gpo: Add user policy extensionsDavid Mulder1-2/+4
Signed-off-by: David Mulder <dmulder@suse.com> Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2018-07-12gpo: Dynamically load gp_extsDavid Mulder1-0/+4
This loads Group Policy Client Side Extensions similar to the way that they are loaded on a Windows client. Extensions are installed to a configuration file in the samba cache path where they receive a unique GUID matched with the path to the python gp_ext file. Classes which inherit from the gp_ext class (as defined in gpclass.py) will be dynamically loaded. Signed-off-by: David Mulder <dmulder@suse.com> Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2018-07-12dns: update tool changed for scavengingAaron Haslett1-9/+1
Now that scavenging is implemented, the DNS update tool needs to be changed so that it always updates every name required by the DC. Otherwise, the records might be scavenged. BUG: https://bugzilla.samba.org/show_bug.cgi?id=10812 Signed-off-by: Aaron Haslett <aaronhaslett@catalyst.net.nz> Reviewed-by: Gary Lockyer <gary@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2018-07-04samba-gpupdate: Change machine option to targetDavid Mulder2-4/+7
On a Windows client, you designate machine/user apply with a 'target' parameter. This change makes gpupdate work more like that command. Signed-off-by: David Mulder <dmulder@suse.com> Reviewed-by: Andreas Schneider <asn@samba.org> Reviewed-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 Jul 4 13:23:09 CEST 2018 on sn-devel-144
2018-07-04samba_gpoupdate: Rename the command to samba-gpupdateDavid Mulder4-10/+10
On a Windows client, this command is called 'gpupdate' Signed-off-by: David Mulder <dmulder@suse.com> Reviewed-by: Andreas Schneider <asn@samba.org> Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2018-06-28provision: set 'binddns dir' when making new smb.confTim Beale1-0/+3
When creating a new smb.conf from scratch during a join/clone/etc, the 'binddns dir' setting still uses the source smb.conf/default setting, instead of the targetdir sub-directory. I noticed this problem when trying to create a new testenv - the provision() was trying to create /usr/local/samba/bind-dns directory, which would fail if samba hadn't already been installed on the host machine. Now that this is fixed, we also need to fix tests that were explicitly asserting that no unexpected directories were left behind after the test completes. This change also breaks the upgradeprovision script. The upgrade- provision calls newprovision() to create a reference provision in a temporary directory. However, previously this temporary provision was creating the bind-dns directory in the actual upgrade directory as a side-effect, e.g. it did a provision() with targetdir=alpha13_upgrade_full/private/referenceprovisionLBKBh2 and this ended up creating alpha13_upgrade_full/bind-dns as a side-effect. The provision() now creates bind-dns in the specified targetdir, but this means check_for_DNS() fails (it tries to create bind-dns sub- directories, but the upgrade's bind-dns doesn't exist). I've avoided this problem by making sure bind-dns exists as part of the check_for_DNS() processing. Signed-off-by: Tim Beale <timbeale@catalyst.net.nz> Reviewed-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): Thu Jun 28 06:22:16 CEST 2018 on sn-devel-144
2018-06-01dnsupdate: Fix a typoVolker Lendecke1-1/+1
Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Andreas Schneider <asn@samba.org>
2018-05-12s4/scripting/devel: py2/py3 compatability always decode result of b64encodeNoel Power2-7/+7
Signed-off-by: Noel Power <noel.power@suse.com> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2018-05-12s4/scripting/bin: py2/py3 compatability always decode result of b64encodeNoel Power5-5/+5
Signed-off-by: Noel Power <noel.power@suse.com> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2018-05-12python/samba: Bulk replace of '.next()' method with function 'next()'Noel Power1-3/+3
Signed-off-by: Noel Power <noel.power@suse.com> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2018-05-12devel: removing unused code from chgkrbtgtpassAaron Haslett1-4/+1
Signed-off-by: Aaron Haslett <aaronhaslett@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Garming Sam <garming@catalyst.net.nz> Autobuild-User(master): Andrew Bartlett <abartlet@samba.org> Autobuild-Date(master): Sat May 12 12:05:31 CEST 2018 on sn-devel-144
2018-05-03samba_dnsupdate: Put samba.kcc import after path insert of bin/pythonGarming Sam1-1/+1
Signed-off-by: Garming Sam <garming@catalyst.net.nz> Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
2018-04-13python: bulk replace dict.itervalues to values for py3Joe Guo1-2/+2
In py3, iterxxx methods are removed. 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-12gpo: Move implementation from samba_gpoupdateDavid Mulder1-77/+2
The implementation of group policy apply should not be in the application script. One reason is to implement user apply, we can call these functions via the python c-api, (passing creds via the command line will expose them via ps). Another reason for this is if some overrides the smb.conf "gpo update command" option, it would be useful to have these functions. Signed-off-by: David Mulder <dmulder@suse.com> Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2018-04-06upgradeprovision: detect and handle lmdb databasesGary Lockyer1-4/+22
Signed-off-by: Gary Lockyer <gary@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org> Autobuild-User(master): Andrew Bartlett <abartlet@samba.org> Autobuild-Date(master): Fri Apr 6 05:12:11 CEST 2018 on sn-devel-144
2018-04-06upgradeprovision: Do not copy backup lmdb -lock filesGary Lockyer1-3/+4
Signed-off-by: Gary Lockyer <gary@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2018-03-23s4/scripting: convert print func to be py2/py3 compatibleNoel Power6-60/+66
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-21samba_dnsupdate: Introduce automatic site coverageGarming Sam1-0/+27
This uses the underlying function in kcc_utils.py which already has tests. Signed-off-by: Garming Sam <garming@catalyst.net.nz> Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
2018-02-15source4/scripting python: convert 'except X, e' to 'except X as e'Douglas Bagnall10-20/+20
Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2018-01-13gpo: Add the winbind call to gpupdateDavid Mulder3-6/+24
Signed-off-by: David Mulder <dmulder@suse.com> Reviewed-by: Garming Sam <garming@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2018-01-13gpo: Continue parsing GPOs even if one failsDavid Mulder1-6/+8
Signed-off-by: David Mulder <dmulder@suse.com> Reviewed-by: Garming Sam <garming@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2017-12-15gpo: Test that unapply worksDavid Mulder1-2/+2
Signed-off-by: David Mulder <dmulder@suse.com> Reviewed-by: Garming Sam <garming@catalyst.net.nz> Reviewed-by: Jeremy Allison <jra@samba.org>
2017-12-14upgradeprovision: Change test to always use 2008 R2 schemaTim Beale1-1/+1
This tool (and the corresponding test) is designed to migrate a Samba DC from a pre-4.0.0 release up to a more recent schema (i.e. Windows 2008R2). Going further than 2008R2 turns this test into a bit of a nightmare. We now have a better adprep/'samba-tool domain schemaupgrade' option for upgrading from 2008R2 to a more recent schema. It seems to make most sense to leave this tests just running against 2008R2 schema provisions and add new tests to migrate from 2008R2 to 2012R2. Signed-off-by: Tim Beale <timbeale@catalyst.net.nz> Reviewed-by: Garming Sam <garming@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2017-11-21Fix formating of sources to be less than 80 linesGarming Sam1-4/+6
Signed-off-by: David Mulder <dmulder@suse.com> 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): Tue Nov 21 01:51:59 CET 2017 on sn-devel-144
2017-11-20doc: Add samba_gpoupdate man page, update WHATSNEWDavid Mulder2-0/+120
Signed-off-by: David Mulder <dmulder@suse.com> Signed-off-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Garming Sam <garming@catalyst.net.nz>
2017-11-20gpo: Always enforce policy, even if unchangedDavid Mulder1-10/+14
Policies should always be enforced, even if the gpo hasn't changed. Signed-off-by: David Mulder <dmulder@suse.com> Reviewed-by: Garming Sam <garming@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2017-11-20gpo: Add GPO unapplyDavid Mulder1-31/+59
Keep a log of applied settings, and add an option to samba_gpoupdate to allow unapply. An unapply will revert settings to a state prior to any policy application. Signed-off-by: David Mulder <dmulder@suse.com> Reviewed-by: Garming Sam <garming@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2017-11-20gpo: Install the samba_gpoupdate scriptDavid Mulder2-1/+2
The samba_gpoupdate script was not being installed by waf. Added samba_gpoupdate to the wscripts so it gets installed as part of a make install. Signed-off-by: David Mulder <dmulder@suse.com> Reviewed-by: Garming Sam <garming@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2017-11-20gpoupdate: Rewrite samba_gpoupdateDavid Mulder1-214/+87
Use new python bindings and remove obsoleted code Signed-off-by: David Mulder <dmulder@suse.com> Reviewed-by: Garming Sam <garming@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2017-11-20gpo: Make the gpclass more easily extensibleDavid Mulder1-4/+4
Signed-off-by: David Mulder <dmulder@suse.com> Reviewed-by: Garming Sam <garming@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2017-11-20gpo: Make the gpoupdate script much more reliableDavid Mulder1-21/+39
Using a static file blanks the file when samba_gpoupdate crashes. Transformed to a tdb file and added transactions. Add info logging to monitor gpo changes, etc. Also handle parse errors and log an error message, then recover. Modified the parsing code to use ConfigParser. Also, use the backslash in path names when opening smb files, otherwise it fails against a windows server. Signed-off-by: David Mulder <dmulder@suse.com> Reviewed-by: Garming Sam <garming@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2017-11-20gpo: Initial commit for GPO workLuke Morrison1-0/+235
Enclosed is my Summer of Code 2013 patch to have vital password GPO always applied to the Samba4 Domain Controller using a GPO update service. To try it out "make -j" your samba with the patch, apply a security password GPO and see the difference in ~20 seconds. It also takes GPO hierarchy into account. Split from "Initial commit for GPO work done by Luke Morrison" by David Mulder Signed-off-by: Garming Sam <garming@catalyst.net.nz> Signed-off-by: Luke Morrison <luke@hubtrek.com> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2017-11-20waf: Move script list to one-per-lineAndrew Bartlett1-1/+7
Signed-off-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Garming Sam <garming@catalyst.net.nz>
2017-10-25s4:scripting: Fix ntstatus_gen.h generation on 32bitAndreas Schneider1-1/+1
The hex() function results in different output on 32bit systems. It adds a L for long for some numbers. Thus we have a different header file. This patch makes sure we have a consistent file generation on different paltforms. BUG: https://bugzilla.samba.org/show_bug.cgi?id=13099 Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: David Disseldorp <ddiss@samba.org> Autobuild-User(master): David Disseldorp <ddiss@samba.org> Autobuild-Date(master): Wed Oct 25 22:28:39 CEST 2017 on sn-devel-144
2017-10-19python: add a failed test to show Popen deadlockJoe Guo2-1/+54
`Popen.wait()` will deadlock when using stdout=PIPE and/or stderr=PIPE and the child process generates large output to a pipe such that it blocks waiting for the OS pipe buffer to accept more data. Use communicate() to avoid that. This patch is commited to show the issue, a fix patch will come later. 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>
2017-09-23scripting: Add script (backportable) to undo a GUID indexAndrew Bartlett1-0/+84
This script allows the DB to be read, and re-indexed, by an earlier Samba version, most likely 4.7 with some backported patches. Signed-off-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Garming Sam <garming@catalyst.net.nz> Autobuild-User(master): Andrew Bartlett <abartlet@samba.org> Autobuild-Date(master): Sat Sep 23 09:16:31 CEST 2017 on sn-devel-144
2017-09-16samba_upgradedns: When we setup the internal dns cleanup bind-dns dirAndreas Schneider1-0/+17
Make sure to remove everything from the bind-dns directory to avoid possible security issues with the named group having write access to all AD partions BUG: https://bugzilla.samba.org/show_bug.cgi?id=12957 Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
2017-09-16samba_upgradedns: Print better hints after we migrated the configAndreas Schneider1-3/+15
BUG: https://bugzilla.samba.org/show_bug.cgi?id=12957 Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
2017-09-16samba_upgradedns: Change the group of the 'binddns dir' tooAndreas Schneider1-0/+7
BUG: https://bugzilla.samba.org/show_bug.cgi?id=12957 Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
2017-09-06python:samba: Add code to remove obsolete files in the private dirAndreas Schneider1-0/+34
BUG: https://bugzilla.samba.org/show_bug.cgi?id=12957 Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Andrew Bartlet <abartlet@samba.org> Autobuild-User(master): Jeremy Allison <jra@samba.org> Autobuild-Date(master): Wed Sep 6 03:54:19 CEST 2017 on sn-devel-144
2017-09-05python:samba: Use 'binddns dir' in samba-tool and samba_upgradednsAndreas Schneider2-17/+38
This provisions the bind_dlz files in the 'binddns dir'. If you want to migrate to the new files strcuture you can run samba_upgradedns! BUG: https://bugzilla.samba.org/show_bug.cgi?id=12957 Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Andrew Bartlet <abartlet@samba.org>
2017-08-22python: Make generated modules samba.ntstatus and samba.werror Python 3 ↵Lumir Balhar2-8/+24
compatible. Signed-off-by: Lumir Balhar <lbalhar@redhat.com> Reviewed-by: Andreas Schneider <asn@samba.org> Reviewed-by: Andrew Bartlet <abartlet@samba.org> Autobuild-User(master): Andreas Schneider <asn@cryptomilk.org> Autobuild-Date(master): Tue Aug 22 17:38:17 CEST 2017 on sn-devel-144
2017-08-22python: scripting: Port ntstatus and werror generators to Python 3 ↵Lumir Balhar3-9/+9
compatible form. Signed-off-by: Lumir Balhar <lbalhar@redhat.com> Reviewed-by: Andreas Schneider <asn@samba.org> Reviewed-by: Andrew Bartlet <abartlet@samba.org>
2017-06-10samba_dnsupdate: fix "samba-tool" fallback error handlingAndrew Bartlett1-1/+1
Signed-off-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Garming Sam <garming@catalyst.net.nz>
2017-06-10samba_dnsupdate: Extend possible server list to all NS servers for the zoneAndrew Bartlett1-29/+69
This should eventually be removed, but for now this unblocks samba_dnsupdate operation in existing domains that have lost the original Samba DC Signed-off-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Garming Sam <garming@catalyst.net.nz>
2017-06-10samba_dnsupate: Try to get ticket to the SOA, not the NS serversAndrew Bartlett1-3/+5
Signed-off-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Garming Sam <garming@catalyst.net.nz>