The branch, master has been updated
       via  808a7b8b76d s3: VFS: streams_xattr: Add the same accommodation to 
streams_xattr_unlinkat() as used in streams_xattr_renameat().
       via  238b2cbb8f3 s3: tests: Add test that shows smbd crashes using 
vfs_fruit with fruit:resource = stream on deleting a file.
      from  81fdcf95ae9 s3/client: fix dfs deltree, resolve dfs path

https://git.samba.org/?p=samba.git;a=shortlog;h=master


- Log -----------------------------------------------------------------
commit 808a7b8b76dbcaac1db0508fd410d0bcf702af7a
Author: Jeremy Allison <j...@samba.org>
Date:   Fri Jun 17 17:51:35 2022 -0700

    s3: VFS: streams_xattr: Add the same accommodation to 
streams_xattr_unlinkat() as used in streams_xattr_renameat().
    
    vfs_fruit passes a synthetic filename here where smb_fname->fsp==NULL
    when configured to use "fruit:resource = stream" so we need to use
    synthetic_pathref() to get an fsp on the smb_fname->base_name
    in order to call SMB_VFS_FREMOVEXATTR().
    
    This is the same change we already use in streams_xattr_renameat()
    and streams_xattr_stat(), the other pathname operations we implement
    here.
    
    Remove knownfail.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=15099
    
    Signed-off-by: Jeremy Allison <j...@samba.org>
    Reviewed-by: Noel Power <npo...@samba.org>
    
    Autobuild-User(master): Noel Power <npo...@samba.org>
    Autobuild-Date(master): Mon Jun 20 14:24:20 UTC 2022 on sn-devel-184

commit 238b2cbb8f352375c448d86b462f13752640e16b
Author: Jeremy Allison <j...@samba.org>
Date:   Fri Jun 17 17:49:43 2022 -0700

    s3: tests: Add test that shows smbd crashes using vfs_fruit with 
fruit:resource = stream on deleting a file.
    
    Add knownfail.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=15099
    
    Signed-off-by: Jeremy Allison <j...@samba.org>
    Reviewed-by: Noel Power <npo...@samba.org>

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

Summary of changes:
 selftest/target/Samba3.pm                          |  9 +++++
 source3/modules/vfs_streams_xattr.c                | 25 +++++++++++--
 source3/script/tests/test_fruit_resource_stream.sh | 41 ++++++++++++++++++++++
 source3/selftest/tests.py                          |  4 +++
 4 files changed, 76 insertions(+), 3 deletions(-)
 create mode 100755 source3/script/tests/test_fruit_resource_stream.sh


Changeset truncated at 500 lines:

diff --git a/selftest/target/Samba3.pm b/selftest/target/Samba3.pm
index 798796bc21f..db8c55602da 100755
--- a/selftest/target/Samba3.pm
+++ b/selftest/target/Samba3.pm
@@ -2567,6 +2567,9 @@ sub provision($$)
        my $local_symlinks_shrdir="$shrdir/local_symlinks";
        push(@dirs,$local_symlinks_shrdir);
 
+       my $fruit_resource_stream_shrdir="$shrdir/fruit_resource_stream";
+       push(@dirs,$fruit_resource_stream_shrdir);
+
        # this gets autocreated by winbindd
        my $wbsockdir="$prefix_abs/wbsock";
 
@@ -3127,6 +3130,12 @@ sub provision($$)
        fruit:metadata = stream
        fruit:zero_file_id=yes
 
+[fruit_resource_stream]
+       path = $fruit_resource_stream_shrdir
+       vfs objects = fruit streams_xattr acl_xattr xattr_tdb
+       fruit:resource = stream
+       fruit:metadata = stream
+
 [badname-tmp]
        path = $badnames_shrdir
        guest ok = yes
diff --git a/source3/modules/vfs_streams_xattr.c 
b/source3/modules/vfs_streams_xattr.c
index 324490354b0..3e39770bb37 100644
--- a/source3/modules/vfs_streams_xattr.c
+++ b/source3/modules/vfs_streams_xattr.c
@@ -479,6 +479,8 @@ static int streams_xattr_unlinkat(vfs_handle_struct *handle,
        NTSTATUS status;
        int ret = -1;
        char *xattr_name = NULL;
+       struct smb_filename *pathref = NULL;
+       struct files_struct *fsp = smb_fname->fsp;
 
        if (!is_named_stream(smb_fname)) {
                return SMB_VFS_NEXT_UNLINKAT(handle,
@@ -497,10 +499,26 @@ static int streams_xattr_unlinkat(vfs_handle_struct 
*handle,
                goto fail;
        }
 
-       SMB_ASSERT(smb_fname->fsp != NULL);
-       SMB_ASSERT(fsp_is_alternate_stream(smb_fname->fsp));
+       if (fsp == NULL) {
+               status = synthetic_pathref(talloc_tos(),
+                                       handle->conn->cwd_fsp,
+                                       smb_fname->base_name,
+                                       NULL,
+                                       NULL,
+                                       smb_fname->twrp,
+                                       smb_fname->flags,
+                                       &pathref);
+               if (!NT_STATUS_IS_OK(status)) {
+                       errno = ENOENT;
+                       goto fail;
+               }
+               fsp = pathref->fsp;
+       } else {
+               SMB_ASSERT(fsp_is_alternate_stream(smb_fname->fsp));
+               fsp = fsp->base_fsp;
+       }
 
-       ret = SMB_VFS_FREMOVEXATTR(smb_fname->fsp->base_fsp, xattr_name);
+       ret = SMB_VFS_FREMOVEXATTR(fsp, xattr_name);
 
        if ((ret == -1) && (errno == ENOATTR)) {
                errno = ENOENT;
@@ -511,6 +529,7 @@ static int streams_xattr_unlinkat(vfs_handle_struct *handle,
 
  fail:
        TALLOC_FREE(xattr_name);
+       TALLOC_FREE(pathref);
        return ret;
 }
 
diff --git a/source3/script/tests/test_fruit_resource_stream.sh 
b/source3/script/tests/test_fruit_resource_stream.sh
new file mode 100755
index 00000000000..7e99ea3de5c
--- /dev/null
+++ b/source3/script/tests/test_fruit_resource_stream.sh
@@ -0,0 +1,41 @@
+#!/bin/sh
+
+# this tests copying a file and then deleting it
+# to a share using fruit:resource = stream
+# BUG: https://bugzilla.samba.org/show_bug.cgi?id=15099
+
+if [ $# -lt 6 ]; then
+       cat <<EOF
+Usage: $0 SERVER SHARE USERNAME PASSWORD LOCAL_PATH SMBCLIENT
+EOF
+       exit 1
+fi
+
+SERVER="${1}"
+SHARE="${2}"
+USERNAME="${3}"
+PASSWORD="${4}"
+LOCAL_PATH="${5}"
+SMBCLIENT="${6}"
+SMBCLIENT="$VALGRIND ${SMBCLIENT}"
+
+incdir=$(dirname "$0")/../../../testprogs/blackbox
+. "$incdir/subunit.sh"
+
+failed=0
+
+put_then_delete_file()
+{
+       $SMBCLIENT //"$SERVER"/"$SHARE" -U"$USERNAME"%"$PASSWORD" -c "lcd 
$LOCAL_PATH; put src dst; rm dst" >/dev/null 2>&1
+}
+
+rm -f "$LOCAL_PATH/src"
+rm -f "$LOCAL_PATH/dst"
+touch "$LOCAL_PATH/src"
+
+testit "resource_stream" put_then_delete_file || failed=$((failed + 1))
+
+rm -f "$LOCAL_PATH/src"
+rm -f "$LOCAL_PATH/dst"
+
+testok "$0" "$failed"
diff --git a/source3/selftest/tests.py b/source3/selftest/tests.py
index 2e62696cb82..c53be8b471b 100755
--- a/source3/selftest/tests.py
+++ b/source3/selftest/tests.py
@@ -676,6 +676,10 @@ for env in ["fileserver"]:
     plantestsuite("samba3.blackbox.test_full_audit_fail_badname", env,
                   [os.path.join(samba3srcdir, 
"script/tests/test_bad_auditnames.sh"),
                   '$SERVER', 'full_audit_fail_bad_name', '$USERNAME', 
'$PASSWORD', smbclient3])
+    plantestsuite("samba3.blackbox.fruit.resource_stream", env,
+                  [os.path.join(samba3srcdir, 
"script/tests/test_fruit_resource_stream.sh"),
+                  '$SERVER', 'fruit_resource_stream', '$USERNAME', '$PASSWORD',
+                  '$LOCAL_PATH/fruit_resource_stream', smbclient3])
 
 for env in ["fileserver:local"]:
     plantestsuite("samba3.blackbox.net_usershare", env, 
[os.path.join(samba3srcdir, "script/tests/test_net_usershare.sh"), '$SERVER', 
'$SERVER_IP', '$USERNAME', '$PASSWORD', smbclient3])


-- 
Samba Shared Repository

Reply via email to