[SCM] Samba Shared Repository - branch master updated

Jeremy Allison jra at samba.org
Fri Oct 27 21:20:01 UTC 2023


The branch, master has been updated
       via  952d6c2cf48 smbd: Fix read_symlink_reparse()
       via  cc1657c5857 tests: Get a file through an absolute symlink within a subdirectory
      from  03af1176938 gp_pol: Test multiple values multi_sz roundtrip

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


- Log -----------------------------------------------------------------
commit 952d6c2cf48b19807e96a49b95c19c224bd6e732
Author: Volker Lendecke <vl at samba.org>
Date:   Thu Oct 26 16:12:29 2023 +0200

    smbd: Fix read_symlink_reparse()
    
    Bug: https://bugzilla.samba.org/show_bug.cgi?id=15505
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>
    
    Autobuild-User(master): Jeremy Allison <jra at samba.org>
    Autobuild-Date(master): Fri Oct 27 21:19:35 UTC 2023 on atb-devel-224

commit cc1657c5857f22d41830898ef2eb384d5fc52a42
Author: Volker Lendecke <vl at samba.org>
Date:   Thu Oct 26 16:16:29 2023 +0200

    tests: Get a file through an absolute symlink within a subdirectory
    
    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 at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

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

Summary of changes:
 source3/script/tests/test_smbclient_s3.sh | 39 +++++++++++++++++++++++++++++++
 source3/smbd/files.c                      | 14 ++++++++---
 2 files changed, 50 insertions(+), 3 deletions(-)


Changeset truncated at 500 lines:

diff --git a/source3/script/tests/test_smbclient_s3.sh b/source3/script/tests/test_smbclient_s3.sh
index cbff5026ee7..e4b05b12dfa 100755
--- a/source3/script/tests/test_smbclient_s3.sh
+++ b/source3/script/tests/test_smbclient_s3.sh
@@ -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
 
diff --git a/source3/smbd/files.c b/source3/smbd/files.c
index d19cbcc0dda..1bbf822df28 100644
--- a/source3/smbd/files.c
+++ b/source3/smbd/files.c
@@ -752,11 +752,19 @@ NTSTATUS read_symlink_reparse(
 	}
 
 	if (symlink->substitute_name[0] == '/') {
-		const char *connectpath = dirfsp->conn->connectpath;
+		char *subdir_path = NULL;
 		char *abs_target_canon = NULL;
 		const char *relative = NULL;
 		bool in_share;
 
+		subdir_path = talloc_asprintf(talloc_tos(),
+					      "%s/%s",
+					      dirfsp->conn->connectpath,
+					      dirfsp->fsp_name->base_name);
+		if (subdir_path == NULL) {
+			goto nomem;
+		}
+
 		abs_target_canon =
 			canonicalize_absolute_path(talloc_tos(),
 						   symlink->substitute_name);
@@ -764,8 +772,8 @@ NTSTATUS read_symlink_reparse(
 			goto nomem;
 		}
 
-		in_share = subdir_of(connectpath,
-				     strlen(connectpath),
+		in_share = subdir_of(subdir_path,
+				     strlen(subdir_path),
 				     abs_target_canon,
 				     &relative);
 		if (in_share) {


-- 
Samba Shared Repository



More information about the samba-cvs mailing list