summaryrefslogtreecommitdiff
path: root/source4/scripting
Commit message (Collapse)AuthorAgeFilesLines
* Spelling fixes s/exising/existing/Mathieu Parent2019-09-011-1/+1
| | | | | | Signed-off-by: Mathieu Parent <math.parent@gmail.com> Reviewed-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Gary Lockyer <gary@catalyst.net.nz>
* Spelling fixes s/containter/container/Mathieu Parent2019-09-011-1/+1
| | | | | | Signed-off-by: Mathieu Parent <math.parent@gmail.com> Reviewed-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Gary Lockyer <gary@catalyst.net.nz>
* downgradedatabase: installing scriptAaron Haslett2019-08-202-2/+3
| | | | | | | | | | | | | | Installing downgrade script so people don't need the source tree for it. Exception added in usage test because running the script without arguments is valid. (This avoids the need to knownfail it). BUG: https://bugzilla.samba.org/show_bug.cgi?id=14059 Signed-off-by: Aaron Haslett <aaronhaslett@catalyst.net.nz> Signed-off-by: Tim Beale <timbeale@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Garming Sam <garming@catalyst.net.nz>
* downgradedatabase: rename to samba_downgrade_dbTim Beale2019-08-201-0/+0
| | | | | | | | | | Just so that it's slightly less of a mouthful for users. BUG: https://bugzilla.samba.org/show_bug.cgi?id=14059 Signed-off-by: Tim Beale <timbeale@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Garming Sam <garming@catalyst.net.nz>
* downgradedatabase: comply with samba.tests.sourceAaron Haslett2019-08-201-3/+23
| | | | | | | | | | | | In next commit we'll install the script, samba.tests.source picked up the lack of a copyright message and some whitespace errors, so this patch fixes that stuff first. BUG: https://bugzilla.samba.org/show_bug.cgi?id=14059 Signed-off-by: Aaron Haslett <aaronhaslett@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Garming Sam <garming@catalyst.net.nz>
* s4/scripting/smbstatus: begoneDouglas Bagnall2019-07-051-92/+0
| | | | | | | Untested and unused. Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
* s4/scripting/autoidl: remove itDouglas Bagnall2019-07-051-164/+0
| | | | | | | | | | | | | What does it even do? Possibly nothing, not least because nobody ever runs it. It was introduced as source4/scripting/bin/autoidl.py in a2446e5f8550582c0d4353bb85874dea17cf1d98 ("initial work for script that uses probing to figure out IDL"). Since then it has only had superficial patches, generally aimed at Python 3. Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
* s4/scripting/samba_dnsupdate: print usage with no argumentsDouglas Bagnall2019-07-051-4/+16
| | | | | Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
* s4/scripting/demodirsync: print usage if no host namedDouglas Bagnall2019-07-051-0/+3
| | | | | Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
* s4/scripting/mymachinepw: print usage with bad argumentsDouglas Bagnall2019-07-051-3/+6
| | | | | | | | Also, use sys.exit() function, not exit(), because sys.exit() reliably exists. Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
* s4/scripting/get-descriptors: print usage with insufficient argumentsDouglas Bagnall2019-07-051-0/+4
| | | | | Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
* kcc: default to logging to DBGLVL_WARNINGGary Lockyer2019-07-021-1/+4
| | | | | | | | | | | | | | | | | If the "-d" debug level parameter is not supplied, default to DBGLVL_WARNING. Overiding the "log level" set in smb.conf. When samba runs the kcc command stderr output is logged at DBGLVL_ERR, the default log destination is stderr. As a result any log messages generated by the kcc command, are effectively logged at DBGLVL_ERR. This causes issues if auth or audit logging are enabled in smb.conf. Signed-off-by: Gary Lockyer <gary@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org> Pair-programmed-with: Tim Beale <timbeale@catalyst.net.nz> Autobuild-User(master): Andrew Bartlett <abartlet@samba.org> Autobuild-Date(master): Tue Jul 2 05:49:43 UTC 2019 on sn-devel-184
* s4/scripting/smbstatus: approach py3 compatibilityDouglas Bagnall2019-07-021-2/+2
| | | | | | | It is still unused and untested, probably not working. Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
* s4/script/rodcdns: str type doesn't need decodingDouglas Bagnall2019-07-021-1/+1
| | | | | Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
* s4/scripting/autoidl: another py3 incompatible exceptDouglas Bagnall2019-07-021-1/+2
| | | | | Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
* downgradedatabase: adding special case for MDBAaron Haslett2019-05-291-2/+27
| | | | | | | | | | | | | Though this script was initially written for undoing GUID indexing on TDB databases, we're repurposing it to do a full downgrade of any database. MDB databases can't be DN indexed, but they can have pack format version 2 and ORDERED_INTEGER data types, which must be removed during a downgrade. Signed-off-by: Aaron Haslett <aaronhaslett@catalyst.net.nz> Signed-off-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Garming Sam <garming@catalyst.net.nz> Pair-Programmed-With: Andrew Bartlett <abartlet@samba.org>
* sambadowngradedatabase: Add "or later" to warning about using tools from ↵Andrew Bartlett2019-05-291-1/+1
| | | | | | | Samba 4.8 Signed-off-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Garming Sam <garming@catalyst.net.nz>
* sambaundoguididx: renamed to downgradedatabaseAaron Haslett2019-05-291-0/+0
| | | | | | | | | | In forthcoming commits we're going to repurpose this script to do an entire downgrade of a database, disabling all new database features. downgradedatabase is a more appropriate name. Signed-off-by: Aaron Haslett <aaronhaslett@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Garming Sam <garming@catalyst.net.nz>
* sambaundoguididx: fix for -sAndrew Bartlett2019-05-291-2/+4
| | | | | | | | | Quick fix running this script with -s instead of -H. samdb_url() returns a url with a protocol prefix, which causes issues further down in the script. Signed-off-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Garming Sam <garming@catalyst.net.nz>
* sambaundoguididx: Add flags=ldb.FLG_DONT_CREATE_DB and port to Python3Andrew Bartlett2019-05-231-6/+10
| | | | | | | | | | | In py3 we need to add an extra str() around the returned ldb value to enable .split() to be used. Signed-off-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 May 23 14:25:52 UTC 2019 on sn-devel-184
* samba_dnsupdate: flush dns update cache file after writeJoe Guo2019-05-101-0/+1
| | | | | | | | | | While running samba python tests with `coverage.py`, `make test` failed to start ad_dc env since dns_update_cache stays empty. Flush the file after write fix the issue. Signed-off-by: Joe Guo <joeg@catalyst.net.nz> Signed-off-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Gary Lockyer <gary@catalyst.net.nz>
* s4/scripting/bin Remove unecessary scriptsNoel Power2019-05-062-753/+0
| | | | | | | Apparently we get official schema from MS these days Signed-off-by: Noel Power <noel.power@suse.com> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
* build: Remove ndr_PyLong_FromUnsignedLongLong wrapper from NT_STATUS and ↵Andrew Bartlett2019-05-062-18/+2
| | | | | | | W_ERROR table generator Signed-off-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Gary Lockyer <gary@catalyst.net.nz>
* samba_dnsupdate: small tweaks to make code more pythonicJoe Guo2019-04-021-49/+19
| | | | | | Signed-off-by: Joe Guo <joeg@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Noel Power <npower@samba.org>
* s4/scripting: remove obsolete w32err_code.pyDouglas Bagnall2019-03-141-363/+0
| | | | | | | | This has been replaced by gen_werror.py which shares common code with other scripts (e.g. gen_ntstatus) and is more likely to work with conteporary microsoft HTML. Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
* s4/scripting: Remove legacy selftest-vars.sh scriptTim Beale2019-03-121-36/+0
| | | | | | | | | | | | | | This script was added in 2010 and has only been sporadically kept up-to-date since. It doesn't appear to work (I think that selftest and the testenvs have perhaps grown in complexity since 2010 and it's no longer possible to try to access a testenv from a different process-space, due to how we use the cwrap libraries). There's now an alternative (export_envvars_to_file()) in the selftest code to regenerate a similar file, if anyone actually needs it. Signed-off-by: Tim Beale <timbeale@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
* selftest: Remove unused SELFTEST_INTERFACESTim Beale2019-03-121-1/+0
| | | | | | | This doesn't appear to be used anywhere and dates back to 2008. Signed-off-by: Tim Beale <timbeale@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
* s4/scripting/autoidl: p3 exception syntaxDouglas Bagnall2019-03-121-1/+2
| | | | | Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
* s4/scripting: MORE py3 compatible print functionsDouglas Bagnall2019-03-129-62/+71
| | | | | Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
* selftest: Remove unused environment variablesTim Beale2019-02-181-12/+0
| | | | | | | | | | | | | | | | | | We only really want generic environment variables. For 2+ DC environments, we have the $SERVER and $DC_SERVER (aka PDC) variables. However, lots of testenvs also export really specific environment variables, e.g. VAMPIRE_2000_DC_SERVER_IP (despite that testenv being only used for a single test case). Previously the <testenv>_SERVER variable was used for DRS tests, but we can avoid the need to do this now. The other variables are not used at all. The RODC and TRUST environment variables are still used by a few tests. SUBDOM_DC_SERVER is only used within Samba4.pm and not exported. Signed-off-by: Tim Beale <timbeale@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
* sambaundoguididx: use the right escaped oder unescaped sam ldb filesBjörn Jacke2019-02-171-2/+1
| | | | | | | | | | | the correct filename is taken from the partition database before, we should not unescape that because this can result in a new unescaped ldb file being created and the script not to work at all. BUG: https://bugzilla.samba.org/show_bug.cgi?id=13759 Signed-off-by: Bjoern Jacke <bjacke@samba.org> Reviewed-by: Andreas Schneider <asn@samba.org>
* samba_dnsupdate: make rodc_dns_update() more robust against timing problemsStefan Metzmacher2019-02-141-1/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | Without this we had an interesting race! The messaging_dgm code caches connected datagram sockets based on the destination pid for 1 second. The fact that samba_dnsupdate constantly recreates its messaging context (and the underlying datagram socket) means that we the winbindd messaging context may get a stale connection. As a result sending any message from winbindd back to samba_dnsupdate will result in ECONNREFUSED. That means the IRPC response from winbindd never reaches samba_dnsupdate, which will then hit a timeout. In turn samba_dnsupdate on the RODC times out. This was a workaround for the problem, by having just one global IRPC handle and thus just one messaging_dgm context. The actual problem is solved a few commits before ("messages_dgm: Properly handle receiver re-initialization"). But we keep this as an performance optimization, which hopefully means that the overall samba_dnsupdate is less likely to timeout after the hardcoded 20 seconds. Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
* samba_dnsupdate: make it clear that opts.use_file is active and we're not ↵Stefan Metzmacher2019-02-141-3/+6
| | | | | | | using nsupdate Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
* s4/scripting/bin: open unicode files with utf8 encoding and write unicode stringJoe Guo2019-02-082-8/+14
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In files like `libcli/util/werror_err_table.txt` and `libcli/util/ntstatus_err_table.txt`, there were unicode quote symbols at line 6: ...(“this documentation”)... In `libcli/util/wscript_build`, it will run `gen_werror.py` and `gen_ntstatus.py` to `open` above files, read content from them and write to other files. When encoding not specified, `open` in both python 2/3 will guess encoding from locale. When locale is not set, it defaults to POSIX or C, and then python will use encoding `ANSI_X3.4-1968`. So, on a system locale is not set, `make` will fail with encoding error for both python 2 and 3: File "/home/ubuntu/samba/source4/scripting/bin/gen_werror.py", line 139, in main errors = parseErrorDescriptions(input_file, True, transformErrorName) File "/home/ubuntu/samba/source4/scripting/bin/gen_error_common.py", line 52, in parseErrorDescriptions for line in file_contents: File "/usr/lib/python3.5/encodings/ascii.py", line 26, in decode return codecs.ascii_decode(input, self.errors)[0] UnicodeDecodeError: 'ascii' codec can't decode byte 0xe2 in position 318: ordinal not in range(128) In this case, we have to use `io.open` with `encoding='utf8'`. However, then we got unicode strs and try to write them with other strs into new file, which means the new file must also open with utf-8 and all other strs have to be unicode, too. Instead of prefix `u` to all strs, a more easier/elegant way is to enable unicode literals for the python scripts, which we normally didn't do in samba. Since both `gen_werror.py` and `gen_ntstatus.py` are bin scripts and no other modules import them, it should be ok for this case. Signed-off-by: Joe Guo <joeg@catalyst.net.nz> Autobuild-User(master): Douglas Bagnall <dbagnall@samba.org> Autobuild-Date(master): Fri Feb 8 06:34:47 CET 2019 on sn-devel-144
* samba_dnsupdate: With dns_hub, we don't need resolv_wrapVolker Lendecke2019-01-151-25/+12
| | | | | | | Best viewed with git show -b Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* s4:scripting:bin: rm rpcclientGuo Qiao2018-12-171-305/+0
| | | | | | | | This file only works in py2, and no one use it. Just delete it. Signed-off-by: Joe Guo <joeg@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Gary Lockyer <gary@catalyst.net.nz>
* PY3: change shebang to python3 in source4/scripting dirJoe Guo2018-12-1412-12/+12
| | | | | Signed-off-by: Joe Guo <joeg@catalyst.net.nz> Reviewed-by: Noel Power <npower@samba.org>
* PY3: change shebang to python3 in source4/scripting/bin dirJoe Guo2018-12-1429-29/+29
| | | | | | | Samba default python is 3 now. Signed-off-by: Joe Guo <joeg@catalyst.net.nz> Reviewed-by: Noel Power <npower@samba.org>
* s4/scripting: python3 fix string.find instanceNoel Power2018-12-141-2/+2
| | | | | | | | string.find doesn't exist in python3. Instead use the 'find' method of the string instance itself Signed-off-by: Noel Power <noel.power@suse.com> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
* various: Remove references to about to be deleted thirdparty/dnspythonNoel Power2018-12-112-2/+0
| | | | | Signed-off-by: Noel Power <noel.power@suse.com> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
* python/samba/tests: PY3 port samba.tests.dnsNoel Power2018-12-101-1/+2
| | | | | | | | | | | | | Misc hanges needed to get make test TEST=samba.tests.dns & samb.tests.dns_fowarder to run and pass under PY3 * socket.send needs bytes not string * rec.dwTimeStamp expects int not float (in PY3 / operator will give float results, for int use '//' instead) * re.match using bytes needs a bytes search term Signed-off-by: Noel Power <noel.power@suse.com> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
* s4/scripting/bin: gensec_client.update needs bytesNoel Power2018-11-141-2/+1
| | | | | | | PY3 test was failing as param passed to update was str rather than bytes Signed-off-by: Noel Power <noel.power@suse.com> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
* s4/scripting/bin: PY3 convert servicePrincipalName attr to stringTim Beale2018-11-141-1/+1
| | | | | | | | | | res[0]["servicePrincipalName"] is an instance of ldb.bytes in PY3 If we wish to get the string value we need to call the custom str function which attempts to decode the bytes to 'utf8' Signed-off-by: Tim Beale <timbeale@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org> Reviewed by: Noel Power <npower@samba.org>
* s4/scripting/*: py3 compatible printDouglas Bagnall2018-11-0214-31/+32
| | | | | Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Noel Power <noel.power@suse.com>
* dnsupdate: Skip kerberos step if use-file specifiedTim Beale2018-11-011-2/+2
| | | | | | | | | | | | | | | | | | If there's a problem in get_credentials() (getting the machine account Kerberos credentials), then we fallback to use_samba_tool (essentially ignoring use-file). However, there's no need to do this, as use-file shouldn't require Kerberos credentials. This was making bootstrapping issues starting a testenv harder to debug. Obviously, Kerberos is dependent on DNS functioning correctly, but running dnsupdate was also dependent on having a working Kerberos KDC. In my case, the testenv had a bad krb5.conf file, but the problem appeared as resolv-wrapper errors (due to a missing RESOLV_WRAPPER_HOSTS file, which should've been generated by dnsupdate). Signed-off-by: Tim Beale <timbeale@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org> Pair-Programmed-With: Garming Sam <garming@catalyst.net.nz>
* dnsupdate: Pass smb.conf through to samba-tool commandsTim Beale2018-11-011-0/+4
| | | | | | | | | | | | | | If you call samba_dnsupdate with a --configfile option, this wasn't passed through to the samba-tool commands the script tries to run. Normally, samba_dnsupdate would only be run on the DC itself, so it shouldn't be a big deal, however, this may be a problem if you install the samba database into a non-default location (i.e. not /usr/local/samba). This patch passes through the smb.conf file, if one was specified. Signed-off-by: Tim Beale <timbeale@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
* s4/scripting/pfm_verify: PY3: use compat.text_typeDouglas Bagnall2018-11-011-2/+2
| | | | | Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Noel Power <noel.power@suse.com>
* s4/scripting/samba_upgradedns: avoid .has_key()Douglas Bagnall2018-11-011-2/+2
| | | | | Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Noel Power <noel.power@suse.com>
* s4/scripting/minschema: whitespace reformat and py3 compatible printDouglas Bagnall2018-11-011-8/+8
| | | | | Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Noel Power <noel.power@suse.com>
* s4/scripting/autoidl: py3 compatible exceptDouglas Bagnall2018-11-011-2/+2
| | | | | Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Noel Power <noel.power@suse.com>