From 422337deda88dd45ba1e6c2fcaaa71d2ba59c5ba Mon Sep 17 00:00:00 2001 From: Ralph Boehme 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 Reviewed-by: Jeremy Allison (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 <"$tmpfile" < 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 Reviewed-by: Jeremy Allison (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 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 Reviewed-by: Jeremy Allison Autobuild-User(master): Jeremy Allison 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