The branch, master has been updated
       via  96870782516 smbd: avoid mangling names in 
smbd_dirptr_lanman2_match_fn() for POSIX
       via  e5ff201592e smbd: pass dirfsp instead of conn and dptr to 
smbd_dirptr_lanman2_entry() and get_lanman2_dir_entry()
       via  8b2ae47a511 libsmb: use parse_finfo_posix_info in 
is_bad_finfo_name()
       via  bc300c7a300 libsmb: set finfo->flags.posix in 
parse_finfo_posix_info()
       via  4b7175eae80 libsmb: add flags to struct file_info
       via  93ad870a1e4 tests: expand SMB3 POSIX test for Windows illegal 
characters behaviour
      from  88572cc8f62 libads: fix get_kdc_ip_string() ...

https://git.samba.org/?p=samba.git;a=shortlog;h=master


- Log -----------------------------------------------------------------
commit 9687078251620c50420ebbeb6d7d3d53c04705a7
Author: Ralph Boehme <s...@samba.org>
Date:   Sun May 25 20:05:59 2025 +0200

    smbd: avoid mangling names in smbd_dirptr_lanman2_match_fn() for POSIX
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=15862
    
    Signed-off-by: Ralph Boehme <s...@samba.org>
    Reviewed-by: Jeremy Allison <j...@samba.org>
    
    Autobuild-User(master): Jeremy Allison <j...@samba.org>
    Autobuild-Date(master): Mon Jul  7 17:45:13 UTC 2025 on atb-devel-224

commit e5ff201592eec86b22ccaa977f3efd3c0e5f9053
Author: Ralph Boehme <s...@samba.org>
Date:   Sun May 25 20:04:53 2025 +0200

    smbd: pass dirfsp instead of conn and dptr to smbd_dirptr_lanman2_entry() 
and get_lanman2_dir_entry()
    
    No change in behaviour.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=15862
    
    Signed-off-by: Ralph Boehme <s...@samba.org>
    Reviewed-by: Jeremy Allison <j...@samba.org>

commit 8b2ae47a5110592cdaef070c972514a47bce0b50
Author: Ralph Boehme <s...@samba.org>
Date:   Mon May 26 10:37:42 2025 +0200

    libsmb: use parse_finfo_posix_info in is_bad_finfo_name()
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=15862
    
    Signed-off-by: Ralph Boehme <s...@samba.org>
    Reviewed-by: Jeremy Allison <j...@samba.org>

commit bc300c7a300bafe4dc417d074f56ffd2547dd2f9
Author: Ralph Boehme <s...@samba.org>
Date:   Mon May 26 10:37:18 2025 +0200

    libsmb: set finfo->flags.posix in parse_finfo_posix_info()
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=15862
    
    Signed-off-by: Ralph Boehme <s...@samba.org>
    Reviewed-by: Jeremy Allison <j...@samba.org>

commit 4b7175eae803a026b9a0709ff1fe71b9cf43d631
Author: Ralph Boehme <s...@samba.org>
Date:   Mon May 26 10:35:21 2025 +0200

    libsmb: add flags to struct file_info
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=15862
    
    Signed-off-by: Ralph Boehme <s...@samba.org>
    Reviewed-by: Jeremy Allison <j...@samba.org>

commit 93ad870a1e497066f82e8ec85c8a643dcd15b4de
Author: Ralph Boehme <s...@samba.org>
Date:   Sun May 25 15:15:27 2025 +0200

    tests: expand SMB3 POSIX test for Windows illegal characters behaviour
    
    The test was testing file creation, but not FIND behaviour.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=15862
    
    Signed-off-by: Ralph Boehme <s...@samba.org>
    Reviewed-by: Jeremy Allison <j...@samba.org>

-----------------------------------------------------------------------

Summary of changes:
 python/samba/tests/smb3unix.py      | 21 +++++++++++++++++++--
 source3/include/client.h            |  3 +++
 source3/libsmb/cli_smb2_fnum.c      |  1 +
 source3/libsmb/clilist.c            |  4 +++-
 source3/smbd/globals.h              |  3 +--
 source3/smbd/smb1_trans2.c          | 11 ++++-------
 source3/smbd/smb2_query_directory.c |  3 +--
 source3/smbd/smb2_trans2.c          | 13 ++++++++++---
 8 files changed, 42 insertions(+), 17 deletions(-)


Changeset truncated at 500 lines:

diff --git a/python/samba/tests/smb3unix.py b/python/samba/tests/smb3unix.py
index 5c8ab182061..289bc5ac5b4 100644
--- a/python/samba/tests/smb3unix.py
+++ b/python/samba/tests/smb3unix.py
@@ -182,13 +182,30 @@ class Smb3UnixTests(samba.tests.libsmb.LibsmbTests):
                 wire_mode = libsmb.unix_mode_to_wire(0o744)
                 f,_,cc_out = c.create_ex('\\%s' % fname,
                                 CreateDisposition=libsmb.FILE_CREATE,
-                                DesiredAccess=security.SEC_STD_DELETE,
+                                DesiredAccess=security.SEC_FILE_READ_ATTRIBUTE,
                                 CreateContexts=[posix_context(wire_mode)])
             except NTSTATUSError as e:
                 self.fail(e)
-            c.delete_on_close(f, True)
             c.close(f)
 
+        try:
+            res = c.list('', info_level=libsmb.SMB2_FIND_POSIX_INFORMATION)
+            found_files = {get_string(i['name']): i for i in res}
+            for fname in test_files:
+                self.assertTrue(fname in found_files)
+        except NTSTATUSError as e:
+            self.fail(e)
+        finally:
+            wire_mode = libsmb.unix_mode_to_wire(0o600)
+            for fname in test_files:
+                f,_,_ = c.create_ex('\\%s' % fname,
+                                CreateDisposition=libsmb.FILE_OPEN,
+                                DesiredAccess=security.SEC_STD_DELETE,
+                                CreateContexts=[posix_context(wire_mode)])
+                c.delete_on_close(f, True)
+                c.close(f)
+
+
     def test_posix_delete_on_close(self):
         c = libsmb.Conn(
             self.server_ip,
diff --git a/source3/include/client.h b/source3/include/client.h
index aaac2956f32..18f76019ae8 100644
--- a/source3/include/client.h
+++ b/source3/include/client.h
@@ -111,6 +111,9 @@ struct file_info {
        nlink_t st_ex_nlink;
        struct dom_sid owner_sid;
        struct dom_sid group_sid;
+       struct {
+               bool posix : 1;
+       } flags;
 };
 
 #define CLI_FULL_CONNECTION_DONT_SPNEGO 0x0001
diff --git a/source3/libsmb/cli_smb2_fnum.c b/source3/libsmb/cli_smb2_fnum.c
index dcd6aa50c58..cbbd1208e04 100644
--- a/source3/libsmb/cli_smb2_fnum.c
+++ b/source3/libsmb/cli_smb2_fnum.c
@@ -1334,6 +1334,7 @@ static NTSTATUS parse_finfo_posix_info(const uint8_t 
*dir_data,
        finfo->st_ex_mode = wire_mode_to_unix(info.cc.posix_mode);
        sid_copy(&finfo->owner_sid, &info.cc.owner);
        sid_copy(&finfo->group_sid, &info.cc.group);
+       finfo->flags.posix = true;
 
        if (dir_data_length < 4) {
                return NT_STATUS_INFO_LENGTH_MISMATCH;
diff --git a/source3/libsmb/clilist.c b/source3/libsmb/clilist.c
index f954405ba10..9ec3e3240f4 100644
--- a/source3/libsmb/clilist.c
+++ b/source3/libsmb/clilist.c
@@ -66,7 +66,9 @@ NTSTATUS is_bad_finfo_name(const struct cli_state *cli,
        NTSTATUS status = NT_STATUS_OK;
        bool windows_names = true;
 
-       if (cli->requested_posix_capabilities & CIFS_UNIX_POSIX_PATHNAMES_CAP) {
+       if ((cli->requested_posix_capabilities & CIFS_UNIX_POSIX_PATHNAMES_CAP)
+           || finfo->flags.posix)
+       {
                windows_names = false;
        }
        if (finfo->name != NULL) {
diff --git a/source3/smbd/globals.h b/source3/smbd/globals.h
index c74762248c1..e518c710cda 100644
--- a/source3/smbd/globals.h
+++ b/source3/smbd/globals.h
@@ -162,8 +162,7 @@ NTSTATUS smbd_do_qfsinfo(struct smbXsrv_connection *xconn,
                         int *ret_data_len);
 
 NTSTATUS smbd_dirptr_lanman2_entry(TALLOC_CTX *ctx,
-                              connection_struct *conn,
-                              struct dptr_struct *dirptr,
+                              struct files_struct *dirfsp,
                               uint16_t flags2,
                               const char *path_mask,
                               uint32_t dirtype,
diff --git a/source3/smbd/smb1_trans2.c b/source3/smbd/smb1_trans2.c
index 643c05dd77e..568a5611223 100644
--- a/source3/smbd/smb1_trans2.c
+++ b/source3/smbd/smb1_trans2.c
@@ -769,8 +769,7 @@ static void call_trans2open(connection_struct *conn,
 }
 
 static NTSTATUS get_lanman2_dir_entry(TALLOC_CTX *ctx,
-                               connection_struct *conn,
-                               struct dptr_struct *dirptr,
+                               struct files_struct *dirfsp,
                                uint16_t flags2,
                                const char *path_mask,
                                uint32_t dirtype,
@@ -792,7 +791,7 @@ static NTSTATUS get_lanman2_dir_entry(TALLOC_CTX *ctx,
                align = 1;
        }
 
-       return smbd_dirptr_lanman2_entry(ctx, conn, dirptr, flags2,
+       return smbd_dirptr_lanman2_entry(ctx, dirfsp, flags2,
                                         path_mask, dirtype, info_level,
                                         requires_resume_key, dont_descend,
                                         true, align, do_pad,
@@ -1108,8 +1107,7 @@ static void call_trans2findfirst(connection_struct *conn,
        for (i=0;(i<maxentries) && !finished && !out_of_space;i++) {
 
                ntstatus = get_lanman2_dir_entry(talloc_tos(),
-                                                conn,
-                                                fsp->dptr,
+                                                fsp,
                                                 req->flags2,
                                                 mask,
                                                 dirtype,
@@ -1568,8 +1566,7 @@ static void call_trans2findnext(connection_struct *conn,
        for (i=0;(i<(int)maxentries) && !finished && !out_of_space ;i++) {
 
                ntstatus = get_lanman2_dir_entry(ctx,
-                                                conn,
-                                                fsp->dptr,
+                                                fsp,
                                                 req->flags2,
                                                 mask,
                                                 dirtype,
diff --git a/source3/smbd/smb2_query_directory.c 
b/source3/smbd/smb2_query_directory.c
index ba8b690e1d7..0e66705425a 100644
--- a/source3/smbd/smb2_query_directory.c
+++ b/source3/smbd/smb2_query_directory.c
@@ -534,8 +534,7 @@ static bool smb2_query_directory_next_entry(struct 
tevent_req *req)
        SMB_ASSERT(space_remaining >= 0);
 
        status = smbd_dirptr_lanman2_entry(state,
-                                          state->dirfsp->conn,
-                                          state->dirfsp->dptr,
+                                          state->dirfsp,
                                           state->smbreq->flags2,
                                           state->in_file_name,
                                           state->dirtype,
diff --git a/source3/smbd/smb2_trans2.c b/source3/smbd/smb2_trans2.c
index 3483a413335..deb371beaba 100644
--- a/source3/smbd/smb2_trans2.c
+++ b/source3/smbd/smb2_trans2.c
@@ -920,6 +920,7 @@ struct smbd_dirptr_lanman2_state {
        uint32_t info_level;
        bool check_mangled_names;
        bool case_sensitive;
+       bool posix_paths;
 };
 
 static bool smbd_dirptr_lanman2_match_fn(TALLOC_CTX *ctx,
@@ -936,7 +937,9 @@ static bool smbd_dirptr_lanman2_match_fn(TALLOC_CTX *ctx,
        const char *fname;
 
        /* Mangle fname if it's an illegal name. */
-       if (mangle_must_mangle(dname, state->conn->params)) {
+       if (!state->posix_paths &&
+           mangle_must_mangle(dname, state->conn->params))
+       {
                /*
                 * Slow path - ensure we can push the original name as UCS2. If
                 * not, then just don't return this name.
@@ -1758,8 +1761,7 @@ static NTSTATUS smbd_marshall_dir_entry(TALLOC_CTX *ctx,
 }
 
 NTSTATUS smbd_dirptr_lanman2_entry(TALLOC_CTX *ctx,
-                              connection_struct *conn,
-                              struct dptr_struct *dirptr,
+                              struct files_struct *dirfsp,
                               uint16_t flags2,
                               const char *path_mask,
                               uint32_t dirtype,
@@ -1778,6 +1780,8 @@ NTSTATUS smbd_dirptr_lanman2_entry(TALLOC_CTX *ctx,
                               struct ea_list *name_list,
                               struct file_id *file_id)
 {
+       struct connection_struct *conn = dirfsp->conn;
+       struct dptr_struct *dirptr = dirfsp->dptr;
        const char *p;
        const char *mask = NULL;
        uint32_t mode = 0;
@@ -1799,6 +1803,9 @@ NTSTATUS smbd_dirptr_lanman2_entry(TALLOC_CTX *ctx,
                state.check_mangled_names = true;
        }
        state.case_sensitive = dptr_case_sensitive(dirptr);
+       if (dirfsp->fsp_name->flags & SMB_FILENAME_POSIX_PATH) {
+               state.posix_paths = true;
+       }
 
        p = strrchr_m(path_mask,'/');
        if(p != NULL) {


-- 
Samba Shared Repository

Reply via email to