The branch, v4-9-test has been updated
       via  d18c5775771 vfs_shadow_copy2: in fstat also convert fsp->fsp_name 
and fsp->base_fsp->fsp_name
       via  fa2a9c3be08 s3:smbd: pass down twrp from SMB2_CREATE to 
filename_convert()
       via  baf1e0f30fe s3:smbd: add twrp args to filename_convert()
       via  f8c144fa191 s3:smbd: add twrp processing to 
filename_convert_internal()
       via  88863119323 s3:smbd: prepare filename_convert_internal() for twrp
       via  3295cc8b4a5 s3:selftest: add a VSS test reading a stream
       via  1f897e6c1d2 s3-vfs: Prevent NULL pointer dereference in 
vfs_glusterfs.
       via  e60c9431c6e vfs_shadow_copy2: nicely deal with attempts to open 
previous version for writing
       via  256d488b593 vfs_shadow_copy2: add 
shadow_copy2_strip_snapshot_converted
       via  0e355e3826f vfs_shadow_copy2: add _already_converted arg to 
shadow_copy2_strip_snapshot_internal()
       via  0244de24cfe s3:script/tests: add a test for VSS write behaviour
       via  6f8ea0a08ea s4:torture: add a test-suite for VSS
       via  1cf55de5ceb vfs_error_inject: add EBADF error
       via  8eaf7922410 vfs_error_inject: add pwrite
       via  f53459c9232 s3:libads: Add net ads leave keep-account option
      from  1d0e4511ce1 winbindd: Route predefined domains through the BUILTIN 
domain child

https://git.samba.org/?p=samba.git;a=shortlog;h=v4-9-test


- Log -----------------------------------------------------------------
commit d18c5775771d8c3bb9661335c0af2415a2c4b0e8
Author: Ralph Boehme <s...@samba.org>
Date:   Wed Nov 21 17:20:30 2018 +0100

    vfs_shadow_copy2: in fstat also convert fsp->fsp_name and 
fsp->base_fsp->fsp_name
    
    Stacked VFS modules might use the file name, not the file
    handle. Looking at you, vfs_fruit...
    
    Bug: https://bugzilla.samba.org/show_bug.cgi?id=13455
    
    Signed-off-by: Ralph Boehme <s...@samba.org>
    Reviewed-by: Jeremy Allison <j...@samba.org>
    (cherry picked from commit aa1fac696956f96e89e54ddd4535a6e2844161b0)
    
    Autobuild-User(v4-9-test): Karolin Seeger <ksee...@samba.org>
    Autobuild-Date(v4-9-test): Thu Dec 13 16:47:40 CET 2018 on sn-devel-144

commit fa2a9c3be08c42c8b2f800e384c0d428a232bacb
Author: Ralph Boehme <s...@samba.org>
Date:   Sat Nov 24 10:54:06 2018 +0100

    s3:smbd: pass down twrp from SMB2_CREATE to filename_convert()
    
    Bug: https://bugzilla.samba.org/show_bug.cgi?id=13455
    
    Signed-off-by: Ralph Boehme <s...@samba.org>
    Reviewed-by: Jeremy Allison <j...@samba.org>
    (cherry picked from commit 9c462e1b324ebad60c51bd6e8e659b39a31ec02e)

commit baf1e0f30fe052156ba10f956a870e0e4937f1d5
Author: Ralph Boehme <s...@samba.org>
Date:   Sat Nov 24 10:45:49 2018 +0100

    s3:smbd: add twrp args to filename_convert()
    
    All existing callers pass NULL, no change in behaviour.
    
    Bug: https://bugzilla.samba.org/show_bug.cgi?id=13455
    
    Signed-off-by: Ralph Boehme <s...@samba.org>
    Reviewed-by: Jeremy Allison <j...@samba.org>
    (cherry picked from commit 14b6e6842b76d7c3e53249ba026a3ff51615ebd7)

commit f8c144fa191b1c30f7a16fa527ddd540266f7927
Author: Ralph Boehme <s...@samba.org>
Date:   Sat Nov 24 09:05:37 2018 +0100

    s3:smbd: add twrp processing to filename_convert_internal()
    
    Not used for now, existing callers pass NULL.
    
    Bug: https://bugzilla.samba.org/show_bug.cgi?id=13455
    
    Signed-off-by: Ralph Boehme <s...@samba.org>
    Reviewed-by: Jeremy Allison <j...@samba.org>
    (cherry picked from commit c69bd336a17ca04dbfb4f5d04a963d25b9925118)

commit 88863119323fd758b922e2cfe05b13462f72bde9
Author: Ralph Boehme <s...@samba.org>
Date:   Sat Nov 24 08:56:49 2018 +0100

    s3:smbd: prepare filename_convert_internal() for twrp
    
    Bug: https://bugzilla.samba.org/show_bug.cgi?id=13455
    
    Signed-off-by: Ralph Boehme <s...@samba.org>
    Reviewed-by: Jeremy Allison <j...@samba.org>
    (cherry picked from commit bffc540bc8459cbb1bd1a98528fb1d3b2b54d1d2)

commit 3295cc8b4a51c09009785026b541c5ce1fc2fd2a
Author: Ralph Boehme <s...@samba.org>
Date:   Fri Nov 23 14:36:56 2018 +0100

    s3:selftest: add a VSS test reading a stream
    
    Bug: https://bugzilla.samba.org/show_bug.cgi?id=13455
    
    Signed-off-by: Ralph Boehme <s...@samba.org>
    Reviewed-by: Jeremy Allison <j...@samba.org>
    (cherry picked from commit cfffa2e2428b42db65a4ece00602e0cef8ceb5a3)

commit 1f897e6c1d2b29e92b9ddbc62a07ce66dbec4d93
Author: Günther Deschner <g...@samba.org>
Date:   Wed Oct 10 17:32:25 2018 +0200

    s3-vfs: Prevent NULL pointer dereference in vfs_glusterfs.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=13708
    
    Guenther
    
    Signed-off-by: Guenther Deschner <g...@samba.org>
    Reviewed-by: Ralph Boehme <s...@samba.org>
    
    Autobuild-User(master): Günther Deschner <g...@samba.org>
    Autobuild-Date(master): Tue Dec 11 17:26:31 CET 2018 on sn-devel-144
    
    (cherry picked from commit 75d15484f3b71b1a2684c4a73e53aaa467f9932b)

commit e60c9431c6e5619f84374851b90cbbf59e4fbb61
Author: Ralph Boehme <s...@samba.org>
Date:   Fri Nov 23 14:08:15 2018 +0100

    vfs_shadow_copy2: nicely deal with attempts to open previous version for 
writing
    
    Bug: https://bugzilla.samba.org/show_bug.cgi?id=13688
    
    Signed-off-by: Ralph Boehme <s...@samba.org>
    Reviewed-by: Jeremy Allison <j...@samba.org>
    (cherry picked from commit cf95756235f718478e556ce1fbf7c032f9c9acfb)

commit 256d488b593278482d2d9bb2e75b6304d8562d0a
Author: Ralph Boehme <s...@samba.org>
Date:   Thu Nov 22 11:04:54 2018 +0100

    vfs_shadow_copy2: add shadow_copy2_strip_snapshot_converted
    
    Can be used by callers to determine if a path is in fact pointing at a
    file in a snapshot. Will be used in the next commit.
    
    Bug: https://bugzilla.samba.org/show_bug.cgi?id=13688
    
    Signed-off-by: Ralph Boehme <s...@samba.org>
    Reviewed-by: Jeremy Allison <j...@samba.org>
    (cherry picked from commit 14d6488d355e960ab02e72c414cbbc316f1db718)

commit 0e355e3826fc0fa251a068ed5d620269168a308f
Author: Ralph Boehme <s...@samba.org>
Date:   Thu Nov 22 11:02:24 2018 +0100

    vfs_shadow_copy2: add _already_converted arg to 
shadow_copy2_strip_snapshot_internal()
    
    Not used for now, all existing callers pass NULL.
    
    Bug: https://bugzilla.samba.org/show_bug.cgi?id=13688
    
    Signed-off-by: Ralph Boehme <s...@samba.org>
    Reviewed-by: Jeremy Allison <j...@samba.org>
    (cherry picked from commit 87bf06ed790dad8a4f650c0cd1b6781864666cbf)

commit 0244de24cfe2df7c85bb8e28fa228ccebb9cacb2
Author: Ralph Boehme <s...@samba.org>
Date:   Fri Nov 23 10:18:44 2018 +0100

    s3:script/tests: add a test for VSS write behaviour
    
    Bug: https://bugzilla.samba.org/show_bug.cgi?id=13688
    
    Signed-off-by: Ralph Boehme <s...@samba.org>
    Reviewed-by: Jeremy Allison <j...@samba.org>
    (backported from commit 12778f015988f7e8755016c72c26939998758dae)

commit 6f8ea0a08eaced713bb358dc4f1b74cc84028f9f
Author: Ralph Boehme <s...@samba.org>
Date:   Wed Nov 14 13:45:11 2018 +0100

    s4:torture: add a test-suite for VSS
    
    This test will not be run from the main torture test runner in selftest,
    as there we don't pass the required arguments 'twrp_file' and
    'twrp_snapshot'.
    
    The test needs a carefully prepared environment with provisioned
    snapshot data, so the test will be started from a blackbox test
    script. That comes next.
    
    Bug: https://bugzilla.samba.org/show_bug.cgi?id=13688
    
    Signed-off-by: Ralph Boehme <s...@samba.org>
    Reviewed-by: Jeremy Allison <j...@samba.org>
    (cherry picked from commit 48ddb87a32ca44c2fcc5aac0cc28c5527dc7eade)

commit 1cf55de5cebbe4b043b0538595a0c57ed2da1806
Author: Ralph Boehme <s...@samba.org>
Date:   Fri Nov 23 10:18:10 2018 +0100

    vfs_error_inject: add EBADF error
    
    Bug: https://bugzilla.samba.org/show_bug.cgi?id=13688
    
    Signed-off-by: Ralph Boehme <s...@samba.org>
    Reviewed-by: Jeremy Allison <j...@samba.org>
    (cherry picked from commit 523a9b312c9f09178a5afefb48343e684e41d817)

commit 8eaf7922410657c9e87b4cf1f04a9eae6cf77990
Author: Ralph Boehme <s...@samba.org>
Date:   Fri Nov 23 10:07:29 2018 +0100

    vfs_error_inject: add pwrite
    
    Bug: https://bugzilla.samba.org/show_bug.cgi?id=13688
    
    Signed-off-by: Ralph Boehme <s...@samba.org>
    Reviewed-by: Jeremy Allison <j...@samba.org>
    (cherry picked from commit 55a82f907f6410ff478e82b0cf7f1caeacaf5ddd)

commit f53459c923232d85489844634289638f26000c9c
Author: Justin Stephenson <jstep...@redhat.com>
Date:   Wed Jun 27 11:32:31 2018 -0400

    s3:libads: Add net ads leave keep-account option
    
    Add the ability to leave the domain with --keep-account argument to avoid
    removal of the host machine account.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=13498
    
    Signed-off-by: Justin Stephenson <jstep...@redhat.com>
    Reviewed-by: Andrew Bartlett <abart...@samba.org>
    Reviewed-by: Alexander Bokovoy <a...@samba.org>
    (cherry picked from commit d881f0c8a0ce2fc7cabf1966c5724e72c70d6694)

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

Summary of changes:
 docs-xml/manpages/net.8.xml                      |   9 +-
 selftest/target/Samba3.pm                        |   9 +
 source3/libnet/libnet_join.c                     |   2 +
 source3/modules/vfs_error_inject.c               |  19 ++
 source3/modules/vfs_glusterfs.c                  | 176 ++++++++++++++---
 source3/modules/vfs_shadow_copy2.c               | 230 +++++++++++++++++++++--
 source3/rpc_server/srvsvc/srv_srvsvc_nt.c        |   2 +
 source3/script/tests/test_shadow_copy_torture.sh | 114 +++++++++++
 source3/selftest/tests.py                        |   1 +
 source3/smbd/filename.c                          |  32 +++-
 source3/smbd/nttrans.c                           |   4 +
 source3/smbd/open.c                              |   1 +
 source3/smbd/proto.h                             |   1 +
 source3/smbd/reply.c                             |  15 ++
 source3/smbd/smb2_create.c                       |  30 +--
 source3/smbd/smb2_query_directory.c              |   1 +
 source3/smbd/trans2.c                            |   8 +
 source3/utils/net.c                              |   3 +-
 source3/utils/net.h                              |   1 +
 source3/utils/net_ads.c                          |   9 +-
 source4/torture/smb2/create.c                    | 174 +++++++++++++++++
 source4/torture/smb2/smb2.c                      |   1 +
 22 files changed, 766 insertions(+), 76 deletions(-)
 create mode 100755 source3/script/tests/test_shadow_copy_torture.sh


Changeset truncated at 500 lines:

diff --git a/docs-xml/manpages/net.8.xml b/docs-xml/manpages/net.8.xml
index 3154ee5ff85..d2bcd24c502 100644
--- a/docs-xml/manpages/net.8.xml
+++ b/docs-xml/manpages/net.8.xml
@@ -377,6 +377,13 @@
                </para></listitem>
                </varlistentry>
 
+               <varlistentry>
+               <term>--keep-account</term>
+               <listitem><para>Prevent the machine account removal as
+               part of "net ads leave".
+               </para></listitem>
+               </varlistentry>
+
                &stdarg.encrypt;
                &popt.common.samba.client;
 
@@ -1276,7 +1283,7 @@ against an NT4 Domain Controller.
 </refsect2>
 
 <refsect2>
-<title>ADS LEAVE</title>
+<title>ADS LEAVE [--keep-account]</title>
 
 <para>Make the remote host leave the domain it is part of. </para>
 
diff --git a/selftest/target/Samba3.pm b/selftest/target/Samba3.pm
index 438cb3409bb..314aae55bc5 100755
--- a/selftest/target/Samba3.pm
+++ b/selftest/target/Samba3.pm
@@ -2134,6 +2134,15 @@ sub provision($$$$$$$$$)
        vfs objects = shadow_copy2
        shadow:mountpoint = $shadow_mntdir
        wide links = yes
+
+[shadow_write]
+       path = $shadow_tstdir
+       comment = previous versions snapshots under mount point
+       vfs objects = shadow_copy2 streams_xattr error_inject
+       aio write size = 0
+       error_inject:pwrite = EBADF
+       shadow:mountpoint = $shadow_tstdir
+
 [dfq]
        path = $shrdir/dfree
        vfs objects = acl_xattr fake_acls xattr_tdb fake_dfq
diff --git a/source3/libnet/libnet_join.c b/source3/libnet/libnet_join.c
index a9405e8d288..27fc5135442 100644
--- a/source3/libnet/libnet_join.c
+++ b/source3/libnet/libnet_join.c
@@ -2868,6 +2868,8 @@ static WERROR libnet_DomainUnjoin(TALLOC_CTX *mem_ctx,
                        return ntstatus_to_werror(status);
                }
 
+               r->out.dns_domain_name = talloc_strdup(mem_ctx,
+                                                     r->in.domain_name);
                r->out.disabled_machine_account = true;
        }
 
diff --git a/source3/modules/vfs_error_inject.c 
b/source3/modules/vfs_error_inject.c
index bb5477a449f..c8c3ea4701f 100644
--- a/source3/modules/vfs_error_inject.c
+++ b/source3/modules/vfs_error_inject.c
@@ -28,6 +28,7 @@ struct unix_error_map {
        int error;
 } unix_error_map_array[] = {
        {       "ESTALE",       ESTALE  },
+       {       "EBADF",        EBADF   },
 };
 
 static int find_unix_error_from_string(const char *err_str)
@@ -88,8 +89,26 @@ static int vfs_error_inject_chdir(vfs_handle_struct *handle,
        return SMB_VFS_NEXT_CHDIR(handle, smb_fname);
 }
 
+static ssize_t vfs_error_inject_pwrite(vfs_handle_struct *handle,
+                                      files_struct *fsp,
+                                      const void *data,
+                                      size_t n,
+                                      off_t offset)
+{
+       int error;
+
+       error = inject_unix_error("pwrite", handle);
+       if (error != 0) {
+               errno = error;
+               return -1;
+       }
+
+       return SMB_VFS_NEXT_PWRITE(handle, fsp, data, n, offset);
+}
+
 static struct vfs_fn_pointers vfs_error_inject_fns = {
        .chdir_fn = vfs_error_inject_chdir,
+       .pwrite_fn = vfs_error_inject_pwrite,
 };
 
 static_decl_vfs;
diff --git a/source3/modules/vfs_glusterfs.c b/source3/modules/vfs_glusterfs.c
index 02289a64e50..e32456f60b3 100644
--- a/source3/modules/vfs_glusterfs.c
+++ b/source3/modules/vfs_glusterfs.c
@@ -491,11 +491,33 @@ static DIR *vfs_gluster_opendir(struct vfs_handle_struct 
*handle,
        return (DIR *) fd;
 }
 
+static glfs_fd_t *vfs_gluster_fetch_glfd(struct vfs_handle_struct *handle,
+                                        files_struct *fsp)
+{
+       glfs_fd_t **glfd = (glfs_fd_t **)VFS_FETCH_FSP_EXTENSION(handle, fsp);
+       if (glfd == NULL) {
+               DBG_INFO("Failed to fetch fsp extension\n");
+               return NULL;
+       }
+       if (*glfd == NULL) {
+               DBG_INFO("Empty glfs_fd_t pointer\n");
+               return NULL;
+       }
+
+       return *glfd;
+}
+
 static DIR *vfs_gluster_fdopendir(struct vfs_handle_struct *handle,
                                  files_struct *fsp, const char *mask,
                                  uint32_t attributes)
 {
-       return (DIR *) *(glfs_fd_t **)VFS_FETCH_FSP_EXTENSION(handle, fsp);
+       glfs_fd_t *glfd = vfs_gluster_fetch_glfd(handle, fsp);
+       if (glfd == NULL) {
+               DBG_ERR("Failed to fetch gluster fd\n");
+               return NULL;
+       }
+
+       return (DIR *)glfd;
 }
 
 static int vfs_gluster_closedir(struct vfs_handle_struct *handle, DIR *dirp)
@@ -586,8 +608,12 @@ static int vfs_gluster_open(struct vfs_handle_struct 
*handle,
 static int vfs_gluster_close(struct vfs_handle_struct *handle,
                             files_struct *fsp)
 {
-       glfs_fd_t *glfd;
-       glfd = *(glfs_fd_t **)VFS_FETCH_FSP_EXTENSION(handle, fsp);
+       glfs_fd_t *glfd = vfs_gluster_fetch_glfd(handle, fsp);
+       if (glfd == NULL) {
+               DBG_ERR("Failed to fetch gluster fd\n");
+               return -1;
+       }
+
        VFS_REMOVE_FSP_EXTENSION(handle, fsp);
        return glfs_close(glfd);
 }
@@ -596,7 +622,13 @@ static ssize_t vfs_gluster_pread(struct vfs_handle_struct 
*handle,
                                 files_struct *fsp, void *data, size_t n,
                                 off_t offset)
 {
-       return glfs_pread(*(glfs_fd_t **)VFS_FETCH_FSP_EXTENSION(handle, fsp), 
data, n, offset, 0);
+       glfs_fd_t *glfd = vfs_gluster_fetch_glfd(handle, fsp);
+       if (glfd == NULL) {
+               DBG_ERR("Failed to fetch gluster fd\n");
+               return -1;
+       }
+
+       return glfs_pread(glfd, data, n, offset, 0);
 }
 
 struct glusterfs_aio_state;
@@ -798,6 +830,12 @@ static struct tevent_req *vfs_gluster_pread_send(struct 
vfs_handle_struct
        struct glusterfs_aio_state *state = NULL;
        struct tevent_req *req = NULL;
        int ret = 0;
+       glfs_fd_t *glfd = vfs_gluster_fetch_glfd(handle, fsp);
+
+       if (glfd == NULL) {
+               DBG_ERR("Failed to fetch gluster fd\n");
+               return NULL;
+       }
 
        state = aio_state_create(mem_ctx);
 
@@ -821,8 +859,7 @@ static struct tevent_req *vfs_gluster_pread_send(struct 
vfs_handle_struct
        tevent_req_defer_callback(req, ev);
 
        PROFILE_TIMESTAMP(&state->start);
-       ret = glfs_pread_async(*(glfs_fd_t **)VFS_FETCH_FSP_EXTENSION(handle,
-                               fsp), data, n, offset, 0, aio_glusterfs_done,
+       ret = glfs_pread_async(glfd, data, n, offset, 0, aio_glusterfs_done,
                                state);
        if (ret < 0) {
                tevent_req_error(req, -ret);
@@ -842,6 +879,12 @@ static struct tevent_req *vfs_gluster_pwrite_send(struct 
vfs_handle_struct
        struct glusterfs_aio_state *state = NULL;
        struct tevent_req *req = NULL;
        int ret = 0;
+       glfs_fd_t *glfd = vfs_gluster_fetch_glfd(handle, fsp);
+
+       if (glfd == NULL) {
+               DBG_ERR("Failed to fetch gluster fd\n");
+               return NULL;
+       }
 
        state = aio_state_create(mem_ctx);
 
@@ -865,8 +908,7 @@ static struct tevent_req *vfs_gluster_pwrite_send(struct 
vfs_handle_struct
        tevent_req_defer_callback(req, ev);
 
        PROFILE_TIMESTAMP(&state->start);
-       ret = glfs_pwrite_async(*(glfs_fd_t **)VFS_FETCH_FSP_EXTENSION(handle,
-                               fsp), data, n, offset, 0, aio_glusterfs_done,
+       ret = glfs_pwrite_async(glfd, data, n, offset, 0, aio_glusterfs_done,
                                state);
        if (ret < 0) {
                tevent_req_error(req, -ret);
@@ -910,13 +952,25 @@ static ssize_t vfs_gluster_pwrite(struct 
vfs_handle_struct *handle,
                                  files_struct *fsp, const void *data,
                                  size_t n, off_t offset)
 {
-       return glfs_pwrite(*(glfs_fd_t **)VFS_FETCH_FSP_EXTENSION(handle, fsp), 
data, n, offset, 0);
+       glfs_fd_t *glfd = vfs_gluster_fetch_glfd(handle, fsp);
+       if (glfd == NULL) {
+               DBG_ERR("Failed to fetch gluster fd\n");
+               return -1;
+       }
+
+       return glfs_pwrite(glfd, data, n, offset, 0);
 }
 
 static off_t vfs_gluster_lseek(struct vfs_handle_struct *handle,
                               files_struct *fsp, off_t offset, int whence)
 {
-       return glfs_lseek(*(glfs_fd_t **)VFS_FETCH_FSP_EXTENSION(handle, fsp), 
offset, whence);
+       glfs_fd_t *glfd = vfs_gluster_fetch_glfd(handle, fsp);
+       if (glfd == NULL) {
+               DBG_ERR("Failed to fetch gluster fd\n");
+               return -1;
+       }
+
+       return glfs_lseek(glfd, offset, whence);
 }
 
 static ssize_t vfs_gluster_sendfile(struct vfs_handle_struct *handle, int tofd,
@@ -952,6 +1006,12 @@ static struct tevent_req *vfs_gluster_fsync_send(struct 
vfs_handle_struct
        struct tevent_req *req = NULL;
        struct glusterfs_aio_state *state = NULL;
        int ret = 0;
+       glfs_fd_t *glfd = vfs_gluster_fetch_glfd(handle, fsp);
+
+       if (glfd == NULL) {
+               DBG_ERR("Failed to fetch gluster fd\n");
+               return NULL;
+       }
 
        state = aio_state_create(mem_ctx);
 
@@ -975,8 +1035,7 @@ static struct tevent_req *vfs_gluster_fsync_send(struct 
vfs_handle_struct
        tevent_req_defer_callback(req, ev);
 
        PROFILE_TIMESTAMP(&state->start);
-       ret = glfs_fsync_async(*(glfs_fd_t **)VFS_FETCH_FSP_EXTENSION(handle,
-                               fsp), aio_glusterfs_done, state);
+       ret = glfs_fsync_async(glfd, aio_glusterfs_done, state);
        if (ret < 0) {
                tevent_req_error(req, -ret);
                return tevent_req_post(req, ev);
@@ -1015,8 +1074,14 @@ static int vfs_gluster_fstat(struct vfs_handle_struct 
*handle,
 {
        struct stat st;
        int ret;
+       glfs_fd_t *glfd = vfs_gluster_fetch_glfd(handle, fsp);
 
-       ret = glfs_fstat(*(glfs_fd_t **)VFS_FETCH_FSP_EXTENSION(handle, fsp), 
&st);
+       if (glfd == NULL) {
+               DBG_ERR("Failed to fetch gluster fd\n");
+               return -1;
+       }
+
+       ret = glfs_fstat(glfd, &st);
        if (ret == 0) {
                smb_stat_ex_from_stat(sbuf, &st);
        }
@@ -1067,7 +1132,14 @@ static int vfs_gluster_chmod(struct vfs_handle_struct 
*handle,
 static int vfs_gluster_fchmod(struct vfs_handle_struct *handle,
                              files_struct *fsp, mode_t mode)
 {
-       return glfs_fchmod(*(glfs_fd_t **)VFS_FETCH_FSP_EXTENSION(handle, fsp), 
mode);
+       glfs_fd_t *glfd = vfs_gluster_fetch_glfd(handle, fsp);
+
+       if (glfd == NULL) {
+               DBG_ERR("Failed to fetch gluster fd\n");
+               return -1;
+       }
+
+       return glfs_fchmod(glfd, mode);
 }
 
 static int vfs_gluster_chown(struct vfs_handle_struct *handle,
@@ -1081,7 +1153,13 @@ static int vfs_gluster_chown(struct vfs_handle_struct 
*handle,
 static int vfs_gluster_fchown(struct vfs_handle_struct *handle,
                              files_struct *fsp, uid_t uid, gid_t gid)
 {
-       return glfs_fchown(*(glfs_fd_t **)VFS_FETCH_FSP_EXTENSION(handle, fsp), 
uid, gid);
+       glfs_fd_t *glfd = vfs_gluster_fetch_glfd(handle, fsp);
+       if (glfd == NULL) {
+               DBG_ERR("Failed to fetch gluster fd\n");
+               return -1;
+       }
+
+       return glfs_fchown(glfd, uid, gid);
 }
 
 static int vfs_gluster_lchown(struct vfs_handle_struct *handle,
@@ -1159,7 +1237,13 @@ static int vfs_gluster_ntimes(struct vfs_handle_struct 
*handle,
 static int vfs_gluster_ftruncate(struct vfs_handle_struct *handle,
                                 files_struct *fsp, off_t offset)
 {
-       return glfs_ftruncate(*(glfs_fd_t **)VFS_FETCH_FSP_EXTENSION(handle, 
fsp), offset);
+       glfs_fd_t *glfd = vfs_gluster_fetch_glfd(handle, fsp);
+       if (glfd == NULL) {
+               DBG_ERR("Failed to fetch gluster fd\n");
+               return -1;
+       }
+
+       return glfs_ftruncate(glfd, offset);
 }
 
 static int vfs_gluster_fallocate(struct vfs_handle_struct *handle,
@@ -1169,6 +1253,11 @@ static int vfs_gluster_fallocate(struct 
vfs_handle_struct *handle,
 {
 #ifdef HAVE_GFAPI_VER_6
        int keep_size, punch_hole;
+       glfs_fd_t *glfd = vfs_gluster_fetch_glfd(handle, fsp);
+       if (glfd == NULL) {
+               DBG_ERR("Failed to fetch gluster fd\n");
+               return -1;
+       }
 
        keep_size = mode & VFS_FALLOCATE_FL_KEEP_SIZE;
        punch_hole = mode & VFS_FALLOCATE_FL_PUNCH_HOLE;
@@ -1180,14 +1269,10 @@ static int vfs_gluster_fallocate(struct 
vfs_handle_struct *handle,
        }
 
        if (punch_hole) {
-               return glfs_discard(*(glfs_fd_t **)
-                                   VFS_FETCH_FSP_EXTENSION(handle, fsp),
-                                   offset, len);
+               return glfs_discard(glfd, offset, len);
        }
 
-       return glfs_fallocate(*(glfs_fd_t **)
-                             VFS_FETCH_FSP_EXTENSION(handle, fsp),
-                             keep_size, offset, len);
+       return glfs_fallocate(glfd, keep_size, offset, len);
 #else
        errno = ENOTSUP;
        return -1;
@@ -1224,6 +1309,11 @@ static bool vfs_gluster_lock(struct vfs_handle_struct 
*handle,
 {
        struct flock flock = { 0, };
        int ret;
+       glfs_fd_t *glfd = vfs_gluster_fetch_glfd(handle, fsp);
+       if (glfd == NULL) {
+               DBG_ERR("Failed to fetch gluster fd\n");
+               return false;
+       }
 
        flock.l_type = type;
        flock.l_whence = SEEK_SET;
@@ -1231,7 +1321,7 @@ static bool vfs_gluster_lock(struct vfs_handle_struct 
*handle,
        flock.l_len = count;
        flock.l_pid = 0;
 
-       ret = glfs_posix_lock(*(glfs_fd_t **)VFS_FETCH_FSP_EXTENSION(handle, 
fsp), op, &flock);
+       ret = glfs_posix_lock(glfd, op, &flock);
 
        if (op == F_GETLK) {
                /* lock query, true if someone else has locked */
@@ -1271,6 +1361,11 @@ static bool vfs_gluster_getlock(struct vfs_handle_struct 
*handle,
 {
        struct flock flock = { 0, };
        int ret;
+       glfs_fd_t *glfd = vfs_gluster_fetch_glfd(handle, fsp);
+       if (glfd == NULL) {
+               DBG_ERR("Failed to fetch gluster fd\n");
+               return false;
+       }
 
        flock.l_type = *ptype;
        flock.l_whence = SEEK_SET;
@@ -1278,7 +1373,7 @@ static bool vfs_gluster_getlock(struct vfs_handle_struct 
*handle,
        flock.l_len = *pcount;
        flock.l_pid = 0;
 
-       ret = glfs_posix_lock(*(glfs_fd_t **)VFS_FETCH_FSP_EXTENSION(handle, 
fsp), F_GETLK, &flock);
+       ret = glfs_posix_lock(glfd, F_GETLK, &flock);
 
        if (ret == -1) {
                return false;
@@ -1388,7 +1483,13 @@ static ssize_t vfs_gluster_fgetxattr(struct 
vfs_handle_struct *handle,
                                     files_struct *fsp, const char *name,
                                     void *value, size_t size)
 {
-       return glfs_fgetxattr(*(glfs_fd_t **)VFS_FETCH_FSP_EXTENSION(handle, 
fsp), name, value, size);
+       glfs_fd_t *glfd = vfs_gluster_fetch_glfd(handle, fsp);
+       if (glfd == NULL) {
+               DBG_ERR("Failed to fetch gluster fd\n");
+               return -1;
+       }
+
+       return glfs_fgetxattr(glfd, name, value, size);
 }
 
 static ssize_t vfs_gluster_listxattr(struct vfs_handle_struct *handle,
@@ -1403,7 +1504,13 @@ static ssize_t vfs_gluster_flistxattr(struct 
vfs_handle_struct *handle,
                                      files_struct *fsp, char *list,
                                      size_t size)
 {
-       return glfs_flistxattr(*(glfs_fd_t **)VFS_FETCH_FSP_EXTENSION(handle, 
fsp), list, size);
+       glfs_fd_t *glfd = vfs_gluster_fetch_glfd(handle, fsp);
+       if (glfd == NULL) {
+               DBG_ERR("Failed to fetch gluster fd\n");
+               return -1;
+       }
+
+       return glfs_flistxattr(glfd, list, size);
 }
 
 static int vfs_gluster_removexattr(struct vfs_handle_struct *handle,
@@ -1416,7 +1523,13 @@ static int vfs_gluster_removexattr(struct 
vfs_handle_struct *handle,
 static int vfs_gluster_fremovexattr(struct vfs_handle_struct *handle,
                                    files_struct *fsp, const char *name)
 {
-       return glfs_fremovexattr(*(glfs_fd_t **)VFS_FETCH_FSP_EXTENSION(handle, 
fsp), name);
+       glfs_fd_t *glfd = vfs_gluster_fetch_glfd(handle, fsp);
+       if (glfd == NULL) {
+               DBG_ERR("Failed to fetch gluster fd\n");
+               return -1;
+       }
+
+       return glfs_fremovexattr(glfd, name);
 }
 
 static int vfs_gluster_setxattr(struct vfs_handle_struct *handle,
@@ -1431,8 +1544,13 @@ static int vfs_gluster_fsetxattr(struct 
vfs_handle_struct *handle,
                                 files_struct *fsp, const char *name,
                                 const void *value, size_t size, int flags)
 {
-       return glfs_fsetxattr(*(glfs_fd_t **)VFS_FETCH_FSP_EXTENSION(handle, 
fsp), name, value, size,
-                             flags);
+       glfs_fd_t *glfd = vfs_gluster_fetch_glfd(handle, fsp);
+       if (glfd == NULL) {
+               DBG_ERR("Failed to fetch gluster fd\n");
+               return -1;
+       }
+
+       return glfs_fsetxattr(glfd, name, value, size, flags);
 }
 
 /* AIO Operations */
diff --git a/source3/modules/vfs_shadow_copy2.c 
b/source3/modules/vfs_shadow_copy2.c
index aa7cd9c61d0..06ef3ebc9b8 100644
--- a/source3/modules/vfs_shadow_copy2.c
+++ b/source3/modules/vfs_shadow_copy2.c
@@ -36,6 +36,8 @@
 #include "include/ntioctl.h"
 #include "util_tdb.h"
 #include "lib/util_path.h"
+#include "libcli/security/security.h"
+#include "lib/util/tevent_unix.h"
 
 struct shadow_copy2_config {
        char *gmt_format;
@@ -587,7 +589,8 @@ static bool shadow_copy2_strip_snapshot_internal(TALLOC_CTX 
*mem_ctx,
                                        const char *orig_name,
                                        time_t *ptimestamp,
                                        char **pstripped,
-                                       char **psnappath)
+                                       char **psnappath,
+                                       bool *_already_converted)
 {
        struct tm tm;
        time_t timestamp = 0;
@@ -608,6 +611,10 @@ static bool 
shadow_copy2_strip_snapshot_internal(TALLOC_CTX *mem_ctx,
 
        DEBUG(10, (__location__ ": enter path '%s'\n", name));
 
+       if (_already_converted != NULL) {
+               *_already_converted = false;
+       }
+
        abs_path = make_path_absolute(mem_ctx, priv, name);
        if (abs_path == NULL) {
                ret = false;
@@ -630,6 +637,9 @@ static bool shadow_copy2_strip_snapshot_internal(TALLOC_CTX 
*mem_ctx,
        }
 
        if (already_converted) {
+               if (_already_converted != NULL) {
+                       *_already_converted = true;
+               }


-- 
Samba Shared Repository

Reply via email to