The branch, v4-10-test has been updated via a4466ec4282 ctdb: Print locks latency in machinereadable stats via 16b1971ea0a WHATSNEW: Update for Bug 13676 changes in Samba 4.10 via 26cd687f14d netcmd: Try to improve domain backup error message via f088f070b4c tests: Run ntacls_backup tests against testenv with SMBv1 disabled via 7399fe07fea selftest: Give the backup testenvs a 'test1' share via 349cfec01df tests: Run GPO commands against testenv with SMBv1 disabled via e682347bc18 ntacls: Pass correct use_ntvfs through to setntacl() via 6158ca6e299 tests: Run samba_tool.gpo tests against backup testenvs via 9d9b00566c1 s4:pysmb: Add error log that the s4 bindings are deprecated via c4323c00ec5 netcmd: Change GPO commands to use s3 SMB Py bindings via c9fdea2e361 s3:pylibsmb: Add FILE_READ_ATTRIBUTES access to .loadfile() API via b47e42e0400 netcmd: Change SMB flags from s4 Py bindings to s3 via 3ed03bd24eb s3:pylibsmb: Add .set_acl API to SMB py bindings via f43abe39d56 python/gpclass: Convert gpclass to use s3 SMB Python bindings via 529b29203d4 s3:libsmb: Honor disable_netbios option in smbsock_connect_send from 248c234e06b VERSION: Bump version up to 4.10.0rc2...
https://git.samba.org/?p=samba.git;a=shortlog;h=v4-10-test - Log ----------------------------------------------------------------- commit a4466ec428265be9b31cec0820ce44c6c9bbc61e Author: Volker Lendecke <v...@samba.org> Date: Mon Jan 14 15:04:59 2019 +0100 ctdb: Print locks latency in machinereadable stats Bug: https://bugzilla.samba.org/show_bug.cgi?id=13742 Signed-off-by: Volker Lendecke <v...@samba.org> Reviewed-by: Martin Schwenke <mar...@meltin.net> Autobuild-User(master): Volker Lendecke <v...@samba.org> Autobuild-Date(master): Wed Jan 16 05:34:17 CET 2019 on sn-devel-144 (cherry picked from commit 193a0d6f01372604b925d1972591062a0bb2400f) Autobuild-User(v4-10-test): Karolin Seeger <ksee...@samba.org> Autobuild-Date(v4-10-test): Mon Feb 4 13:09:49 CET 2019 on sn-devel-144 commit 16b1971ea0ae76d0738f1dae9997b58af1bd5eac Author: Tim Beale <timbe...@catalyst.net.nz> Date: Tue Jan 22 11:08:13 2019 +1300 WHATSNEW: Update for Bug 13676 changes in Samba 4.10 Although it's unlikely that users will be using the 'smb' Python bindings, it's probably worth noting in the release notes that these bindings will be deprecated in future releases. BUG: https://bugzilla.samba.org/show_bug.cgi?id=13676 Signed-off-by: Tim Beale <timbe...@catalyst.net.nz> Reviewed-by: Jeremy Allison <j...@samba.org> commit 26cd687f14d70676c41e038b98551944ebd95356 Author: Tim Beale <timbe...@catalyst.net.nz> Date: Thu Jan 17 09:41:21 2019 +1300 netcmd: Try to improve domain backup error message 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 <timbe...@catalyst.net.nz> Reviewed-by: Noel Power <npo...@samba.org> Autobuild-User(master): Noel Power <npo...@samba.org> Autobuild-Date(master): Mon Jan 21 16:34:06 CET 2019 on sn-devel-144 (cherry picked from commit 10e54a095f005c0988a7e5e8a35cea6200197854) commit f088f070b4cb5a18fdb6f819c5857ef325f53033 Author: Tim Beale <timbe...@catalyst.net.nz> Date: Wed Jan 16 10:02:07 2019 +1300 tests: Run ntacls_backup tests against testenv with SMBv1 disabled Just to prove that the NTACL backup works over SMBv2. BUG: https://bugzilla.samba.org/show_bug.cgi?id=13676 Signed-off-by: Tim Beale <timbe...@catalyst.net.nz> Reviewed-by: Jeremy Allison <j...@samba.org> (cherry picked from commit 7fb93eaca74ffe17bbe7255210dd3090afe8d5dc) commit 7399fe07feadfe7adf76c650a511fb7948554d18 Author: Tim Beale <timbe...@catalyst.net.nz> Date: Thu Dec 13 16:29:33 2018 +1300 selftest: Give the backup testenvs a 'test1' share The ntacls_backup tests use the test1 share, and we want to run them against the restoredc (which has SMBv1 disabled). The xattr.tdb file is needed for the backend_obj.wrap_getxattr() call (in ntacls.py) to work. BUG: https://bugzilla.samba.org/show_bug.cgi?id=13676 Signed-off-by: Tim Beale <timbe...@catalyst.net.nz> Reviewed-by: Jeremy Allison <j...@samba.org> (cherry picked from commit a310de2db13c02a602e74139cb47ea9a25628e01) commit 349cfec01df89f0591b04a5f39a9876b73d217d9 Author: Tim Beale <timbe...@catalyst.net.nz> Date: Tue Jan 15 17:12:20 2019 +1300 tests: Run GPO commands against testenv with SMBv1 disabled Just to prove that they work across SMBv2. BUG: https://bugzilla.samba.org/show_bug.cgi?id=13676 Signed-off-by: Tim Beale <timbe...@catalyst.net.nz> Reviewed-by: Jeremy Allison <j...@samba.org> (cherry picked from commit da33c2c4e4849f0985b08fbdc58cbd59b8426ec6) commit e682347bc1863a800373703f33866ea9c1f11626 Author: Tim Beale <timbe...@catalyst.net.nz> Date: Tue Jan 15 14:09:15 2019 +1300 ntacls: Pass correct use_ntvfs through to setntacl() We were already checking the smb.conf to see if it uses the NTVFS file server or the default smbd server. However, we weren't passing this through to the setntacl() call. This fixes the problem we noticed with 'samba-tool gpo aclcheck' failing after a restore. BUG: https://bugzilla.samba.org/show_bug.cgi?id=13676 Signed-off-by: Tim Beale <timbe...@catalyst.net.nz> Reviewed-by: Jeremy Allison <j...@samba.org> (cherry picked from commit f3fe96fc2e2d942b4a2e241777b5ee12b2295b97) commit 6158ca6e2994c5090312cf4677024b43df6bcc7e Author: Tim Beale <timbe...@catalyst.net.nz> Date: Fri Jan 11 15:09:48 2019 +1300 tests: Run samba_tool.gpo tests against backup testenvs Run the GPO tests against the backup/restore testenvs. Because the backup/restore preserves the NTACLs of the sysvol files, running the GPO tests against the backup testenvs is a good sanity- check. If fact it highlights that there is currently a problem with restoring the GPO files - this shows up in 'samba-tool gpo aclcheck', but we never noticed it until now. NTACL backup works slightly different for offline backups, and rename backups end up with more sysvol files, so run the tests against both these envs. BUG: https://bugzilla.samba.org/show_bug.cgi?id=13676 Signed-off-by: Tim Beale <timbe...@catalyst.net.nz> Reviewed-by: Jeremy Allison <j...@samba.org> (cherry picked from commit 2a7372da7b84921b247cefc23d7003b8056d74a4) commit 9d9b00566c1e7795600075f7a7c572d67fb0714d Author: Tim Beale <timbe...@catalyst.net.nz> Date: Fri Jan 11 15:57:21 2019 +1300 s4:pysmb: Add error log that the s4 bindings are deprecated We plan to delete the s4 SMB Python bindings in the next Samba release after v4.10, but first give external consumers a heads-up, just in case they are currently using the s4 bindings. Note the auth_log tests still use the s4 bindings, but all user-facing tools should now be updated to use the s3 bindings. BUG: https://bugzilla.samba.org/show_bug.cgi?id=13676 Signed-off-by: Tim Beale <timbe...@catalyst.net.nz> Reviewed-by: Jeremy Allison <j...@samba.org> (cherry picked from commit 6a29e63f32c0024587020fc1f92b3d1ecaa0afbc) commit c4323c00ec59112bcd2160b87ae5fe37a95cd34b Author: Tim Beale <timbe...@catalyst.net.nz> Date: Fri Jan 11 14:53:16 2019 +1300 netcmd: Change GPO commands to use s3 SMB Py bindings This means we can now use GPO commands on a DC that has SMBv1 disabled. BUG: https://bugzilla.samba.org/show_bug.cgi?id=13676 Signed-off-by: Tim Beale <timbe...@catalyst.net.nz> Reviewed-by: Jeremy Allison <j...@samba.org> (cherry picked from commit 08f1627cb3fa1c9ff7a0f74e32874d305647dc42) commit c9fdea2e361c842d566d662255a361c07932d003 Author: Tim Beale <timbe...@catalyst.net.nz> Date: Fri Jan 11 14:25:32 2019 +1300 s3:pylibsmb: Add FILE_READ_ATTRIBUTES access to .loadfile() API Add FILE_READ_ATTRIBUTES when opening the file handle, as we need to read the file's size. The .loadfile() API can end up calling cli_qfileinfo_basic() to get the file size. This can end up doing a 'FILE_ALL_INFORMATION' SMBv2 request underneath, which the MS-SMB2 spec (section 3.3.5.20.1 Handling SMB2_0_INFO_FILE) says the file handle must have FILE_READ_ATTRIBUTES access granted. I noticed this problem when running .loadfile() against the NTVFS server. BUG: https://bugzilla.samba.org/show_bug.cgi?id=13676 Signed-off-by: Tim Beale <timbe...@catalyst.net.nz> Reviewed-by: Jeremy Allison <j...@samba.org> (cherry picked from commit 0304b08de5ba1b4a6e08568a559c52f7d9e943d3) commit b47e42e04006549ae24360191e3b36f6cc01dc2f Author: Tim Beale <timbe...@catalyst.net.nz> Date: Tue Jan 8 15:10:46 2019 +1300 netcmd: Change SMB flags from s4 Py bindings to s3 BUG: https://bugzilla.samba.org/show_bug.cgi?id=13676 Signed-off-by: Tim Beale <timbe...@catalyst.net.nz> Reviewed-by: Jeremy Allison <j...@samba.org> (cherry picked from commit 345746ea5f4cca2620421ac0c8a649a596f5c19d) commit 3ed03bd24eb6c236df23025aa25b9618a2d76a25 Author: Tim Beale <timbe...@catalyst.net.nz> Date: Tue Jan 8 14:42:05 2019 +1300 s3:pylibsmb: Add .set_acl API to SMB py bindings This is pretty similar code to py_smb_getacl(), except it's calling cli_set_security_descriptor() instead of cli_query_security_descriptor() BUG: https://bugzilla.samba.org/show_bug.cgi?id=13676 Signed-off-by: Tim Beale <timbe...@catalyst.net.nz> Reviewed-by: Jeremy Allison <j...@samba.org> (cherry picked from commit b982811b60521624f1f600841ffa05e306eb936a) commit f43abe39d56b772628a6b9f803f0bf68f5870d08 Author: Tim Beale <timbe...@catalyst.net.nz> Date: Fri Dec 14 10:37:11 2018 +1300 python/gpclass: Convert gpclass to use s3 SMB Python bindings BUG: https://bugzilla.samba.org/show_bug.cgi?id=13676 Signed-off-by: Tim Beale <timbe...@catalyst.net.nz> Reviewed-by: Jeremy Allison <j...@samba.org> (cherry picked from commit 3b2e86bba1f6b22b144b07db454b842f0c0779ae) commit 529b29203d4263bb2e3263e7d873f74f5236814a Author: Justin Stephenson <jstep...@redhat.com> Date: Mon Jan 14 10:36:47 2019 -0500 s3:libsmb: Honor disable_netbios option in smbsock_connect_send If disable_netbios is set, return before the tevent timer is triggered to prevent outgoing netbios connections. BUG: https://bugzilla.samba.org/show_bug.cgi?id=13727 Signed-off-by: Justin Stephenson <jstep...@redhat.com> Reviewed-by: Andreas Schneider <a...@samba.org> Reviewed-by: Jeremy Allison <j...@samba.org> (cherry picked from commit c324f84a2fa25e29d2f7879fbcd35ce0e76a78f8) ----------------------------------------------------------------------- Summary of changes: WHATSNEW.txt | 14 ++++++++++ ctdb/tools/ctdb.c | 5 ++++ python/samba/gpclass.py | 10 +++++-- python/samba/netcmd/domain_backup.py | 5 ++-- python/samba/netcmd/gpo.py | 20 +++++++------ python/samba/ntacls.py | 3 +- selftest/target/Samba4.pm | 8 ++++++ source3/libsmb/pylibsmb.c | 54 +++++++++++++++++++++++++++++++++++- source3/libsmb/smbsock_connect.c | 7 +++++ source4/libcli/pysmb.c | 12 ++++++++ source4/selftest/tests.py | 15 +++++----- 11 files changed, 131 insertions(+), 22 deletions(-) Changeset truncated at 500 lines: diff --git a/WHATSNEW.txt b/WHATSNEW.txt index 267cc5402a9..493d9c2b35f 100644 --- a/WHATSNEW.txt +++ b/WHATSNEW.txt @@ -153,7 +153,13 @@ log entries has been removed to make the parsing of the JSON log messages easier. JSON log entries now start with 2 spaces followed by an opening brace i.e. " {" +SMBv2 samba-tool support +------------------------ +On previous releases, some samba-tool commands would not work against a remote +DC that had SMBv1 disabled. SMBv2 support has now been added for samba-tool. +The affected commands are 'samba-tool domain backup|rename' and the +'samba-tool gpo' set of commands. Refer also bug #13676. REMOVED FEATURES @@ -176,6 +182,14 @@ samba_backup The samba_backup script has been removed. This has now been replaced by the 'samba-tool domain backup offline' command. +SMB client Python bindings +-------------------------- + +The SMB client python bindings are now deprecated and will be removed in future +Samba releases. This will only affects users that may have used the Samba +Python bindings to write their own utilities, i.e. users with a custom Python +script that includes the line 'from samba import smb'. + smb.conf changes ================ diff --git a/ctdb/tools/ctdb.c b/ctdb/tools/ctdb.c index eb4c684e8b0..ee64566ba04 100644 --- a/ctdb/tools/ctdb.c +++ b/ctdb/tools/ctdb.c @@ -1237,6 +1237,11 @@ static void print_statistics_machine(struct ctdb_statistics *s, printf("%.6f%s", LATENCY_AVG(s->call_latency), options.sep); printf("%.6f%s", s->call_latency.max, options.sep); + printf("%u%s", s->locks.latency.num, options.sep); + printf("%.6f%s", s->locks.latency.min, options.sep); + printf("%.6f%s", LATENCY_AVG(s->locks.latency), options.sep); + printf("%.6f%s", s->locks.latency.max, options.sep); + printf("%d%s", s->childwrite_latency.num, options.sep); printf("%.6f%s", s->childwrite_latency.min, options.sep); printf("%.6f%s", LATENCY_AVG(s->childwrite_latency), options.sep); diff --git a/python/samba/gpclass.py b/python/samba/gpclass.py index fb7c705a47e..0040f235e6e 100644 --- a/python/samba/gpclass.py +++ b/python/samba/gpclass.py @@ -29,7 +29,8 @@ import xml.etree.ElementTree as etree import re from samba.net import Net from samba.dcerpc import nbt -from samba import smb +from samba.samba3 import libsmb_samba_internal as libsmb +from samba.samba3 import param as s3param import samba.gpo as gpo from samba.param import LoadParm from uuid import UUID @@ -386,7 +387,7 @@ def cache_gpo_dir(conn, cache, sub_dir): if e.errno != errno.EEXIST: raise for fdata in conn.list(sub_dir): - if fdata['attrib'] & smb.FILE_ATTRIBUTE_DIRECTORY: + if fdata['attrib'] & libsmb.FILE_ATTRIBUTE_DIRECTORY: cache_gpo_dir(conn, cache, os.path.join(sub_dir, fdata['name'])) else: local_name = fdata['name'].upper() @@ -407,7 +408,10 @@ def check_safe_path(path): def check_refresh_gpo_list(dc_hostname, lp, creds, gpos): - conn = smb.SMB(dc_hostname, 'sysvol', lp=lp, creds=creds, sign=True) + # the SMB bindings rely on having a s3 loadparm + s3_lp = s3param.get_context() + s3_lp.load(lp.configfile) + conn = libsmb.Conn(dc_hostname, 'sysvol', lp=s3_lp, creds=creds, sign=True) cache_path = lp.cache_path('gpo_cache') for gpo in gpos: if not gpo.file_sys_path: diff --git a/python/samba/netcmd/domain_backup.py b/python/samba/netcmd/domain_backup.py index 4cacf571f3d..4e32b4b9b1c 100644 --- a/python/samba/netcmd/domain_backup.py +++ b/python/samba/netcmd/domain_backup.py @@ -1009,8 +1009,9 @@ class cmd_domain_backup_offline(samba.netcmd.Command): paths = samba.provision.provision_paths_from_lp(lp, lp.get('realm')) if not (paths.samdb and os.path.exists(paths.samdb)): - raise CommandError('No sam.db found. This backup ' + - 'tool is only for AD DCs') + logger.error("No database found at {0}".format(paths.samdb)) + raise CommandError('Please check you are root, and ' + + 'are running this command on an AD DC') check_targetdir(logger, targetdir) diff --git a/python/samba/netcmd/gpo.py b/python/samba/netcmd/gpo.py index a064f44147a..1b5e927f633 100644 --- a/python/samba/netcmd/gpo.py +++ b/python/samba/netcmd/gpo.py @@ -43,7 +43,8 @@ import samba.auth from samba.auth import AUTH_SESSION_INFO_DEFAULT_GROUPS, AUTH_SESSION_INFO_AUTHENTICATED, AUTH_SESSION_INFO_SIMPLE_PRIVILEGES from samba.netcmd.common import netcmd_finddc from samba import policy -from samba import smb +from samba.samba3 import param as s3param +from samba.samba3 import libsmb_samba_internal as libsmb from samba import NTSTATUSError import uuid from samba.ntacls import dsacl2fsacl @@ -280,7 +281,7 @@ def backup_directory_remote_to_local(conn, remotedir, localdir): r_name = r_dir + '\\' + e['name'] l_name = os.path.join(l_dir, e['name']) - if e['attrib'] & smb.FILE_ATTRIBUTE_DIRECTORY: + if e['attrib'] & libsmb.FILE_ATTRIBUTE_DIRECTORY: r_dirs.append(r_name) l_dirs.append(l_name) os.mkdir(l_name) @@ -294,10 +295,10 @@ def backup_directory_remote_to_local(conn, remotedir, localdir): parser.write_xml(l_name + '.xml') -attr_flags = smb.FILE_ATTRIBUTE_SYSTEM | \ - smb.FILE_ATTRIBUTE_DIRECTORY | \ - smb.FILE_ATTRIBUTE_ARCHIVE | \ - smb.FILE_ATTRIBUTE_HIDDEN +attr_flags = libsmb.FILE_ATTRIBUTE_SYSTEM | \ + libsmb.FILE_ATTRIBUTE_DIRECTORY | \ + libsmb.FILE_ATTRIBUTE_ARCHIVE | \ + libsmb.FILE_ATTRIBUTE_HIDDEN def copy_directory_remote_to_local(conn, remotedir, localdir): @@ -315,7 +316,7 @@ def copy_directory_remote_to_local(conn, remotedir, localdir): r_name = r_dir + '\\' + e['name'] l_name = os.path.join(l_dir, e['name']) - if e['attrib'] & smb.FILE_ATTRIBUTE_DIRECTORY: + if e['attrib'] & libsmb.FILE_ATTRIBUTE_DIRECTORY: r_dirs.append(r_name) l_dirs.append(l_name) os.mkdir(l_name) @@ -364,7 +365,10 @@ def create_directory_hier(conn, remotedir): def smb_connection(dc_hostname, service, lp, creds, sign=False): # SMB connect to DC try: - conn = smb.SMB(dc_hostname, service, lp=lp, creds=creds, sign=sign) + # the SMB bindings rely on having a s3 loadparm + s3_lp = s3param.get_context() + s3_lp.load(lp.configfile) + conn = libsmb.Conn(dc_hostname, service, lp=s3_lp, creds=creds, sign=sign) except Exception: raise CommandError("Error connecting to '%s' using SMB" % dc_hostname) return conn diff --git a/python/samba/ntacls.py b/python/samba/ntacls.py index 99245737529..5bf646caf9f 100644 --- a/python/samba/ntacls.py +++ b/python/samba/ntacls.py @@ -454,7 +454,8 @@ class NtaclsHelper: def setntacl(self, path, ntacl_sd): # ntacl_sd can be obj or str - return setntacl(self.lp, path, ntacl_sd, self.dom_sid) + return setntacl(self.lp, path, ntacl_sd, self.dom_sid, + use_ntvfs=self.use_ntvfs) def _create_ntacl_file(dst, ntacl_sddl_str): diff --git a/selftest/target/Samba4.pm b/selftest/target/Samba4.pm index 5346cb172df..f2635e574cd 100755 --- a/selftest/target/Samba4.pm +++ b/selftest/target/Samba4.pm @@ -3007,12 +3007,14 @@ sub prepare_dc_testenv # add support for sysvol/netlogon/tmp shares $ctx->{share} = "$ctx->{prefix_abs}/share"; push(@{$ctx->{directories}}, "$ctx->{share}"); + push(@{$ctx->{directories}}, "$ctx->{share}/test1"); $ctx->{smb_conf_extra_options} = " $conf_options max xmit = 32K server max protocol = SMB2 samba kcc command = /bin/true + xattr_tdb:file = $ctx->{statedir}/xattr.tdb [sysvol] path = $ctx->{statedir}/sysvol @@ -3029,6 +3031,12 @@ sub prepare_dc_testenv posix:oplocktimeout = 3 posix:writetimeupdatedelay = 50000 +[test1] + path = $ctx->{share}/test1 + read only = no + posix:sharedelay = 100000 + posix:oplocktimeout = 3 + posix:writetimeupdatedelay = 500000 "; my $env = $self->provision_raw_step1($ctx); diff --git a/source3/libsmb/pylibsmb.c b/source3/libsmb/pylibsmb.c index e0ce518d91b..b4903a9b8c5 100644 --- a/source3/libsmb/pylibsmb.c +++ b/source3/libsmb/pylibsmb.c @@ -928,7 +928,8 @@ static PyObject *py_smb_loadfile(struct py_cli_state *self, PyObject *args, /* get a read file handle */ req = cli_ntcreate_send(NULL, self->ev, self->cli, filename, 0, - FILE_READ_DATA, FILE_ATTRIBUTE_NORMAL, + FILE_READ_DATA | FILE_READ_ATTRIBUTES, + FILE_ATTRIBUTE_NORMAL, FILE_SHARE_READ, FILE_OPEN, 0, SMB2_IMPERSONATION_IMPERSONATION, 0); if (!py_tevent_req_wait_exc(self, req)) { @@ -1525,6 +1526,54 @@ static PyObject *py_smb_getacl(struct py_cli_state *self, PyObject *args) sd, sd); } +/* + * Set ACL on file/directory using given security descriptor object + */ +static PyObject *py_smb_setacl(struct py_cli_state *self, PyObject *args) +{ + NTSTATUS status; + char *filename = NULL; + PyObject *py_sd = NULL; + struct security_descriptor *sd = NULL; + unsigned int sinfo = SECINFO_DEFAULT_FLAGS; + uint16_t fnum; + + /* there's no async version of cli_set_security_descriptor() */ + if (self->thread_state != NULL) { + PyErr_SetString(PyExc_RuntimeError, + "set_acl() is not supported on " + "a multi_threaded connection"); + return NULL; + } + + if (!PyArg_ParseTuple(args, "sO|I:set_acl", &filename, &py_sd, + &sinfo)) { + return NULL; + } + + sd = pytalloc_get_type(py_sd, struct security_descriptor); + if (!sd) { + PyErr_Format(PyExc_TypeError, + "Expected dcerpc.security.descriptor as argument, got %s", + talloc_get_name(pytalloc_get_ptr(py_sd))); + return NULL; + } + + status = cli_ntcreate(self->cli, filename, 0, + SEC_FLAG_MAXIMUM_ALLOWED, 0, + FILE_SHARE_READ|FILE_SHARE_WRITE, + FILE_OPEN, 0x0, 0x0, &fnum, NULL); + PyErr_NTSTATUS_IS_ERR_RAISE(status); + + status = cli_set_security_descriptor(self->cli, fnum, sinfo, sd); + PyErr_NTSTATUS_IS_ERR_RAISE(status); + + status = cli_close(self->cli, fnum); + PyErr_NTSTATUS_IS_ERR_RAISE(status); + + Py_RETURN_NONE; +} + static PyMethodDef py_cli_state_methods[] = { { "settimeout", (PyCFunction)py_cli_settimeout, METH_VARARGS, "settimeout(new_timeout_msecs) => return old_timeout_msecs" }, @@ -1577,6 +1626,9 @@ static PyMethodDef py_cli_state_methods[] = { { "get_acl", (PyCFunction)py_smb_getacl, METH_VARARGS, "get_acl(path[, security_info=0]) -> security_descriptor object\n\n" "\t\tGet security descriptor for file." }, + { "set_acl", (PyCFunction)py_smb_setacl, METH_VARARGS, + "set_acl(path, security_descriptor[, security_info=0]) -> None\n\n" + "\t\tSet security descriptor for file." }, { NULL, NULL, 0, NULL } }; diff --git a/source3/libsmb/smbsock_connect.c b/source3/libsmb/smbsock_connect.c index bb3cb07646c..be52b9a4f79 100644 --- a/source3/libsmb/smbsock_connect.c +++ b/source3/libsmb/smbsock_connect.c @@ -415,6 +415,13 @@ struct tevent_req *smbsock_connect_send(TALLOC_CTX *mem_ctx, tevent_req_set_callback(state->req_445, smbsock_connect_connected, req); + /* + * Check for disable_netbios + */ + if (lp_disable_netbios()) { + return req; + } + /* * After 5 msecs, fire the 139 (NBT) request */ diff --git a/source4/libcli/pysmb.c b/source4/libcli/pysmb.c index 45ff9a0a7c0..5a028169661 100644 --- a/source4/libcli/pysmb.c +++ b/source4/libcli/pysmb.c @@ -614,6 +614,18 @@ static PyObject *py_smb_new(PyTypeObject *type, PyObject *args, PyObject *kwargs uint8_t use_spnego = 0xFF; PyObject *sign = Py_False; + /* + * These Python bindings are now deprecated because the s4 SMB client + * code doesn't support SMBv2 (and is unlikely to ever support it). + * The s3 libsmb_samba_internal bindings are a better choice for use + * within the Samba codebase, and support much the same API. + * This warning is mostly for external consumers that might be using + * these Python bindings (in which case, note libsmb_samba_internal + * is not a stable API and may change in future). + */ + DBG_ERR("The smb.SMB() Python bindings are now deprecated " + "and will be removed in the next samba release\n"); + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "zz|OObbO", discard_const_p(char *, kwnames), &hostname, &service, &py_creds, &py_lp, diff --git a/source4/selftest/tests.py b/source4/selftest/tests.py index a1f38424af7..b8132086ef8 100755 --- a/source4/selftest/tests.py +++ b/source4/selftest/tests.py @@ -656,11 +656,14 @@ for env in ["ad_dc_ntvfs", "fl2000dc", "fl2003dc", "fl2008r2dc"]: for env in ["ad_dc:local", "ad_dc_ntvfs:local", "fl2000dc:local", "fl2003dc:local", "fl2008r2dc:local"]: plantestsuite("samba.tests.samba_tool.edit", env, [os.path.join(srcdir(), "python/samba/tests/samba_tool/edit.sh"), '$SERVER', '$USERNAME', '$PASSWORD']) -# We run this test against both AD DC implemetnations because it is +# We run this test against both AD DC implementations because it is # the only test we have of GPO get/set behaviour, and this involves # the file server as well as the LDAP server. -planpythontestsuite("ad_dc_ntvfs:local", "samba.tests.samba_tool.gpo", py3_compatible=True) -planpythontestsuite("ad_dc:local", "samba.tests.samba_tool.gpo", py3_compatible=True) +# It's also a good sanity-check that sysvol backup worked correctly. +for env in ["ad_dc_ntvfs", "ad_dc", "offlinebackupdc", "renamedc", + smbv1_disabled_testenv]: + planpythontestsuite(env + ":local", "samba.tests.samba_tool.gpo", + py3_compatible=True) planpythontestsuite("ad_dc_ntvfs:local", "samba.tests.samba_tool.processes", py3_compatible=True) planpythontestsuite("ad_dc_ntvfs:local", "samba.tests.samba_tool.user", py3_compatible=True) @@ -692,15 +695,13 @@ planoldpythontestsuite("ad_dc:local", "samba.tests.dckeytab", extra_args=['-U"$U for env in ["ad_dc", smbv1_disabled_testenv]: planoldpythontestsuite(env, "samba.tests.smb", extra_args=['-U"$USERNAME%$PASSWORD"'], py3_compatible=True) + planoldpythontestsuite(env + ":local", "samba.tests.ntacls_backup", + extra_args=['-U"$USERNAME%$PASSWORD"'], py3_compatible=True) planoldpythontestsuite( "ad_dc_ntvfs:local", "samba.tests.dcerpc.registry", extra_args=['-U"$USERNAME%$PASSWORD"'], py3_compatible=True) -planoldpythontestsuite( - "ad_dc:local", "samba.tests.ntacls_backup", - extra_args=['-U"$USERNAME%$PASSWORD"'], py3_compatible=True) - planoldpythontestsuite("ad_dc_ntvfs", "samba.tests.dcerpc.dnsserver", extra_args=['-U"$USERNAME%$PASSWORD"'], py3_compatible=True) planoldpythontestsuite("ad_dc", "samba.tests.dcerpc.dnsserver", extra_args=['-U"$USERNAME%$PASSWORD"'], py3_compatible=True) planoldpythontestsuite("chgdcpass", "samba.tests.dcerpc.raw_protocol", py3_compatible=True, -- Samba Shared Repository