The Samba-Bugzilla – Attachment 17897 Details for
Bug 15375
Symlinks to files can have random DOS mode information in a directory listing
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch for 4.18 cherry-picked from master
v418-bug15375.patch (text/plain), 6.57 KB, created by
Ralph Böhme
on 2023-05-26 13:46:29 UTC
(
hide
)
Description:
Patch for 4.18 cherry-picked from master
Filename:
MIME Type:
Creator:
Ralph Böhme
Created:
2023-05-26 13:46:29 UTC
Size:
6.57 KB
patch
obsolete
>From 422337deda88dd45ba1e6c2fcaaa71d2ba59c5ba Mon Sep 17 00:00:00 2001 >From: Ralph Boehme <slow@samba.org> >Date: Wed, 24 May 2023 13:13:19 +0200 >Subject: [PATCH 1/3] CI: add a test that checks the dosmode of symlinks > >BUG: https://bugzilla.samba.org/show_bug.cgi?id=15375 > >Signed-off-by: Ralph Boehme <slow@samba.org> >Reviewed-by: Jeremy Allison <jra@samba.org> >(cherry picked from commit b4af281b2d7bfddbdb7289dadbed9db623bf0e84) >--- > .../samba3.blackbox.test_symlink_dosmode | 1 + > source3/script/tests/test_symlink_dosmode.sh | 74 +++++++++++++++++++ > source3/selftest/tests.py | 4 + > 3 files changed, 79 insertions(+) > create mode 100644 selftest/knownfail.d/samba3.blackbox.test_symlink_dosmode > create mode 100755 source3/script/tests/test_symlink_dosmode.sh > >diff --git a/selftest/knownfail.d/samba3.blackbox.test_symlink_dosmode b/selftest/knownfail.d/samba3.blackbox.test_symlink_dosmode >new file mode 100644 >index 000000000000..93546ab0ba4e >--- /dev/null >+++ b/selftest/knownfail.d/samba3.blackbox.test_symlink_dosmode >@@ -0,0 +1 @@ >+^samba3.blackbox.test_symlink_dosmode.symlink_dosmode\(fileserver\) >diff --git a/source3/script/tests/test_symlink_dosmode.sh b/source3/script/tests/test_symlink_dosmode.sh >new file mode 100755 >index 000000000000..dd6cb6be4722 >--- /dev/null >+++ b/source3/script/tests/test_symlink_dosmode.sh >@@ -0,0 +1,74 @@ >+#!/bin/sh >+ >+if [ $# -lt 7 ]; then >+ cat <<EOF >+Usage: test_symlink_dosmode.sh SERVER SERVER_IP USERNAME PASSWORD LOCAL_PATH PREFIX SMBCLIENT >+EOF >+ exit 1 >+fi >+ >+SERVER="${1}" >+SERVER_IP="${2}" >+USERNAME="${3}" >+PASSWORD="${4}" >+LOCAL_PATH="${5}" >+PREFIX="${6}" >+SMBCLIENT="${7}" >+SMBCLIENT="$VALGRIND ${SMBCLIENT}" >+shift 6 >+ >+incdir=$(dirname "$0")/../../../testprogs/blackbox >+. "$incdir"/subunit.sh >+ >+failed=0 >+ >+# Do not let deprecated option warnings muck this up >+SAMBA_DEPRECATED_SUPPRESS=1 >+export SAMBA_DEPRECATED_SUPPRESS >+ >+# Define the test environment/filenames. >+# >+share_test_dir="$LOCAL_PATH" >+ >+rm -rf "$share_test_dir/testdir" >+ >+mkdir -p "$share_test_dir/testdir/dir" >+touch "$share_test_dir/testdir/file" >+ln -s "../file" "$share_test_dir/testdir/dir/symlink" >+ >+test_symlink_dosmode() >+{ >+ tmpfile=$PREFIX/smbclient_interactive_prompt_commands >+ cat >"$tmpfile" <<EOF >+ls testdir/dir/* >+quit >+EOF >+ cmd='CLI_FORCE_INTERACTIVE=yes $SMBCLIENT -U$USERNAME%$PASSWORD //$SERVER/local_symlinks -I$SERVER_IP < $tmpfile 2>&1' >+ eval echo "$cmd" >+ out=$(eval "$cmd") >+ ret=$? >+ rm -f "$tmpfile" >+ >+ if [ $ret != 0 ]; then >+ printf "%s\n" "$out" >+ printf "failed accessing local_symlinks with error %s\n" "$ret" >+ return 1 >+ fi >+ >+ mode=$(printf "%s" "$out" | awk '/symlink/ {print $2}') >+ echo "mode: $mode" >+ if [ x"$mode" != x"N" ] ; then >+ printf "Bad mode: '%s', expected 'N'\n" "$mode" >+ printf "%s\n" "$out" >+ return 1 >+ fi >+ return 0 >+} >+ >+testit "symlink_dosmode" \ >+ test_symlink_dosmode || >+ failed=$((failed + 1)) >+ >+rm -rf "$share_test_dir/testdir" >+ >+testok "$0" "$failed" >diff --git a/source3/selftest/tests.py b/source3/selftest/tests.py >index fc3227be9b50..f24f67791508 100755 >--- a/source3/selftest/tests.py >+++ b/source3/selftest/tests.py >@@ -777,6 +777,10 @@ plantestsuite("samba3.blackbox.smbclient_s3.SMB3.crypt", env, [os.path.join(samb > [os.path.join(samba3srcdir, "script/tests/test_stream_dir_rename.sh"), > '$SERVER', '$USERNAME', '$PASSWORD', '$PREFIX', smbclient3]) > >+ plantestsuite("samba3.blackbox.test_symlink_dosmode", env, >+ [os.path.join(samba3srcdir, "script/tests/test_symlink_dosmode.sh"), >+ '$SERVER', '$SERVER_IP', '$USERNAME', '$PASSWORD', '$LOCAL_PATH/local_symlinks', >+ '$PREFIX', smbclient3]) > # > # tar command tests > # >-- >2.40.0 > > >From 070c3aace988fd11ce84b4ed2b32cf0b54917d9c Mon Sep 17 00:00:00 2001 >From: Ralph Boehme <slow@samba.org> >Date: Tue, 23 May 2023 17:23:28 +0200 >Subject: [PATCH 2/3] smbd: zero intialize SMB_STRUCT_STAT in vfswrap_readdir() > >Avoid returning an uninitialized st.cached_dos_attributes. > >BUG: https://bugzilla.samba.org/show_bug.cgi?id=15375 > >Signed-off-by: Ralph Boehme <slow@samba.org> >Reviewed-by: Jeremy Allison <jra@samba.org> >(cherry picked from commit 0391120079b032077c3914c10189b85e61dc8498) >--- > selftest/knownfail.d/samba3.blackbox.test_symlink_dosmode | 1 - > source3/modules/vfs_default.c | 2 +- > 2 files changed, 1 insertion(+), 2 deletions(-) > delete mode 100644 selftest/knownfail.d/samba3.blackbox.test_symlink_dosmode > >diff --git a/selftest/knownfail.d/samba3.blackbox.test_symlink_dosmode b/selftest/knownfail.d/samba3.blackbox.test_symlink_dosmode >deleted file mode 100644 >index 93546ab0ba4e..000000000000 >--- a/selftest/knownfail.d/samba3.blackbox.test_symlink_dosmode >+++ /dev/null >@@ -1 +0,0 @@ >-^samba3.blackbox.test_symlink_dosmode.symlink_dosmode\(fileserver\) >diff --git a/source3/modules/vfs_default.c b/source3/modules/vfs_default.c >index 000c23208f56..89eec1146d74 100644 >--- a/source3/modules/vfs_default.c >+++ b/source3/modules/vfs_default.c >@@ -603,7 +603,7 @@ static struct dirent *vfswrap_readdir(vfs_handle_struct *handle, > struct dirent *result; > bool fake_ctime = lp_fake_directory_create_times(SNUM(handle->conn)); > int flags = AT_SYMLINK_NOFOLLOW; >- SMB_STRUCT_STAT st; >+ SMB_STRUCT_STAT st = {0}; > int ret; > > START_PROFILE(syscall_readdir); >-- >2.40.0 > > >From 89d7ab55d41119df9676cb70b114b0c73bba1149 Mon Sep 17 00:00:00 2001 >From: Ralph Boehme <slow@samba.org> >Date: Tue, 23 May 2023 17:26:03 +0200 >Subject: [PATCH 3/3] smbd: also reset struct stat_ex.cached_dos_attributes in > SET_STAT_INVALID() > >BUG: https://bugzilla.samba.org/show_bug.cgi?id=15375 > >Signed-off-by: Ralph Boehme <slow@samba.org> >Reviewed-by: Jeremy Allison <jra@samba.org> > >Autobuild-User(master): Jeremy Allison <jra@samba.org> >Autobuild-Date(master): Wed May 24 21:42:50 UTC 2023 on atb-devel-224 > >(cherry picked from commit 412373984db6d0c20ba38076d06d0a87631890d0) >--- > source3/include/smb_macros.h | 5 ++++- > 1 file changed, 4 insertions(+), 1 deletion(-) > >diff --git a/source3/include/smb_macros.h b/source3/include/smb_macros.h >index 0f44d1402a85..42ff9ffb0d45 100644 >--- a/source3/include/smb_macros.h >+++ b/source3/include/smb_macros.h >@@ -108,7 +108,10 @@ > > #define VALID_STAT(st) ((st).st_ex_nlink != 0) > #define VALID_STAT_OF_DIR(st) (VALID_STAT(st) && S_ISDIR((st).st_ex_mode)) >-#define SET_STAT_INVALID(st) ((st).st_ex_nlink = 0) >+#define SET_STAT_INVALID(st) { \ >+ (st).st_ex_nlink = 0; \ >+ (st).cached_dos_attributes = FILE_ATTRIBUTES_INVALID; \ >+}; > > /* Macros to get at offsets within smb_lkrng and smb_unlkrng > structures. We cannot define these as actual structures >-- >2.40.0 >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Raw
Flags:
jra
:
review+
Actions:
View
Attachments on
bug 15375
:
17896
| 17897