The branch, master has been updated via 412373984db smbd: also reset struct stat_ex.cached_dos_attributes in SET_STAT_INVALID() via 0391120079b smbd: zero intialize SMB_STRUCT_STAT in vfswrap_readdir() via b4af281b2d7 CI: add a test that checks the dosmode of symlinks from a5235a9d05b librpc/idl: Alias the DS_ constants in netlogon.idl to the NBT_SERVER equivilants
https://git.samba.org/?p=samba.git;a=shortlog;h=master - Log ----------------------------------------------------------------- commit 412373984db6d0c20ba38076d06d0a87631890d0 Author: Ralph Boehme <s...@samba.org> Date: Tue May 23 17:26:03 2023 +0200 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 <s...@samba.org> Reviewed-by: Jeremy Allison <j...@samba.org> Autobuild-User(master): Jeremy Allison <j...@samba.org> Autobuild-Date(master): Wed May 24 21:42:50 UTC 2023 on atb-devel-224 commit 0391120079b032077c3914c10189b85e61dc8498 Author: Ralph Boehme <s...@samba.org> Date: Tue May 23 17:23:28 2023 +0200 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 <s...@samba.org> Reviewed-by: Jeremy Allison <j...@samba.org> commit b4af281b2d7bfddbdb7289dadbed9db623bf0e84 Author: Ralph Boehme <s...@samba.org> Date: Wed May 24 13:13:19 2023 +0200 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 <s...@samba.org> Reviewed-by: Jeremy Allison <j...@samba.org> ----------------------------------------------------------------------- Summary of changes: source3/include/smb_macros.h | 5 +- source3/modules/vfs_default.c | 2 +- source3/script/tests/test_symlink_dosmode.sh | 74 ++++++++++++++++++++++++++++ source3/selftest/tests.py | 4 ++ 4 files changed, 83 insertions(+), 2 deletions(-) create mode 100755 source3/script/tests/test_symlink_dosmode.sh Changeset truncated at 500 lines: diff --git a/source3/include/smb_macros.h b/source3/include/smb_macros.h index 0f44d1402a8..42ff9ffb0d4 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 diff --git a/source3/modules/vfs_default.c b/source3/modules/vfs_default.c index 000c23208f5..89eec1146d7 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); diff --git a/source3/script/tests/test_symlink_dosmode.sh b/source3/script/tests/test_symlink_dosmode.sh new file mode 100755 index 00000000000..dd6cb6be472 --- /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 55087f922c1..76bc90df1ad 100755 --- a/source3/selftest/tests.py +++ b/source3/selftest/tests.py @@ -784,6 +784,10 @@ for env in ["fileserver"]: [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 # -- Samba Shared Repository