smbd: Prevent creation of vetoed files
authorRalph Boehme <slow@samba.org>
Wed, 5 Apr 2023 09:03:52 +0000 (11:03 +0200)
committerJule Anger <janger@samba.org>
Tue, 11 Apr 2023 15:09:09 +0000 (15:09 +0000)
commitd477f6fa70a7db5a13655cb6aab1df4b251a4832
tree55fef0b58c34e758ec4838f3336cefd4425bbeeb
parentc3582deb5a01b686ecad7254cb087effbaf062d3
smbd: Prevent creation of vetoed files

The problem is when checking for vetoed names on the last path component in
openat_pathref_fsp_case_insensitive() we return
NT_STATUS_OBJECT_NAME_NOT_FOUND. The in the caller
filename_convert_dirfsp_nosymlink() this is treated as the "file creation case"
causing filename_convert_dirfsp_nosymlink() to return NT_STATUS_OK.

In order to correctly distinguish between the cases

1) file doesn't exist, we may be creating it, return
2) a vetoed a file

we need 2) to return a more specific error to
filename_convert_dirfsp_nosymlink(). I've chosen NT_STATUS_OBJECT_NAME_INVALID
which gets mapped to the appropriate errror NT_STATUS_OBJECT_PATH_NOT_FOUND or
NT_STATUS_OBJECT_NAME_NOT_FOUND depending on which path component was vetoed.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=15143

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): Thu Apr  6 23:03:50 UTC 2023 on atb-devel-224

(cherry picked from commit 8b23a4a7eca9b8f80cc4113bb8cf9bb7bd5b4807)
selftest/knownfail.d/samba3.blackbox.test_veto_files.get_veto_file [deleted file]
source3/smbd/filename.c