]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
tests: Get a file through an absolute symlink within a subdirectory
authorVolker Lendecke <vl@samba.org>
Thu, 26 Oct 2023 14:16:29 +0000 (16:16 +0200)
committerJeremy Allison <jra@samba.org>
Fri, 27 Oct 2023 20:14:30 +0000 (20:14 +0000)
This shows that read_symlink_reparse() is broken when trying to
replace an absolute with a relative filename within a
share.

read_symlink_reparse() is used only in openat_pathref_fsp_nosymlink()
so far to chase symlinks for non-lcomp path components. Chasing lcomp
symlinks is done through non_widelink_open(), which gets it right.

Bug: https://bugzilla.samba.org/show_bug.cgi?id=15505

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
selftest/knownfail.d/bug-15505 [new file with mode: 0644]
source3/script/tests/test_smbclient_s3.sh

diff --git a/selftest/knownfail.d/bug-15505 b/selftest/knownfail.d/bug-15505
new file mode 100644 (file)
index 0000000..9f24496
--- /dev/null
@@ -0,0 +1 @@
+^samba3.blackbox.smbclient_s3.*.follow\ local\ symlinks.*
\ No newline at end of file
index cbff5026ee7b6df4376c3091b9ffd42ba724e0e9..e4b05b12dfaf46883226694003c2f2ef20707235 100755 (executable)
@@ -1492,6 +1492,17 @@ EOF
                return
        fi
 
+       # Create a file to be accessed behind the symlink
+       touch $local_slink_target_dir/x
+       ret=$?
+       if [ $ret -ne 0 ]; then
+               echo "$out"
+               echo "failed - unable to create file"
+               ls -la $local_test_dir
+               false
+               return
+       fi
+
        # Can we cd into the symlink name and ls ?
        tmpfile=$PREFIX/smbclient_interactive_prompt_commands
        cat >$tmpfile <<EOF
@@ -1521,6 +1532,34 @@ EOF
                return
        fi
 
+       # Can we get the test file behind the symlink'ed dir?
+       tmpfile=$PREFIX/smbclient_interactive_prompt_commands
+       cat >$tmpfile <<EOF
+get $share_test_dir\\sym_name\\x -
+quit
+EOF
+       cmd='CLI_FORCE_INTERACTIVE=yes $SMBCLIENT "$@" -U$USERNAME%$PASSWORD //$SERVER/local_symlinks -I $SERVER_IP $LOCAL_ADDARGS < $tmpfile 2>&1'
+       eval echo "$cmd"
+       out=$(eval $cmd)
+       ret=$?
+       rm -f $tmpfile
+
+       if [ $ret -ne 0 ]; then
+               echo "$out"
+               echo "failed accessing local_symlinks with error $ret"
+               false
+               return
+       fi
+
+       echo "$out" | grep 'NT_STATUS_'
+       ret=$?
+       if [ $ret -eq 0 ]; then
+               echo "$out"
+               echo "failed - got an NT_STATUS error"
+               false
+               return
+       fi
+
        # CLEANUP
        rm -f $local_slink_name