The branch, master has been updated
       via  3df388b8f14 smbd: use op->global->open_global_id for the 
share_mode_entry.share_file_id
       via  ff60b753841 smbd: move calling fsp_set_gen_id() to fsp_bind_smb()
       via  2b5cbb955ab mdssvc: implement elasticsearch:default_fields
       via  594eb4eb0eb mdssvc: fix filtering by share path prefix
       via  a8791c0cad4 mdssvc: fix running test command manually
       via  a112978ed12 vfs_fruit: ignore Set-ACL requests with zero ACEs
       via  b3132202cf7 smbd: hang directory pattern matching case sensitivity 
on the pathname
       via  75fa416f911 smbd: hang posix brl per-handle check on the pathname
       via  e86f0c2de80 vfs_fruit: add option "fruit:posix_opens = yes|no" 
(default: yes)
       via  68ed6279335 smbtorture: add test vfs.fruit.case_insensitive_find
       via  777db5b5068 smbtorture: add test vfs.fruit.readonly-exclusive-lock
       via  795a8c0e84f smbd: don't use sticky write times on POSIX handles
       via  3052839636f smbtorture: fix locking offset in 
test_fruit_locking_conflict()
      from  cfc1c0afcc8 vfs_fake_acls: Call fake_acls_fstatat() from 
fake_acls_[l]stat()

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


- Log -----------------------------------------------------------------
commit 3df388b8f148c00a3ef331d393cea976fb9340b3
Author: Ralph Boehme <[email protected]>
Date:   Thu Oct 9 15:27:31 2025 +0200

    smbd: use op->global->open_global_id for the share_mode_entry.share_file_id
    
    open_global_id is an uint32_t, share_file_id is an uint64_t.
    
    For internal opens that don't have an smbXsrv_open_global.tdb entry, 
continue to
    use a generation counter starting at UINT32_MAX + 1.
    
    We don't expose internal opens via srvsrc, which imposes the requirement for
    using an uint32_t, so we can use larger ids for the internal opens as srvsvc
    never sees them (as they're not in smbXsrv_open_global.tdb and srvsvc as any
    other component listing open files like smbstatus lists 
smbXsrv_open_global.tdb).
    
    Signed-off-by: Ralph Boehme <[email protected]>
    Reviewed-by: Volker Lendecke <[email protected]>
    
    Autobuild-User(master): Volker Lendecke <[email protected]>
    Autobuild-Date(master): Fri Oct 10 11:43:16 UTC 2025 on atb-devel-224

commit ff60b7538412a76253c51a830da3a204a574d4a0
Author: Ralph Boehme <[email protected]>
Date:   Thu Oct 9 15:17:38 2025 +0200

    smbd: move calling fsp_set_gen_id() to fsp_bind_smb()
    
    No change in behaviour. fsp_set_gen_id() sets the primary key for the
    share_mode_entry of the corresponding open file handle. None of the pathref 
fsp
    needs that before being passed to SMB_VFS_CREATE_FILE().
    
    As file_new() calls fsp_bind_smb(), all fsps will get an id when
    create_file_unixpath() either calls file_new when creating files or it calls
    fsp_bind_smb() when "converting" an pathref fsp that was passed into
    SMB_VFS_CREATE_FILE() to an FSA fsp.
    
    Signed-off-by: Ralph Boehme <[email protected]>
    Reviewed-by: Volker Lendecke <[email protected]>

commit 2b5cbb955ab2cf278272aa8457a672aa27ff1020
Author: Ralph Boehme <[email protected]>
Date:   Mon Sep 1 14:55:04 2025 +0200

    mdssvc: implement elasticsearch:default_fields
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=15927
    
    Signed-off-by: Ralph Boehme <[email protected]>
    Reviewed-by: Volker Lendecke <[email protected]>

commit 594eb4eb0eb4a6c87c5b136106afd05357b80e91
Author: Ralph Boehme <[email protected]>
Date:   Thu Sep 4 17:41:44 2025 +0200

    mdssvc: fix filtering by share path prefix
    
    To correctly filter by share path, use a filter with a prefix match.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=15927
    
    Signed-off-by: Ralph Boehme <[email protected]>
    Reviewed-by: Volker Lendecke <[email protected]>

commit a8791c0cad4fb03606ea484c2da7ee69d9de5d48
Author: Ralph Boehme <[email protected]>
Date:   Thu Oct 2 17:08:55 2025 +0200

    mdssvc: fix running test command manually
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=15927
    
    Signed-off-by: Ralph Boehme <[email protected]>
    Reviewed-by: Volker Lendecke <[email protected]>

commit a112978ed1240c399eb90e4472d5c43d867c49d9
Author: Ralph Boehme <[email protected]>
Date:   Sat Sep 6 08:48:44 2025 +0200

    vfs_fruit: ignore Set-ACL requests with zero ACEs
    
    Workaround for a new behaviour in latest macOS versions.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=15926
    
    Signed-off-by: Ralph Boehme <[email protected]>
    Reviewed-by: Volker Lendecke <[email protected]>

commit b3132202cf787cc9fb061e39eaf1509157f53953
Author: Ralph Boehme <[email protected]>
Date:   Thu Sep 18 20:35:22 2025 +0200

    smbd: hang directory pattern matching case sensitivity on the pathname
    
    For the SMB3 POSIX client both posix_open=true and (fsp->fsp_name->flags &
    SMB_FILENAME_POSIX_PATH) will always be the case, so this is no change in
    behaviour for that case.
    
    However, for the macOS client fruit will carefully setup both flags as
    posix_open=true but SMB_FILENAME_POSIX_PATH will not be set.
    
    This is a deliberate hack to give the macOS client POSIX behaviour for some
    operations, but not for others, while also allowing the POSIX-ified macOS 
client
    to continue to get case insensitive behavour.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=15926
    
    Signed-off-by: Ralph Boehme <[email protected]>
    Reviewed-by: Volker Lendecke <[email protected]>

commit 75fa416f911f1f30aae8bdf14b423140874acaa0
Author: Ralph Boehme <[email protected]>
Date:   Thu Sep 18 23:44:34 2025 +0200

    smbd: hang posix brl per-handle check on the pathname
    
    For the SMB3 POSIX client both posix_open=true and (fsp->fsp_name->flags &
    SMB_FILENAME_POSIX_PATH) will always be the case, so this is no change in
    behaviour for that case.
    
    However, for the macOS client fruit will carefully setup both flags as
    posix_open=true but SMB_FILENAME_POSIX_PATH will not be set.
    
    This is a deliberate hack to give the macOS client POSIX behaviour for some
    operations, but not for others, while also allowing the POSIX-ified macOS 
client
    to continue to get case insensitive behavour.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=15926
    
    Signed-off-by: Ralph Boehme <[email protected]>
    Reviewed-by: Volker Lendecke <[email protected]>

commit e86f0c2de80e2409bfe3fc12df24e94470988e3c
Author: Ralph Boehme <[email protected]>
Date:   Mon Mar 10 15:01:42 2025 +0100

    vfs_fruit: add option "fruit:posix_opens = yes|no" (default: yes)
    
    Tags alls opens as POSIX by setting fsp_flags.posix_open to true.
    
    POSIX handles have different behaviour compared to Windows:
    
    Behaviour                          | POSIX      | Windows    | macOS     
|fruit:posix_opens = yes
    
-----------------------------------+------------+----------------------------------------
    Deleting files with open handles   | yes        | no         | yes       | 
yes
    Moving directories with open files | yes        | no         | yes       | 
yes
    Byterange locks behaviour          | POSIX-ish  | Window-ish | POSIX-ish | 
POSIX-ish
    Sticky writetime                   | no         | yes        | no        | 
no
    Case sensitive                     | no         | yes        | yes       | 
yes
    Streams allowed                    | no         | yes        | yes       | 
yes
    
    macOS follows POSIX for the first four, but needs case insensitive behaviour
    and needs streams.
    
    By carefully setting fsp_flags.posix_open to true *after* going through the 
path
    resolution logic, but before opens are added to locking.tdb, with
    "fruit:posix_opens = yes" we get closest to macOS semantics.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=15926
    
    Signed-off-by: Ralph Boehme <[email protected]>
    Reviewed-by: Volker Lendecke <[email protected]>

commit 68ed6279335cfac13a624ae8a7738dac3d9b0d1a
Author: Ralph Boehme <[email protected]>
Date:   Fri Sep 19 06:43:57 2025 +0200

    smbtorture: add test vfs.fruit.case_insensitive_find
    
    Verifies case insensitive directory scanning works.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=15926
    
    Signed-off-by: Ralph Boehme <[email protected]>
    Reviewed-by: Volker Lendecke <[email protected]>

commit 777db5b50689d28c53d6b0116818601fd8e52aa8
Author: Ralph Boehme <[email protected]>
Date:   Fri Sep 19 00:20:43 2025 +0200

    smbtorture: add test vfs.fruit.readonly-exclusive-lock
    
    Verify macOS clients get Windows byterange lock behavour by trying to set an
    exclusive lock on a file opened in read-only mode.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=15926
    
    Signed-off-by: Ralph Boehme <[email protected]>
    Reviewed-by: Volker Lendecke <[email protected]>

commit 795a8c0e84f2bf2b70c8070737183e33f4254a54
Author: Ralph Boehme <[email protected]>
Date:   Fri Aug 1 17:28:04 2025 +0200

    smbd: don't use sticky write times on POSIX handles
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=15926
    
    Signed-off-by: Ralph Boehme <[email protected]>
    Reviewed-by: Volker Lendecke <[email protected]>

commit 3052839636f185307edb8832de9bdba4b2e2c83c
Author: Ralph Boehme <[email protected]>
Date:   Wed Aug 13 17:02:16 2025 +0200

    smbtorture: fix locking offset in test_fruit_locking_conflict()
    
    AD_FILELOCK_RSRC_DENY_WR = AD_FILELOCK_BASE + 6
     = (0x7FFFFFFFFFFFFFFF - 9) + 6
     = 0x7FFFFFFFFFFFFFFC
    
    No change in behaviour though, just stumpled across it.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=15926
    
    Signed-off-by: Ralph Boehme <[email protected]>
    Reviewed-by: Volker Lendecke <[email protected]>

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

Summary of changes:
 docs-xml/manpages/vfs_fruit.8.xml                  |  34 ++++
 .../smbdotconf/misc/elasticsearchdefaultfields.xml |  19 +++
 python/samba/tests/blackbox/mdsearch.py            |  18 ++-
 python/samba/tests/dcerpc/mdssvc.py                |  54 ++++++-
 source3/include/vfs.h                              |  18 +++
 source3/locking/share_mode_lock.c                  |   2 +-
 source3/modules/vfs_fruit.c                        |  49 +++++-
 source3/rpc_server/mdssvc/es_parser.y              |   8 +-
 source3/rpc_server/mdssvc/es_parser_test.c         |   3 -
 source3/rpc_server/mdssvc/mdssvc_es.c              |  58 ++++---
 source3/rpc_server/mdssvc/mdssvc_es.h              |   1 +
 source3/rpc_server/mdssvc/test_mdsparser_es.c      | 115 ++++++-------
 source3/smbd/dir.c                                 |   2 +-
 source3/smbd/dosmode.c                             |   3 +
 source3/smbd/durable.c                             |   2 +-
 source3/smbd/files.c                               |  19 +--
 source3/smbd/smb2_lock.c                           |  16 +-
 source4/torture/vfs/fruit.c                        | 179 ++++++++++++++++++++-
 18 files changed, 486 insertions(+), 114 deletions(-)
 create mode 100644 docs-xml/smbdotconf/misc/elasticsearchdefaultfields.xml


Changeset truncated at 500 lines:

diff --git a/docs-xml/manpages/vfs_fruit.8.xml 
b/docs-xml/manpages/vfs_fruit.8.xml
index 037fe611c4e..333f8678e61 100644
--- a/docs-xml/manpages/vfs_fruit.8.xml
+++ b/docs-xml/manpages/vfs_fruit.8.xml
@@ -447,6 +447,40 @@
 
             </listitem>
          </varlistentry>
+
+         <varlistentry>
+           <term>fruit:posix_opens = yes | no</term>
+           <listitem>
+
+             <para>When <parameter>fruit:posix_opens</parameter> is set to
+             <parameter>yes</parameter>, vfs_fruit will internally translate
+             all filesystem semantics to use POSIX behaviour instead of Windows
+             behaviour. As Macs are closer to POSIX than Windows with regard
+             to filesystem semantics, this improves access semantics for
+             a lot of corner cases.</para>
+             <para>The default is <emphasis>yes</emphasis>.</para>
+
+            </listitem>
+         </varlistentry>
+
+         <varlistentry>
+           <term>fruit:ignore_zero_aces = yes | no</term>
+           <listitem>
+
+             <para>When <parameter>fruit:ignore_zero_aces</parameter> is
+             enabled, attempts to modify filesystem permissions fail if the ACL
+             sent over the wire contains no ACEs. This is completely valid
+             client behaviour, but it means subsequently no further access is
+             possible to the file, unless permissions get fixed by an
+             administrator.</para>
+             <para>This problematic behaviour has been reported for latest
+             macOS versions and this new option allows to work around
+             it.</para>
+             <para>The default is <emphasis>yes</emphasis>.</para>
+
+            </listitem>
+         </varlistentry>
+
        </variablelist>
 </refsect1>
 
diff --git a/docs-xml/smbdotconf/misc/elasticsearchdefaultfields.xml 
b/docs-xml/smbdotconf/misc/elasticsearchdefaultfields.xml
new file mode 100644
index 00000000000..9230e9280b7
--- /dev/null
+++ b/docs-xml/smbdotconf/misc/elasticsearchdefaultfields.xml
@@ -0,0 +1,19 @@
+<samba:parameter name="elasticsearch:default_fields"
+                 context="G"
+                 type="string"
+                 xmlns:samba="http://www.samba.org/samba/DTD/samba-doc";>
+  <description>
+    <para>
+      Default attributes in Elasticsearch to query when receiving a Spotlight
+      query that searches in the special attribute "*". This is the default 
used
+      by macOS clients when searching from the Finder.
+    </para>
+    <para>
+      This option expects a list of Elasticsearch attributes separated by
+      comma where each attributes must be enclosed in double quotes.
+    </para>
+  </description>
+
+  <value type="default">"file.filename", "content"</value>
+  <value type="example">"foo", "bar"</value>
+</samba:parameter>
diff --git a/python/samba/tests/blackbox/mdsearch.py 
b/python/samba/tests/blackbox/mdsearch.py
index 8d67090e182..a2e6eb09029 100644
--- a/python/samba/tests/blackbox/mdsearch.py
+++ b/python/samba/tests/blackbox/mdsearch.py
@@ -102,8 +102,22 @@ class MdfindBlackboxTests(BlackboxTestCase):
         json_in = r'''{
           "from": 0, "size": 50, "_source": ["path.real"],
           "query": {
-            "query_string": {
-              "query": "(samba*) AND path.real.fulltext:\"%BASEPATH%\""
+            "bool": {
+              "filter": [
+                {
+                  "prefix": {
+                    "path.real": "%BASEPATH%/"
+                  }
+                }
+              ],
+              "must": [
+                {
+                  "query_string": {
+                    "query": "samba*",
+                    "fields": ["file.filename", "content"]
+                  }
+                }
+              ]
             }
           }
         }'''
diff --git a/python/samba/tests/dcerpc/mdssvc.py 
b/python/samba/tests/dcerpc/mdssvc.py
index cd256548b91..40005ff1824 100644
--- a/python/samba/tests/dcerpc/mdssvc.py
+++ b/python/samba/tests/dcerpc/mdssvc.py
@@ -133,8 +133,22 @@ class MdssvcTests(RpcInterfaceTestCase):
         exp_json_query = r'''{
           "from": 0, "size": 50, "_source": ["path.real"],
           "query": {
-            "query_string": {
-              "query": "(samba*) AND path.real.fulltext:\"%BASEPATH%\""
+            "bool": {
+              "filter": [
+                {
+                  "prefix": {
+                    "path.real": "%BASEPATH%/"
+                  }
+                }
+              ],
+              "must": [
+                {
+                  "query_string": {
+                    "query": "samba*",
+                    "fields": ["file.filename", "content"]
+                  }
+                }
+              ]
             }
           }
         }'''
@@ -165,8 +179,22 @@ class MdssvcTests(RpcInterfaceTestCase):
         exp_json_query = r'''{
           "from": 0, "size": 50, "_source": ["path.real"],
           "query": {
-            "query_string": {
-              "query": "(file.filename:x\\+x OR file.filename:x\\*x OR 
file.filename:x=x OR file.filename:x'x OR file.filename:x\\?x OR 
file.filename:x\\ x OR file.filename:x\\(x OR file.filename:x\\\"x OR 
file.filename:x\\\\x) AND path.real.fulltext:\"%BASEPATH%\""
+            "bool": {
+              "filter": [
+                {
+                  "prefix": {
+                    "path.real": "%BASEPATH%/"
+                  }
+                }
+              ],
+              "must": [
+                {
+                  "query_string": {
+                    "query": "file.filename:x\\+x OR file.filename:x\\*x OR 
file.filename:x=x OR file.filename:x'x OR file.filename:x\\?x OR 
file.filename:x\\ x OR file.filename:x\\(x OR file.filename:x\\\"x OR 
file.filename:x\\\\x",
+                    "fields": ["file.filename", "content"]
+                  }
+                }
+              ]
             }
           }
         }'''
@@ -207,8 +235,22 @@ class MdssvcTests(RpcInterfaceTestCase):
         exp_json_query = r'''{
           "from": 0, "size": 50, "_source": ["path.real"],
           "query": {
-            "query_string": {
-              "query": "(*samba*) AND path.real.fulltext:\"%BASEPATH%\""
+            "bool": {
+              "filter": [
+                {
+                  "prefix": {
+                    "path.real": "%BASEPATH%/"
+                  }
+                }
+              ],
+              "must": [
+                {
+                  "query_string": {
+                    "query": "*samba*",
+                    "fields": ["file.filename", "content"]
+                  }
+                }
+              ]
             }
           }
         }'''
diff --git a/source3/include/vfs.h b/source3/include/vfs.h
index 0acd7c86cad..34bd97fa3de 100644
--- a/source3/include/vfs.h
+++ b/source3/include/vfs.h
@@ -465,6 +465,15 @@ typedef struct files_struct {
                bool lock_failure_seen : 1;
                bool encryption_required : 1;
                bool fstat_before_close : 1;
+               /*
+                * For POSIX clients struct files_struct.fsp_flags.posix_open
+                * and struct smb_filename.flags SMB_FILENAME_POSIX_PATH will
+                * always be set to the same value.
+                *
+                * For macOS clients vfs_fruit with fruit:posix_open=yes, we
+                * deliberately set both flags to fsp_flags.posix_open=true
+                * while SMB_FILENAME_POSIX_PATH will not be set.
+                */
                bool posix_open : 1;
                bool posix_append : 1;
                bool ntcreatex_deny_dos : 1;
@@ -892,6 +901,15 @@ struct smb_filename {
        struct fsp_smb_fname_link *fsp_link;
 };
 
+/*
+ * For POSIX clients struct files_struct.fsp_flags.posix_open
+ * and struct smb_filename.flags SMB_FILENAME_POSIX_PATH will
+ * always be set to the same value.
+ *
+ * For macOS clients vfs_fruit with fruit:posix_open=yes, we
+ * deliberately set both flags to fsp_flags.posix_open=true
+ * while SMB_FILENAME_POSIX_PATH will not be set.
+ */
 #define SMB_FILENAME_POSIX_PATH                0x01
 
 enum vfs_translate_direction {
diff --git a/source3/locking/share_mode_lock.c 
b/source3/locking/share_mode_lock.c
index ce5ef40e370..66a7c1b6c04 100644
--- a/source3/locking/share_mode_lock.c
+++ b/source3/locking/share_mode_lock.c
@@ -2739,7 +2739,7 @@ bool mark_share_mode_disconnected(struct share_mode_lock 
*lck,
        ok = reset_share_mode_entry(
                lck,
                messaging_server_id(fsp->conn->sconn->msg_ctx),
-               fh_get_gen_id(fsp->fh),
+               fsp->op->global->open_persistent_id,
                disconnected_pid,
                UINT64_MAX,
                fsp->op->global->open_persistent_id);
diff --git a/source3/modules/vfs_fruit.c b/source3/modules/vfs_fruit.c
index 4ef7a68a30f..d4f2cbc06c8 100644
--- a/source3/modules/vfs_fruit.c
+++ b/source3/modules/vfs_fruit.c
@@ -125,6 +125,7 @@ struct fruit_config_data {
        bool use_aapl;          /* config from smb.conf */
        bool use_copyfile;
        bool readdir_attr_enabled;
+       bool posix_opens;
        bool unix_info_enabled;
        bool copyfile_enabled;
        bool veto_appledouble;
@@ -137,6 +138,7 @@ struct fruit_config_data {
        bool delete_empty_adfiles;
        bool validate_afpinfo;
        bool veto_localized;
+       bool ignore_zero_aces;
 
        /*
         * Additional options, all enabled by default,
@@ -340,6 +342,14 @@ static int init_fruit_config(vfs_handle_struct *handle)
        config->use_copyfile = lp_parm_bool(-1, FRUIT_PARAM_TYPE_NAME,
                                           "copyfile", false);
 
+       config->posix_opens = lp_parm_bool(
+               SNUM(handle->conn), FRUIT_PARAM_TYPE_NAME, "posix_opens", true);
+
+       config->ignore_zero_aces = lp_parm_bool(SNUM(handle->conn),
+                                               FRUIT_PARAM_TYPE_NAME,
+                                               "ignore_zero_aces",
+                                               true);
+
        config->aapl_zero_file_id =
            lp_parm_bool(SNUM(handle->conn), FRUIT_PARAM_TYPE_NAME,
                         "zero_file_id", true);
@@ -1730,16 +1740,27 @@ static int fruit_openat(vfs_handle_struct *handle,
                        files_struct *fsp,
                        const struct vfs_open_how *how)
 {
+       struct fruit_config_data *config = NULL;
        int fd;
 
+       SMB_VFS_HANDLE_GET_DATA(handle, config,
+                               struct fruit_config_data, return -1);
+
        DBG_DEBUG("Path [%s]\n", smb_fname_str_dbg(smb_fname));
 
        if (!is_named_stream(smb_fname)) {
-               return SMB_VFS_NEXT_OPENAT(handle,
-                                          dirfsp,
-                                          smb_fname,
-                                          fsp,
-                                          how);
+               fd = SMB_VFS_NEXT_OPENAT(handle,
+                                        dirfsp,
+                                        smb_fname,
+                                        fsp,
+                                        how);
+               if (fd == -1) {
+                       return -1;
+               }
+               if (config->posix_opens && global_fruit_config.nego_aapl) {
+                       fsp->fsp_flags.posix_open = true;
+               }
+               return fd;
        }
 
        if ((how->resolve & ~VFS_OPEN_HOW_WITH_BACKUP_INTENT) != 0) {
@@ -1774,7 +1795,13 @@ static int fruit_openat(vfs_handle_struct *handle,
        DBG_DEBUG("Path [%s] fd [%d]\n", smb_fname_str_dbg(smb_fname), fd);
 
        /* Prevent reopen optimisation */
+       if (fd == -1) {
+               return -1;
+       }
        fsp->fsp_flags.have_proc_fds = false;
+       if (config->posix_opens && global_fruit_config.nego_aapl) {
+               fsp->fsp_flags.posix_open = true;
+       }
        return fd;
 }
 
@@ -4612,6 +4639,7 @@ static NTSTATUS fruit_fset_nt_acl(vfs_handle_struct 
*handle,
                                  uint32_t security_info_sent,
                                  const struct security_descriptor *orig_psd)
 {
+       struct fruit_config_data *config = NULL;
        NTSTATUS status;
        bool do_chmod;
        mode_t ms_nfs_mode = 0;
@@ -4619,6 +4647,10 @@ static NTSTATUS fruit_fset_nt_acl(vfs_handle_struct 
*handle,
        struct security_descriptor *psd = NULL;
        uint32_t orig_num_aces = 0;
 
+       SMB_VFS_HANDLE_GET_DATA(handle, config,
+                               struct fruit_config_data,
+                               return NT_STATUS_UNSUCCESSFUL);
+
        if (orig_psd->dacl != NULL) {
                orig_num_aces = orig_psd->dacl->num_aces;
        }
@@ -4630,6 +4662,13 @@ static NTSTATUS fruit_fset_nt_acl(vfs_handle_struct 
*handle,
 
        DBG_DEBUG("%s\n", fsp_str_dbg(fsp));
 
+       if (config->ignore_zero_aces && (psd->dacl->num_aces == 0)) {
+               /*
+                * Just ignore Set-ACL requests with zero ACEs.
+                */
+               return NT_STATUS_OK;
+       }
+
        status = check_ms_nfs(handle, fsp, psd, &ms_nfs_mode, &do_chmod);
        if (!NT_STATUS_IS_OK(status)) {
                DEBUG(1, ("fruit_fset_nt_acl: check_ms_nfs failed%s\n", 
fsp_str_dbg(fsp)));
diff --git a/source3/rpc_server/mdssvc/es_parser.y 
b/source3/rpc_server/mdssvc/es_parser.y
index 7f3275d3d92..62ca63d90f2 100644
--- a/source3/rpc_server/mdssvc/es_parser.y
+++ b/source3/rpc_server/mdssvc/es_parser.y
@@ -85,7 +85,6 @@
        int mdsyylwrap(void);
        bool map_spotlight_to_es_query(TALLOC_CTX *mem_ctx,
                                       json_t *mappings,
-                                      const char *path_scope,
                                       const char *query_string,
                                       char **_es_query);
 }
@@ -640,7 +639,6 @@ int mdsyylwrap(void)
  **/
 bool map_spotlight_to_es_query(TALLOC_CTX *mem_ctx,
                               json_t *mappings,
-                              const char *path_scope,
                               const char *query_string,
                               char **_es_query)
 {
@@ -691,13 +689,11 @@ bool map_spotlight_to_es_query(TALLOC_CTX *mem_ctx,
                return false;
        }
 
-       es_query = talloc_asprintf(mem_ctx,
-                                  "(%s) AND path.real.fulltext:\\\"%s\\\"",
-                                  s.result, path_scope);
-       TALLOC_FREE(s.frame);
+       es_query = talloc_strdup(mem_ctx, s.result);
        if (es_query == NULL) {
                return false;
        }
+       TALLOC_FREE(s.frame);
 
        *_es_query = es_query;
        return true;
diff --git a/source3/rpc_server/mdssvc/es_parser_test.c 
b/source3/rpc_server/mdssvc/es_parser_test.c
index 7d88c67abff..dfce8601911 100644
--- a/source3/rpc_server/mdssvc/es_parser_test.c
+++ b/source3/rpc_server/mdssvc/es_parser_test.c
@@ -41,7 +41,6 @@ int main(int argc, char **argv)
        char *default_path = NULL;
        const char *path = NULL;
        const char *query_string = NULL;
-       const char *path_scope = NULL;
        char *es_query = NULL;
        bool ok;
 
@@ -50,7 +49,6 @@ int main(int argc, char **argv)
                return 1;
        }
        query_string = argv[1];
-       path_scope = "/foo/bar";
 
        lp_load_global(get_dyn_CONFIGFILE());
 
@@ -86,7 +84,6 @@ int main(int argc, char **argv)
 
        ok = map_spotlight_to_es_query(mem_ctx,
                                           mappings,
-                                          path_scope,
                                           query_string,
                                           &es_query);
        printf("%s\n", ok ? es_query : "*mapping failed*");
diff --git a/source3/rpc_server/mdssvc/mdssvc_es.c 
b/source3/rpc_server/mdssvc/mdssvc_es.c
index d51441092b4..eb19d5fdc4a 100644
--- a/source3/rpc_server/mdssvc/mdssvc_es.c
+++ b/source3/rpc_server/mdssvc/mdssvc_es.c
@@ -36,17 +36,27 @@
 #undef DBGC_CLASS
 #define DBGC_CLASS DBGC_RPC_SRV
 
-#define MDSSVC_ELASTIC_QUERY_TEMPLATE  \
-       "{"                             \
-       "    \"from\": %zu,"            \
-       "    \"size\": %zu,"            \
-       "    \"_source\": [%s],"        \
-       "    \"query\": {"              \
-        "        \"query_string\": {"  \
-       "            \"query\": \"%s\"" \
-       "        }"                     \
-       "    }"                         \
-       "}"
+#define MDSSVC_ELASTIC_QUERY_TEMPLATE                  \
+       "{\n"                                           \
+       "    \"from\": %zu,\n"                          \
+       "    \"size\": %zu,\n"                          \
+       "    \"_source\": [%s],\n"                      \
+       "    \"query\": {\n"                            \
+       "        \"bool\": {\n"                         \
+       "            \"filter\": [ {\n"                 \
+       "                \"prefix\": {\n"               \
+       "                    \"path.real\": \"%s/\"\n"  \
+       "                }\n"                           \
+       "            } ],\n"                            \
+       "            \"must\": [ {\n"                   \
+        "                \"query_string\": {\n"                \
+       "                    \"query\": \"%s\",\n"      \
+       "                    \"fields\": [%s]\n"        \
+       "                }\n"                           \
+       "            } ]\n"                             \
+       "        }\n"                                   \
+       "    }\n"                                       \
+       "}\n"
 
 #define MDSSVC_ELASTIC_SOURCES \
        "\"path.real\""
@@ -57,6 +67,7 @@ static bool mdssvc_es_init(struct mdssvc_ctx *mdssvc_ctx)
        json_error_t json_error;
        char *default_path = NULL;
        const char *path = NULL;
+       const char *default_fields = "\"file.filename\", \"content\"";
 
        mdssvc_es_ctx = talloc_zero(mdssvc_ctx, struct mdssvc_es_ctx);
        if (mdssvc_es_ctx == NULL) {
@@ -97,6 +108,15 @@ static bool mdssvc_es_init(struct mdssvc_ctx *mdssvc_ctx)
        }
        TALLOC_FREE(default_path);
 
+       mdssvc_es_ctx->default_fields = 
lp_parm_const_string(GLOBAL_SECTION_SNUM,
+                                                            "elasticsearch",
+                                                            "default_fields",
+                                                            default_fields);
+       if (mdssvc_es_ctx->default_fields == NULL) {
+               TALLOC_FREE(mdssvc_es_ctx);
+               return false;
+       }
+
        mdssvc_ctx->backend_private = mdssvc_es_ctx;
        return true;
 }
@@ -413,7 +433,6 @@ static bool mds_es_search(struct sl_query *slq)
        ok = map_spotlight_to_es_query(
                s,
                mds_es_ctx->mdssvc_es_ctx->mappings,
-               slq->path_scope,
                slq->query_string,
                &s->es_query);
        if (!ok) {
@@ -616,12 +635,15 @@ static struct tevent_req *mds_es_search_send(TALLOC_CTX 
*mem_ctx,
                return tevent_req_post(req, ev);
        }
 
-       elastic_query = talloc_asprintf(state,
-                                       MDSSVC_ELASTIC_QUERY_TEMPLATE,
-                                       s->from,
-                                       s->size,
-                                       MDSSVC_ELASTIC_SOURCES,
-                                       s->es_query);
+       elastic_query = talloc_asprintf(
+               state,
+               MDSSVC_ELASTIC_QUERY_TEMPLATE,
+               s->from,
+               s->size,
+               MDSSVC_ELASTIC_SOURCES,
+               s->slq->path_scope,
+               s->es_query,
+               s->mds_es_ctx->mdssvc_es_ctx->default_fields);


-- 
Samba Shared Repository

Reply via email to