From 17bbd6ec4c2607afeadd91a29c245054a6ca6828 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Wed, 14 Dec 2022 17:35:17 +0100 Subject: [PATCH] smbd: Add "posix" flag to openat_pathref_dirfsp_nosymlink() MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Don't do the get_real_filename() retry if we're in posix context of if the connection is case sensitive. The whole concept of case sensivity blows my brain. In SMB1 without posix extensions it's a per-request thing. In SMB2 without posix extensions this should just depend on "case sensitive = yes/no", and in future SMB2 posix extensions this will become a per-request thing again, depending on the existence of the posix create context. Then there are other semantics that are attached to posix-ness, which have nothing to do with case sensivity. See for example merge request 2819 and bug 8776, or commit f0e1137425f. Also see check_path_syntax_internal(). This patch uses the same flags as openat_pathref_fsp_case_insensitive() does, but I am 100% certain this is wrong in a subtle way. Signed-off-by: Volker Lendecke Reviewed-by: Ralph Boehme Autobuild-User(master): Ralph Böhme Autobuild-Date(master): Thu Dec 15 11:30:04 UTC 2022 on sn-devel-184 --- selftest/knownfail.d/posix_case_sensivity | 1 - source3/smbd/filename.c | 1 + source3/smbd/files.c | 8 +++++++- source3/smbd/proto.h | 1 + 4 files changed, 9 insertions(+), 2 deletions(-) delete mode 100644 selftest/knownfail.d/posix_case_sensivity diff --git a/selftest/knownfail.d/posix_case_sensivity b/selftest/knownfail.d/posix_case_sensivity deleted file mode 100644 index 895c9e3c848..00000000000 --- a/selftest/knownfail.d/posix_case_sensivity +++ /dev/null @@ -1 +0,0 @@ -samba.tests.smb1posix diff --git a/source3/smbd/filename.c b/source3/smbd/filename.c index c66e8b4b24e..0859e6fd5c3 100644 --- a/source3/smbd/filename.c +++ b/source3/smbd/filename.c @@ -1122,6 +1122,7 @@ static NTSTATUS filename_convert_dirfsp_nosymlink( conn, dirname, 0, + posix, &smb_dirname, &unparsed, &substitute); diff --git a/source3/smbd/files.c b/source3/smbd/files.c index ea1c31f4e85..3ea879eee3e 100644 --- a/source3/smbd/files.c +++ b/source3/smbd/files.c @@ -738,6 +738,7 @@ NTSTATUS openat_pathref_dirfsp_nosymlink( struct connection_struct *conn, const char *path_in, NTTIME twrp, + bool posix, struct smb_filename **_smb_fname, size_t *unparsed, char **substitute) @@ -746,14 +747,17 @@ NTSTATUS openat_pathref_dirfsp_nosymlink( struct smb_filename full_fname = { .base_name = NULL, .twrp = twrp, + .flags = posix ? SMB_FILENAME_POSIX_PATH : 0, }; struct smb_filename rel_fname = { .base_name = NULL, .twrp = twrp, + .flags = full_fname.flags, }; struct smb_filename *result = NULL; struct files_struct *fsp = NULL; char *path = NULL, *next = NULL; + bool case_sensitive; int fd; NTSTATUS status; struct vfs_open_how how = { @@ -922,7 +926,9 @@ next: fsp, &how); - if ((fd == -1) && (errno == ENOENT)) { + case_sensitive = (posix || conn->case_sensitive); + + if ((fd == -1) && (errno == ENOENT) && !case_sensitive) { const char *orig_base_name = rel_fname.base_name; status = get_real_filename_at( diff --git a/source3/smbd/proto.h b/source3/smbd/proto.h index 069c069f803..4a9ffbc0998 100644 --- a/source3/smbd/proto.h +++ b/source3/smbd/proto.h @@ -453,6 +453,7 @@ NTSTATUS openat_pathref_dirfsp_nosymlink( struct connection_struct *conn, const char *path_in, NTTIME twrp, + bool posix, struct smb_filename **_smb_fname, size_t *unparsed, char **substitute); -- 2.34.1