]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
smbd: Add "posix" flag to openat_pathref_dirfsp_nosymlink()
authorVolker Lendecke <vl@samba.org>
Wed, 14 Dec 2022 16:35:17 +0000 (17:35 +0100)
committerRalph Boehme <slow@samba.org>
Thu, 15 Dec 2022 11:30:04 +0000 (11:30 +0000)
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 <vl@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
Autobuild-User(master): Ralph Böhme <slow@samba.org>
Autobuild-Date(master): Thu Dec 15 11:30:04 UTC 2022 on sn-devel-184

selftest/knownfail.d/posix_case_sensivity [deleted file]
source3/smbd/filename.c
source3/smbd/files.c
source3/smbd/proto.h

diff --git a/selftest/knownfail.d/posix_case_sensivity b/selftest/knownfail.d/posix_case_sensivity
deleted file mode 100644 (file)
index 895c9e3..0000000
+++ /dev/null
@@ -1 +0,0 @@
-samba.tests.smb1posix
index c66e8b4b24eed266ea85dde0d7b64bca2b4ab2e5..0859e6fd5c39eb1b296985d91fc4f69c790d9724 100644 (file)
@@ -1122,6 +1122,7 @@ static NTSTATUS filename_convert_dirfsp_nosymlink(
                        conn,
                        dirname,
                        0,
+                       posix,
                        &smb_dirname,
                        &unparsed,
                        &substitute);
index ea1c31f4e85e74a98e56e67c50cdcf8c315a132d..3ea879eee3e77b7c5b3f11fd6d08c9736b043254 100644 (file)
@@ -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(
index 069c069f803337dcce559a53def5631c9bac6da0..4a9ffbc099831224400af56a5036a954d633b423 100644 (file)
@@ -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);