[SCM] Samba Shared Repository - branch v4-8-test updated

Karolin Seeger kseeger at samba.org
Thu Dec 13 17:21:03 UTC 2018


The branch, v4-8-test has been updated
       via  74507e182c7 vfs_shadow_copy2: in fstat also convert fsp->fsp_name and fsp->base_fsp->fsp_name
       via  0d353c2ab06 s3:smbd: pass down twrp from SMB2_CREATE to filename_convert()
       via  299eef1e7e1 s3:smbd: add twrp args to filename_convert()
       via  b2dcbafef73 s3:smbd: add twrp processing to filename_convert_internal()
       via  b12bceb8b7e s3:smbd: prepare filename_convert_internal() for twrp
       via  450ac189c88 s3:selftest: add a VSS test reading a stream
       via  6f55dc0ccdf s3-vfs: Prevent NULL pointer dereference in vfs_glusterfs.
       via  06336d8a59e vfs_shadow_copy2: nicely deal with attempts to open previous version for writing
       via  eae534f01ca vfs_shadow_copy2: add shadow_copy2_strip_snapshot_converted
       via  5a0d7463c60 vfs_shadow_copy2: add _already_converted arg to shadow_copy2_strip_snapshot_internal()
       via  de114204480 s3:script/tests: add a test for VSS write behaviour
       via  8c031cf05e5 s4:torture: add a test-suite for VSS
       via  b22e8f355bd vfs_error_inject: add EBADF error
       via  688f91e366a vfs_error_inject: add pwrite
      from  a988dcb90c4 VERSION: Bump version up to 4.8.9...

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


- Log -----------------------------------------------------------------
commit 74507e182c7b0b4382cedc1b1c9d3c5c0830e411
Author: Ralph Boehme <slow at 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 <slow at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>
    (cherry picked from commit aa1fac696956f96e89e54ddd4535a6e2844161b0)
    
    Autobuild-User(v4-8-test): Karolin Seeger <kseeger at samba.org>
    Autobuild-Date(v4-8-test): Thu Dec 13 18:20:47 CET 2018 on sn-devel-144

commit 0d353c2ab0692a95b4e7f0d1b13cdfe34d24047e
Author: Ralph Boehme <slow at 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 <slow at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>
    (cherry picked from commit 9c462e1b324ebad60c51bd6e8e659b39a31ec02e)

commit 299eef1e7e1a282f9aef0ebd9b6d948ef6cbdd9f
Author: Ralph Boehme <slow at 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 <slow at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>
    (cherry picked from commit 14b6e6842b76d7c3e53249ba026a3ff51615ebd7)

commit b2dcbafef734cf77ee7c0c53ca7f173a9482259d
Author: Ralph Boehme <slow at 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 <slow at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>
    (cherry picked from commit c69bd336a17ca04dbfb4f5d04a963d25b9925118)

commit b12bceb8b7e6a89c09bd5ca4d002925c1afc535e
Author: Ralph Boehme <slow at 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 <slow at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>
    (cherry picked from commit bffc540bc8459cbb1bd1a98528fb1d3b2b54d1d2)

commit 450ac189c88bfa43e0a15ac4d81a5192e59c5ec4
Author: Ralph Boehme <slow at 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 <slow at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>
    (cherry picked from commit cfffa2e2428b42db65a4ece00602e0cef8ceb5a3)

commit 6f55dc0ccdf7f576719d08b22ef17af7e6769c2c
Author: Günther Deschner <gd at 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 <gd at samba.org>
    Reviewed-by: Ralph Boehme <slow at samba.org>
    
    Autobuild-User(master): Günther Deschner <gd at samba.org>
    Autobuild-Date(master): Tue Dec 11 17:26:31 CET 2018 on sn-devel-144
    
    (cherry picked from commit 75d15484f3b71b1a2684c4a73e53aaa467f9932b)

commit 06336d8a59e1d25a06834c1df0b73817c822353b
Author: Ralph Boehme <slow at 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 <slow at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>
    (cherry picked from commit cf95756235f718478e556ce1fbf7c032f9c9acfb)

commit eae534f01cae6ea6fa875bae15f11dd0006b406e
Author: Ralph Boehme <slow at 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 <slow at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>
    (cherry picked from commit 14d6488d355e960ab02e72c414cbbc316f1db718)

commit 5a0d7463c601f14fd0efd2e793192fd520cc48bf
Author: Ralph Boehme <slow at 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 <slow at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>
    (cherry picked from commit 87bf06ed790dad8a4f650c0cd1b6781864666cbf)

commit de114204480a59b06ac6d8e63647cb6ec9e06b7e
Author: Ralph Boehme <slow at 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 <slow at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>
    (backported from commit 12778f015988f7e8755016c72c26939998758dae)

commit 8c031cf05e52c1d5ade78d33db2e9f4ff21d17e7
Author: Ralph Boehme <slow at 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 <slow at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>
    (cherry picked from commit 48ddb87a32ca44c2fcc5aac0cc28c5527dc7eade)

commit b22e8f355bdb013dfdb46d2fdafaa0d8e57387b8
Author: Ralph Boehme <slow at 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 <slow at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>
    (cherry picked from commit 523a9b312c9f09178a5afefb48343e684e41d817)

commit 688f91e366a983d102111193d85e5671d951d13f
Author: Ralph Boehme <slow at 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 <slow at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>
    (cherry picked from commit 55a82f907f6410ff478e82b0cf7f1caeacaf5ddd)

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

Summary of changes:
 selftest/target/Samba3.pm                        |   9 +
 source3/modules/vfs_error_inject.c               |  19 ++
 source3/modules/vfs_glusterfs.c                  | 200 ++++++++++++++++----
 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 +
 source4/torture/smb2/create.c                    | 174 +++++++++++++++++
 source4/torture/smb2/smb2.c                      |   1 +
 17 files changed, 767 insertions(+), 75 deletions(-)
 create mode 100755 source3/script/tests/test_shadow_copy_torture.sh


Changeset truncated at 500 lines:

diff --git a/selftest/target/Samba3.pm b/selftest/target/Samba3.pm
index 3747a1e087e..e30d1a4c7c8 100755
--- a/selftest/target/Samba3.pm
+++ b/selftest/target/Samba3.pm
@@ -2158,6 +2158,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/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 38abb78f1f3..e6448cc874a 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);
 }
@@ -595,14 +621,26 @@ static int vfs_gluster_close(struct vfs_handle_struct *handle,
 static ssize_t vfs_gluster_read(struct vfs_handle_struct *handle,
 				files_struct *fsp, void *data, size_t n)
 {
-	return glfs_read(*(glfs_fd_t **)VFS_FETCH_FSP_EXTENSION(handle, fsp), data, n, 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_read(glfd, data, n, 0);
 }
 
 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;
@@ -795,6 +833,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);
 
@@ -810,8 +854,7 @@ static struct tevent_req *vfs_gluster_pread_send(struct vfs_handle_struct
 	}
 
 	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);
@@ -831,6 +874,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);
 
@@ -846,8 +895,7 @@ static struct tevent_req *vfs_gluster_pwrite_send(struct vfs_handle_struct
 	}
 
 	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);
@@ -890,20 +938,38 @@ static ssize_t vfs_gluster_recv(struct tevent_req *req,
 static ssize_t vfs_gluster_write(struct vfs_handle_struct *handle,
 				 files_struct *fsp, const void *data, size_t n)
 {
-	return glfs_write(*(glfs_fd_t **)VFS_FETCH_FSP_EXTENSION(handle, fsp), data, n, 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_write(glfd, data, n, 0);
 }
 
 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,
@@ -934,7 +1000,13 @@ static int vfs_gluster_rename(struct vfs_handle_struct *handle,
 static int vfs_gluster_fsync(struct vfs_handle_struct *handle,
 			     files_struct *fsp)
 {
-	return glfs_fsync(*(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;
+	}
+
+	return glfs_fsync(glfd);
 }
 
 static struct tevent_req *vfs_gluster_fsync_send(struct vfs_handle_struct
@@ -945,6 +1017,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);
 
@@ -960,8 +1038,7 @@ static struct tevent_req *vfs_gluster_fsync_send(struct vfs_handle_struct
 	}
 
 	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);
@@ -1000,8 +1077,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);
 	}
@@ -1052,7 +1135,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,
@@ -1066,7 +1156,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,
@@ -1144,7 +1240,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,
@@ -1154,6 +1256,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;
@@ -1165,14 +1272,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;
@@ -1209,6 +1312,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;
@@ -1216,7 +1324,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 */
@@ -1256,6 +1364,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;
@@ -1263,7 +1376,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;
@@ -1373,7 +1486,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,
@@ -1388,7 +1507,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,
@@ -1401,7 +1526,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,
@@ -1416,8 +1547,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 b6745cf169b..22d9331ed22 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) {


-- 
Samba Shared Repository



More information about the samba-cvs mailing list