From 3cee7fbe6916098eda125bd69127b8596d997f4f Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Thu, 11 Aug 2022 09:51:11 -0700 Subject: [PATCH 1/3] s3: tests: Add samba3.blackbox.test_veto_files. Shows we currently don't look at smb.conf veto files parameter when opening a file. Add knownfail. BUG: https://bugzilla.samba.org/show_bug.cgi?id=15143 Signed-off-by: Jeremy Allison --- selftest/knownfail.d/veto_files | 1 + selftest/target/Samba3.pm | 4 + source3/script/tests/test_veto_files.sh | 125 ++++++++++++++++++++++++ source3/selftest/tests.py | 4 + 4 files changed, 134 insertions(+) create mode 100644 selftest/knownfail.d/veto_files create mode 100755 source3/script/tests/test_veto_files.sh diff --git a/selftest/knownfail.d/veto_files b/selftest/knownfail.d/veto_files new file mode 100644 index 00000000000..ad7d841a033 --- /dev/null +++ b/selftest/knownfail.d/veto_files @@ -0,0 +1 @@ +^samba3.blackbox.test_veto_files.get_veto_file\(fileserver\) diff --git a/selftest/target/Samba3.pm b/selftest/target/Samba3.pm index 2313f6fce36..ecff6da2cec 100755 --- a/selftest/target/Samba3.pm +++ b/selftest/target/Samba3.pm @@ -1914,6 +1914,10 @@ sub setup_fileserver path = $veto_sharedir delete veto files = yes +[veto_files] + path = $veto_sharedir + veto files = /veto_name*/ + [delete_yes_unwrite] read only = no path = $delete_unwrite_sharedir diff --git a/source3/script/tests/test_veto_files.sh b/source3/script/tests/test_veto_files.sh new file mode 100755 index 00000000000..d2ca3179f79 --- /dev/null +++ b/source3/script/tests/test_veto_files.sh @@ -0,0 +1,125 @@ +#!/bin/sh +# +# Check smbclient cannot get a file that matches a veto files +# parameter, or inside a directory that matches a veto files +# parameter. +# +# BUG: https://bugzilla.samba.org/show_bug.cgi?id=15143 +# + +if [ $# -lt 6 ]; then + cat <"$tmpfile" <"$tmpfile" < Date: Thu, 11 Aug 2022 09:55:56 -0700 Subject: [PATCH 2/3] s3: smbd: Add IS_VETO_PATH check to filename_convert_dirfsp_nosymlink(). Returns NT_STATUS_OBJECT_PATH_NOT_FOUND for directory component. BUG: https://bugzilla.samba.org/show_bug.cgi?id=15143 Signed-off-by: Jeremy Allison --- source3/smbd/filename.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/source3/smbd/filename.c b/source3/smbd/filename.c index 2baff7b0adf..cf1e3a193ec 100644 --- a/source3/smbd/filename.c +++ b/source3/smbd/filename.c @@ -1171,6 +1171,14 @@ static NTSTATUS filename_convert_dirfsp_nosymlink( goto fail; } + /* Check veto files. */ + if (IS_VETO_PATH(conn, smb_dirname->base_name)) { + DBG_DEBUG("veto files rejecting directory %s\n", + smb_fname_str_dbg(smb_dirname)); + status = NT_STATUS_OBJECT_PATH_NOT_FOUND; + goto fail; + } + /* * Only look at bad last component values * once we know we have a valid directory. That -- 2.34.1 From 4db19b308f9887d7a5b502016758c69ec0b99cca Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Thu, 11 Aug 2022 10:03:58 -0700 Subject: [PATCH 3/3] s3: smbd: Add IS_VETO_PATH check to filename_convert_dirfsp_nosymlink(). Returns NT_STATUS_OBJECT_NAME_NOT_FOUND for file component. Remove knownfail. BUG: https://bugzilla.samba.org/show_bug.cgi?id=15143 Signed-off-by: Jeremy Allison --- selftest/knownfail.d/veto_files | 1 - source3/smbd/filename.c | 8 ++++++++ 2 files changed, 8 insertions(+), 1 deletion(-) delete mode 100644 selftest/knownfail.d/veto_files diff --git a/selftest/knownfail.d/veto_files b/selftest/knownfail.d/veto_files deleted file mode 100644 index ad7d841a033..00000000000 --- a/selftest/knownfail.d/veto_files +++ /dev/null @@ -1 +0,0 @@ -^samba3.blackbox.test_veto_files.get_veto_file\(fileserver\) diff --git a/source3/smbd/filename.c b/source3/smbd/filename.c index cf1e3a193ec..c511089d950 100644 --- a/source3/smbd/filename.c +++ b/source3/smbd/filename.c @@ -1236,6 +1236,14 @@ static NTSTATUS filename_convert_dirfsp_nosymlink( goto fail; } + /* Check veto files. */ + if (IS_VETO_PATH(conn, smb_fname_rel->base_name)) { + DBG_DEBUG("veto files rejecting file %s\n", + smb_fname_str_dbg(smb_fname_rel)); + status = NT_STATUS_OBJECT_NAME_NOT_FOUND; + goto fail; + } + status = openat_pathref_fsp_case_insensitive( smb_dirname->fsp, smb_fname_rel, ucf_flags); -- 2.34.1