]> git.ipfire.org Git - thirdparty/samba.git/log
thirdparty/samba.git
4 years agopytest/dcerpc/dnsserver.py: use dnsserver.flag_from_string
Douglas Bagnall [Fri, 26 Mar 2021 08:04:20 +0000 (21:04 +1300)] 
pytest/dcerpc/dnsserver.py: use dnsserver.flag_from_string

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andreas Schneider <asn@samba.org>
4 years agopytest/dcerpcdnsserver: use record_from_string helper
Douglas Bagnall [Sat, 27 Mar 2021 02:41:10 +0000 (15:41 +1300)] 
pytest/dcerpcdnsserver: use record_from_string helper

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andreas Schneider <asn@samba.org>
4 years agopy/dnsserver add flag from string function
Douglas Bagnall [Thu, 1 Apr 2021 02:29:32 +0000 (15:29 +1300)] 
py/dnsserver add flag from string function

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andreas Schneider <asn@samba.org>
4 years agopy/dnsserver: add record_from_string helper function
Douglas Bagnall [Thu, 1 Apr 2021 02:28:49 +0000 (15:28 +1300)] 
py/dnsserver: add record_from_string helper function

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andreas Schneider <asn@samba.org>
4 years agopy/dnsserver: add .from_string() methods
Douglas Bagnall [Wed, 7 Apr 2021 01:34:50 +0000 (13:34 +1200)] 
py/dnsserver: add .from_string() methods

The logic to parse DNS value strings (e.g. "example.com 10" for an MX,
which needs to be split on the space) is repeated at least in
samba-tool dns and tests/dcerpc/dnsserver.py. Here we bring it
together so we can do it once.

The sep= keyword allows callers to separate on all runs of
whitespace (the default, as samba-tool dns does) or, using sep='', to
separate on true spaces only.

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andreas Schneider <asn@samba.org>
4 years agopy/dnsserver: remove workaround of fixed bug
Douglas Bagnall [Thu, 1 Apr 2021 02:26:01 +0000 (15:26 +1300)] 
py/dnsserver: remove workaround of fixed bug

We used to do something wrong with the refcounts, but we don't anymore,
so we don't need this confusing nonsense.

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andreas Schneider <asn@samba.org>
4 years agopy/provision/sambadns: Add a comment about DNS types
Douglas Bagnall [Thu, 1 Apr 2021 02:23:48 +0000 (15:23 +1300)] 
py/provision/sambadns: Add a comment about DNS types

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andreas Schneider <asn@samba.org>
4 years agopy/provision/sambadns: rename CNameRecord -> CNAMERecord
Douglas Bagnall [Sat, 27 Mar 2021 02:55:03 +0000 (15:55 +1300)] 
py/provision/sambadns: rename CNameRecord -> CNAMERecord

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andreas Schneider <asn@samba.org>
4 years agopy/dnsserver: replace obsolete comments with useful ones
Douglas Bagnall [Fri, 26 Mar 2021 07:42:49 +0000 (20:42 +1300)] 
py/dnsserver: replace obsolete comments with useful ones

The replaced comment was about a long fixed Python reference counting bug.

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andreas Schneider <asn@samba.org>
4 years agopydns: rename s/CNameRecord/CNAMERecord/ for consistency
Douglas Bagnall [Fri, 26 Mar 2021 05:22:17 +0000 (18:22 +1300)] 
pydns: rename s/CNameRecord/CNAMERecord/ for consistency

Everything else is TXTRecord, SRVRrcord, SOARecord.

Making CNAME the same allows easier lookups.

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andreas Schneider <asn@samba.org>
4 years agoVFS: Remove SMB_VFS_SET_DOS_ATTRIBUTE, no longer used
Noel Power [Wed, 3 Mar 2021 10:26:39 +0000 (10:26 +0000)] 
VFS: Remove SMB_VFS_SET_DOS_ATTRIBUTE, no longer used

                              -------------------
                             /                   \
                            /        REST         \
                           /          IN           \
                          /          PEACE          \
                         /                           \
                         |                           |
                         | SMB_VFS_SET_DOS_ATTRIBUTE |
                         |                           |
                         |                           |
                         |         3 March           |
                         |           2021            |
                         |                           |
                         |                           |
                        *|      *  *  *        * *   | *
                _________)/\\_//(\/(/\)/\//\/\////\\/|_)_______
Signed-off-by: Noel Power <noel.power@suse.com>
Reviewed-by: Jeremy Allison <jra@samba.org>
Autobuild-User(master): Jeremy Allison <jra@samba.org>
Autobuild-Date(master): Thu Apr  8 18:38:40 UTC 2021 on sn-devel-184

4 years agos3/smbd: SMB_VFS_SET_DOS_ATTRIBUTES -> SMB_VFS_FSET_DOS_ATTRIBUTES
Noel Power [Tue, 2 Mar 2021 10:30:40 +0000 (10:30 +0000)] 
s3/smbd: SMB_VFS_SET_DOS_ATTRIBUTES -> SMB_VFS_FSET_DOS_ATTRIBUTES

Signed-off-by: Noel Power <noel.power@suse.com>
Reviewed-by: Jeremy Allison <jra@samba.org>
4 years agos3/smbd: VFS Fix incorrect VFS_FIND
Noel Power [Wed, 3 Mar 2021 11:29:43 +0000 (11:29 +0000)] 
s3/smbd: VFS Fix incorrect VFS_FIND

smb_vfs_call_fset_dos_attributes is looking for the wrong function

Signed-off-by: Noel Power <noel.power@suse.com>
Reviewed-by: Jeremy Allison <jra@samba.org>
4 years agosmbd: SMB2 Compound related chain handling when generation of FileId has failed
Ralph Boehme [Thu, 8 Apr 2021 10:17:22 +0000 (12:17 +0200)] 
smbd: SMB2 Compound related chain handling when generation of FileId has failed

Issue:
We have a scenario where an application sends a Compound Related chain
consisting of:
SMB2_CREATE
SMB2_IOCTL
SMB2_SET_INFO
SMB2_CLOSE

SMB2_CREATE failed with NT_STATUS_ACCESS_DENIED and subsequent
requests all fail. In Samba they return NT_STATUS_FILE_CLOSED.

When I tried the same against a Win2k12 server, I noticed that all the
failed requests of the chain would return NT_STATUS_ACCESS_DENIED.

I believe this behaviour is also mentioned in the [MS-SMB2] Specs
3.3.5.2.7.2: Handling Compounded Related Requests

"When the current operation requires a FileId and the previous
operation either contains or generates a FileId, if the previous
operation fails with an error, the server SHOULD<223> fail the current
operation with the same error code returned by the previous
operation."

Fix:
Save NTATUS of a failed Create request. When we process subsequent
requests of the chain we check if the previous Create has failed. In
case of a Create failure we returned the saved NTSTATUS.

Signed-off-by: Anubhav Rakshit <anubhav.rakshit@gmail.com>
Reviewed-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
Autobuild-User(master): Jeremy Allison <jra@samba.org>
Autobuild-Date(master): Thu Apr  8 17:30:50 UTC 2021 on sn-devel-184

4 years agotorture: add another smbtorture compound SMB2 requests test "related9"
Ralph Boehme [Thu, 8 Apr 2021 10:25:22 +0000 (12:25 +0200)] 
torture: add another smbtorture compound SMB2 requests test "related9"

This test verifies that if a compound related request is not preceeded by a
request that generates or contains a File-ID, the request fails with
NT_STATUS_INVALID_PARAMETER.

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
4 years agotorture: add smbtorture compound SMB2 requests test "related8"
Ralph Boehme [Thu, 8 Apr 2021 10:14:19 +0000 (12:14 +0200)] 
torture: add smbtorture compound SMB2 requests test "related8"

This verifies that if the initial create fails with
NT_STATUS_OBJECT_NAME_NOT_FOUND, compount related operations fail with the same
error.

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
4 years agotorture: add smbtorture testcase "related7" for failure in compound related chain
Anubhav Rakshit [Wed, 15 Jul 2020 04:44:52 +0000 (10:14 +0530)] 
torture: add smbtorture testcase "related7" for failure in compound related chain

We want to verify what Windows does when the first request of the
chain has failed and an async request is part of the chain. We see
Windows fails the async request with the same error. Also the async
request is immediately failed.

Signed-off-by: Anubhav Rakshit <anubhav.rakshit@gmail.com>
Reviewed-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
4 years agotorture: smbtorture test case to verify Compound related handling
Anubhav Rakshit [Mon, 18 May 2020 14:50:05 +0000 (20:20 +0530)] 
torture: smbtorture test case to verify Compound related handling

This test case checks what happens when we have an intermediate request
failure and how it impacts rest of the chain.

Signed-off-by: Anubhav Rakshit <anubhav.rakshit@gmail.com>
Reviewed-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
4 years agotorture: Add couple of compound related test cases to verify that server should retur...
Anubhav Rakshit [Fri, 15 May 2020 18:32:18 +0000 (00:02 +0530)] 
torture: Add couple of compound related test cases to verify that server should return NTSTATUS of the failed Create for succeeding requests.

We already pass samba3.smb2.compound.related5, but mark related4 as knownfail.

Signed-off-by: Anubhav Rakshit <anubhav.rakshit@gmail.com>
Reviewed-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
4 years agoUpdate status of SMB_VFS_REMOVEXATTR
Jeremy Allison [Mon, 22 Mar 2021 19:36:39 +0000 (12:36 -0700)] 
Update status of SMB_VFS_REMOVEXATTR

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 17:32:07 UTC 2021 on sn-devel-184

4 years agoVFS: Remove SMB_VFS_REMOVEXATTR, no longer used
Jeremy Allison [Mon, 22 Mar 2021 19:33:46 +0000 (12:33 -0700)] 
VFS: Remove SMB_VFS_REMOVEXATTR, no longer used

                                       ---------------
                                      /               \
                                     /      REST       \
                                    /        IN         \
                                   /        PEACE        \
                                  /                       \
                                  |                       |
                                  |  SMB_VFS_REMOVEXATTR  |
                                  |                       |
                                  |                       |
                                  |       22 March        |
                                  |         2021          |
                                  |                       |
                                  |                       |
                                 *|     *  *  *           | *
                        _________)/\\_//(\/(/\)/\//\/\////|_)_______

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

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

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

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
4 years agos3: VFS: shadow_copy2: Remove shadow_copy2_removexattr(). No longer called.
Jeremy Allison [Mon, 22 Mar 2021 19:05:02 +0000 (12:05 -0700)] 
s3: VFS: shadow_copy2: Remove shadow_copy2_removexattr(). No longer called.

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
4 years agos3: VFS: posix_eadb: Remove posix_eadb_removexattr(). No longer called.
Jeremy Allison [Mon, 22 Mar 2021 19:02:08 +0000 (12:02 -0700)] 
s3: VFS: posix_eadb: Remove posix_eadb_removexattr(). No longer called.

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

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

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

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
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