The branch, master has been updated
       via  4bb3e4df3e4 torture: test that a find with a mangled name works
       via  08997ac1a71 torture: convert mangling test to a suite
       via  0fa7c3f70c7 torture: add an interactive test that works out maximum 
name and path lenghts
       via  3ece2cb807a smbd: remove oplock paranoia check from file_find_dif()
       via  6e1f58ab7c6 torture: add a test veryfing timestamps across rename
       via  8d58174cdde lib/torture: fix tctx arg usage in 
torture_assert_nttime_equal() macro
       via  6c997c7fb5b torture: add another large directory enumeration 
performance test
       via  cac95c3bba9 torture: print duration of smb2.dir.test_large_files
       via  c0be0b68730 torture: increase find buffer to 1 MB in 
multiple_smb2_search()
       via  9e1c2fedb84 torture: add another simple DOS attributes test
       via  fba4b290856 s4:torture: remove remaining checks if alloc_size is 0 
on empty files
       via  043ce404cae vfs_zfsacl: fix mixed declaration and code error
       via  09a844c69eb vfs_zfsacl: remove unused function
       via  8a2c763d264 lib/cmdline/tests: add missing includes
       via  8ccbbbd4ba4 s3:locking: split out del_share_mode_open_id()
       via  6cc866b5901 smbd: introduce 'delete_on_close' helper variables
       via  0db39fad9e7 g_lock: check for zero timeout in g_lock_lock()
       via  aa8b0ef8b93 smbd: debug in smbd_smb2_close_send()
       via  19a017496d6 s3/locking: Revert "s3:locking: Remove dead code"
       via  a9c6a329a25 s3:locking: re-add saved_errno handling to 
fd_close_posix()
       via  46ac8daa797 smbd: use fsp_getinfo_ask_sharemode() in 
open_file_ntcreate()
       via  f0e0fc17d3a smbd: use fsp_search_ask_sharemode() and 
fsp_getinfo_ask_sharemode()
       via  0226e0c31e6 smbd: add fsp_search_ask_sharemode() and 
fsp_getinfo_ask_sharemode()
       via  7f20625f982 smbd: use reference_smb_fname_fsp_link() in 
rename_internals_fsp()
       via  d1dd3f3d73f smbd: factor out reference_smb_fname_fsp_link() from 
parent_pathref()
       via  67042d95bb3 Fix memleak in _nss_winbind_initgroups_dyn
      from  70e8da42917 s3:libads: Fix debug message

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


- Log -----------------------------------------------------------------
commit 4bb3e4df3e44dc7935d3852c8f45b5e4652a4df3
Author: Ralph Boehme <s...@samba.org>
Date:   Thu Dec 1 06:13:22 2022 +0100

    torture: test that a find with a mangled name works
    
    This was spawned by https://bugzilla.samba.org/show_bug.cgi?id=13472 back
    then. Samba implement this correctly, just add this test found in the attic.
    
    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): Sat Dec 10 00:07:09 UTC 2022 on sn-devel-184

commit 08997ac1a711f4254603c7e5e90ee9309448f2a5
Author: Ralph Boehme <s...@samba.org>
Date:   Thu Dec 1 06:09:09 2022 +0100

    torture: convert mangling test to a suite
    
    More tests to come...
    
    Signed-off-by: Ralph Boehme <s...@samba.org>
    Reviewed-by: Jeremy Allison <j...@samba.org>

commit 0fa7c3f70c70db1420cbb0971493fee328d70915
Author: Ralph Boehme <s...@samba.org>
Date:   Tue Nov 29 18:30:35 2022 +0100

    torture: add an interactive test that works out maximum name and path 
lenghts
    
    Signed-off-by: Ralph Boehme <s...@samba.org>
    Reviewed-by: Jeremy Allison <j...@samba.org>

commit 3ece2cb807a122b7684096f6fe5bcfa277a3844f
Author: Ralph Boehme <s...@samba.org>
Date:   Thu Dec 1 21:38:32 2022 +0100

    smbd: remove oplock paranoia check from file_find_dif()
    
    Since 4.16 stat opens will have a real fd, the only case where currently 
the fd
    can still be -1 is a POSIX request on a symlink.
    
    Signed-off-by: Ralph Boehme <s...@samba.org>
    Reviewed-by: Jeremy Allison <j...@samba.org>

commit 6e1f58ab7c68030a7cbc923cd22055636e233b42
Author: Ralph Boehme <s...@samba.org>
Date:   Tue Nov 29 06:20:31 2022 +0100

    torture: add a test veryfing timestamps across rename
    
    Signed-off-by: Ralph Boehme <s...@samba.org>
    Reviewed-by: Jeremy Allison <j...@samba.org>

commit 8d58174cddeb2a5e62557ca23724b7acbb56e4c5
Author: Ralph Boehme <s...@samba.org>
Date:   Tue Nov 29 12:07:19 2022 +0100

    lib/torture: fix tctx arg usage in torture_assert_nttime_equal() macro
    
    Signed-off-by: Ralph Boehme <s...@samba.org>
    Reviewed-by: Jeremy Allison <j...@samba.org>

commit 6c997c7fb5b114407566887a19e9b832d067b18b
Author: Ralph Boehme <s...@samba.org>
Date:   Fri Nov 25 17:05:26 2022 +0100

    torture: add another large directory enumeration performance test
    
    This one renames one file per iteration and can also be used to torture any
    directory caching the server may employ.
    
    Signed-off-by: Ralph Boehme <s...@samba.org>
    Reviewed-by: Jeremy Allison <j...@samba.org>

commit cac95c3bba9f0fbd02f3e96691cd679e0cd2085e
Author: Ralph Boehme <s...@samba.org>
Date:   Mon Nov 28 18:05:28 2022 +0100

    torture: print duration of smb2.dir.test_large_files
    
    Signed-off-by: Ralph Boehme <s...@samba.org>
    Reviewed-by: Jeremy Allison <j...@samba.org>

commit c0be0b687301f5b613c917bc8f75248042fd32aa
Author: Ralph Boehme <s...@samba.org>
Date:   Fri Nov 25 17:03:37 2022 +0100

    torture: increase find buffer to 1 MB in multiple_smb2_search()
    
    This is used by performance tests that don't want to measure network 
latency but
    fileserver IO latency.
    
    Signed-off-by: Ralph Boehme <s...@samba.org>
    Reviewed-by: Jeremy Allison <j...@samba.org>

commit 9e1c2fedb8450703b4b18646d983a3c3f9df39e5
Author: Ralph Boehme <s...@samba.org>
Date:   Fri Nov 25 16:02:27 2022 +0100

    torture: add another simple DOS attributes test
    
    - create file with ARCHIVE
    - open file with ARCHIVE+HIDDEN+...
    - check DOS attrs are still only ARCHIVE from the initial create
    
    Signed-off-by: Ralph Boehme <s...@samba.org>
    Reviewed-by: Jeremy Allison <j...@samba.org>

commit fba4b290856faaf17305103efc65f6383ea4f61c
Author: Ralph Boehme <s...@samba.org>
Date:   Fri Nov 25 11:33:30 2022 +0100

    s4:torture: remove remaining checks if alloc_size is 0 on empty files
    
    commit 55b2f247f9ba56516efba52481418966a777343e already remove a few of 
these,
    but a few remained.
    
    Signed-off-by: Ralph Boehme <s...@samba.org>
    Reviewed-by: Jeremy Allison <j...@samba.org>

commit 043ce404caeb043b2d00e6842731e7c580d748fd
Author: Ralph Boehme <s...@samba.org>
Date:   Thu Jul 28 16:04:38 2022 +0200

    vfs_zfsacl: fix mixed declaration and code error
    
    Signed-off-by: Ralph Boehme <s...@samba.org>
    Reviewed-by: Jeremy Allison <j...@samba.org>

commit 09a844c69ebf29b437199f43c1c5d81d5cacb2e4
Author: Ralph Boehme <s...@samba.org>
Date:   Thu Jul 28 16:04:26 2022 +0200

    vfs_zfsacl: remove unused function
    
    Signed-off-by: Ralph Boehme <s...@samba.org>
    Reviewed-by: Jeremy Allison <j...@samba.org>

commit 8a2c763d264c266eb00f31898b7bfa13916e97b4
Author: Ralph Boehme <s...@samba.org>
Date:   Thu Jul 28 16:04:09 2022 +0200

    lib/cmdline/tests: add missing includes
    
    Signed-off-by: Ralph Boehme <s...@samba.org>
    Reviewed-by: Jeremy Allison <j...@samba.org>

commit 8ccbbbd4ba4de405ce5bbf839e3aa0236aaf274b
Author: Stefan Metzmacher <me...@samba.org>
Date:   Fri Oct 11 17:42:18 2019 +0200

    s3:locking: split out del_share_mode_open_id()
    
    Signed-off-by: Stefan Metzmacher <me...@samba.org>
    Reviewed-by: Ralph Boehme <s...@samba.org>
    Reviewed-by: Jeremy Allison <j...@samba.org>

commit 6cc866b5901796aacb6fc6721e717058271daf32
Author: Ralph Boehme <s...@samba.org>
Date:   Fri Nov 25 06:26:52 2022 +0100

    smbd: introduce 'delete_on_close' helper variables
    
    Signed-off-by: Ralph Boehme <s...@samba.org>
    Reviewed-by: Jeremy Allison <j...@samba.org>

commit 0db39fad9e7a79145146d95a1eecfe1703abfdb9
Author: Ralph Boehme <s...@samba.org>
Date:   Fri Mar 25 15:50:54 2022 +0100

    g_lock: check for zero timeout in g_lock_lock()
    
    If the record is already locked check if the requested timeout is zero
    and fail directly with NT_STATUS_LOCK_NOT_GRANTED.
    
    Signed-off-by: Ralph Boehme <s...@samba.org>
    Reviewed-by: Jeremy Allison <j...@samba.org>

commit aa8b0ef8b93b9318b4182a6c52f4685c9bb7d8d8
Author: Ralph Boehme <s...@samba.org>
Date:   Fri Nov 25 06:02:31 2022 +0100

    smbd: debug in smbd_smb2_close_send()
    
    Signed-off-by: Ralph Boehme <s...@samba.org>
    Reviewed-by: Jeremy Allison <j...@samba.org>

commit 19a017496d65ba15d83ada8b9c98bf8d5f658e24
Author: Ralph Boehme <s...@samba.org>
Date:   Thu Apr 7 11:10:15 2022 +0200

    s3/locking: Revert "s3:locking: Remove dead code"
    
    This reverts commit de493a3e3b5b8d54f62c45072e27f2fefd4af43a:
    
        s3:locking: Remove dead code
    
        Found by Coverity.
    
        Signed-off-by: Andreas Schneider <a...@samba.org>
        Reviewed-by: Isaac Boukris <ibouk...@samba.org>
    
    dbwrap_do_locked() correctly returns saved_errno which is a possible
    errno returned by close() inside fd_close_posix_fn().
    
    Signed-off-by: Ralph Boehme <s...@samba.org>
    Reviewed-by: Jeremy Allison <j...@samba.org>

commit a9c6a329a255d678b62f617649ffcb436e532d01
Author: Stefan Metzmacher <me...@samba.org>
Date:   Fri Oct 11 17:57:29 2019 +0200

    s3:locking: re-add saved_errno handling to fd_close_posix()
    
    Signed-off-by: Stefan Metzmacher <me...@samba.org>
    Reviewed-by: Jeremy Allison <j...@samba.org>

commit 46ac8daa797748290cbc15c14774a5453f38befb
Author: Ralph Boehme <s...@samba.org>
Date:   Wed May 11 18:14:11 2022 +0200

    smbd: use fsp_getinfo_ask_sharemode() in open_file_ntcreate()
    
    Note: this is a behaviour change in the non-default case when the user
    has disabled "getinfo ask sharemode".
    
    Pair-Programmed-With: Stefan Metzmacher <me...@samba.org>
    Signed-off-by: Ralph Boehme <s...@samba.org>
    Reviewed-by: Jeremy Allison <j...@samba.org>

commit f0e0fc17d3a455b7c5c5170b582d2d8ff53670bb
Author: Ralph Boehme <s...@samba.org>
Date:   Wed May 11 18:13:13 2022 +0200

    smbd: use fsp_search_ask_sharemode() and fsp_getinfo_ask_sharemode()
    
    Pair-Programmed-With: Stefan Metzmacher <me...@samba.org>
    Signed-off-by: Ralph Boehme <s...@samba.org>
    Reviewed-by: Jeremy Allison <j...@samba.org>

commit 0226e0c31e69aea03b7f73a648d02c9a4c28ec9d
Author: Ralph Boehme <s...@samba.org>
Date:   Wed May 11 18:09:10 2022 +0200

    smbd: add fsp_search_ask_sharemode() and fsp_getinfo_ask_sharemode()
    
    Pair-Programmed-With: Stefan Metzmacher <me...@samba.org>
    Signed-off-by: Ralph Boehme <s...@samba.org>
    Reviewed-by: Jeremy Allison <j...@samba.org>

commit 7f20625f982cbb7f0ed05f4602dcedfa41278917
Author: Ralph Boehme <s...@samba.org>
Date:   Fri Apr 8 11:54:01 2022 +0200

    smbd: use reference_smb_fname_fsp_link() in rename_internals_fsp()
    
    Pair-Programmed-With: Stefan Metzmacher <me...@samba.org>
    Signed-off-by: Ralph Boehme <s...@samba.org>
    Reviewed-by: Jeremy Allison <j...@samba.org>

commit d1dd3f3d73fd283e4817ddc76d3687ed2e9933d0
Author: Ralph Boehme <s...@samba.org>
Date:   Fri Apr 8 11:44:28 2022 +0200

    smbd: factor out reference_smb_fname_fsp_link() from parent_pathref()
    
    Pair-Programmed-With: Stefan Metzmacher <me...@samba.org>
    Signed-off-by: Ralph Boehme <s...@samba.org>
    Reviewed-by: Jeremy Allison <j...@samba.org>

commit 67042d95bb39fe4b479fa952eec0ae1c1c82ebd6
Author: Sushmita Bhattacharya <sushmita.bhattacha...@oracle.com>
Date:   Fri Dec 9 10:55:53 2022 +0000

    Fix memleak in _nss_winbind_initgroups_dyn
    
    Free the response at the end of _nss_winbind_initgroups_dyn
    
    Signed-off-by: Sushmita Bhattacharya <sushmita.bhattacha...@oracle.com>
    Reviewed-by: Volker Lendecke <v...@samba.org>
    Reviewed-by: Jeremy Allison <j...@samba.org>

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

Summary of changes:
 lib/cmdline/tests/test_cmdline.c    |   2 +
 lib/torture/torture.h               |   2 +-
 nsswitch/winbind_nss_linux.c        |   1 +
 source3/lib/g_lock.c                |   4 +
 source3/locking/posix.c             |  20 +++-
 source3/locking/share_mode_lock.c   |  34 +++++--
 source3/locking/share_mode_lock.h   |   3 +
 source3/modules/vfs_zfsacl.c        |  38 +-------
 source3/smbd/files.c                | 101 ++++++++++++++------
 source3/smbd/open.c                 |   8 +-
 source3/smbd/proto.h                |   5 +
 source3/smbd/smb1_reply.c           |   8 +-
 source3/smbd/smb1_trans2.c          |  21 ++--
 source3/smbd/smb2_close.c           |  12 +++
 source3/smbd/smb2_getinfo.c         |   4 +-
 source3/smbd/smb2_query_directory.c |   2 +-
 source3/smbd/smb2_reply.c           |  12 +++
 source4/torture/raw/open.c          |   2 -
 source4/torture/smb2/attr.c         |  57 +++++++++++
 source4/torture/smb2/create.c       | 131 ++++++++++++++++++++++++-
 source4/torture/smb2/dir.c          | 185 +++++++++++++++++++++++++++++++++++-
 source4/torture/smb2/durable_open.c |   5 +-
 source4/torture/smb2/mangle.c       |  98 ++++++++++++++++++-
 source4/torture/smb2/multichannel.c |   1 -
 source4/torture/smb2/rename.c       | 137 ++++++++++++++++++++++++++
 source4/torture/smb2/smb2.c         |   3 +-
 source4/torture/smb2/timestamps.c   |   2 -
 27 files changed, 785 insertions(+), 113 deletions(-)


Changeset truncated at 500 lines:

diff --git a/lib/cmdline/tests/test_cmdline.c b/lib/cmdline/tests/test_cmdline.c
index 5148243ccaa..16dd09c63fa 100644
--- a/lib/cmdline/tests/test_cmdline.c
+++ b/lib/cmdline/tests/test_cmdline.c
@@ -22,6 +22,8 @@
 #include <stdint.h>
 #include <setjmp.h>
 #include <cmocka.h>
+#include <time.h>
+#include <sys/time.h>
 
 #include "lib/cmdline/cmdline.h"
 
diff --git a/lib/torture/torture.h b/lib/torture/torture.h
index ea34c15e0e9..f6089684afd 100644
--- a/lib/torture/torture.h
+++ b/lib/torture/torture.h
@@ -685,7 +685,7 @@ static inline void torture_dump_data_str_cb(const char 
*buf, void *private_data)
 #define torture_assert_nttime_equal(torture_ctx,got,expected,cmt) \
        do { NTTIME __got = got, __expected = expected; \
        if (!nt_time_equal(&__got, &__expected)) { \
-               torture_result(torture_ctx, TORTURE_FAIL, __location__": "#got" 
was %s, expected %s: %s", nt_time_string(tctx, __got), nt_time_string(tctx, 
__expected), cmt); \
+               torture_result(torture_ctx, TORTURE_FAIL, __location__": "#got" 
was %s, expected %s: %s", nt_time_string(torture_ctx, __got), 
nt_time_string(torture_ctx, __expected), cmt); \
                return false; \
        }\
        } while(0)
diff --git a/nsswitch/winbind_nss_linux.c b/nsswitch/winbind_nss_linux.c
index 1d647ca25e5..a19c86dcdcc 100644
--- a/nsswitch/winbind_nss_linux.c
+++ b/nsswitch/winbind_nss_linux.c
@@ -1165,6 +1165,7 @@ _nss_winbind_initgroups_dyn(const char *user, gid_t 
group, long int *start,
        /* Back to your regularly scheduled programming */
 
  done:
+       winbindd_free_response(&response);
 #ifdef DEBUG_NSS
        fprintf(stderr, "[%5d]: initgroups %s returns %s (%d)\n", getpid(),
                user, nss_err_str(ret), ret);
diff --git a/source3/lib/g_lock.c b/source3/lib/g_lock.c
index 40687f47526..3c27a63d8d5 100644
--- a/source3/lib/g_lock.c
+++ b/source3/lib/g_lock.c
@@ -1292,6 +1292,10 @@ NTSTATUS g_lock_lock(struct g_lock_ctx *ctx, TDB_DATA 
key,
                        return state.status;
                }
 
+               if (timeval_is_zero(&timeout)) {
+                       return NT_STATUS_LOCK_NOT_GRANTED;
+               }
+
                /*
                 * Fall back to the full g_lock_trylock logic,
                 * g_lock_lock_simple_fn() called above only covers
diff --git a/source3/locking/posix.c b/source3/locking/posix.c
index 5aad427a218..ccc9d6276da 100644
--- a/source3/locking/posix.c
+++ b/source3/locking/posix.c
@@ -544,6 +544,7 @@ static void fd_close_posix_fn(
        TDB_DATA data,
        void *private_data)
 {
+       int *saved_errno = (int *)private_data;
        size_t num_fds, i;
 
        SMB_ASSERT((data.dsize % sizeof(int)) == 0);
@@ -551,8 +552,12 @@ static void fd_close_posix_fn(
 
        for (i=0; i<num_fds; i++) {
                int fd;
+               int ret;
                memcpy(&fd, data.dptr, sizeof(int));
-               close(fd);
+               ret = close(fd);
+               if (ret == -1) {
+                       *saved_errno = errno;
+               }
                data.dptr += sizeof(int);
        }
        dbwrap_record_delete(rec);
@@ -566,6 +571,8 @@ static void fd_close_posix_fn(
 
 int fd_close_posix(const struct files_struct *fsp)
 {
+       int saved_errno = 0;
+       int ret;
        NTSTATUS status;
 
        if (!lp_locking(fsp->conn->params) ||
@@ -597,7 +604,7 @@ int fd_close_posix(const struct files_struct *fsp)
                posix_pending_close_db,
                fd_array_key_fsp(fsp),
                fd_close_posix_fn,
-               NULL);
+               &saved_errno);
        if (!NT_STATUS_IS_OK(status)) {
                DBG_WARNING("dbwrap_do_locked failed: %s\n",
                            nt_errstr(status));
@@ -610,7 +617,14 @@ int fd_close_posix(const struct files_struct *fsp)
         * Finally close the fd associated with this fsp.
         */
 
-       return close(fsp_get_pathref_fd(fsp));
+       ret = close(fsp_get_pathref_fd(fsp));
+
+       if (ret == 0 && saved_errno != 0) {
+               errno = saved_errno;
+               ret = -1;
+       }
+
+       return ret;
 }
 
 /****************************************************************************
diff --git a/source3/locking/share_mode_lock.c 
b/source3/locking/share_mode_lock.c
index a30ab3921ee..909bfdfbcce 100644
--- a/source3/locking/share_mode_lock.c
+++ b/source3/locking/share_mode_lock.c
@@ -2495,7 +2495,9 @@ static void del_share_mode_fn(
        state->ok = true;
 }
 
-bool del_share_mode(struct share_mode_lock *lck, files_struct *fsp)
+bool del_share_mode_open_id(struct share_mode_lock *lck,
+                           struct server_id open_pid,
+                           uint64_t open_file_id)
 {
        struct del_share_mode_state state = { .ok = false };
        struct share_mode_data *d = NULL;
@@ -2504,21 +2506,14 @@ bool del_share_mode(struct share_mode_lock *lck, 
files_struct *fsp)
 
        status = share_mode_lock_access_private_data(lck, &d);
        if (!NT_STATUS_IS_OK(status)) {
-               struct file_id id = share_mode_lock_file_id(lck);
-               struct file_id_buf id_buf;
                /* Any error recovery possible here ? */
-               DBG_ERR("share_mode_lock_access_private_data() failed for "
-                       "%s %s - %s\n",
-                       file_id_str_buf(id, &id_buf),
-                       fsp_str_dbg(fsp),
-                       nt_errstr(status));
                return false;
        }
 
        ok = share_mode_entry_do(
                d,
-               messaging_server_id(fsp->conn->sconn->msg_ctx),
-               fh_get_gen_id(fsp->fh),
+               open_pid,
+               open_file_id,
                del_share_mode_fn,
                &state);
        if (!ok) {
@@ -2532,6 +2527,25 @@ bool del_share_mode(struct share_mode_lock *lck, 
files_struct *fsp)
        return true;
 }
 
+bool del_share_mode(struct share_mode_lock *lck, files_struct *fsp)
+{
+       struct server_id pid =
+               messaging_server_id(fsp->conn->sconn->msg_ctx);
+       bool ok;
+
+       ok = del_share_mode_open_id(lck, pid, fh_get_gen_id(fsp->fh));
+       if (!ok) {
+               struct file_id id = share_mode_lock_file_id(lck);
+               struct file_id_buf id_buf;
+               DBG_ERR("share_mode_lock_access_private_data() failed for "
+                       "%s %s\n",
+                       file_id_str_buf(id, &id_buf),
+                       fsp_str_dbg(fsp));
+               return false;
+       }
+       return true;
+}
+
 struct remove_share_oplock_state {
        bool ok;
 };
diff --git a/source3/locking/share_mode_lock.h 
b/source3/locking/share_mode_lock.h
index 0ce539229b5..eb74144a77d 100644
--- a/source3/locking/share_mode_lock.h
+++ b/source3/locking/share_mode_lock.h
@@ -37,6 +37,9 @@ struct file_id share_mode_lock_file_id(const struct 
share_mode_lock *lck);
 struct share_mode_lock *get_existing_share_mode_lock(TALLOC_CTX *mem_ctx,
                                                     struct file_id id);
 
+bool del_share_mode_open_id(struct share_mode_lock *lck,
+                           struct server_id open_pid,
+                           uint64_t open_file_id);
 bool del_share_mode(struct share_mode_lock *lck,
                    struct files_struct *fsp);
 bool downgrade_share_oplock(struct share_mode_lock *lck,
diff --git a/source3/modules/vfs_zfsacl.c b/source3/modules/vfs_zfsacl.c
index 69a1db59249..d69d7003110 100644
--- a/source3/modules/vfs_zfsacl.c
+++ b/source3/modules/vfs_zfsacl.c
@@ -278,41 +278,6 @@ static NTSTATUS zfs_set_nt_acl(vfs_handle_struct *handle, 
files_struct *fsp,
                                zfs_process_smbacl);
 }
 
-static int get_zfsacl(TALLOC_CTX *mem_ctx,
-                     const struct smb_filename *smb_fname,
-                     ace_t **outbuf)
-{
-       int naces, rv;
-       ace_t *acebuf = NULL;
-
-       naces = acl(smb_fname->base_name, ACE_GETACLCNT, 0, NULL);
-       if (naces == -1) {
-               int dbg_level = 10;
-
-               if (errno == ENOSYS) {
-                       dbg_level = 1;
-               }
-               DEBUG(dbg_level, ("acl(ACE_GETACLCNT, %s): %s ",
-                                 smb_fname->base_name, strerror(errno)));
-               return naces;
-       }
-       acebuf = talloc_size(mem_ctx, sizeof(ace_t)*naces);
-       if (acebuf == NULL) {
-               errno = ENOMEM;
-               return -1;
-       }
-
-       rv = acl(smb_fname->base_name, ACE_GETACL, naces, acebuf);
-       if (rv == -1) {
-               DBG_DEBUG("acl(ACE_GETACL, %s) failed: %s ",
-                         smb_fname->base_name, strerror(errno));
-               return -1;
-       }
-
-       *outbuf = acebuf;
-       return naces;
-}
-
 static int fget_zfsacl(TALLOC_CTX *mem_ctx,
                       struct files_struct *fsp,
                       ace_t **outbuf)
@@ -361,6 +326,7 @@ static NTSTATUS zfsacl_fget_nt_acl(struct vfs_handle_struct 
*handle,
                                   TALLOC_CTX *mem_ctx,
                                   struct security_descriptor **ppdesc)
 {
+       TALLOC_CTX *frame = NULL;
        struct SMB4ACL_T *pacl;
        NTSTATUS status;
        struct zfsacl_config_data *config = NULL;
@@ -371,7 +337,7 @@ static NTSTATUS zfsacl_fget_nt_acl(struct vfs_handle_struct 
*handle,
                                struct zfsacl_config_data,
                                return NT_STATUS_INTERNAL_ERROR);
 
-       TALLOC_CTX *frame = talloc_stackframe();
+       frame = talloc_stackframe();
 
        naces = fget_zfsacl(talloc_tos(), fsp, &acebuf);
        if (naces == -1) {
diff --git a/source3/smbd/files.c b/source3/smbd/files.c
index 1b486757506..ea1c31f4e85 100644
--- a/source3/smbd/files.c
+++ b/source3/smbd/files.c
@@ -1172,6 +1172,39 @@ NTSTATUS move_smb_fname_fsp_link(struct smb_filename 
*smb_fname_dst,
        return NT_STATUS_OK;
 }
 
+static int fsp_ref_no_close_destructor(struct smb_filename *smb_fname)
+{
+       destroy_fsp_smb_fname_link(&smb_fname->fsp_link);
+       return 0;
+}
+
+NTSTATUS reference_smb_fname_fsp_link(struct smb_filename *smb_fname_dst,
+                                     const struct smb_filename *smb_fname_src)
+{
+       NTSTATUS status;
+
+       /*
+        * The target should always not be linked yet!
+        */
+       SMB_ASSERT(smb_fname_dst->fsp == NULL);
+       SMB_ASSERT(smb_fname_dst->fsp_link == NULL);
+
+       if (smb_fname_src->fsp == NULL) {
+               return NT_STATUS_OK;
+       }
+
+       status = fsp_smb_fname_link(smb_fname_src->fsp,
+                                   &smb_fname_dst->fsp_link,
+                                   &smb_fname_dst->fsp);
+       if (!NT_STATUS_IS_OK(status)) {
+               return status;
+       }
+
+       talloc_set_destructor(smb_fname_dst, fsp_ref_no_close_destructor);
+
+       return NT_STATUS_OK;
+}
+
 /**
  * Create an smb_fname and open smb_fname->fsp pathref
  **/
@@ -1209,12 +1242,6 @@ NTSTATUS synthetic_pathref(TALLOC_CTX *mem_ctx,
        return NT_STATUS_OK;
 }
 
-static int atname_destructor(struct smb_filename *smb_fname)
-{
-       destroy_fsp_smb_fname_link(&smb_fname->fsp_link);
-       return 0;
-}
-
 /**
  * Turn a path into a parent pathref and atname
  *
@@ -1258,16 +1285,12 @@ NTSTATUS parent_pathref(TALLOC_CTX *mem_ctx,
                return status;
        }
 
-       if (smb_fname->fsp != NULL) {
-               status = fsp_smb_fname_link(smb_fname->fsp,
-                                           &atname->fsp_link,
-                                           &atname->fsp);
-               if (!NT_STATUS_IS_OK(status)) {
-                       TALLOC_FREE(parent);
-                       return status;
-               }
-               talloc_set_destructor(atname, atname_destructor);
+       status = reference_smb_fname_fsp_link(atname, smb_fname);
+       if (!NT_STATUS_IS_OK(status)) {
+               TALLOC_FREE(parent);
+               return status;
        }
+
        *_parent = parent;
        *_atname = atname;
        return NT_STATUS_OK;
@@ -1541,22 +1564,6 @@ files_struct *file_find_dif(struct 
smbd_server_connection *sconn,
                if (count > 10) {
                        DLIST_PROMOTE(sconn->files, fsp);
                }
-               /* Paranoia check. */
-               if ((fsp_get_pathref_fd(fsp) == -1) &&
-                   (fsp->oplock_type != NO_OPLOCK &&
-                    fsp->oplock_type != LEASE_OPLOCK))
-               {
-                       struct file_id_buf idbuf;
-
-                       DBG_ERR("file %s file_id = "
-                               "%s, gen = %u oplock_type = %u is a "
-                               "stat open with oplock type !\n",
-                               fsp_str_dbg(fsp),
-                               file_id_str_buf(fsp->file_id, &idbuf),
-                               (unsigned int)fh_get_gen_id(fsp->fh),
-                               (unsigned int)fsp->oplock_type);
-                       smb_panic("file_find_dif");
-               }
                return fsp;
        }
 
@@ -2135,3 +2142,35 @@ struct files_struct *metadata_fsp(struct files_struct 
*fsp)
        }
        return fsp;
 }
+
+static bool fsp_generic_ask_sharemode(struct files_struct *fsp)
+{
+       if (fsp == NULL) {
+               return false;
+       }
+
+       if (fsp->posix_flags & FSP_POSIX_FLAGS_PATHNAMES) {
+               /* Always use filesystem for UNIX mtime query. */
+               return false;
+       }
+
+       return true;
+}
+
+bool fsp_search_ask_sharemode(struct files_struct *fsp)
+{
+       if (!fsp_generic_ask_sharemode(fsp)) {
+               return false;
+       }
+
+       return lp_smbd_search_ask_sharemode(SNUM(fsp->conn));
+}
+
+bool fsp_getinfo_ask_sharemode(struct files_struct *fsp)
+{
+       if (!fsp_generic_ask_sharemode(fsp)) {
+               return false;
+       }
+
+       return lp_smbd_getinfo_ask_sharemode(SNUM(fsp->conn));
+}
diff --git a/source3/smbd/open.c b/source3/smbd/open.c
index 5c26ea190ff..3ad6b205116 100644
--- a/source3/smbd/open.c
+++ b/source3/smbd/open.c
@@ -3348,6 +3348,7 @@ static NTSTATUS check_and_store_share_mode(
        int oplock_type = NO_OPLOCK;
        uint32_t granted_lease = 0;
        const struct smb2_lease_key *lease_key = NULL;
+       bool delete_on_close;
        bool ok;
 
        /* Get the types we need to examine. */
@@ -3355,7 +3356,8 @@ static NTSTATUS check_and_store_share_mode(
                smb_panic("validate_oplock_types failed");
        }
 
-       if (has_delete_on_close(lck, fsp->name_hash)) {
+       delete_on_close = has_delete_on_close(lck, fsp->name_hash);
+       if (delete_on_close) {
                return NT_STATUS_DELETE_PENDING;
        }
 
@@ -4505,7 +4507,9 @@ static NTSTATUS open_file_ntcreate(connection_struct 
*conn,
        /*
         * Deal with other opens having a modified write time.
         */
-       if (!is_omit_timespec(&lck_state.write_time)) {
+       if (fsp_getinfo_ask_sharemode(fsp) &&
+           !is_omit_timespec(&lck_state.write_time))
+       {
                update_stat_ex_mtime(&fsp->fsp_name->st, lck_state.write_time);
        }
 
diff --git a/source3/smbd/proto.h b/source3/smbd/proto.h
index 9335ae476f7..a9060aeafc1 100644
--- a/source3/smbd/proto.h
+++ b/source3/smbd/proto.h
@@ -424,6 +424,8 @@ size_t fsp_fullbasepath(struct files_struct *fsp, char 
*buf, size_t buflen);
 void fsp_set_base_fsp(struct files_struct *fsp, struct files_struct *base_fsp);
 bool fsp_is_alternate_stream(const struct files_struct *fsp);
 struct files_struct *metadata_fsp(struct files_struct *fsp);
+bool fsp_search_ask_sharemode(struct files_struct *fsp);
+bool fsp_getinfo_ask_sharemode(struct files_struct *fsp);
 
 NTSTATUS create_internal_fsp(connection_struct *conn,
                             const struct smb_filename *smb_fname,
@@ -465,6 +467,9 @@ void smb_fname_fsp_unlink(struct smb_filename *smb_fname);
 NTSTATUS move_smb_fname_fsp_link(struct smb_filename *smb_fname_dst,
                                 struct smb_filename *smb_fname_src);
 
+NTSTATUS reference_smb_fname_fsp_link(struct smb_filename *smb_fname_dst,
+                                     const struct smb_filename *smb_fname_src);
+
 NTSTATUS synthetic_pathref(TALLOC_CTX *mem_ctx,
                           struct files_struct *dirfsp,
                           const char *base_name,
diff --git a/source3/smbd/smb1_reply.c b/source3/smbd/smb1_reply.c
index 343b7ee2b49..d53f5902da4 100644
--- a/source3/smbd/smb1_reply.c
+++ b/source3/smbd/smb1_reply.c
@@ -659,7 +659,6 @@ void reply_getatr(struct smb_request *req)
        const char *p;
        NTSTATUS status;
        TALLOC_CTX *ctx = talloc_tos();
-       bool ask_sharemode = lp_smbd_search_ask_sharemode(SNUM(conn));
 
        START_PROFILE(SMBgetatr);
 
@@ -685,6 +684,8 @@ void reply_getatr(struct smb_request *req)
                struct files_struct *dirfsp = NULL;
                uint32_t ucf_flags = ucf_flags_from_smb_request(req);
                NTTIME twrp = 0;
+               bool ask_sharemode;
+
                if (ucf_flags & UCF_GMT_PATHNAME) {
                        extract_snapshot_token(fname, &twrp);
                }
@@ -716,6 +717,7 @@ void reply_getatr(struct smb_request *req)
                mode = fdos_mode(smb_fname->fsp);
                size = smb_fname->st.st_ex_size;
 
+               ask_sharemode = fsp_search_ask_sharemode(smb_fname->fsp);
                if (ask_sharemode) {
                        struct timespec write_time_ts;
                        struct file_id fileid;
@@ -1029,7 +1031,6 @@ void reply_search(struct smb_request *req)
        bool mask_contains_wcard = False;
        bool allow_long_path_components = (req->flags2 & 
FLAGS2_LONG_PATH_COMPONENTS) ? True : False;
        TALLOC_CTX *ctx = talloc_tos();
-       bool ask_sharemode = lp_smbd_search_ask_sharemode(SNUM(conn));
        struct smbXsrv_connection *xconn = req->xconn;
        struct smbd_server_connection *sconn = req->sconn;
        files_struct *fsp = NULL;
@@ -1226,6 +1227,7 @@ void reply_search(struct smb_request *req)
                unsigned int i;
                size_t hdr_size = ((uint8_t *)smb_buf(req->outbuf) + 3 - 
req->outbuf);
                size_t available_space = xconn->smb1.sessions.max_send - 
hdr_size;
+               bool ask_sharemode;
 
                maxentries = MIN(maxentries, available_space/DIR_STRUCT_SIZE);
 
@@ -1235,6 +1237,8 @@ void reply_search(struct smb_request *req)
                        check_descend = True;
                }
 
+               ask_sharemode = fsp_search_ask_sharemode(fsp);
+


-- 
Samba Shared Repository

Reply via email to