The branch, master has been updated via 17bbd6ec4c2 smbd: Add "posix" flag to openat_pathref_dirfsp_nosymlink() via 612c8da01cf tests: Show that in smb1 posix we don't treat dirs as case sensitive from 897f08f7a03 testprogs: Use new kerberos options for samba-tool in test_kpasswd_mit.sh
https://git.samba.org/?p=samba.git;a=shortlog;h=master - Log ----------------------------------------------------------------- commit 17bbd6ec4c2607afeadd91a29c245054a6ca6828 Author: Volker Lendecke <v...@samba.org> Date: Wed Dec 14 17:35:17 2022 +0100 smbd: Add "posix" flag to openat_pathref_dirfsp_nosymlink() 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 <v...@samba.org> Reviewed-by: Ralph Boehme <s...@samba.org> Autobuild-User(master): Ralph Böhme <s...@samba.org> Autobuild-Date(master): Thu Dec 15 11:30:04 UTC 2022 on sn-devel-184 commit 612c8da01cf54be1268f2fe27fb187161cc2d0b3 Author: Volker Lendecke <v...@samba.org> Date: Wed Dec 14 18:05:04 2022 +0100 tests: Show that in smb1 posix we don't treat dirs as case sensitive Signed-off-by: Volker Lendecke <v...@samba.org> Reviewed-by: Ralph Boehme <s...@samba.org> ----------------------------------------------------------------------- Summary of changes: python/samba/tests/smb1posix.py | 52 +++++++++++++++++++++++++++++++++++++++++ source3/selftest/tests.py | 1 + source3/smbd/filename.c | 1 + source3/smbd/files.c | 8 ++++++- source3/smbd/proto.h | 1 + 5 files changed, 62 insertions(+), 1 deletion(-) create mode 100644 python/samba/tests/smb1posix.py Changeset truncated at 500 lines: diff --git a/python/samba/tests/smb1posix.py b/python/samba/tests/smb1posix.py new file mode 100644 index 00000000000..52b0312ac8b --- /dev/null +++ b/python/samba/tests/smb1posix.py @@ -0,0 +1,52 @@ +# Unix SMB/CIFS implementation. +# Copyright Volker Lendecke <v...@samba.org> 2022 +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. +# + +from samba.samba3 import libsmb_samba_internal as libsmb +from samba import (ntstatus,NTSTATUSError) +from samba.dcerpc import security as sec +import samba.tests.libsmb + +class Smb1PosixTests(samba.tests.libsmb.LibsmbTests): + + def test_directory_case_sensivity(self): + """Test that in smb1 posix dirs are case sensitive""" + conn = libsmb.Conn( + self.server_ip, + "posix_share", + self.lp, + self.creds, + force_smb1=True) + conn.smb1_posix() + + try: + conn.mkdir("lower") + except NTSTATUSError as e: + if e.args[0] != ntstatus.NT_STATUS_OBJECT_NAME_COLLISION: + raise + try: + conn.mkdir("lower/second") + except NTSTATUSError as e: + if e.args[0] != ntstatus.NT_STATUS_OBJECT_NAME_COLLISION: + raise + + self.assertFalse(conn.chkpath("Lower/second")) + conn.rmdir("lower/second") + conn.rmdir("lower") + +if __name__ == '__main__': + import unittest + unittest.main() diff --git a/source3/selftest/tests.py b/source3/selftest/tests.py index 1630fdd2035..a1379e8080e 100755 --- a/source3/selftest/tests.py +++ b/source3/selftest/tests.py @@ -1689,3 +1689,4 @@ for t in CLUSTERED_LOCAL_TESTS: planpythontestsuite("fileserver", "samba.tests.smb3unix") planpythontestsuite("fileserver", "samba.tests.reparsepoints") planpythontestsuite("fileserver_smb1", "samba.tests.smb2symlink") +planpythontestsuite("fileserver_smb1", "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); -- Samba Shared Repository