[SCM] Samba Shared Repository - branch v4-17-test updated

Jule Anger janger at samba.org
Tue Aug 23 14:27:01 UTC 2022


The branch, v4-17-test has been updated
       via  4d37152c666 smbd: directly pass fsp to SMB_VFS_FGETXATTR() in fget_ea_dos_attribute()
       via  25d6dcd8897 smbd: add and use vfs_fget_dos_attributes()
       via  9df07ee0fa5 smbtorture: add test smb2.stream.attributes2
       via  81be412fb01 smbtorture: rename smb2.streams.attributes to smb2.streams.attributes1
       via  0d0eff66058 vfs_default: assert all passed in fsp's and names are non-stream type
       via  f2272106f36 vfs_streams_xattr: restrict which fcntl's are allowed on streams
       via  aca819549c3 smbd: skip access checks for stat-opens on streams in open_file()
       via  7c713f386f3 smbd: use metadata_fsp() in get_acl_group_bits()
       via  107af8fd98b smbd: ignore request to set the SPARSE attribute on streams
       via  69742bab667 smbd: use metadata_fsp() with SMB_VFS_FSET_DOS_ATTRIBUTES()
       via  814fd4e8e89 smbd: use metadata_fsp() with SMB_VFS_FGET_DOS_ATTRIBUTES()
       via  1434b66f2a1 smbd: use metadata_fsp() with SMB_VFS_FSET_NT_ACL()
       via  ba468a9b416 smbd: use metadata_fsp() with SMB_VFS_FGET_NT_ACL()
       via  ab76ab52c39 CI: add a test trying to delete a stream on a pathref ("stat open") handle
       via  3994f71f039 vfs_xattr_tdb: add "xattr_tdb:ignore_user_xattr" option
       via  aa85dac1e95 vfs_xattr_tdb: add a module config
       via  bae285ed702 vfs_xattr_tdb: move close_xattr_db()
       via  f23ef830bc7 smdb: use fsp_is_alternate_stream() in open_file()
      from  721ea813b54 waf: Fix SO version number of libsamba-errors

https://git.samba.org/?p=samba.git;a=shortlog;h=v4-17-test


- Log -----------------------------------------------------------------
commit 4d37152c666d84e7c76d4e0e976d051c4bbaa9df
Author: Ralph Boehme <slow at samba.org>
Date:   Sun Aug 14 16:39:37 2022 +0200

    smbd: directly pass fsp to SMB_VFS_FGETXATTR() in fget_ea_dos_attribute()
    
    We're now consistently passing the base_fsp to SMB_VFS_FSET_DOS_ATTRIBUTES(), so
    we don't need to check for a stream_fsp here anymore.
    
    Additionally vfs_default will assert a non-stream fsp inside
    vfswrap_fgetxattr(), so in case any caller wrongly passes a stream fsp, this is
    caught in vfs_default.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=15126
    MR: https://gitlab.com/samba-team/samba/-/merge_requests/2643
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Stefan Metzmacher <metze at samba.org>
    (cherry picked from commit 968a5ae89f0d0da219e7dd05dd1f7f7c96dbb910)
    
    Autobuild-User(v4-17-test): Jule Anger <janger at samba.org>
    Autobuild-Date(v4-17-test): Tue Aug 23 14:26:49 UTC 2022 on sn-devel-184

commit 25d6dcd88975368e6eaa90257a2546b51d414f82
Author: Ralph Boehme <slow at samba.org>
Date:   Thu Aug 11 17:18:13 2022 +0200

    smbd: add and use vfs_fget_dos_attributes()
    
    Commit d71ef1365cdde47aeb3465699181656b0655fa04 caused a regression where the
    creation date on streams wasn't updated anymore on the stream fsp.
    
    By adding a simple wrapper vfs_fget_dos_attributes() that takes care of
    
    - passing only the base_fsp to the VFS, so the VFS can be completely agnostic of
      all the streams related complexity like fake fds,
    
    - propagating any updated btime from the base_fsp->fsp_name to the
      stream_fsp->fsp_name
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=15126
    MR: https://gitlab.com/samba-team/samba/-/merge_requests/2643
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Stefan Metzmacher <metze at samba.org>
    (cherry picked from commit 3f7d8db9945a325020e4d1574289dea9e8331c29)

commit 9df07ee0fa5dfc9bb45070078169890c339b8835
Author: Ralph Boehme <slow at samba.org>
Date:   Sat Aug 13 16:13:07 2022 +0200

    smbtorture: add test smb2.stream.attributes2
    
    Specifically torture the creation date is the same for the file and its streams.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=15126
    MR: https://gitlab.com/samba-team/samba/-/merge_requests/2643
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Stefan Metzmacher <metze at samba.org>
    (cherry picked from commit e74b10e17ee5df0f77ac5349242841be8d71c4e8)

commit 81be412fb01a585337122e0a2fc58df338c322c9
Author: Ralph Boehme <slow at samba.org>
Date:   Sat Aug 13 17:04:50 2022 +0200

    smbtorture: rename smb2.streams.attributes to smb2.streams.attributes1
    
    A subsequent commit adds another streams test named "attributes2", this change
    avoids matching the new testname with the existing knownfail entries.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=15126
    MR: https://gitlab.com/samba-team/samba/-/merge_requests/2643
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Stefan Metzmacher <metze at samba.org>
    (cherry picked from commit b5848d391be4f7633745d9c36e432ac8b1c9dba2)

commit 0d0eff660583c7ec1675323a43c181205ea9b2ae
Author: Ralph Boehme <slow at samba.org>
Date:   Wed Jul 27 18:40:21 2022 +0200

    vfs_default: assert all passed in fsp's and names are non-stream type
    
    Enforce fsp is a non-stream one in as many VFS operations as possible in
    vfs_default. We really need an assert here instead of returning an error, as
    otherwise he can have very hard to diagnose bugs.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=15126
    MR: https://gitlab.com/samba-team/samba/-/merge_requests/2643
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Volker Lendecke <vl at samba.org>
    
    Autobuild-User(master): Volker Lendecke <vl at samba.org>
    Autobuild-Date(master): Wed Aug 10 16:32:35 UTC 2022 on sn-devel-184
    
    (cherry picked from commit fc45fcfde51b0b0bdcd524c82a0f9eabf7273045)

commit f2272106f360524cff023be42e27e7ea33e8dcfc
Author: Ralph Boehme <slow at samba.org>
Date:   Fri Jul 29 07:07:25 2022 +0200

    vfs_streams_xattr: restrict which fcntl's are allowed on streams
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=15126
    MR: https://gitlab.com/samba-team/samba/-/merge_requests/2643
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Volker Lendecke <vl at samba.org>
    (cherry picked from commit 51243e3849736acbbf1d8f52cc02cdec5995fde4)

commit aca819549c3f60b29464678f3492fb1f6d09a0fb
Author: Ralph Boehme <slow at samba.org>
Date:   Wed Jul 27 15:58:37 2022 +0200

    smbd: skip access checks for stat-opens on streams in open_file()
    
    For streams, access is already checked in create_file_unixpath() by
    check_base_file_access().
    
    We already skip the access check in this function when doing an IO open of a
    file, see above in open_file(), also skip it for "stat opens".
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=15126
    MR: https://gitlab.com/samba-team/samba/-/merge_requests/2643
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Volker Lendecke <vl at samba.org>
    (cherry picked from commit f0299abf1b28a14518328710d9f84bef17fd2ecf)

commit 7c713f386f378152e9730bf2648ae87f5df54517
Author: Ralph Boehme <slow at samba.org>
Date:   Wed Jul 27 19:05:26 2022 +0200

    smbd: use metadata_fsp() in get_acl_group_bits()
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=15126
    MR: https://gitlab.com/samba-team/samba/-/merge_requests/2643
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Volker Lendecke <vl at samba.org>
    (cherry picked from commit 06555c6bcb5644fc9eea35b3cbae8d8801c65ab6)

commit 107af8fd98b6608df08ab346efb1f53addf13111
Author: Ralph Boehme <slow at samba.org>
Date:   Fri Jul 29 14:56:41 2022 +0200

    smbd: ignore request to set the SPARSE attribute on streams
    
    As per MS-FSA 2.1.1.5 this is a per stream attribute, but our backends don't
    support it in a consistent way, therefor just pretend success and ignore the
    request.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=15126
    MR: https://gitlab.com/samba-team/samba/-/merge_requests/2643
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Volker Lendecke <vl at samba.org>
    (cherry picked from commit 3af8f8e8741cc8c889bbf416ccd38a1b702917ec)

commit 69742bab6679f3d13e691485664442769dfb7689
Author: Ralph Boehme <slow at samba.org>
Date:   Fri Jul 29 14:56:21 2022 +0200

    smbd: use metadata_fsp() with SMB_VFS_FSET_DOS_ATTRIBUTES()
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=15126
    MR: https://gitlab.com/samba-team/samba/-/merge_requests/2643
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Volker Lendecke <vl at samba.org>
    (cherry picked from commit 55e55804bb2d0f21c1bbe207257bb40555f3b7a2)

commit 814fd4e8e89a843985f187b75f76ec1427965c56
Author: Ralph Boehme <slow at samba.org>
Date:   Fri Jul 29 14:55:08 2022 +0200

    smbd: use metadata_fsp() with SMB_VFS_FGET_DOS_ATTRIBUTES()
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=15126
    MR: https://gitlab.com/samba-team/samba/-/merge_requests/2643
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Volker Lendecke <vl at samba.org>
    (cherry picked from commit 03b9ce84736d536ab2dd8a5ce1a2656e6a90c8c8)

commit 1434b66f2a1835563a6378158c2251f69192cf4c
Author: Ralph Boehme <slow at samba.org>
Date:   Fri Jul 29 14:54:07 2022 +0200

    smbd: use metadata_fsp() with SMB_VFS_FSET_NT_ACL()
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=15126
    MR: https://gitlab.com/samba-team/samba/-/merge_requests/2643
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Volker Lendecke <vl at samba.org>
    (cherry picked from commit 4ab29e2a345b48ebba652d5154e96adf954a6757)

commit ba468a9b416bbc44338f00983d4f8f21d697504e
Author: Ralph Boehme <slow at samba.org>
Date:   Fri Jul 29 14:49:56 2022 +0200

    smbd: use metadata_fsp() with SMB_VFS_FGET_NT_ACL()
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=15126
    MR: https://gitlab.com/samba-team/samba/-/merge_requests/2643
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Volker Lendecke <vl at samba.org>
    (cherry picked from commit c949e4b2a42423ac3851e86e489fd0c5d46d7f1f)

commit ab76ab52c3926c85664f6d6dd852b56492e2d05a
Author: Ralph Boehme <slow at samba.org>
Date:   Wed Jul 27 13:37:32 2022 +0200

    CI: add a test trying to delete a stream on a pathref ("stat open") handle
    
    When using vfs_streams_xattr, for a pathref handle of a stream the system fd
    will be a fake fd created by pipe() in vfs_fake_fd().
    
    For the following callchain we wrongly pass a stream fsp to
    SMB_VFS_FGET_NT_ACL():
    
    SMB_VFS_CREATE_FILE(..., "file:stream", ...)
    => open_file():
       if (open_fd):
       -> taking the else branch:
       -> smbd_check_access_rights_fsp(stream_fsp)
          -> SMB_VFS_FGET_NT_ACL(stream_fsp)
    
    This is obviously wrong and can lead to strange permission errors when using
    vfs_acl_xattr:
    
    in vfs_acl_xattr we will try to read the stored ACL by calling
    fgetxattr(fake-fd) which of course faild with EBADF. Now unfortunately the
    vfs_acl_xattr code ignores the specific error and handles this as if there was
    no ACL stored and subsequently runs the code to synthesize a default ACL
    according to the setting of "acl:default acl style".
    
    As the correct access check for streams has already been carried out by calling
    check_base_file_access() from create_file_unixpath(), the above problem is not
    a security issue: it can only lead to "decreased" permissions resulting in
    unexpected ACCESS_DENIED errors.
    
    The fix is obviously going to be calling
    smbd_check_access_rights_fsp(stream_fsp->base_fsp).
    
    This test verifies that deleting a file works when the stored NT ACL grants
    DELETE_FILE while the basic POSIX permissions (used in the acl_xattr fallback
    code) do not.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=15126
    MR: https://gitlab.com/samba-team/samba/-/merge_requests/2643
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Volker Lendecke <vl at samba.org>
    (cherry picked from commit 23bc760ec5d61208c2d8778991e3d7e202eab352)

commit 3994f71f039db76f5802b378c660112fd964e8dc
Author: Ralph Boehme <slow at samba.org>
Date:   Wed Jul 27 12:47:21 2022 +0200

    vfs_xattr_tdb: add "xattr_tdb:ignore_user_xattr" option
    
    Allows passing on "user." xattr to the backend. This can be useful for testing
    specific aspects of operation on streams when "streams_xattr" is configured as
    stream filesystem backend.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=15126
    MR: https://gitlab.com/samba-team/samba/-/merge_requests/2643
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Volker Lendecke <vl at samba.org>
    (cherry picked from commit 92e0045d7ca7c0b94efd0244ba0e426cad0a05b6)

commit aa85dac1e9579194dd41d04f46787733fa70fd81
Author: Ralph Boehme <slow at samba.org>
Date:   Wed Jul 27 11:59:54 2022 +0200

    vfs_xattr_tdb: add a module config
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=15126
    MR: https://gitlab.com/samba-team/samba/-/merge_requests/2643
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Volker Lendecke <vl at samba.org>
    (cherry picked from commit 451ad315a9bf32c627e1966ec30185542701c87e)

commit bae285ed7023bcee80148365d25024bfa0d33ce0
Author: Ralph Boehme <slow at samba.org>
Date:   Wed Jul 27 12:43:01 2022 +0200

    vfs_xattr_tdb: move close_xattr_db()
    
    This just makes the diff of the next commit smaller and easier to digest.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=15126
    MR: https://gitlab.com/samba-team/samba/-/merge_requests/2643
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Volker Lendecke <vl at samba.org>
    (cherry picked from commit b26dc252aaf3f4b960bdfdb6a3dfe612b89fcdd5)

commit f23ef830bc74b52f615c3e45334bc37213de63c1
Author: Ralph Boehme <slow at samba.org>
Date:   Wed Jul 27 16:04:24 2022 +0200

    smdb: use fsp_is_alternate_stream() in open_file()
    
    No change in behaviour.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=15126
    MR: https://gitlab.com/samba-team/samba/-/merge_requests/2643
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Volker Lendecke <vl at samba.org>
    (cherry picked from commit 0d3995cec10c5fae8c8b6a1df312062e38437e6f)

-----------------------------------------------------------------------

Summary of changes:
 selftest/knownfail                         |   4 +-
 selftest/target/Samba3.pm                  |   7 +
 source3/include/proto.h                    |   3 +
 source3/modules/vfs_default.c              |  92 +++++---
 source3/modules/vfs_streams_xattr.c        |  33 +++
 source3/modules/vfs_xattr_tdb.c            | 293 ++++++++++++++---------
 source3/rpc_server/srvsvc/srv_srvsvc_nt.c  |   2 +-
 source3/script/tests/test_delete_stream.sh | 123 ++++++++++
 source3/selftest/tests.py                  |   1 +
 source3/smbd/dir.c                         |   2 +-
 source3/smbd/dosmode.c                     |  24 +-
 source3/smbd/file_access.c                 |   2 +-
 source3/smbd/open.c                        |  63 ++---
 source3/smbd/posix_acls.c                  |   2 +-
 source3/smbd/pysmbd.c                      |   4 +-
 source3/smbd/vfs.c                         |  39 ++++
 source3/torture/cmd_vfs.c                  |  12 +-
 source4/torture/smb2/streams.c             | 361 ++++++++++++++++++++++++++++-
 18 files changed, 881 insertions(+), 186 deletions(-)
 create mode 100755 source3/script/tests/test_delete_stream.sh


Changeset truncated at 500 lines:

diff --git a/selftest/knownfail b/selftest/knownfail
index 173286a96a0..0b4c5a44a7f 100644
--- a/selftest/knownfail
+++ b/selftest/knownfail
@@ -207,10 +207,10 @@
 ^samba3.smb2.oplock.stream1
 ^samba3.smb2.streams.rename
 ^samba3.smb2.streams.rename2
-^samba3.smb2.streams.attributes
+^samba3.smb2.streams.attributes1\(.*\)
 ^samba3.smb2.streams streams_xattr.rename\(nt4_dc\)
 ^samba3.smb2.streams streams_xattr.rename2\(nt4_dc\)
-^samba3.smb2.streams streams_xattr.attributes\(nt4_dc\)
+^samba3.smb2.streams streams_xattr.attributes1\(nt4_dc\)
 ^samba3.smb2.getinfo.complex
 ^samba3.smb2.getinfo.fsinfo # quotas don't work yet
 ^samba3.smb2.setinfo.setinfo
diff --git a/selftest/target/Samba3.pm b/selftest/target/Samba3.pm
index a5392fbf26c..d413f14bacd 100755
--- a/selftest/target/Samba3.pm
+++ b/selftest/target/Samba3.pm
@@ -3373,6 +3373,13 @@ sub provision($$)
 	copy = tmp
 	vfs objects = streams_xattr xattr_tdb
 
+[acl_streams_xattr]
+	copy = tmp
+	vfs objects = acl_xattr streams_xattr fake_acls xattr_tdb
+	acl_xattr:ignore system acls = yes
+	acl_xattr:security_acl_name = user.acl
+	xattr_tdb:ignore_user_xattr = yes
+
 [compound_find]
 	copy = tmp
 	smbd:find async delay usec = 10000
diff --git a/source3/include/proto.h b/source3/include/proto.h
index 6a6edc36dfb..f632cf37c08 100644
--- a/source3/include/proto.h
+++ b/source3/include/proto.h
@@ -82,6 +82,9 @@ NTSTATUS vfs_at_fspcwd(TALLOC_CTX *mem_ctx,
 		       struct connection_struct *conn,
 		       struct files_struct **_fsp);
 
+NTSTATUS vfs_fget_dos_attributes(struct files_struct *fsp,
+				 uint32_t *dosmode);
+
 #include "source3/lib/interface.h"
 
 /* The following definitions come from lib/ldap_debug_handler.c  */
diff --git a/source3/modules/vfs_default.c b/source3/modules/vfs_default.c
index 5d8ee98e2ca..48ff174ebbe 100644
--- a/source3/modules/vfs_default.c
+++ b/source3/modules/vfs_default.c
@@ -728,11 +728,7 @@ static int vfswrap_openat(vfs_handle_struct *handle,
 		goto out;
 	}
 
-	if (is_named_stream(smb_fname)) {
-		errno = ENOENT;
-		result = -1;
-		goto out;
-	}
+	SMB_ASSERT(!is_named_stream(smb_fname));
 
 #ifdef O_PATH
 	have_opath = true;
@@ -1327,17 +1323,14 @@ static int vfswrap_renameat(vfs_handle_struct *handle,
 
 	START_PROFILE(syscall_renameat);
 
-	if (is_named_stream(smb_fname_src) || is_named_stream(smb_fname_dst)) {
-		errno = ENOENT;
-		goto out;
-	}
+	SMB_ASSERT(!is_named_stream(smb_fname_src));
+	SMB_ASSERT(!is_named_stream(smb_fname_dst));
 
 	result = renameat(fsp_get_pathref_fd(srcfsp),
 			smb_fname_src->base_name,
 			fsp_get_pathref_fd(dstfsp),
 			smb_fname_dst->base_name);
 
- out:
 	END_PROFILE(syscall_renameat);
 	return result;
 }
@@ -1349,14 +1342,11 @@ static int vfswrap_stat(vfs_handle_struct *handle,
 
 	START_PROFILE(syscall_stat);
 
-	if (is_named_stream(smb_fname)) {
-		errno = ENOENT;
-		goto out;
-	}
+	SMB_ASSERT(!is_named_stream(smb_fname));
 
 	result = sys_stat(smb_fname->base_name, &smb_fname->st,
 			  lp_fake_directory_create_times(SNUM(handle->conn)));
- out:
+
 	END_PROFILE(syscall_stat);
 	return result;
 }
@@ -1379,14 +1369,11 @@ static int vfswrap_lstat(vfs_handle_struct *handle,
 
 	START_PROFILE(syscall_lstat);
 
-	if (is_named_stream(smb_fname)) {
-		errno = ENOENT;
-		goto out;
-	}
+	SMB_ASSERT(!is_named_stream(smb_fname));
 
 	result = sys_lstat(smb_fname->base_name, &smb_fname->st,
 			   lp_fake_directory_create_times(SNUM(handle->conn)));
- out:
+
 	END_PROFILE(syscall_lstat);
 	return result;
 }
@@ -1402,10 +1389,7 @@ static int vfswrap_fstatat(
 
 	START_PROFILE(syscall_fstatat);
 
-	if (is_named_stream(smb_fname)) {
-		errno = ENOENT;
-		goto out;
-	}
+	SMB_ASSERT(!is_named_stream(smb_fname));
 
 	result = sys_fstatat(
 		fsp_get_pathref_fd(dirfsp),
@@ -1413,7 +1397,7 @@ static int vfswrap_fstatat(
 		sbuf,
 		flags,
 		lp_fake_directory_create_times(SNUM(handle->conn)));
- out:
+
 	END_PROFILE(syscall_fstatat);
 	return result;
 }
@@ -1510,6 +1494,8 @@ static NTSTATUS vfswrap_fsctl(struct vfs_handle_struct *handle,
 	char **out_data = (char **)_out_data;
 	NTSTATUS status;
 
+	SMB_ASSERT(!fsp_is_alternate_stream(fsp));
+
 	switch (function) {
 	case FSCTL_SET_SPARSE:
 	{
@@ -1874,6 +1860,8 @@ static struct tevent_req *vfswrap_get_dos_attributes_send(
 	struct tevent_req *subreq = NULL;
 	struct vfswrap_get_dos_attributes_state *state = NULL;
 
+	SMB_ASSERT(!is_named_stream(smb_fname));
+
 	req = tevent_req_create(mem_ctx, &state,
 				struct vfswrap_get_dos_attributes_state);
 	if (req == NULL) {
@@ -2030,6 +2018,8 @@ static NTSTATUS vfswrap_fget_dos_attributes(struct vfs_handle_struct *handle,
 {
 	bool offline;
 
+	SMB_ASSERT(!fsp_is_alternate_stream(fsp));
+
 	offline = vfswrap_is_offline(handle->conn, fsp->fsp_name);
 	if (offline) {
 		*dosmode |= FILE_ATTRIBUTE_OFFLINE;
@@ -2042,6 +2032,8 @@ static NTSTATUS vfswrap_fset_dos_attributes(struct vfs_handle_struct *handle,
 					    struct files_struct *fsp,
 					    uint32_t dosmode)
 {
+	SMB_ASSERT(!fsp_is_alternate_stream(fsp));
+
 	return set_ea_dos_attribute(handle->conn, fsp->fsp_name, dosmode);
 }
 
@@ -2718,15 +2710,12 @@ static int vfswrap_unlinkat(vfs_handle_struct *handle,
 
 	START_PROFILE(syscall_unlinkat);
 
-	if (is_named_stream(smb_fname)) {
-		errno = ENOENT;
-		goto out;
-	}
+	SMB_ASSERT(!is_named_stream(smb_fname));
+
 	result = unlinkat(fsp_get_pathref_fd(dirfsp),
 			smb_fname->base_name,
 			flags);
 
- out:
 	END_PROFILE(syscall_unlinkat);
 	return result;
 }
@@ -3211,6 +3200,8 @@ static int vfswrap_linux_setlease(vfs_handle_struct *handle, files_struct *fsp,
 
 	START_PROFILE(syscall_linux_setlease);
 
+	SMB_ASSERT(!fsp_is_alternate_stream(fsp));
+
 #ifdef HAVE_KERNEL_OPLOCKS_LINUX
 	result = linux_setlease(fsp_get_io_fd(fsp), leasetype);
 #else
@@ -3229,6 +3220,8 @@ static int vfswrap_symlinkat(vfs_handle_struct *handle,
 
 	START_PROFILE(syscall_symlinkat);
 
+	SMB_ASSERT(!is_named_stream(new_smb_fname));
+
 	result = symlinkat(link_target->base_name,
 			fsp_get_pathref_fd(dirfsp),
 			new_smb_fname->base_name);
@@ -3246,6 +3239,8 @@ static int vfswrap_readlinkat(vfs_handle_struct *handle,
 
 	START_PROFILE(syscall_readlinkat);
 
+	SMB_ASSERT(!is_named_stream(smb_fname));
+
 	result = readlinkat(fsp_get_pathref_fd(dirfsp),
 			smb_fname->base_name,
 			buf,
@@ -3266,6 +3261,9 @@ static int vfswrap_linkat(vfs_handle_struct *handle,
 
 	START_PROFILE(syscall_linkat);
 
+	SMB_ASSERT(!is_named_stream(old_smb_fname));
+	SMB_ASSERT(!is_named_stream(new_smb_fname));
+
 	result = linkat(fsp_get_pathref_fd(srcfsp),
 			old_smb_fname->base_name,
 			fsp_get_pathref_fd(dstfsp),
@@ -3286,6 +3284,8 @@ static int vfswrap_mknodat(vfs_handle_struct *handle,
 
 	START_PROFILE(syscall_mknodat);
 
+	SMB_ASSERT(!is_named_stream(smb_fname));
+
 	result = sys_mknodat(fsp_get_pathref_fd(dirfsp),
 			smb_fname->base_name,
 			mode,
@@ -3324,6 +3324,8 @@ static int vfswrap_fchflags(vfs_handle_struct *handle,
 #ifdef HAVE_FCHFLAGS
 	int fd = fsp_get_pathref_fd(fsp);
 
+	SMB_ASSERT(!fsp_is_alternate_stream(fsp));
+
 	if (!fsp->fsp_flags.is_pathref) {
 		return fchflags(fd, flags);
 	}
@@ -3395,6 +3397,8 @@ static NTSTATUS vfswrap_fstreaminfo(vfs_handle_struct *handle,
 	struct stream_struct *streams = *pstreams;
 	NTSTATUS status;
 
+	SMB_ASSERT(!fsp_is_alternate_stream(fsp));
+
 	if (fsp->fsp_flags.is_directory) {
 		/*
 		 * No default streams on directories
@@ -3495,6 +3499,9 @@ static NTSTATUS vfswrap_fget_nt_acl(vfs_handle_struct *handle,
 	NTSTATUS result;
 
 	START_PROFILE(fget_nt_acl);
+
+	SMB_ASSERT(!fsp_is_alternate_stream(fsp));
+
 	result = posix_fget_nt_acl(fsp, security_info,
 				   mem_ctx, ppdesc);
 	END_PROFILE(fget_nt_acl);
@@ -3506,6 +3513,9 @@ static NTSTATUS vfswrap_fset_nt_acl(vfs_handle_struct *handle, files_struct *fsp
 	NTSTATUS result;
 
 	START_PROFILE(fset_nt_acl);
+
+	SMB_ASSERT(!fsp_is_alternate_stream(fsp));
+
 	result = set_nt_acl(fsp, security_info_sent, psd);
 	END_PROFILE(fset_nt_acl);
 	return result;
@@ -3525,6 +3535,8 @@ static SMB_ACL_T vfswrap_sys_acl_get_fd(vfs_handle_struct *handle,
 					SMB_ACL_TYPE_T type,
 					TALLOC_CTX *mem_ctx)
 {
+	SMB_ASSERT(!fsp_is_alternate_stream(fsp));
+
 	return sys_acl_get_fd(handle, fsp, type, mem_ctx);
 }
 
@@ -3533,12 +3545,16 @@ static int vfswrap_sys_acl_set_fd(vfs_handle_struct *handle,
 				  SMB_ACL_TYPE_T type,
 				  SMB_ACL_T theacl)
 {
+	SMB_ASSERT(!fsp_is_alternate_stream(fsp));
+
 	return sys_acl_set_fd(handle, fsp, type, theacl);
 }
 
 static int vfswrap_sys_acl_delete_def_fd(vfs_handle_struct *handle,
 					 files_struct *fsp)
 {
+	SMB_ASSERT(!fsp_is_alternate_stream(fsp));
+
 	return sys_acl_delete_def_fd(handle, fsp);
 }
 
@@ -3554,6 +3570,8 @@ static ssize_t vfswrap_fgetxattr(struct vfs_handle_struct *handle,
 {
 	int fd = fsp_get_pathref_fd(fsp);
 
+	SMB_ASSERT(!fsp_is_alternate_stream(fsp));
+
 	if (!fsp->fsp_flags.is_pathref) {
 		return fgetxattr(fd, name, value, size);
 	}
@@ -3624,6 +3642,8 @@ static struct tevent_req *vfswrap_getxattrat_send(
 	bool have_per_thread_creds = false;
 	bool do_async = false;
 
+	SMB_ASSERT(!is_named_stream(smb_fname));
+
 	req = tevent_req_create(mem_ctx, &state,
 				struct vfswrap_getxattrat_state);
 	if (req == NULL) {
@@ -3730,10 +3750,9 @@ static void vfswrap_getxattrat_do_sync(struct tevent_req *req)
 {
 	struct vfswrap_getxattrat_state *state = tevent_req_data(
 		req, struct vfswrap_getxattrat_state);
-	struct files_struct *fsp = metadata_fsp(state->smb_fname->fsp);
 
 	state->xattr_size = vfswrap_fgetxattr(state->handle,
-					      fsp,
+					      state->smb_fname->fsp,
 					      state->xattr_name,
 					      state->xattr_value,
 					      talloc_array_length(state->xattr_value));
@@ -3753,7 +3772,6 @@ static void vfswrap_getxattrat_do_async(void *private_data)
 	struct timespec start_time;
 	struct timespec end_time;
 	int ret;
-	struct files_struct *fsp = metadata_fsp(state->smb_fname->fsp);
 
 	PROFILE_TIMESTAMP(&start_time);
 	SMBPROFILE_BYTES_ASYNC_SET_BUSY(state->profile_bytes);
@@ -3777,7 +3795,7 @@ static void vfswrap_getxattrat_do_async(void *private_data)
 	}
 
 	state->xattr_size = vfswrap_fgetxattr(state->handle,
-					      fsp,
+					      state->smb_fname->fsp,
 					      state->xattr_name,
 					      state->xattr_value,
 					      talloc_array_length(state->xattr_value));
@@ -3878,6 +3896,8 @@ static ssize_t vfswrap_flistxattr(struct vfs_handle_struct *handle, struct files
 {
 	int fd = fsp_get_pathref_fd(fsp);
 
+	SMB_ASSERT(!fsp_is_alternate_stream(fsp));
+
 	if (!fsp->fsp_flags.is_pathref) {
 		return flistxattr(fd, list, size);
 	}
@@ -3904,6 +3924,8 @@ static int vfswrap_fremovexattr(struct vfs_handle_struct *handle, struct files_s
 {
 	int fd = fsp_get_pathref_fd(fsp);
 
+	SMB_ASSERT(!fsp_is_alternate_stream(fsp));
+
 	if (!fsp->fsp_flags.is_pathref) {
 		return fremovexattr(fd, name);
 	}
@@ -3930,6 +3952,8 @@ static int vfswrap_fsetxattr(struct vfs_handle_struct *handle, struct files_stru
 {
 	int fd = fsp_get_pathref_fd(fsp);
 
+	SMB_ASSERT(!fsp_is_alternate_stream(fsp));
+
 	if (!fsp->fsp_flags.is_pathref) {
 		return fsetxattr(fd, name, value, size, flags);
 	}
diff --git a/source3/modules/vfs_streams_xattr.c b/source3/modules/vfs_streams_xattr.c
index 3dfb894a800..f3371ca9b7e 100644
--- a/source3/modules/vfs_streams_xattr.c
+++ b/source3/modules/vfs_streams_xattr.c
@@ -1539,6 +1539,38 @@ static bool streams_xattr_strict_lock_check(struct vfs_handle_struct *handle,
 	return true;
 }
 
+static int streams_xattr_fcntl(vfs_handle_struct *handle,
+			       files_struct *fsp,
+			       int cmd,
+			       va_list cmd_arg)
+{
+	va_list dup_cmd_arg;
+	void *arg;
+	int ret;
+
+	if (fsp_is_alternate_stream(fsp)) {
+		switch (cmd) {
+		case F_GETFL:
+		case F_SETFL:
+			break;
+		default:
+			DBG_ERR("Unsupported fcntl() cmd [%d] on [%s]\n",
+				cmd, fsp_str_dbg(fsp));
+			errno = EINVAL;
+			return -1;
+		}
+	}
+
+	va_copy(dup_cmd_arg, cmd_arg);
+	arg = va_arg(dup_cmd_arg, void *);
+
+	ret = SMB_VFS_NEXT_FCNTL(handle, fsp, cmd, arg);
+
+	va_end(dup_cmd_arg);
+
+	return ret;
+}
+
 static struct vfs_fn_pointers vfs_streams_xattr_fns = {
 	.fs_capabilities_fn = streams_xattr_fs_capabilities,
 	.connect_fn = streams_xattr_connect,
@@ -1567,6 +1599,7 @@ static struct vfs_fn_pointers vfs_streams_xattr_fns = {
 	.filesystem_sharemode_fn = streams_xattr_filesystem_sharemode,
 	.linux_setlease_fn = streams_xattr_linux_setlease,
 	.strict_lock_check_fn = streams_xattr_strict_lock_check,
+	.fcntl_fn = streams_xattr_fcntl,
 
 	.fchown_fn = streams_xattr_fchown,
 	.fchmod_fn = streams_xattr_fchmod,
diff --git a/source3/modules/vfs_xattr_tdb.c b/source3/modules/vfs_xattr_tdb.c
index 07b95899d80..261ebc2b213 100644
--- a/source3/modules/vfs_xattr_tdb.c
+++ b/source3/modules/vfs_xattr_tdb.c
@@ -29,7 +29,21 @@
 #undef DBGC_CLASS
 #define DBGC_CLASS DBGC_VFS
 
-static bool xattr_tdb_init(int snum, TALLOC_CTX *mem_ctx, struct db_context **p_db);
+struct xattr_tdb_config {
+	struct db_context *db;
+	bool ignore_user_xattr;
+};
+
+static bool xattr_tdb_init(struct vfs_handle_struct *handle,
+			   struct xattr_tdb_config **_config);
+
+static bool is_user_xattr(const char *xattr_name)
+{
+	int match;
+
+	match = strncmp(xattr_name, "user.", strlen("user."));
+	return (match == 0);
+}
 
 static int xattr_tdb_get_file_id(struct vfs_handle_struct *handle,
 				const char *path, struct file_id *id)
@@ -68,6 +82,8 @@ struct xattr_tdb_getxattrat_state {
 	uint8_t *xattr_value;
 };
 
+static void xattr_tdb_getxattrat_done(struct tevent_req *subreq);
+
 static struct tevent_req *xattr_tdb_getxattrat_send(
 			TALLOC_CTX *mem_ctx,
 			struct tevent_context *ev,
@@ -77,16 +93,21 @@ static struct tevent_req *xattr_tdb_getxattrat_send(
 			const char *xattr_name,
 			size_t alloc_hint)
 {
+	struct xattr_tdb_config *config = NULL;
 	struct tevent_req *req = NULL;
+	struct tevent_req *subreq = NULL;
 	struct xattr_tdb_getxattrat_state *state = NULL;
 	struct smb_filename *cwd = NULL;
-	struct db_context *db = NULL;
 	struct file_id id;
 	int ret;
 	int error;
 	int cwd_ret;
 	DATA_BLOB xattr_blob;
 
+	if (!xattr_tdb_init(handle, &config)) {
+		return NULL;
+	}
+
 	req = tevent_req_create(mem_ctx, &state,
 				struct xattr_tdb_getxattrat_state);
 	if (req == NULL) {
@@ -94,11 +115,20 @@ static struct tevent_req *xattr_tdb_getxattrat_send(
 	}
 	state->xattr_size = -1;
 
-	SMB_VFS_HANDLE_GET_DATA(handle, db, struct db_context,
-				if (!xattr_tdb_init(-1, state, &db)) {
-					tevent_req_error(req, EIO);
-					return tevent_req_post(req, ev);
-				});
+	if (config->ignore_user_xattr && is_user_xattr(xattr_name)) {
+		subreq = SMB_VFS_NEXT_GETXATTRAT_SEND(state,


-- 
Samba Shared Repository



More information about the samba-cvs mailing list