[SCM] Samba Shared Repository - branch master updated

Jeremy Allison jra at samba.org
Tue Mar 24 21:24:02 UTC 2020


The branch, master has been updated
       via  2a5d994b1a1 vfs: remove SMB_VFS_OPENDIR()
       via  54e0f250713 smbd: use open_internal_dirfsp_at() and OpenDir_fsp() in OpenDir()
       via  45f62cece03 smbd: add open_internal_dirfsp_at()
       via  af622683115 smbd: reformat OpenDir() function definition
       via  b6bcc4bddc7 smbd: update smb_Dir_destructor() to cope with fsp->dptr not being set
       via  6dccfd63a86 smbd: remove fdopendir() fallback
       via  d961608ce9f smbd: simplify non_widelink_open()
       via  38cce1bccbf vfs_shadow_copy2: use create_internal_dirfsp_at() and SMB_VFS_FDOPENDIR()
       via  974ea2ce349 smbd: add create_internal_dirfsp_at()
       via  4d28b614af6 vfs_shadow_copy: use OpenDir() in shadow_copy_get_shadow_copy_data()
       via  8339b485a6f vfs_streams_depot: use OpenDir() in walk_streams()
       via  7217694cab4 vfs_fruit: use OpenDir() in fruit_disk_free()
       via  a5e4f70db3d vfs_fruit: pass e->d_name directly to fruit_tmsize_do_dirent()
       via  232d7481111 vfs_fruit: let fruit_get_num_bands() take bundle as const
       via  b0dab9d9711 vfs_fruit: use OpenDir() instead of SMB_VFS_OPENDIR() in fruit_get_num_bands()
       via  cc07cdafce9 vfs_ceph_snapshots: use OpenDir() in ceph_snap_gmt_convert_dir()
       via  ec9fcb31135 vfs_ceph_snapshots: use OpenDir() in ceph_snap_enum_snapdir()
       via  afa69567cf9 vfstest: use OpenDir()
       via  11f14c2ca11 smbd: use canonicalize_connect_path() in create_conn_struct_as_root()
       via  67b9b52bb66 smbd: make canonicalize_connect_path() public
       via  70d33236fc9 smbd: use OpenDir() in form_junctions()
       via  0a9d8c41e01 smbd: use OpenDir() in count_dfs_links()
       via  12b1913e346 vfs_fruit: move fruit_unlink_internal() back into fruit_unlinkat()
       via  43093743f2c vfs_fruit: remove internal directory cleanup logic
      from  d61a33acda4 selftest: Fix string compare in DnsHandler() of dns_hub.py

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


- Log -----------------------------------------------------------------
commit 2a5d994b1a136af1ed1542fbb008c3744ac661bb
Author: Ralph Boehme <slow at samba.org>
Date:   Mon Mar 23 10:44:08 2020 +0100

    vfs: remove SMB_VFS_OPENDIR()
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>
    
    Autobuild-User(master): Jeremy Allison <jra at samba.org>
    Autobuild-Date(master): Tue Mar 24 21:23:43 UTC 2020 on sn-devel-184

commit 54e0f25071364fafb98f2383828856184a6c0e8d
Author: Ralph Boehme <slow at samba.org>
Date:   Wed Mar 18 16:01:17 2020 +0100

    smbd: use open_internal_dirfsp_at() and OpenDir_fsp() in OpenDir()
    
    This allows consolidating symlink safe processing of pathnames to the low-level
    function non_widelink_open() used in the file open codepath via fd_open() and
    the new utility function open_internal_dirfsp_at().
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 45f62cece038a40892b2a567969313fac75e39c2
Author: Ralph Boehme <slow at samba.org>
Date:   Mon Mar 16 18:53:15 2020 +0100

    smbd: add open_internal_dirfsp_at()
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit af622683115a0738adacbdccd2d797067f3ba3cc
Author: Ralph Boehme <slow at samba.org>
Date:   Mon Mar 23 13:56:49 2020 +0100

    smbd: reformat OpenDir() function definition
    
    Gives a nicer diff in the next commit. No change in behaviour.
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit b6bcc4bddc73e27ff3d36946f8bce927e41337c7
Author: Ralph Boehme <slow at samba.org>
Date:   Wed Mar 18 18:25:33 2020 +0100

    smbd: update smb_Dir_destructor() to cope with fsp->dptr not being set
    
    Currently the only caller of OpenDir_fsp() is dptr_create() which means
    fsp->dptr will always be set by dptr_create().
    
    A subsequent commit will add another caller so that fsp->dptr will end up being
    NULL.
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 6dccfd63a868b71227c662ecc86c9bc091be11a9
Author: Ralph Boehme <slow at samba.org>
Date:   Wed Mar 18 15:59:11 2020 +0100

    smbd: remove fdopendir() fallback
    
    In order to get rid of SMB_VFS_OPENDIR, we have to require
    fdopendir(). Everybody but macOS seems to have it, so RIP opendir() fallback.
    
    This also prepares for a subsequent commit where we're going to start calling
    OpenDir_fsp() from inside OpenDir(). Without removing the fallback this would
    result in a recursion.
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit d961608ce9fbb2ec6ce6ad0979c08bb9911bbbee
Author: Ralph Boehme <slow at samba.org>
Date:   Tue Mar 17 17:35:44 2020 +0100

    smbd: simplify non_widelink_open()
    
    As fsp->is_directory is already correctly populated by our callers, we can drop
    the complicated and possibly broken logic that relies on O_DIRECTORY being
    defined.
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 38cce1bccbf482fae60d9f09fc33e299d7d4816d
Author: Ralph Boehme <slow at samba.org>
Date:   Sun Mar 22 12:21:10 2020 +0100

    vfs_shadow_copy2: use create_internal_dirfsp_at() and SMB_VFS_FDOPENDIR()
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 974ea2ce349627732bfc683598d148da20a5b118
Author: Ralph Boehme <slow at samba.org>
Date:   Mon Mar 23 11:36:42 2020 +0100

    smbd: add create_internal_dirfsp_at()
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 4d28b614af6aac3a16f8cd758afdce79b2bd15e6
Author: Ralph Boehme <slow at samba.org>
Date:   Thu Mar 19 12:03:27 2020 +0100

    vfs_shadow_copy: use OpenDir() in shadow_copy_get_shadow_copy_data()
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 8339b485a6f0c9dc38ff8bfbdcb2f906425b4ebd
Author: Ralph Boehme <slow at samba.org>
Date:   Thu Mar 19 12:03:27 2020 +0100

    vfs_streams_depot: use OpenDir() in walk_streams()
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 7217694cab4d5bb900ca39adfc714c4722d0764f
Author: Ralph Boehme <slow at samba.org>
Date:   Thu Mar 19 12:03:27 2020 +0100

    vfs_fruit: use OpenDir() in fruit_disk_free()
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit a5e4f70db3d9f43bacbd022a1a6006bde8ed6db8
Author: Ralph Boehme <slow at samba.org>
Date:   Thu Mar 19 12:42:45 2020 +0100

    vfs_fruit: pass e->d_name directly to fruit_tmsize_do_dirent()
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 232d748111159094558fa669722bb1e90b527a1e
Author: Ralph Boehme <slow at samba.org>
Date:   Thu Mar 19 12:39:44 2020 +0100

    vfs_fruit: let fruit_get_num_bands() take bundle as const
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit b0dab9d971152e7c54ae1979b8aba0a8ef076b26
Author: Ralph Boehme <slow at samba.org>
Date:   Thu Mar 19 12:03:27 2020 +0100

    vfs_fruit: use OpenDir() instead of SMB_VFS_OPENDIR() in fruit_get_num_bands()
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit cc07cdafce97fbda520033971cf8f4243f79c6ce
Author: Ralph Boehme <slow at samba.org>
Date:   Thu Mar 19 12:03:27 2020 +0100

    vfs_ceph_snapshots: use OpenDir() in ceph_snap_gmt_convert_dir()
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit ec9fcb3113592db51aa1c5165f44089cd5b787f1
Author: Ralph Boehme <slow at samba.org>
Date:   Thu Mar 19 12:03:27 2020 +0100

    vfs_ceph_snapshots: use OpenDir() in ceph_snap_enum_snapdir()
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit afa69567cf9f7eaac401a0acb9556d3d18d274a2
Author: Ralph Boehme <slow at samba.org>
Date:   Wed Mar 18 17:40:29 2020 +0100

    vfstest: use OpenDir()
    
    Note that as ReadDirName() returns translated names (in Windows "encoding"), in
    cmd_translate_name() test we have to translate back to UNIX "encoding" to check
    if the filename matches the user requested path which is also in UNIX
    "encoding".
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 11f14c2ca116115d895b150b2901c1d909bb75de
Author: Ralph Boehme <slow at samba.org>
Date:   Thu Mar 19 11:19:48 2020 +0100

    smbd: use canonicalize_connect_path() in create_conn_struct_as_root()
    
    This fix ensures create_conn_struct_as_root() works the same way as
    make_connection_snum() used in smbd for SMB sessions. Without this any caller of
    create_conn_struct_as_root() will fail to use work on shares if the sharepath
    contains a symlink.
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 67b9b52bb66051d7ae32a4355b6ed61202ddcb7f
Author: Ralph Boehme <slow at samba.org>
Date:   Thu Mar 19 11:19:34 2020 +0100

    smbd: make canonicalize_connect_path() public
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 70d33236fc9c93275f4d070659d88abf4c63b8f6
Author: Ralph Boehme <slow at samba.org>
Date:   Wed Mar 18 16:12:09 2020 +0100

    smbd: use OpenDir() in form_junctions()
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 0a9d8c41e010d796f0e25ece6c6409b48fb5082c
Author: Ralph Boehme <slow at samba.org>
Date:   Wed Mar 18 12:05:06 2020 +0100

    smbd: use OpenDir() in count_dfs_links()
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 12b1913e3460cd210b9f11e5ae4febd2018413d3
Author: Ralph Boehme <slow at samba.org>
Date:   Thu Mar 19 14:07:23 2020 +0100

    vfs_fruit: move fruit_unlink_internal() back into fruit_unlinkat()
    
    I think this makes fruit_unlinkat() easier to read. No change in behaviour.
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 43093743f2cd0acce6a90e3826afd1223f75edc9
Author: Ralph Boehme <slow at samba.org>
Date:   Tue Mar 17 19:03:53 2020 +0100

    vfs_fruit: remove internal directory cleanup logic
    
    Currently fruit does a cleanup run on a directory when it is being removed: it
    lists the directory and does an explicit unlink on any found file that is a
    genuine AppleDouble file.
    
    This is not realy needed: the ._ AppleDouble sidecar files are either vetoed by
    default, so cleanup can be turned on by the built-in "delete veto files"
    options. Or, if the user sets "fruit:veto_appledouble", the client will see the
    file in a directory list as ordinary files, so the client is responsible for
    deleting them first before removing the parent directory.
    
    tl;dr
    
    One caller of SMB_VFS_OPENDIR() less. :)
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

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

Summary of changes:
 examples/VFS/skel_opaque.c            |   9 --
 examples/VFS/skel_transparent.c       |   9 --
 source3/include/vfs.h                 |  13 +-
 source3/include/vfs_macros.h          |   5 -
 source3/modules/vfs_audit.c           |  18 ---
 source3/modules/vfs_cap.c             |  26 ----
 source3/modules/vfs_catia.c           |  39 -----
 source3/modules/vfs_ceph.c            |  20 ---
 source3/modules/vfs_ceph_snapshots.c  | 129 ++++++----------
 source3/modules/vfs_default.c         |  14 --
 source3/modules/vfs_dirsort.c         |  62 --------
 source3/modules/vfs_extd_audit.c      |  24 ---
 source3/modules/vfs_fruit.c           | 274 +++++++++++-----------------------
 source3/modules/vfs_full_audit.c      |  21 ---
 source3/modules/vfs_glusterfs.c       |  21 ---
 source3/modules/vfs_media_harmony.c   |  57 -------
 source3/modules/vfs_not_implemented.c |   9 --
 source3/modules/vfs_shadow_copy.c     |  98 ++++--------
 source3/modules/vfs_shadow_copy2.c    |  93 +++++-------
 source3/modules/vfs_snapper.c         |  47 ------
 source3/modules/vfs_streams_depot.c   |  25 ++--
 source3/modules/vfs_time_audit.c      |  21 ---
 source3/modules/vfs_unityed_media.c   |  53 -------
 source3/smbd/dir.c                    | 222 +++------------------------
 source3/smbd/files.c                  |  85 +++++++++++
 source3/smbd/msdfs.c                  |  39 ++---
 source3/smbd/open.c                   |   9 +-
 source3/smbd/proto.h                  |  11 ++
 source3/smbd/service.c                |   2 +-
 source3/smbd/vfs.c                    |   9 --
 source3/torture/cmd_vfs.c             |  97 ++++++------
 source3/torture/vfstest.h             |   3 +-
 32 files changed, 406 insertions(+), 1158 deletions(-)


Changeset truncated at 500 lines:

diff --git a/examples/VFS/skel_opaque.c b/examples/VFS/skel_opaque.c
index c1b5923b752..ed9f108009e 100644
--- a/examples/VFS/skel_opaque.c
+++ b/examples/VFS/skel_opaque.c
@@ -122,14 +122,6 @@ static NTSTATUS skel_read_dfs_pathat(struct vfs_handle_struct *handle,
 	return NT_STATUS_NOT_IMPLEMENTED;
 }
 
-static DIR *skel_opendir(vfs_handle_struct *handle,
-			const struct smb_filename *smb_fname,
-			const char *mask,
-			uint32_t attr)
-{
-	return NULL;
-}
-
 static NTSTATUS skel_snap_check_path(struct vfs_handle_struct *handle,
 				     TALLOC_CTX *mem_ctx,
 				     const char *service_path,
@@ -1059,7 +1051,6 @@ static struct vfs_fn_pointers skel_opaque_fns = {
 
 	/* Directory operations */
 
-	.opendir_fn = skel_opendir,
 	.fdopendir_fn = skel_fdopendir,
 	.readdir_fn = skel_readdir,
 	.seekdir_fn = skel_seekdir,
diff --git a/examples/VFS/skel_transparent.c b/examples/VFS/skel_transparent.c
index d2d05673fb4..1dce543734f 100644
--- a/examples/VFS/skel_transparent.c
+++ b/examples/VFS/skel_transparent.c
@@ -128,14 +128,6 @@ static NTSTATUS skel_read_dfs_pathat(struct vfs_handle_struct *handle,
 					preferral_count);
 }
 
-static DIR *skel_opendir(vfs_handle_struct *handle,
-			const struct smb_filename *smb_fname,
-			const char *mask,
-			uint32_t attr)
-{
-	return SMB_VFS_NEXT_OPENDIR(handle, smb_fname, mask, attr);
-}
-
 static NTSTATUS skel_snap_check_path(struct vfs_handle_struct *handle,
 				     TALLOC_CTX *mem_ctx,
 				     const char *service_path,
@@ -1366,7 +1358,6 @@ static struct vfs_fn_pointers skel_transparent_fns = {
 
 	/* Directory operations */
 
-	.opendir_fn = skel_opendir,
 	.fdopendir_fn = skel_fdopendir,
 	.readdir_fn = skel_readdir,
 	.seekdir_fn = skel_seekdir,
diff --git a/source3/include/vfs.h b/source3/include/vfs.h
index 85da21513fc..bda6cde3fdc 100644
--- a/source3/include/vfs.h
+++ b/source3/include/vfs.h
@@ -292,6 +292,7 @@
 /* Version 42 - Add SMB_VFS_READ_DFS_PATHAT() */
 /* Change to Version 43 - will ship with 4.13. */
 /* Version 43 - Remove deferred_close from struct files_struct */
+/* Version 43 - Remove SMB_VFS_OPENDIR() */
 
 #define SMB_VFS_INTERFACE_VERSION 43
 
@@ -719,10 +720,6 @@ struct vfs_fn_pointers {
 
 	/* Directory operations */
 
-	DIR *(*opendir_fn)(struct vfs_handle_struct *handle,
-					const struct smb_filename *smb_fname,
-					const char *mask,
-					uint32_t attributes);
 	DIR *(*fdopendir_fn)(struct vfs_handle_struct *handle, files_struct *fsp, const char *mask, uint32_t attributes);
 	struct dirent *(*readdir_fn)(struct vfs_handle_struct *handle,
 					 DIR *dirp,
@@ -1230,10 +1227,6 @@ NTSTATUS smb_vfs_call_read_dfs_pathat(struct vfs_handle_struct *handle,
 				const struct smb_filename *smb_fname,
 				struct referral **ppreflist,
 				size_t *preferral_count);
-DIR *smb_vfs_call_opendir(struct vfs_handle_struct *handle,
-			const struct smb_filename *smb_fname,
-			const char *mask,
-			uint32_t attributes);
 DIR *smb_vfs_call_fdopendir(struct vfs_handle_struct *handle,
 					struct files_struct *fsp,
 					const char *mask,
@@ -1678,10 +1671,6 @@ NTSTATUS vfs_not_implemented_read_dfs_pathat(struct vfs_handle_struct *handle,
 				const struct smb_filename *smb_fname,
 				struct referral **ppreflist,
 				size_t *preferral_count);
-DIR *vfs_not_implemented_opendir(vfs_handle_struct *handle,
-			const struct smb_filename *smb_fname,
-			const char *mask,
-			uint32_t attr);
 NTSTATUS vfs_not_implemented_snap_check_path(struct vfs_handle_struct *handle,
 				TALLOC_CTX *mem_ctx,
 				const char *service_path,
diff --git a/source3/include/vfs_macros.h b/source3/include/vfs_macros.h
index 112169ab83b..c8c41cd62f5 100644
--- a/source3/include/vfs_macros.h
+++ b/source3/include/vfs_macros.h
@@ -106,11 +106,6 @@
                 (pcount))
 
 /* Directory operations */
-#define SMB_VFS_OPENDIR(conn, smb_fname, mask, attr) \
-	smb_vfs_call_opendir((conn)->vfs_handles, (smb_fname), (mask), (attr))
-#define SMB_VFS_NEXT_OPENDIR(handle, smb_fname, mask, attr) \
-	smb_vfs_call_opendir((handle)->next, (smb_fname), (mask), (attr))
-
 #define SMB_VFS_FDOPENDIR(fsp, mask, attr) \
 	smb_vfs_call_fdopendir((fsp)->conn->vfs_handles, (fsp), (mask), (attr))
 #define SMB_VFS_NEXT_FDOPENDIR(handle, fsp, mask, attr) \
diff --git a/source3/modules/vfs_audit.c b/source3/modules/vfs_audit.c
index 84640b2bfa9..916d8a04206 100644
--- a/source3/modules/vfs_audit.c
+++ b/source3/modules/vfs_audit.c
@@ -177,23 +177,6 @@ static void audit_disconnect(vfs_handle_struct *handle)
 	return;
 }
 
-static DIR *audit_opendir(vfs_handle_struct *handle,
-			const struct smb_filename *smb_fname,
-			const char *mask,
-			uint32_t attr)
-{
-	DIR *result;
-	
-	result = SMB_VFS_NEXT_OPENDIR(handle, smb_fname, mask, attr);
-
-	syslog(audit_syslog_priority(handle), "opendir %s %s%s\n",
-	       smb_fname->base_name,
-	       (result == NULL) ? "failed: " : "",
-	       (result == NULL) ? strerror(errno) : "");
-
-	return result;
-}
-
 static int audit_mkdirat(vfs_handle_struct *handle,
 		struct files_struct *dirfsp,
 		const struct smb_filename *smb_fname,
@@ -321,7 +304,6 @@ static int audit_fchmod(vfs_handle_struct *handle, files_struct *fsp, mode_t mod
 static struct vfs_fn_pointers vfs_audit_fns = {
 	.connect_fn = audit_connect,
 	.disconnect_fn = audit_disconnect,
-	.opendir_fn = audit_opendir,
 	.mkdirat_fn = audit_mkdirat,
 	.open_fn = audit_open,
 	.close_fn = audit_close,
diff --git a/source3/modules/vfs_cap.c b/source3/modules/vfs_cap.c
index e67cb750e0f..d9c741dd1f8 100644
--- a/source3/modules/vfs_cap.c
+++ b/source3/modules/vfs_cap.c
@@ -82,31 +82,6 @@ static int cap_get_quota(vfs_handle_struct *handle,
 	return SMB_VFS_NEXT_GET_QUOTA(handle, cap_smb_fname, qtype, id, dq);
 }
 
-static DIR *cap_opendir(vfs_handle_struct *handle,
-			const struct smb_filename *smb_fname,
-			const char *mask,
-			uint32_t attr)
-{
-	char *capname = capencode(talloc_tos(), smb_fname->base_name);
-	struct smb_filename *cap_smb_fname = NULL;
-
-	if (!capname) {
-		errno = ENOMEM;
-		return NULL;
-	}
-	cap_smb_fname = synthetic_smb_fname(talloc_tos(),
-					capname,
-					NULL,
-					NULL,
-					smb_fname->flags);
-	if (cap_smb_fname == NULL) {
-		TALLOC_FREE(capname);
-		errno = ENOMEM;
-		return NULL;
-	}
-	return SMB_VFS_NEXT_OPENDIR(handle, cap_smb_fname, mask, attr);
-}
-
 static struct dirent *cap_readdir(vfs_handle_struct *handle,
 				      DIR *dirp,
 				      SMB_STRUCT_STAT *sbuf)
@@ -1046,7 +1021,6 @@ static NTSTATUS cap_read_dfs_pathat(struct vfs_handle_struct *handle,
 static struct vfs_fn_pointers vfs_cap_fns = {
 	.disk_free_fn = cap_disk_free,
 	.get_quota_fn = cap_get_quota,
-	.opendir_fn = cap_opendir,
 	.readdir_fn = cap_readdir,
 	.mkdirat_fn = cap_mkdirat,
 	.open_fn = cap_open,
diff --git a/source3/modules/vfs_catia.c b/source3/modules/vfs_catia.c
index 5bb55cf89f6..e90adaa2d46 100644
--- a/source3/modules/vfs_catia.c
+++ b/source3/modules/vfs_catia.c
@@ -171,44 +171,6 @@ static int catia_connect(struct vfs_handle_struct *handle,
 	return SMB_VFS_NEXT_CONNECT(handle, service, user);
 }
 
-static DIR *catia_opendir(vfs_handle_struct *handle,
-			const struct smb_filename *smb_fname,
-			const char *mask,
-			uint32_t attr)
-{
-	char *name_mapped = NULL;
-	NTSTATUS status;
-	DIR *ret;
-	struct smb_filename *mapped_smb_fname = NULL;
-
-	status = catia_string_replace_allocate(handle->conn,
-				smb_fname->base_name,
-				&name_mapped,
-				vfs_translate_to_unix);
-	if (!NT_STATUS_IS_OK(status)) {
-		errno = map_errno_from_nt_status(status);
-		return NULL;
-	}
-
-	mapped_smb_fname = synthetic_smb_fname(talloc_tos(),
-				name_mapped,
-				NULL,
-				&smb_fname->st,
-				smb_fname->flags);
-	if (mapped_smb_fname == NULL) {
-		TALLOC_FREE(mapped_smb_fname);
-		errno = ENOMEM;
-		return NULL;
-	}
-
-	ret = SMB_VFS_NEXT_OPENDIR(handle, mapped_smb_fname, mask, attr);
-
-	TALLOC_FREE(name_mapped);
-	TALLOC_FREE(mapped_smb_fname);
-
-	return ret;
-}
-
 /*
  * TRANSLATE_NAME call which converts the given name to
  * "WINDOWS displayable" name
@@ -2450,7 +2412,6 @@ static struct vfs_fn_pointers vfs_catia_fns = {
 
 	/* Directory operations */
 	.mkdirat_fn = catia_mkdirat,
-	.opendir_fn = catia_opendir,
 	.readdir_attr_fn = catia_readdir_attr,
 
 	/* File operations */
diff --git a/source3/modules/vfs_ceph.c b/source3/modules/vfs_ceph.c
index 76393a84152..7f4d65d4871 100644
--- a/source3/modules/vfs_ceph.c
+++ b/source3/modules/vfs_ceph.c
@@ -301,25 +301,6 @@ static uint32_t cephwrap_fs_capabilities(struct vfs_handle_struct *handle,
 
 /* Directory operations */
 
-static DIR *cephwrap_opendir(struct vfs_handle_struct *handle,
-			     const struct smb_filename *smb_fname,
-			     const char *mask, uint32_t attr)
-{
-	int ret = 0;
-	struct ceph_dir_result *result;
-	DBG_DEBUG("[CEPH] opendir(%p, %s)\n", handle, smb_fname->base_name);
-
-	/* Returns NULL if it does not exist or there are problems ? */
-	ret = ceph_opendir(handle->data, smb_fname->base_name, &result);
-	if (ret < 0) {
-		result = NULL;
-		errno = -ret; /* We return result which is NULL in this case */
-	}
-
-	DBG_DEBUG("[CEPH] opendir(...) = %d\n", ret);
-	return (DIR *) result;
-}
-
 static DIR *cephwrap_fdopendir(struct vfs_handle_struct *handle,
 			       struct files_struct *fsp,
 			       const char *mask,
@@ -1443,7 +1424,6 @@ static struct vfs_fn_pointers ceph_fns = {
 
 	/* Directory operations */
 
-	.opendir_fn = cephwrap_opendir,
 	.fdopendir_fn = cephwrap_fdopendir,
 	.readdir_fn = cephwrap_readdir,
 	.seekdir_fn = cephwrap_seekdir,
diff --git a/source3/modules/vfs_ceph_snapshots.c b/source3/modules/vfs_ceph_snapshots.c
index 64f195f4add..7af9ff655c1 100644
--- a/source3/modules/vfs_ceph_snapshots.c
+++ b/source3/modules/vfs_ceph_snapshots.c
@@ -176,10 +176,13 @@ static int ceph_snap_enum_snapdir(struct vfs_handle_struct *handle,
 				  bool labels,
 				  struct shadow_copy_data *sc_data)
 {
+	TALLOC_CTX *frame = talloc_stackframe();
+	struct smb_Dir *dir_hnd = NULL;
+	const char *dname = NULL;
+	char *talloced = NULL;
+	long offset = 0;
 	NTSTATUS status;
 	int ret;
-	DIR *d = NULL;
-	struct dirent *e = NULL;
 	uint32_t slots;
 
 	status = smbd_check_access_rights(handle->conn,
@@ -203,8 +206,9 @@ static int ceph_snap_enum_snapdir(struct vfs_handle_struct *handle,
 	 * place we need it (dir=.snap), so we need to dynamically determine it
 	 * via readdir.
 	 */
-	d = SMB_VFS_NEXT_OPENDIR(handle, snaps_dname, NULL, 0);
-	if (d == NULL) {
+
+	dir_hnd = OpenDir(frame, handle->conn, snaps_dname, NULL, 0);
+	if (dir_hnd == NULL) {
 		ret = -errno;
 		goto err_out;
 	}
@@ -213,14 +217,16 @@ static int ceph_snap_enum_snapdir(struct vfs_handle_struct *handle,
 	sc_data->num_volumes = 0;
 	sc_data->labels = NULL;
 
-	for (e = SMB_VFS_NEXT_READDIR(handle, d, NULL);
-	     e != NULL;
-	     e = SMB_VFS_NEXT_READDIR(handle, d, NULL)) {
-		if (ISDOT(e->d_name) || ISDOTDOT(e->d_name)) {
+        while ((dname = ReadDirName(dir_hnd, &offset, NULL, &talloced))
+	       != NULL)
+	{
+		if (ISDOT(dname) || ISDOTDOT(dname)) {
+			TALLOC_FREE(talloced);
 			continue;
 		}
 		sc_data->num_volumes++;
 		if (!labels) {
+			TALLOC_FREE(talloced);
 			continue;
 		}
 		if (sc_data->num_volumes > slots) {
@@ -231,6 +237,7 @@ static int ceph_snap_enum_snapdir(struct vfs_handle_struct *handle,
 							 SHADOW_COPY_LABEL,
 							 new_slot_count);
 			if (sc_data->labels == NULL) {
+				TALLOC_FREE(talloced);
 				ret = -ENOMEM;
 				goto err_closedir;
 			}
@@ -242,28 +249,25 @@ static int ceph_snap_enum_snapdir(struct vfs_handle_struct *handle,
 			slots = new_slot_count;
 		}
 		DBG_DEBUG("filling shadow copy label for %s/%s\n",
-			  snaps_dname->base_name, e->d_name);
+			  snaps_dname->base_name, dname);
 		ret = ceph_snap_fill_label(handle, snaps_dname,
-				snaps_dname->base_name, e->d_name,
+				snaps_dname->base_name, dname,
 				sc_data->labels[sc_data->num_volumes - 1]);
 		if (ret < 0) {
+			TALLOC_FREE(talloced);
 			goto err_closedir;
 		}
-	}
-
-	ret = SMB_VFS_NEXT_CLOSEDIR(handle, d);
-	if (ret != 0) {
-		ret = -errno;
-		goto err_out;
+		TALLOC_FREE(talloced);
 	}
 
 	DBG_DEBUG("%s shadow copy enumeration found %d labels \n",
 		  snaps_dname->base_name, sc_data->num_volumes);
 
+	TALLOC_FREE(frame);
 	return 0;
 
 err_closedir:
-	SMB_VFS_NEXT_CLOSEDIR(handle, d);
+	TALLOC_FREE(frame);
 err_out:
 	TALLOC_FREE(sc_data->labels);
 	return ret;
@@ -522,8 +526,10 @@ static int ceph_snap_gmt_convert_dir(struct vfs_handle_struct *handle,
 {
 	int ret;
 	NTSTATUS status;
-	DIR *d = NULL;
-	struct dirent *e = NULL;
+	struct smb_Dir *dir_hnd = NULL;
+	const char *dname = NULL;
+	char *talloced = NULL;
+	long offset = 0;
 	struct smb_filename *snaps_dname = NULL;
 	const char *snapdir = lp_parm_const_string(SNUM(handle->conn),
 						   "ceph", "snapdir",
@@ -580,39 +586,40 @@ static int ceph_snap_gmt_convert_dir(struct vfs_handle_struct *handle,
 	DBG_DEBUG("enumerating shadow copy dir at %s\n",
 		  snaps_dname->base_name);
 
-	d = SMB_VFS_NEXT_OPENDIR(handle, snaps_dname, NULL, 0);
-	if (d == NULL) {
+	dir_hnd = OpenDir(tmp_ctx, handle->conn, snaps_dname, NULL, 0);
+	if (dir_hnd == NULL) {
 		ret = -errno;
 		goto err_out;
 	}
 
-	for (e = SMB_VFS_NEXT_READDIR(handle, d, NULL);
-	     e != NULL;
-	     e = SMB_VFS_NEXT_READDIR(handle, d, NULL)) {
+        while ((dname = ReadDirName(dir_hnd, &offset, NULL, &talloced))
+	       != NULL)
+	{
 		struct smb_filename *smb_fname;
 		time_t snap_secs;
 
-		if (ISDOT(e->d_name) || ISDOTDOT(e->d_name)) {
+		if (ISDOT(dname) || ISDOTDOT(dname)) {
+			TALLOC_FREE(talloced);
 			continue;
 		}
 
 		ret = snprintf(_converted_buf, buflen, "%s/%s",
-			       snaps_dname->base_name, e->d_name);
+			       snaps_dname->base_name, dname);
 		if (ret >= buflen) {
 			ret = -EINVAL;
-			goto err_closedir;
+			goto err_out;
 		}
 
 		smb_fname = synthetic_smb_fname(tmp_ctx, _converted_buf,
 						NULL, NULL, 0);
 		if (smb_fname == NULL) {
 			ret = -ENOMEM;
-			goto err_closedir;
+			goto err_out;
 		}
 
 		ret = ceph_snap_get_btime(handle, smb_fname, &snap_secs);
 		if (ret < 0) {
-			goto err_closedir;
+			goto err_out;
 		}
 
 		/*
@@ -623,14 +630,15 @@ static int ceph_snap_gmt_convert_dir(struct vfs_handle_struct *handle,
 		}
 		DBG_DEBUG("[connectpath %s] %s@%lld no match for snap %s@%lld\n",
 			  handle->conn->connectpath, name, (long long)timestamp,
-			  e->d_name, (long long)snap_secs);
+			  dname, (long long)snap_secs);
+		TALLOC_FREE(talloced);
 	}
 
-	if (e == NULL) {
+	if (dname == NULL) {
 		DBG_INFO("[connectpath %s] failed to find %s @ time %lld\n",
 			 handle->conn->connectpath, name, (long long)timestamp);
 		ret = -ENOENT;
-		goto err_closedir;
+		goto err_out;
 	}
 
 	/* found, _converted_buf already contains path of interest */
@@ -638,17 +646,12 @@ static int ceph_snap_gmt_convert_dir(struct vfs_handle_struct *handle,
 		  handle->conn->connectpath, name, (long long)timestamp,
 		  _converted_buf);
 
-	ret = SMB_VFS_NEXT_CLOSEDIR(handle, d);
-	if (ret != 0) {
-		ret = -errno;
-		goto err_out;
-	}
+	TALLOC_FREE(talloced);
 	talloc_free(tmp_ctx);
 	return 0;
 
-err_closedir:
-	SMB_VFS_NEXT_CLOSEDIR(handle, d);
 err_out:
+	TALLOC_FREE(talloced);
 	talloc_free(tmp_ctx);
 	return ret;
 }
@@ -717,53 +720,6 @@ static int ceph_snap_gmt_convert(struct vfs_handle_struct *handle,
 	return 0;
 }
 
-static DIR *ceph_snap_gmt_opendir(vfs_handle_struct *handle,
-				const struct smb_filename *csmb_fname,
-				const char *mask,
-				uint32_t attr)
-{
-	time_t timestamp = 0;
-	char stripped[PATH_MAX + 1];


-- 
Samba Shared Repository



More information about the samba-cvs mailing list