]> git.ipfire.org Git - thirdparty/samba.git/log
thirdparty/samba.git
4 years agos3: VFS: ceph_snapshots: Remove ceph_snap_gmt_removexattr(). No longer called.
Jeremy Allison [Mon, 22 Mar 2021 18:20:07 +0000 (11:20 -0700)] 
s3: VFS: ceph_snapshots: Remove ceph_snap_gmt_removexattr(). No longer called.

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
4 years agos3: VFS: ceph: Remove cephwrap_removexattr(). No longer called.
Jeremy Allison [Mon, 22 Mar 2021 18:14:16 +0000 (11:14 -0700)] 
s3: VFS: ceph: Remove cephwrap_removexattr(). No longer called.

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
4 years agos3: VFS: catia: Remove catia_removexattr(). No longer called.
Jeremy Allison [Mon, 22 Mar 2021 18:13:14 +0000 (11:13 -0700)] 
s3: VFS: catia: Remove catia_removexattr(). No longer called.

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
4 years agos3: VFS: cap: Remove cap_removexattr(). No longer called.
Jeremy Allison [Fri, 19 Mar 2021 21:22:24 +0000 (14:22 -0700)] 
s3: VFS: cap: Remove cap_removexattr(). No longer called.

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
4 years agos3: VFS: xattr_tdb: Remove xattr_tdb_removexattr(). No longer called.
Jeremy Allison [Fri, 19 Mar 2021 21:04:22 +0000 (14:04 -0700)] 
s3: VFS: xattr_tdb: Remove xattr_tdb_removexattr(). No longer called.

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
4 years agos3: VFS: vxfs: Remove vxfs_remove_xattr() - no longer called.
Jeremy Allison [Fri, 19 Mar 2021 21:02:17 +0000 (14:02 -0700)] 
s3: VFS: vxfs: Remove vxfs_remove_xattr() - no longer called.

Also remove supporting function from lib_vxfs.c.

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
4 years agos3: torture: Change cmd_removexattr to use SMB_VFS_FREMOVEXATTR().
Jeremy Allison [Fri, 19 Mar 2021 20:12:12 +0000 (13:12 -0700)] 
s3: torture: Change cmd_removexattr to use SMB_VFS_FREMOVEXATTR().

The last user of SMB_VFS_REMOVEXATTR() is gone, I can now
remove the internal VFS functions implementing it.

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
4 years agos3: smbd: Change SMB_VFS_REMOVEXATTR -> SMB_VFS_FREMOVEXATTR.
Jeremy Allison [Thu, 11 Mar 2021 21:42:31 +0000 (13:42 -0800)] 
s3: smbd: Change SMB_VFS_REMOVEXATTR -> SMB_VFS_FREMOVEXATTR.

We no longer need pathname based xattr remove.

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
4 years agoVFS: posixacl_xattr: In posixacl_xattr_acl_delete_def_file() change SMB_VFS_REMOVEXAT...
Jeremy Allison [Fri, 12 Mar 2021 22:47:37 +0000 (14:47 -0800)] 
VFS: posixacl_xattr: In posixacl_xattr_acl_delete_def_file() change SMB_VFS_REMOVEXATTR() -> SMB_VFS_FREMOVEXATTR().

We know this is safe as SMB_VFS_SYS_ACL_DELETE_DEF_FILE() is only
ever called on an fsp->fsp_name.

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
4 years agoVFS: streams_xattr: In streams_xattr_renameat(), change SMB_VFS_REMOVEXATTR() ->...
Jeremy Allison [Fri, 12 Mar 2021 22:36:49 +0000 (14:36 -0800)] 
VFS: streams_xattr: In streams_xattr_renameat(), change SMB_VFS_REMOVEXATTR() -> SMB_VFS_FREMOVEXATTR().

Note that now we're doing this by handle
not by pathname we must do it on the base_fsp,
as we have to remove the actual xattr on the base file.

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
4 years agolib: adouble: Use FREMOVEXATTR in preference to REMOVEXATTR.
Jeremy Allison [Fri, 12 Mar 2021 22:33:14 +0000 (14:33 -0800)] 
lib: adouble: Use FREMOVEXATTR in preference to REMOVEXATTR.

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
4 years agoVFS: fake_acls: Clean up fake_acls_sys_acl_delete_def_file().
Jeremy Allison [Fri, 12 Mar 2021 00:36:09 +0000 (16:36 -0800)] 
VFS: fake_acls: Clean up fake_acls_sys_acl_delete_def_file().

Change SMB_VFS_NEXT_REMOVEXATTR() -> SMB_VFS_NEXT_FREMOVEXATTR().

It doesn't need to do STAT calls, it's always called
with an fsp->fsp_name smb_filename. This will change
later to a handle-based call.

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
4 years agoVFS: gluster: Allow vfs_gluster_fremovexattr() to cope with pathref fsps.
Jeremy Allison [Fri, 12 Mar 2021 22:19:28 +0000 (14:19 -0800)] 
VFS: gluster: Allow vfs_gluster_fremovexattr() to cope with pathref fsps.

Ensure it only uses an io fd for a handle based call.

Otherwise fall back to pathname based. This is the same as the
fallback used in vfs_default.c

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
4 years agoVFS: ceph: Allow cephwrap_fremovexattr() to cope with pathref fsps.
Jeremy Allison [Fri, 12 Mar 2021 22:16:05 +0000 (14:16 -0800)] 
VFS: ceph: Allow cephwrap_fremovexattr() to cope with pathref fsps.

Ensure it only uses an io fd for a handle based call.

Otherwise fall back to pathname based. This is the same as the
fallback used in vfs_default.c

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
4 years agoVFS: nfs4acl_xattr: Change nfs4acl_validate_blob() to use the fsp instead of the...
Jeremy Allison [Thu, 1 Apr 2021 20:33:35 +0000 (13:33 -0700)] 
VFS: nfs4acl_xattr: Change nfs4acl_validate_blob() to use the fsp instead of the name.

Changes use of SMB_VFS_REMOVEXATTR() -> SMB_VFS_FREMOVEXATTR().

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
4 years agoVFS: nfs4acl_xattr: Ensure remove smb_fname argument from nfs4acl_get_blob().
Jeremy Allison [Thu, 1 Apr 2021 20:22:15 +0000 (13:22 -0700)] 
VFS: nfs4acl_xattr: Ensure remove smb_fname argument from nfs4acl_get_blob().

Now we know we always have a valid fsp, use it.

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
4 years agoVFS: nfs4acl_xattr: Ensure nfs4acl_get_blob() always gets a valid fsp pointer.
Jeremy Allison [Thu, 1 Apr 2021 20:16:34 +0000 (13:16 -0700)] 
VFS: nfs4acl_xattr: Ensure nfs4acl_get_blob() always gets a valid fsp pointer.

This means adding a synthetic_pathref() call into the
nfs4acl_xattr version of SMB_VFS_GET_NT_ACL_AT() which
is the pathname-based ACL fetch call.

One place where this (smb_fname->fsp == NULL)
can happen is from open when checking parent
directory ACL - check_parent_access() currently
isn't always passed a smb_fname with a valid
fsp and check_parent_access() currently doesn't
open a pathref smb_fname->fsp itself (eventually
it should be passed in a pathref from the caller).

There are also a few other places inside smbd
that call smbd_check_access_rights() also without
a pathref fsp.

This check should be moved into the
callers inside smbd to ensure that smb_fname->fsp
is always valid here, and in a later patchset (not
part of this set) I will do just that.

Ultimately it may be possible to remove
pathname based SMB_VFS_GET_NT_ACL_AT(), this
requires further investigation.

But until then, we need this change.

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
4 years agos3: smbd: Fix parent_pathref() to cope with symlink parents.
Jeremy Allison [Tue, 6 Apr 2021 18:53:40 +0000 (11:53 -0700)] 
s3: smbd: Fix parent_pathref() to cope with symlink parents.

We know that the parent name must
exist, and the name has been canonicalized
even if this was a POSIX pathname.
Ensure that we follow symlinks for
the parent. See the torture test
POSIX-SYMLINK-PARENT for details.

Remove knownfail entry.

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
Autobuild-User(master): Ralph Böhme <slow@samba.org>
Autobuild-Date(master): Wed Apr  7 15:39:45 UTC 2021 on sn-devel-184

4 years agos3: torture: Add an SMB1 POSIX specific test POSIX-SYMLINK-PARENT.
Jeremy Allison [Tue, 6 Apr 2021 18:46:23 +0000 (11:46 -0700)] 
s3: torture: Add an SMB1 POSIX specific test POSIX-SYMLINK-PARENT.

This creates a directory, then a symlink to a directory,
and then checks we can POSIX create and delete file, directory,
symlink and hardlink filesystem objects under the symlink
parent directory.

Mark as knownfail until next commit.

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
4 years agoauth/credentials: Remove unneeded try/except syntax
Joseph Sutton [Tue, 30 Mar 2021 03:08:40 +0000 (16:08 +1300)] 
auth/credentials: Remove unneeded try/except syntax

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Autobuild-User(master): Andrew Bartlett <abartlet@samba.org>
Autobuild-Date(master): Wed Apr  7 10:24:17 UTC 2021 on sn-devel-184

4 years agocracknames: Allow auto-conversion from an extended canonical name
Joseph Sutton [Tue, 30 Mar 2021 03:02:27 +0000 (16:02 +1300)] 
cracknames: Allow auto-conversion from an extended canonical name

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
4 years agoauth/credentials: Add test for binding with an extended canonical name
Joseph Sutton [Tue, 30 Mar 2021 03:01:44 +0000 (16:01 +1300)] 
auth/credentials: Add test for binding with an extended canonical name

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
4 years agoauth/credentials: Add test for binding with a canonical name
Joseph Sutton [Tue, 30 Mar 2021 03:00:56 +0000 (16:00 +1300)] 
auth/credentials: Add test for binding with a canonical name

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
4 years agocracknames: Add support for SID string format
Joseph Sutton [Tue, 30 Mar 2021 03:00:04 +0000 (16:00 +1300)] 
cracknames: Add support for SID string format

BUG: https://bugzilla.samba.org/show_bug.cgi?id=10319

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
4 years agoauth/credentials: Add test for binding with a domain SID
Joseph Sutton [Tue, 30 Mar 2021 00:28:32 +0000 (13:28 +1300)] 
auth/credentials: Add test for binding with a domain SID

BUG: https://bugzilla.samba.org/show_bug.cgi?id=10319

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
4 years agodcesrv_core: fix build
Bernd Kuhls [Sat, 27 Mar 2021 16:17:34 +0000 (17:17 +0100)] 
dcesrv_core: fix build

Move include of system/network.h to avoid a build error:

In file included from ../../lib/replace/system/network.h:35,
                 from ../../librpc/rpc/dcesrv_core.c:2658:
usr/include/unistd.h: At top level:
usr/include/unistd.h:675:16: error: conflicting types for ‘geteuid’
  675 | extern __uid_t geteuid (void) __THROW;

Signed-off-by: Bernd Kuhls <bernd.kuhls@t-online.de>
Reviewed-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
4 years agos3: rpc_server: Store new association groups in the id tree
Samuel Cabrero [Fri, 26 Jun 2020 15:20:32 +0000 (17:20 +0200)] 
s3: rpc_server: Store new association groups in the id tree

Right now a new association group is created for each connection
assigning the legacy 0x53F0 id, but it is not stored anywhere. When a
second client request to join an association group by its id it is not
found and a new one is created with the same ID.

In practise, it means the association groups are not working even in the
same server process.

This commit stores the created association group in the idtree, but to
make use of it assigns a random id instead of the historical 0x53F0.

The test assoc_group_ok2 was wrongly passing before this change because
the same id 0x53F0 was assigned to all association groups.

Signed-off-by: Samuel Cabrero <scabrero@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
4 years agos3: rpc_server: Search for already created association groups
Samuel Cabrero [Thu, 18 Jun 2020 16:40:16 +0000 (18:40 +0200)] 
s3: rpc_server: Search for already created association groups

If the client requests to join to an association group in the bind operation
try to find it and do not create a new one.

Signed-off-by: Samuel Cabrero <scabrero@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
4 years agoselftest: Test RPC handles and association groups from different connection
Samuel Cabrero [Fri, 19 Jun 2020 14:31:39 +0000 (16:31 +0200)] 
selftest: Test RPC handles and association groups from different connection

Add a test to check if a RPC handle can be used from a different connection
than the one where it was created, when the same association group is
requested in the bind operation of the second connection.

The association group handling is one of the differences between the S3
and S4 RPC server implementations provided by the implementation
callbacks after the merge.

Association groups work fine in the S4 implementation as the RPC server
runs in one process, except for the 'smbd' embedded services provided
by the S3 implementation like winreg (see lp_enforce_ad_dc_settings()).

In the S3 implementation, association groups should work in the same
process, but the merge introduced a bug where a new association group is
always created even when it already exists in the same process.

Signed-off-by: Samuel Cabrero <scabrero@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
4 years agos4:dsdb/password_hash: Add a more useful error message for passwords too long to...
Joseph Sutton [Fri, 12 Mar 2021 01:41:13 +0000 (14:41 +1300)] 
s4:dsdb/password_hash: Add a more useful error message for passwords too long to be hashed

BUG: https://bugzilla.samba.org/show_bug.cgi?id=14621

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
4 years agoprovision tests: Add a test for hashing overly long passwords
Joseph Sutton [Tue, 23 Feb 2021 13:52:06 +0000 (02:52 +1300)] 
provision tests: Add a test for hashing overly long passwords

BUG: https://bugzilla.samba.org/show_bug.cgi?id=14621

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
4 years agos4:dsdb/password_hash: Add additional check for crypt() and crypt_r() failure
Joseph Sutton [Tue, 23 Feb 2021 13:46:38 +0000 (02:46 +1300)] 
s4:dsdb/password_hash: Add additional check for crypt() and crypt_r() failure

While crypt_rn() always returns a null pointer in the event of
failure, crypt() and crypt_r() may instead return a string starting
with the character '*'. This commit adds a check to detect failure in
this case.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=14621

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
4 years agoprovision: Decrease the length of random machine passwords
Joseph Sutton [Tue, 23 Feb 2021 13:03:25 +0000 (02:03 +1300)] 
provision: Decrease the length of random machine passwords

The current length of 128-255 UTF-16 characters currently causes
generation of crypt() passwords to typically fail. This commit
decreases the length to 120 UTF-16 characters, which is the same as
that used by Windows.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=14621

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
4 years agos4:dsdb/password_hash: Don't generate crypt() password for krbtgt account
Joseph Sutton [Tue, 23 Feb 2021 12:13:41 +0000 (01:13 +1300)] 
s4:dsdb/password_hash: Don't generate crypt() password for krbtgt account

Since the length of the krbtgt password after conversion to UTF-8 form is
typically greater than the maximum accepted by crypt(), the call usually
fails. This commit disables generation of crypt() passwords for this specific
account, as it's not necessary.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=14621

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
4 years agoprovision tests: Add test for the CryptSHA256 and CryptSHA512 password hashing schemes
Joseph Sutton [Tue, 23 Feb 2021 10:50:30 +0000 (23:50 +1300)] 
provision tests: Add test for the CryptSHA256 and CryptSHA512 password hashing schemes

BUG: https://bugzilla.samba.org/show_bug.cgi?id=14621

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
4 years agoldb/attrib_handler casefold: simplify space dropping
Douglas Bagnall [Tue, 8 Dec 2020 09:00:55 +0000 (22:00 +1300)] 
ldb/attrib_handler casefold: simplify space dropping

As seen in CVE-2021-20277, ldb_handler_fold() has been making mistakes
when collapsing spaces down to a single space.

This patch fixes the way it handles internal spaces (CVE-2021-20277
was about leading spaces), and involves a rewrite of the parsing loop.

The bug has a detailed description of the problem.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=14656

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  7 03:16:39 UTC 2021 on sn-devel-184

4 years agoldb: fix ldb_comparison_fold off-by-one overrun
Douglas Bagnall [Sat, 6 Mar 2021 03:05:15 +0000 (16:05 +1300)] 
ldb: fix ldb_comparison_fold off-by-one overrun

We run one character over in comparing all the bytes in two ldb_vals.

In almost all circumstances both ldb_vals would have an allocated '\0'
in the overrun position, but it is best not to rely on that.

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
4 years agobuild: Only add -Wl,--as-needed when supported
Martin Schwenke [Mon, 29 Mar 2021 05:30:37 +0000 (16:30 +1100)] 
build: Only add -Wl,--as-needed when supported

If -Wl,--as-needed is added to EXTRA_LDFLAGS (via ADD_LDFLAGS, as per
commit 996560191ac6bd603901dcd6c0de5d239e019ef4) then on some
platforms (at least CentOS 8 and Fedora 33), any indirect/recursive
dependencies (i.e. private libraries) are added to both the
binary (reqid_test in the CTDB case) and to samba-util.so.  However,
only samba-util.so has rpath set to find private libraries.

When ld.so tries to resolve these dependencies for the binary it
fails. This may be a bug on those platforms, but it occurs reliably
and our users will also hit the bug.  For binaries that have other
private library dependencies (e.g. bundled talloc) rpath will contain
the private library directory so the duplicate private library
dependencies are then found... that is, when it works, it works by
accident!

For some reason (deep in waf or wafsamba) if -Wl,--as-needed is added to
LINKFLAGS (as is done in conf.add_as_needed()) then it works: the direct
dependencies are only added to samba-util.so and the same depenencies
(indirect dependencies for binaries) are not added incorrectly to the
binaries.

So, without changing 1/2 of waf/wafsamba the simplest fix is to revert
to adding -Wl,--as-needed to LINKFLAGS, which was the case before
commit 996560191ac6bd603901dcd6c0de5d239e019ef4.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=14288

Signed-off-by: Amitay Isaacs <amitay@gmail.com>
Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Bjoern Jacke <bj@sernet.de>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
4 years agolibrpc: Remove the gensec dependency from library dcerpc-binding
Volker Lendecke [Fri, 2 Apr 2021 11:41:21 +0000 (13:41 +0200)] 
librpc: Remove the gensec dependency from library dcerpc-binding

This means yet another library, but having to depend on gensec just
for dcerpc_parse_binding() and basic packet parsing seems like a bit
overkill to me.

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): Tue Apr  6 23:33:14 UTC 2021 on sn-devel-184

4 years agorpc: Give dcerpc_util.c its own header
Volker Lendecke [Fri, 2 Apr 2021 10:20:38 +0000 (12:20 +0200)] 
rpc: Give dcerpc_util.c its own header

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
4 years agogensec: Remove gensec_security_all(), it was only used internally
Volker Lendecke [Sat, 3 Apr 2021 10:04:04 +0000 (12:04 +0200)] 
gensec: Remove gensec_security_all(), it was only used internally

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
4 years agowinbindd: Remove unused code
Volker Lendecke [Tue, 23 Feb 2021 15:16:39 +0000 (16:16 +0100)] 
winbindd: Remove unused code

Those calls were only used in winbindd_samr which now does direct and
simpler samr calls.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
4 years agowinbindd: Use samr in sam_rids_to_names() instead of lsa
Volker Lendecke [Tue, 23 Feb 2021 15:03:17 +0000 (16:03 +0100)] 
winbindd: Use samr in sam_rids_to_names() instead of lsa

Same argument as with previous patches: We don't need fancy lsa
routing and samr is less prone to deadlock back into winbind

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
4 years agowinbindd: Make sam_sid_to_name use samr instead of lsa
Volker Lendecke [Tue, 23 Feb 2021 10:49:16 +0000 (11:49 +0100)] 
winbindd: Make sam_sid_to_name use samr instead of lsa

Same argument as with name_to_sid: We don't need the lsa lookup
routing, and samr is less prone to deadlocking.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
4 years agowinbindd: Use samr instead of lsa in sam_name_to_sid()
Volker Lendecke [Tue, 23 Feb 2021 09:38:16 +0000 (10:38 +0100)] 
winbindd: Use samr instead of lsa in sam_name_to_sid()

After the "Unix Users/Groups" and wkn names have been taken care of,
all that remains here is our domain (BUILTIN or workgroup). We don't
need any of the fancy routing in lsa_lookupnames, and samr_LookupNames
is a lot less prone to deadlocks back into winbind.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
4 years agowinbindd: Avoid deadlock in sam_name_to_sid()
Volker Lendecke [Tue, 23 Feb 2021 07:27:07 +0000 (08:27 +0100)] 
winbindd: Avoid deadlock in sam_name_to_sid()

"Unix Users" and "Unix Groups" can recurse into nsswitch and thus into
winbind. In the binding process, we have winbindd_off(), but if we
pass the lookupNames request to a forked lsad, lsad does not
necessarily have that setting. So lsad might turn back to winbind,
which could lead to a deadlock. Handle the nsswitch lookups in
winbind.

While there, also do the simple wellknown names and the "DOMAIN\" type
3 lookups directly in winbind.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
4 years agorpc_server: tstream_npa_connect_recv() returns errno into sys_errno
Volker Lendecke [Tue, 9 Feb 2021 17:36:56 +0000 (18:36 +0100)] 
rpc_server: tstream_npa_connect_recv() returns errno into sys_errno

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
4 years agooss-fuzz: Update build script to be compatible with rpm distros
Samuel Cabrero [Tue, 30 Mar 2021 14:17:31 +0000 (16:17 +0200)] 
oss-fuzz: Update build script to be compatible with rpm distros

The /etc/default/locale file does not exists in the rpm family distros
so the do_build.sh script failed with:

./lib/fuzzing/oss-fuzz/do_build.sh: line 31: /etc/default/locale: No
such file or directory

Signed-off-by: Samuel Cabrero <scabrero@samba.org>
Reviewed-by: David Mulder <dmulder@samba.org>
Autobuild-User(master): Samuel Cabrero <scabrero@samba.org>
Autobuild-Date(master): Tue Apr  6 15:54:54 UTC 2021 on sn-devel-184

4 years agosmbd: reduce loglevel for failed openat_pathref_fsp() calls
Ralph Boehme [Tue, 6 Apr 2021 12:47:39 +0000 (14:47 +0200)] 
smbd: reduce loglevel for failed openat_pathref_fsp() calls

BUG: https://bugzilla.samba.org/show_bug.cgi?id=14685
CI: https://gitlab.com/samba-team/samba/-/merge_requests/1884
RN: Log clutter from filename_convert_internal()

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
Autobuild-User(master): Ralph Böhme <slow@samba.org>
Autobuild-Date(master): Tue Apr  6 14:39:46 UTC 2021 on sn-devel-184

4 years agotstream: Add tstream_npa_existing_stream()
Volker Lendecke [Tue, 16 Feb 2021 16:22:40 +0000 (17:22 +0100)] 
tstream: Add tstream_npa_existing_stream()

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): Thu Apr  1 20:36:19 UTC 2021 on sn-devel-184

4 years agotstream_npa: Allow NULL output parameters
Volker Lendecke [Mon, 18 Jan 2021 20:28:30 +0000 (21:28 +0100)] 
tstream_npa: Allow NULL output parameters

When reading the info4, the substructs might not be interesting for
you.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
4 years agotstream_npa: Return named_pipe_auth_req_info4 from accept_existing
Volker Lendecke [Mon, 18 Jan 2021 16:30:42 +0000 (17:30 +0100)] 
tstream_npa: Return named_pipe_auth_req_info4 from accept_existing

Callers might want the full picture. We need to make
named_pipe_auth_req_info4 public for that.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
4 years agotstream_npa: Keep "named_pipe_auth_req" around in tstream_npa_accept_existing_send...
Volker Lendecke [Mon, 18 Jan 2021 15:54:07 +0000 (16:54 +0100)] 
tstream_npa: Keep "named_pipe_auth_req" around in tstream_npa_accept_existing_send()/recv()

This will make it simpler to return a copy of the struct
named_pipe_auth_req_info4 in the next commit.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
4 years agowbinfo: Allow SID for -R
Volker Lendecke [Tue, 23 Feb 2021 15:04:02 +0000 (16:04 +0100)] 
wbinfo: Allow SID for -R

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
4 years agodynconfig: Introduce and expose SAMBA_LIBEXECDIR
Volker Lendecke [Tue, 2 Feb 2021 15:50:48 +0000 (16:50 +0100)] 
dynconfig: Introduce and expose SAMBA_LIBEXECDIR

Right now the smbspool_krb5_wrapper lives there, but we'll have more
in the future.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
4 years agosrv_winreg: Align integer types
Volker Lendecke [Sat, 27 Mar 2021 15:42:29 +0000 (16:42 +0100)] 
srv_winreg: Align integer types

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
4 years agoprinting: Align integer types
Volker Lendecke [Sat, 27 Mar 2021 15:42:52 +0000 (16:42 +0100)] 
printing: Align integer types

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
4 years agosmbd: Factor out a bool expr into a descriptive variable
Volker Lendecke [Fri, 26 Mar 2021 17:50:00 +0000 (18:50 +0100)] 
smbd: Factor out a bool expr into a descriptive variable

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
4 years agotest: Add a test for background_job_send crash
Volker Lendecke [Wed, 31 Mar 2021 11:22:16 +0000 (11:22 +0000)] 
test: Add a test for background_job_send crash

I haven't figured out how to properly add a crashing test to
"knownfail", so this is added after the fix.

Signed-off-by: Volker Lendecke <vl@samba.org>
4 years agolib: Fix rundown of jobs sent with background_job_send()
Volker Lendecke [Tue, 30 Mar 2021 15:18:10 +0000 (17:18 +0200)] 
lib: Fix rundown of jobs sent with background_job_send()

When using this with a trigger message in smbd it will crash at
rundown in messaging_deregister because the global messaging context
can be TALLOC_FREE'ed before the background job is freed.

Using messaging_filtered_send already takes care of this situation
properly.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
4 years agolib: Add required includes to source3/lib/background.h
Volker Lendecke [Wed, 31 Mar 2021 11:21:52 +0000 (11:21 +0000)] 
lib: Add required includes to source3/lib/background.h

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
4 years agoasn1: Remove unused function asn1_check_enumerated()
Joseph Sutton [Thu, 18 Mar 2021 23:47:57 +0000 (12:47 +1300)] 
asn1: Remove unused function asn1_check_enumerated()

This function was reported as containing a bug, but it is unused and so
can be safely removed.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=4153

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Jeremy Allison <jra@samba.org>
Reviewed-by: David Mulder <dmulder@samba.org>
Autobuild-User(master): Jeremy Allison <jra@samba.org>
Autobuild-Date(master): Thu Apr  1 17:50:49 UTC 2021 on sn-devel-184

4 years agoselftest: Allow to set the 'log level' for clients
Andreas Schneider [Wed, 31 Mar 2021 13:24:20 +0000 (15:24 +0200)] 
selftest: Allow to set the 'log level' for clients

This allows to set the 'log level' for clients on the command line:

    make test TESTS=wurst CLIENT_LOG_LEVEL=10

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
Autobuild-User(master): Jeremy Allison <jra@samba.org>
Autobuild-Date(master): Wed Mar 31 21:20:23 UTC 2021 on sn-devel-184

4 years agorpc_server3: Fix a memleak for internal pipes
Volker Lendecke [Tue, 23 Mar 2021 16:06:15 +0000 (17:06 +0100)] 
rpc_server3: Fix a memleak for internal pipes

state->call should not be talloc'ed off a long-lived context

BUG: https://bugzilla.samba.org/show_bug.cgi?id=14675
CI: https://gitlab.com/samba-team/samba/-/merge_requests/1861

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Samuel Cabrero <scabrero@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
Autobuild-User(master): Ralph Böhme <slow@samba.org>
Autobuild-Date(master): Wed Mar 31 12:14:01 UTC 2021 on sn-devel-184

4 years agospools: avoid leaking memory into the callers mem_ctx
Ralph Boehme [Mon, 22 Mar 2021 11:06:39 +0000 (12:06 +0100)] 
spools: avoid leaking memory into the callers mem_ctx

BUG: https://bugzilla.samba.org/show_bug.cgi?id=14675
CI: https://gitlab.com/samba-team/samba/-/merge_requests/1861

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Volker Lendecke <vl@samba.org>
4 years agopidl: set the per-request memory context in the pidl generator
Ralph Boehme [Tue, 23 Mar 2021 10:40:21 +0000 (11:40 +0100)] 
pidl: set the per-request memory context in the pidl generator

The talloc memory context referenced by the pipe_struct mem_ctx member is used
as talloc parent for RPC response data by the RPC service implementations.

In Samba versions up to 4.10 all talloc children of p->mem_ctx were freed after
a RPC response was delivered by calling talloc_free_children(p->mem_ctx). Commit
60fa8e255254d38e9443bf96f2c0f31430be6ab8 removed this call which resulted in all
memory allocations on this context not getting released, which can consume
significant memory in long running RPC connections.

Instead of putting the talloc_free_children(p->mem_ctx) back, just use the
mem_ctx argument of the ${pipename}_op_dispatch_internal() function which is a
dcesrv_call_state object created by dcesrv_process_ncacn_packet() and released
by the RPC server when the RPC request processing is finished.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=14675
CI: https://gitlab.com/samba-team/samba/-/merge_requests/1861

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Volker Lendecke <vl@samba.org>
4 years agos3: smbd: fix deferred renames
Ralph Boehme [Mon, 29 Mar 2021 10:24:39 +0000 (12:24 +0200)] 
s3: smbd: fix deferred renames

This was broken by c7a9e0e4cdfb22e66533b5c8e20af3cfdb8ae78c.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=14679
CI: https://gitlab.com/samba-team/samba/-/merge_requests/1875

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@amba.org>
Autobuild-User(master): Ralph Böhme <slow@samba.org>
Autobuild-Date(master): Wed Mar 31 06:13:39 UTC 2021 on sn-devel-184

4 years agos4: torture. Add smb2.lease.rename_wait test to reproduce regression in delay rename...
Jeremy Allison [Tue, 30 Mar 2021 22:05:47 +0000 (15:05 -0700)] 
s4: torture. Add smb2.lease.rename_wait test to reproduce regression in delay rename for lease break code.

Passes against Windows 10. Add to knownfail, the
next commit will fix this.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=14679
CI: https://gitlab.com/samba-team/samba/-/merge_requests/1875

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
4 years agos3: smbd: Fix SMB_VFS_FGET_NT_ACL/SMB_VFS_FSET_NT_ACL on stream handles.
Jeremy Allison [Thu, 25 Mar 2021 22:46:45 +0000 (15:46 -0700)] 
s3: smbd: Fix SMB_VFS_FGET_NT_ACL/SMB_VFS_FSET_NT_ACL on stream handles.

As this is done on existing files, we know that
fsp->base_fsp != NULL and fsp->base_fsp->fh->fd != -1
(i.e. it's a pathref fd) for stream handles.

When getting and setting ACLs on stream handles,
use the fsp->base_fsp instead (as Windows does).

This not only fixes streams_xattr, but will
allow us to later analyze and remove all
special casing code for get/set ACLs on streams
handles.

Remove the knownfail.d/stream-acl file.

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
Autobuild-User(master): Jeremy Allison <jra@samba.org>
Autobuild-Date(master): Tue Mar 30 20:14:35 UTC 2021 on sn-devel-184

4 years agos3: torture: Add a test for setting and getting ACLs on stream handles (SMB2-STREAM...
Jeremy Allison [Thu, 25 Mar 2021 22:43:16 +0000 (15:43 -0700)] 
s3: torture: Add a test for setting and getting ACLs on stream handles (SMB2-STREAM-ACL).

It shows this isn't done correctly for streams_xattr.

A common config is:

vfs_objects = streams_xattr acl_xattr

to store both streams and Windows ACLs in xattrs.

Unfortunately getting and setting ACLs using handles
opened on stream files isn't being done correctly
in Samba.

This test passes against Windows 10.

This adds tests that prove this doesn't work. Next
patch will add the fix and remove the knownfail.

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
4 years agoldb-samba: remove redundant negative check
Douglas Bagnall [Sun, 21 Mar 2021 07:49:32 +0000 (20:49 +1300)] 
ldb-samba: remove redundant negative check

smb_strtoull() already checks for negative numbers, but does
it properly, catching " -2" as well as "-2".

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Jeremy Allison <jra@samba.org>
Autobuild-User(master): Jeremy Allison <jra@samba.org>
Autobuild-Date(master): Tue Mar 30 18:55:28 UTC 2021 on sn-devel-184

4 years agoldb-samba: avoid VLA in dsdb match dns tombstone
Douglas Bagnall [Wed, 10 Mar 2021 03:23:07 +0000 (16:23 +1300)] 
ldb-samba: avoid VLA in dsdb match dns tombstone

We don't need it (only 64 bytes) and, well, they annoy people.

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Jeremy Allison <jra@samba.org>
4 years agoldb-samba: avoid leak in dsdb_match_for_dns_to_tombstone_time
Douglas Bagnall [Wed, 10 Mar 2021 03:30:16 +0000 (16:30 +1300)] 
ldb-samba: avoid leak in dsdb_match_for_dns_to_tombstone_time

After the first time through the loop, tmp_ctx has been freed and
NULLed, so we end up allocating on NULL and never freeing.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=14659

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Jeremy Allison <jra@samba.org>
4 years agos3:utils: The 'net ads keytab' commands should use machine credentials
Andreas Schneider [Mon, 29 Mar 2021 11:16:28 +0000 (13:16 +0200)] 
s3:utils: The 'net ads keytab' commands should use machine credentials

If the user doesn't specify a username/password on the command line, we
should use the machine credentials to connect to AD. This is how it is
used by default and we should be able to retrieve SPNs.

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
Autobuild-User(master): Ralph Böhme <slow@samba.org>
Autobuild-Date(master): Tue Mar 30 06:48:18 UTC 2021 on sn-devel-184

4 years agos3:utils: Use secrets_store_creds() in net utility
Andreas Schneider [Wed, 24 Mar 2021 09:08:04 +0000 (10:08 +0100)] 
s3:utils: Use secrets_store_creds() in net utility

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
4 years agos3:passdb: Add secrets_store_creds()
Andreas Schneider [Wed, 24 Mar 2021 09:06:18 +0000 (10:06 +0100)] 
s3:passdb: Add secrets_store_creds()

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
4 years agos3:utils: Use libnetapi_set_creds() in net_dom
Andreas Schneider [Thu, 25 Mar 2021 10:39:22 +0000 (11:39 +0100)] 
s3:utils: Use libnetapi_set_creds() in net_dom

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
4 years agos3:utils: Use libnetapi_set_creds() in net_rpc_shell
Andreas Schneider [Wed, 24 Mar 2021 13:37:26 +0000 (14:37 +0100)] 
s3:utils: Use libnetapi_set_creds() in net_rpc_shell

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
4 years agos3:utils: Use libnetapi_set_creds() in net_rpc
Andreas Schneider [Thu, 25 Mar 2021 10:44:36 +0000 (11:44 +0100)] 
s3:utils: Use libnetapi_set_creds() in net_rpc

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
4 years agos3:utils: Fix net_context_creds() with machine password
Andreas Schneider [Thu, 25 Mar 2021 11:03:22 +0000 (12:03 +0100)] 
s3:utils: Fix net_context_creds() with machine password

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
4 years agos3:libnetapi: Remove unused header file
Andreas Schneider [Fri, 26 Mar 2021 08:56:11 +0000 (09:56 +0100)] 
s3:libnetapi: Remove unused header file

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
4 years agorpc/idl dnsserver s/DNS_RPC_DATA/DNS_RPC_RECORD_DATA/
Douglas Bagnall [Wed, 24 Mar 2021 00:36:18 +0000 (13:36 +1300)] 
rpc/idl dnsserver s/DNS_RPC_DATA/DNS_RPC_RECORD_DATA/

Following MS-DNSP.

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Jeremy Allison <jra@samba.org>
Autobuild-User(master): Jeremy Allison <jra@samba.org>
Autobuild-Date(master): Tue Mar 30 00:20:53 UTC 2021 on sn-devel-184

4 years agolibrpc/idl: dnsp tombstone timestamp name matches MS-DNSP
Douglas Bagnall [Tue, 23 Mar 2021 23:49:22 +0000 (12:49 +1300)] 
librpc/idl: dnsp tombstone timestamp name matches MS-DNSP

MS-DNSP uses the term "EntombedTime" in e.g. "2.2.2.2.4.23 DNS_RPC_RECORD_TS"
which is more descriptive than the generic "timestamp", and less likely to be
confused with dwTimestamp, which has been our curse. Let's make it grep-able,
google-able, and evocative.

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Jeremy Allison <jra@samba.org>
4 years agopytest/dnsserver: extend record_type_int to all types
Douglas Bagnall [Thu, 25 Mar 2021 04:47:04 +0000 (17:47 +1300)] 
pytest/dnsserver: extend record_type_int to all types

with improved diagnostics on bad arguments

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Jeremy Allison <jra@samba.org>
4 years agopytest/dns: use self.assertIn() and .assertNotIn()
Douglas Bagnall [Wed, 24 Mar 2021 02:16:21 +0000 (15:16 +1300)] 
pytest/dns: use self.assertIn() and .assertNotIn()

These give a more detailed message than assertTrue(x in y).

They were new in Python 3.1, so we avoided them until recently.

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Jeremy Allison <jra@samba.org>
4 years agopytest/dns: remove redundant argument
Douglas Bagnall [Wed, 24 Mar 2021 01:57:32 +0000 (14:57 +1300)] 
pytest/dns: remove redundant argument

We are always setting zone to the same thing which we already know,
and we can reduce cognative stress by mentioning it less and not doing
that weird pop thing.

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Jeremy Allison <jra@samba.org>
4 years agodsdb/dns scavange: make a helper function static
Douglas Bagnall [Sat, 27 Mar 2021 22:20:25 +0000 (11:20 +1300)] 
dsdb/dns scavange: make a helper function static

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Jeremy Allison <jra@samba.org>
4 years agodsdb/scavange dns: reserve NTTIME type for NTTIME values
Douglas Bagnall [Sat, 27 Mar 2021 22:20:48 +0000 (11:20 +1300)] 
dsdb/scavange dns: reserve NTTIME type for NTTIME values

We know it "really" just means uint64_t, but we also know it means
100-nanosecond intervals since 1601, and that makes any other use very
confusing (and not just to me, or there wouldn't be these bugs we're
chasing).

In these cases we are talking about 32 bit hours-since-1601 timestamps.

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Jeremy Allison <jra@samba.org>
4 years agodns: use unix_to_dns_timestamp almost everywhere
Douglas Bagnall [Thu, 11 Mar 2021 02:58:37 +0000 (15:58 +1300)] 
dns: use unix_to_dns_timestamp almost everywhere

In places we change NTTIME to uint32_t, because that is what is
actually wanted.

There is one instance of the calculation that we are not changing,
because there are other problems there.

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Jeremy Allison <jra@samba.org>
4 years agopydns: expose dns timestamp utils to python, and test
Douglas Bagnall [Sat, 27 Mar 2021 09:09:56 +0000 (09:09 +0000)] 
pydns: expose dns timestamp utils to python, and test

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Jeremy Allison <jra@samba.org>
4 years agodns: add common dns_timestamp util functions
Douglas Bagnall [Thu, 11 Mar 2021 02:17:28 +0000 (15:17 +1300)] 
dns: add common dns_timestamp util functions

The dns structs have an unsigned 32 bit timestamp in hours since the
beginning of 1601. In a number of places we need to convert from unix
time to this timestamp, or from the timestamp to NTTIME.

You'll see subsequent patches that make use of these functions.

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Jeremy Allison <jra@samba.org>
4 years agodns common: always check a talloc NULL.
Douglas Bagnall [Wed, 24 Mar 2021 04:38:15 +0000 (17:38 +1300)] 
dns common: always check a talloc NULL.

Also, since we're there, avoid sorting an array of 1 element.

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Jeremy Allison <jra@samba.org>
4 years agolibcli smb smb2: Use correct enumeration type
Gary Lockyer [Thu, 25 Mar 2021 01:36:50 +0000 (14:36 +1300)] 
libcli smb smb2: Use correct enumeration type

Clang gives the following error:
../../libcli/smb/smb2_signing.c:547:48: error:
   implicit conversion from enumeration type 'gnutls_mac_algorithm_t'
   to different enumeration type 'gnutls_digest_algorithm_t'
   [-Werror,-Wenum-conversion]
   const size_t digest_len = gnutls_hash_get_len(GNUTLS_MAC_SHA256);
~~~~~~~~~~~~~~~~~~~ ^~~~~~~~~~~~~~~~~

Should be using GNUTLS_DIG_SHA256, which is set to GNUTLS_MAC_SHA256.

Signed-off-by: Gary Lockyer <gary@catalyst.net.nz>
Reviewed-by: Andreas Schneider <asn@samba.org>
Autobuild-User(master): Gary Lockyer <gary@samba.org>
Autobuild-Date(master): Mon Mar 29 23:19:24 UTC 2021 on sn-devel-184

4 years agosmb2_tcon: also try to cancel pending compound requests on tdis
Stefan Metzmacher [Tue, 23 Mar 2021 10:10:22 +0000 (11:10 +0100)] 
smb2_tcon: also try to cancel pending compound requests on tdis

There's no reason to do something special here.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=14449

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
Autobuild-User(master): Jeremy Allison <jra@samba.org>
Autobuild-Date(master): Mon Mar 29 20:43:28 UTC 2021 on sn-devel-184

4 years agosmbXsrv_session: always cancel pending requests in smb2srv_session_shutdown_send...
Stefan Metzmacher [Thu, 11 Mar 2021 16:04:37 +0000 (17:04 +0100)] 
smbXsrv_session: always cancel pending requests in smb2srv_session_shutdown_send() in the same way

The session is valid for the lifetime of the requests anyway
and there's no point in having special handling for compound requests.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=14449

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
4 years agosmb2_server: don't cancel pending request if at least one channel is still alive
Stefan Metzmacher [Wed, 24 Feb 2021 16:44:12 +0000 (17:44 +0100)] 
smb2_server: don't cancel pending request if at least one channel is still alive

In order to allow replays of requests on a channel failure, we should
not cancel pending requests, the strategie that seems to make windows
clients happy is to let the requests running and return
NT_STATUS_FILE_NOT_AVAILABLE as long as the original request is still
pending.

Here we introduce xconn->transport.shutdown_wait_queue, this is used
to keep the xconn alive for the lifetime of pending requests.

Now we only cancel pending requests if the disconnected connection
is the last channel for a session.

In that case smbXsrv_session_remove_channel() and
smb2srv_session_shutdown_send() will take care of it.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=14449

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
4 years agosmb2_server: let smbd_smb2_flush_send_queue() destroy pending elements on dead connection
Stefan Metzmacher [Fri, 12 Mar 2021 17:34:06 +0000 (18:34 +0100)] 
smb2_server: let smbd_smb2_flush_send_queue() destroy pending elements on dead connection

Otherwise we'll keep the state of already finished requests arround.

This becomes critical as the next commit will cause us to
let pending requests running and keep the xconn alive for
the lifetime of pending requests, so we would not ever
make progress and deadlock.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=14449

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
4 years agosmbXsrv_open: intruduce smbXsrv_open_replay_cache to support FILE_NOT_AVAILABLE
Stefan Metzmacher [Fri, 12 Mar 2021 14:10:46 +0000 (15:10 +0100)] 
smbXsrv_open: intruduce smbXsrv_open_replay_cache to support FILE_NOT_AVAILABLE

Before processing an open we need to reserve the replay cache entry
in order to signal that we're still in progress.
If a reserved record is already present we need to return
FILE_NOT_AVAILABLE in order to let the client retry again.

[MS-SMB2] contains this:

  <152> Section 3.2.5.1: For the following error codes, Windows-based clients
  will retry the operation up to three times and then retry the operation every 5
  seconds until the count of milliseconds specified by Open.ResilientTimeout is
  exceeded:
  - STATUS_SERVER_UNAVAILABLE
  - STATUS_FILE_NOT_AVAILABLE
  - STATUS_SHARE_UNAVAILABLE

This works fine for windows clients, but current windows servers seems to
return ACCESS_DENIED instead of FILE_NOT_AVAILABLE.

A Windows server doesn't do any replay detection on pending opens,
which wait for a HANDLE lease to be broken (because of a
SHARING_VIOLATION), at all.

As this is not really documented for the server part of the current [MS-SMB2],
I found the key hint in "SMB 2.2: Bigger. Faster. Scalier - (Parts 1 and 2)"
on page 24. There's a picture showing that a replay gets FILE_NOT_AVAILABLE
as long as the original request is still in progress. See:
https://www.snia.org/educational-library/smb-22-bigger-faster-scalier-parts-1-and-2-2011

A Windows client is unhappy with the current windows server behavior if it
such a situation happens. There's also a very strange interaction with oplock
where the replay gets SHARING_VIOLATION after 35 seconds because it conflicts with
the original open.

I think it's good to follow the intial design from the 2011 presentation and
make the clients happy by using FILE_NOT_AVAILABLE (and differ from Windows).
I'll report that to dochelp@microsoft.com in order to get this hopefully fixed in
their server too).

BUG: https://bugzilla.samba.org/show_bug.cgi?id=14449

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
4 years agosmbXsrv_session: smbXsrv_session_remove_channel() should also remove the last channel
Stefan Metzmacher [Wed, 24 Feb 2021 16:44:12 +0000 (17:44 +0100)] 
smbXsrv_session: smbXsrv_session_remove_channel() should also remove the last channel

There's nothing special regarding the last channel,
as the smb2.session.bind2 test demonstrates.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=14449

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
4 years agos4:torture/smb2: add smb2.session.bind2
Stefan Metzmacher [Thu, 18 Mar 2021 13:38:16 +0000 (14:38 +0100)] 
s4:torture/smb2: add smb2.session.bind2

This demonstrates that a session and it's open handles is destroyed
when the last explicitly bound channel gets disconnected.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=14449

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>