summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>2016-02-26 14:53:12 -0800
committerRalph Boehme <slow@samba.org>2016-03-01 15:25:22 +0100
commitc74ae37fe6df0c7a80733e6ed3ae8844345743a5 (patch)
tree24e10adbe609d1e99badd8e046e545d9aec2e0de
parentfb4778f4e9834af556bd5aac177fc04e7f09f152 (diff)
downloadsamba-c74ae37fe6df0c7a80733e6ed3ae8844345743a5.tar.gz
VFS: Modify opendir to take a const struct smb_filename * instead of const char *
Preparing to reduce use of lp_posix_pathnames(). Uses the same techniques as commit 616d068f0cebb8e50a855b6e30f36fccb7f5a3c8 (synthetic_smb_fname()) to cope with modules that modify the incoming pathname. Signed-off-by: Jeremy Allison <jra@samba.org> Reviewed-by: Ralph Boehme <slow@samba.org>
-rw-r--r--examples/VFS/skel_opaque.c6
-rw-r--r--examples/VFS/skel_transparent.c8
-rw-r--r--source3/include/vfs.h12
-rw-r--r--source3/include/vfs_macros.h8
-rw-r--r--source3/modules/vfs_audit.c9
-rw-r--r--source3/modules/vfs_cap.c19
-rw-r--r--source3/modules/vfs_catia.c27
-rw-r--r--source3/modules/vfs_default.c7
-rw-r--r--source3/modules/vfs_dirsort.c9
-rw-r--r--source3/modules/vfs_extd_audit.c11
-rw-r--r--source3/modules/vfs_full_audit.c9
-rw-r--r--source3/modules/vfs_media_harmony.c24
-rw-r--r--source3/modules/vfs_netatalk.c7
-rw-r--r--source3/modules/vfs_shadow_copy.c25
-rw-r--r--source3/modules/vfs_shadow_copy2.c40
-rw-r--r--source3/modules/vfs_snapper.c25
-rw-r--r--source3/modules/vfs_streams_depot.c14
-rw-r--r--source3/modules/vfs_time_audit.c6
-rw-r--r--source3/modules/vfs_unityed_media.c23
-rw-r--r--source3/smbd/dir.c17
-rw-r--r--source3/smbd/msdfs.c24
-rw-r--r--source3/smbd/vfs.c7
-rw-r--r--source3/torture/cmd_vfs.c28
23 files changed, 284 insertions, 81 deletions
diff --git a/examples/VFS/skel_opaque.c b/examples/VFS/skel_opaque.c
index 8961627e41f..ae165a6f5ab 100644
--- a/examples/VFS/skel_opaque.c
+++ b/examples/VFS/skel_opaque.c
@@ -97,8 +97,10 @@ static NTSTATUS skel_get_dfs_referrals(struct vfs_handle_struct *handle,
return NT_STATUS_NOT_IMPLEMENTED;
}
-static DIR *skel_opendir(vfs_handle_struct *handle, const char *fname,
- const char *mask, uint32_t attr)
+static DIR *skel_opendir(vfs_handle_struct *handle,
+ const struct smb_filename *smb_fname,
+ const char *mask,
+ uint32_t attr)
{
return NULL;
}
diff --git a/examples/VFS/skel_transparent.c b/examples/VFS/skel_transparent.c
index ac82432df89..549d7d8d845 100644
--- a/examples/VFS/skel_transparent.c
+++ b/examples/VFS/skel_transparent.c
@@ -95,10 +95,12 @@ static NTSTATUS skel_get_dfs_referrals(struct vfs_handle_struct *handle,
return SMB_VFS_NEXT_GET_DFS_REFERRALS(handle, r);
}
-static DIR *skel_opendir(vfs_handle_struct *handle, const char *fname,
- const char *mask, uint32_t attr)
+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, fname, mask, attr);
+ return SMB_VFS_NEXT_OPENDIR(handle, smb_fname, mask, attr);
}
static NTSTATUS skel_snap_check_path(struct vfs_handle_struct *handle,
diff --git a/source3/include/vfs.h b/source3/include/vfs.h
index b291206af1c..2f34c22c3ae 100644
--- a/source3/include/vfs.h
+++ b/source3/include/vfs.h
@@ -177,6 +177,8 @@
const struct smb_filename * */
/* Version 35 - Change rmdir from const char *, to
const struct smb_filename * */
+/* Version 35 - Change opendir from const char *, to
+ const struct smb_filename * */
#define SMB_VFS_INTERFACE_VERSION 35
@@ -550,7 +552,10 @@ struct vfs_fn_pointers {
/* Directory operations */
- DIR *(*opendir_fn)(struct vfs_handle_struct *handle, const char *fname, const char *mask, uint32_t attributes);
+ 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,
@@ -963,8 +968,9 @@ uint32_t smb_vfs_call_fs_capabilities(struct vfs_handle_struct *handle,
NTSTATUS smb_vfs_call_get_dfs_referrals(struct vfs_handle_struct *handle,
struct dfs_GetDFSReferral *r);
DIR *smb_vfs_call_opendir(struct vfs_handle_struct *handle,
- const char *fname, const char *mask,
- uint32_t attributes);
+ 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,
diff --git a/source3/include/vfs_macros.h b/source3/include/vfs_macros.h
index e50c6a69797..2e8ca1877b7 100644
--- a/source3/include/vfs_macros.h
+++ b/source3/include/vfs_macros.h
@@ -79,10 +79,10 @@
smb_vfs_call_get_dfs_referrals((handle)->next, (r))
/* Directory operations */
-#define SMB_VFS_OPENDIR(conn, fname, mask, attr) \
- smb_vfs_call_opendir((conn)->vfs_handles, (fname), (mask), (attr))
-#define SMB_VFS_NEXT_OPENDIR(handle, fname, mask, attr) \
- smb_vfs_call_opendir((handle)->next, (fname), (mask), (attr))
+#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))
diff --git a/source3/modules/vfs_audit.c b/source3/modules/vfs_audit.c
index e16355ab859..fa47b3c25a9 100644
--- a/source3/modules/vfs_audit.c
+++ b/source3/modules/vfs_audit.c
@@ -106,14 +106,17 @@ static void audit_disconnect(vfs_handle_struct *handle)
return;
}
-static DIR *audit_opendir(vfs_handle_struct *handle, const char *fname, const char *mask, uint32_t attr)
+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, fname, mask, attr);
+ result = SMB_VFS_NEXT_OPENDIR(handle, smb_fname, mask, attr);
syslog(audit_syslog_priority(handle), "opendir %s %s%s\n",
- fname,
+ smb_fname->base_name,
(result == NULL) ? "failed: " : "",
(result == NULL) ? strerror(errno) : "");
diff --git a/source3/modules/vfs_cap.c b/source3/modules/vfs_cap.c
index fb974124fdb..f96455cfb04 100644
--- a/source3/modules/vfs_cap.c
+++ b/source3/modules/vfs_cap.c
@@ -54,15 +54,28 @@ static int cap_get_quota(vfs_handle_struct *handle, const char *path,
return SMB_VFS_NEXT_GET_QUOTA(handle, cappath, qtype, id, dq);
}
-static DIR *cap_opendir(vfs_handle_struct *handle, const char *fname, const char *mask, uint32_t attr)
+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(), fname);
+ char *capname = capencode(talloc_tos(), smb_fname->base_name);
+ struct smb_filename *cap_smb_fname = NULL;
if (!capname) {
errno = ENOMEM;
return NULL;
}
- return SMB_VFS_NEXT_OPENDIR(handle, capname, mask, attr);
+ cap_smb_fname = synthetic_smb_fname(talloc_tos(),
+ capname,
+ NULL,
+ NULL);
+ 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,
diff --git a/source3/modules/vfs_catia.c b/source3/modules/vfs_catia.c
index f65ed4c7e78..9f42e5f52a3 100644
--- a/source3/modules/vfs_catia.c
+++ b/source3/modules/vfs_catia.c
@@ -269,23 +269,38 @@ static NTSTATUS catia_string_replace_allocate(connection_struct *conn,
}
static DIR *catia_opendir(vfs_handle_struct *handle,
- const char *fname,
- const char *mask,
- uint32_t attr)
+ 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, fname,
- &name_mapped, vfs_translate_to_unix);
+ 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;
}
- ret = SMB_VFS_NEXT_OPENDIR(handle, name_mapped, mask, attr);
+ mapped_smb_fname = synthetic_smb_fname(talloc_tos(),
+ name_mapped,
+ NULL,
+ NULL);
+ 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;
}
diff --git a/source3/modules/vfs_default.c b/source3/modules/vfs_default.c
index b13b5173bb3..c96bd0db270 100644
--- a/source3/modules/vfs_default.c
+++ b/source3/modules/vfs_default.c
@@ -375,12 +375,15 @@ static NTSTATUS vfswrap_snap_delete(struct vfs_handle_struct *handle,
/* Directory operations */
-static DIR *vfswrap_opendir(vfs_handle_struct *handle, const char *fname, const char *mask, uint32_t attr)
+static DIR *vfswrap_opendir(vfs_handle_struct *handle,
+ const struct smb_filename *smb_fname,
+ const char *mask,
+ uint32_t attr)
{
DIR *result;
START_PROFILE(syscall_opendir);
- result = opendir(fname);
+ result = opendir(smb_fname->base_name);
END_PROFILE(syscall_opendir);
return result;
}
diff --git a/source3/modules/vfs_dirsort.c b/source3/modules/vfs_dirsort.c
index d1640880e71..f8568353bd9 100644
--- a/source3/modules/vfs_dirsort.c
+++ b/source3/modules/vfs_dirsort.c
@@ -113,8 +113,9 @@ static bool open_and_sort_dir(vfs_handle_struct *handle,
}
static DIR *dirsort_opendir(vfs_handle_struct *handle,
- const char *fname, const char *mask,
- uint32_t attr)
+ const struct smb_filename *smb_fname,
+ const char *mask,
+ uint32_t attr)
{
struct dirsort_privates *list_head = NULL;
struct dirsort_privates *data = NULL;
@@ -131,14 +132,14 @@ static DIR *dirsort_opendir(vfs_handle_struct *handle,
return NULL;
}
- data->smb_fname = synthetic_smb_fname(data, fname, NULL, NULL);
+ data->smb_fname = cp_smb_filename(data, smb_fname);
if (data->smb_fname == NULL) {
TALLOC_FREE(data);
return NULL;
}
/* Open the underlying directory and count the number of entries */
- data->source_directory = SMB_VFS_NEXT_OPENDIR(handle, fname, mask,
+ data->source_directory = SMB_VFS_NEXT_OPENDIR(handle, smb_fname, mask,
attr);
if (data->source_directory == NULL) {
diff --git a/source3/modules/vfs_extd_audit.c b/source3/modules/vfs_extd_audit.c
index 6429370d71b..137bf72a093 100644
--- a/source3/modules/vfs_extd_audit.c
+++ b/source3/modules/vfs_extd_audit.c
@@ -116,20 +116,23 @@ static void audit_disconnect(vfs_handle_struct *handle)
return;
}
-static DIR *audit_opendir(vfs_handle_struct *handle, const char *fname, const char *mask, uint32_t attr)
+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, fname, mask, attr);
+ result = SMB_VFS_NEXT_OPENDIR(handle, smb_fname, mask, attr);
if (lp_syslog() > 0) {
syslog(audit_syslog_priority(handle), "opendir %s %s%s\n",
- fname,
+ smb_fname->base_name,
(result == NULL) ? "failed: " : "",
(result == NULL) ? strerror(errno) : "");
}
DEBUG(1, ("vfs_extd_audit: opendir %s %s %s\n",
- fname,
+ smb_fname->base_name,
(result == NULL) ? "failed: " : "",
(result == NULL) ? strerror(errno) : ""));
diff --git a/source3/modules/vfs_full_audit.c b/source3/modules/vfs_full_audit.c
index 3dd200510cc..311c760ca19 100644
--- a/source3/modules/vfs_full_audit.c
+++ b/source3/modules/vfs_full_audit.c
@@ -776,13 +776,16 @@ static NTSTATUS smb_full_audit_snap_delete(struct vfs_handle_struct *handle,
}
static DIR *smb_full_audit_opendir(vfs_handle_struct *handle,
- const char *fname, const char *mask, uint32_t attr)
+ const struct smb_filename *smb_fname,
+ const char *mask,
+ uint32_t attr)
{
DIR *result;
- result = SMB_VFS_NEXT_OPENDIR(handle, fname, mask, attr);
+ result = SMB_VFS_NEXT_OPENDIR(handle, smb_fname, mask, attr);
- do_log(SMB_VFS_OP_OPENDIR, (result != NULL), handle, "%s", fname);
+ do_log(SMB_VFS_OP_OPENDIR, (result != NULL), handle, "%s",
+ smb_fname->base_name);
return result;
}
diff --git a/source3/modules/vfs_media_harmony.c b/source3/modules/vfs_media_harmony.c
index b5173af4989..786cee9288e 100644
--- a/source3/modules/vfs_media_harmony.c
+++ b/source3/modules/vfs_media_harmony.c
@@ -760,15 +760,16 @@ err:
* Failure: set errno, return NULL
*/
static DIR *mh_opendir(vfs_handle_struct *handle,
- const char *fname,
+ const struct smb_filename *smb_fname,
const char *mask,
uint32_t attr)
{
struct mh_dirinfo_struct *dirInfo;
- DEBUG(MH_INFO_DEBUG, ("Entering with fname '%s'\n", fname));
+ DEBUG(MH_INFO_DEBUG, ("Entering with fname '%s'\n",
+ smb_fname->base_name));
- if (alloc_set_client_dirinfo(handle, fname, &dirInfo))
+ if (alloc_set_client_dirinfo(handle, smb_fname->base_name, &dirInfo))
{
goto err;
}
@@ -776,10 +777,20 @@ static DIR *mh_opendir(vfs_handle_struct *handle,
if (!dirInfo->isInMediaFiles)
{
dirInfo->dirstream = SMB_VFS_NEXT_OPENDIR(handle,
- fname, mask, attr);
+ smb_fname, mask, attr);
} else {
+ struct smb_filename *smb_fname_clientpath =
+ synthetic_smb_fname(talloc_tos(),
+ dirInfo->clientPath,
+ NULL,
+ NULL);
+ if (smb_fname_clientpath == NULL) {
+ goto err;
+ }
+
dirInfo->dirstream = SMB_VFS_NEXT_OPENDIR(handle,
- dirInfo->clientPath, mask, attr);
+ smb_fname_clientpath, mask, attr);
+ TALLOC_FREE(smb_fname_clientpath);
}
if (dirInfo->dirstream == NULL) {
@@ -794,7 +805,8 @@ static DIR *mh_opendir(vfs_handle_struct *handle,
return (DIR*)dirInfo;
err:
/* Failure is freed here. */
- DEBUG(MH_ERR_DEBUG, ("Failing with fname '%s'\n", fname));
+ DEBUG(MH_ERR_DEBUG, ("Failing with fname '%s'\n",
+ smb_fname->base_name));
TALLOC_FREE(dirInfo);
return NULL;
}
diff --git a/source3/modules/vfs_netatalk.c b/source3/modules/vfs_netatalk.c
index 487ab50189c..d8f9f34fc73 100644
--- a/source3/modules/vfs_netatalk.c
+++ b/source3/modules/vfs_netatalk.c
@@ -177,11 +177,14 @@ static void atalk_rrmdir(TALLOC_CTX *ctx, char *path)
/* Directory operations */
-static DIR *atalk_opendir(struct vfs_handle_struct *handle, const char *fname, const char *mask, uint32_t attr)
+static DIR *atalk_opendir(struct vfs_handle_struct *handle,
+ const struct smb_filename *smb_fname,
+ const char *mask,
+ uint32_t attr)
{
DIR *ret = 0;
- ret = SMB_VFS_NEXT_OPENDIR(handle, fname, mask, attr);
+ ret = SMB_VFS_NEXT_OPENDIR(handle, smb_fname, mask, attr);
/*
* when we try to perform delete operation upon file which has fork
diff --git a/source3/modules/vfs_shadow_copy.c b/source3/modules/vfs_shadow_copy.c
index 5c05e254a03..77dc1636c91 100644
--- a/source3/modules/vfs_shadow_copy.c
+++ b/source3/modules/vfs_shadow_copy.c
@@ -73,13 +73,18 @@ static bool shadow_copy_match_name(const char *name)
return False;
}
-static DIR *shadow_copy_opendir(vfs_handle_struct *handle, const char *fname, const char *mask, uint32_t attr)
+static DIR *shadow_copy_opendir(vfs_handle_struct *handle,
+ const struct smb_filename *smb_fname,
+ const char *mask,
+ uint32_t attr)
{
shadow_copy_Dir *dirp;
- DIR *p = SMB_VFS_NEXT_OPENDIR(handle,fname,mask,attr);
+ DIR *p = SMB_VFS_NEXT_OPENDIR(handle,smb_fname,mask,attr);
if (!p) {
- DEBUG(0,("shadow_copy_opendir: SMB_VFS_NEXT_OPENDIR() failed for [%s]\n",fname));
+ DEBUG(0,("shadow_copy_opendir: SMB_VFS_NEXT_OPENDIR() "
+ "failed for [%s]\n",
+ smb_fname->base_name));
return NULL;
}
@@ -221,7 +226,19 @@ static int shadow_copy_get_shadow_copy_data(vfs_handle_struct *handle,
struct shadow_copy_data *shadow_copy_data,
bool labels)
{
- DIR *p = SMB_VFS_NEXT_OPENDIR(handle,fsp->conn->connectpath,NULL,0);
+ DIR *p = NULL;
+ struct smb_filename *smb_fname = synthetic_smb_fname(talloc_tos(),
+ fsp->conn->connectpath,
+ NULL,
+ NULL);
+ if (smb_fname == NULL) {
+ errno = ENOMEM;
+ return -1;
+ }
+
+ p = SMB_VFS_NEXT_OPENDIR(handle,smb_fname,NULL,0);
+
+ TALLOC_FREE(smb_fname);
shadow_copy_data->num_volumes = 0;
shadow_copy_data->labels = NULL;
diff --git a/source3/modules/vfs_shadow_copy2.c b/source3/modules/vfs_shadow_copy2.c
index 7817168a521..27fc8a96cb8 100644
--- a/source3/modules/vfs_shadow_copy2.c
+++ b/source3/modules/vfs_shadow_copy2.c
@@ -690,31 +690,44 @@ static void convert_sbuf(vfs_handle_struct *handle, const char *fname,
}
static DIR *shadow_copy2_opendir(vfs_handle_struct *handle,
- const char *fname,
- const char *mask,
- uint32_t attr)
+ const struct smb_filename *smb_fname,
+ const char *mask,
+ uint32_t attr)
{
time_t timestamp;
char *stripped;
DIR *ret;
int saved_errno;
char *conv;
+ struct smb_filename *conv_smb_fname = NULL;
- if (!shadow_copy2_strip_snapshot(talloc_tos(), handle, fname,
- &timestamp, &stripped)) {
+ if (!shadow_copy2_strip_snapshot(talloc_tos(),
+ handle,
+ smb_fname->base_name,
+ &timestamp,
+ &stripped)) {
return NULL;
}
if (timestamp == 0) {
- return SMB_VFS_NEXT_OPENDIR(handle, fname, mask, attr);
+ return SMB_VFS_NEXT_OPENDIR(handle, smb_fname, mask, attr);
}
conv = shadow_copy2_convert(talloc_tos(), handle, stripped, timestamp);
TALLOC_FREE(stripped);
if (conv == NULL) {
return NULL;
}
- ret = SMB_VFS_NEXT_OPENDIR(handle, conv, mask, attr);
+ conv_smb_fname = synthetic_smb_fname(talloc_tos(),
+ conv,
+ NULL,
+ NULL);
+ if (conv_smb_fname == NULL) {
+ TALLOC_FREE(conv);
+ return NULL;
+ }
+ ret = SMB_VFS_NEXT_OPENDIR(handle, conv_smb_fname, mask, attr);
saved_errno = errno;
TALLOC_FREE(conv);
+ TALLOC_FREE(conv_smb_fname);
errno = saved_errno;
return ret;
}
@@ -1372,6 +1385,7 @@ static int shadow_copy2_get_shadow_copy_data(
{
DIR *p;
const char *snapdir;
+ struct smb_filename *snapdir_smb_fname = NULL;
struct dirent *d;
TALLOC_CTX *tmp_ctx = talloc_stackframe();
bool ret;
@@ -1392,7 +1406,17 @@ static int shadow_copy2_get_shadow_copy_data(
return -1;
}
- p = SMB_VFS_NEXT_OPENDIR(handle, snapdir, NULL, 0);
+ snapdir_smb_fname = synthetic_smb_fname(talloc_tos(),
+ snapdir,
+ NULL,
+ NULL);
+ if (snapdir_smb_fname == NULL) {
+ errno = ENOMEM;
+ talloc_free(tmp_ctx);
+ return -1;
+ }
+
+ p = SMB_VFS_NEXT_OPENDIR(handle, snapdir_smb_fname, NULL, 0);
if (!p) {
DEBUG(2,("shadow_copy2: SMB_VFS_NEXT_OPENDIR() failed for '%s'"
diff --git a/source3/modules/vfs_snapper.c b/source3/modules/vfs_snapper.c
index 80396c4e7f0..5f5e296fcf8 100644
--- a/source3/modules/vfs_snapper.c
+++ b/source3/modules/vfs_snapper.c
@@ -1943,7 +1943,7 @@ err_out:
}
static DIR *snapper_gmt_opendir(vfs_handle_struct *handle,
- const char *fname,
+ const struct smb_filename *smb_fname,
const char *mask,
uint32_t attr)
{
@@ -1952,22 +1952,37 @@ static DIR *snapper_gmt_opendir(vfs_handle_struct *handle,
DIR *ret;
int saved_errno;
char *conv;
+ struct smb_filename *conv_smb_fname = NULL;
- if (!snapper_gmt_strip_snapshot(talloc_tos(), handle, fname,
- &timestamp, &stripped)) {
+ if (!snapper_gmt_strip_snapshot(talloc_tos(),
+ handle,
+ smb_fname->base_name,
+ &timestamp,
+ &stripped)) {
return NULL;
}
if (timestamp == 0) {
- return SMB_VFS_NEXT_OPENDIR(handle, fname, mask, attr);
+ return SMB_VFS_NEXT_OPENDIR(handle, smb_fname, mask, attr);
}
conv = snapper_gmt_convert(talloc_tos(), handle, stripped, timestamp);
TALLOC_FREE(stripped);
if (conv == NULL) {
return NULL;
}
- ret = SMB_VFS_NEXT_OPENDIR(handle, conv, mask, attr);
+ conv_smb_fname = synthetic_smb_fname(talloc_tos(),
+ conv,
+ NULL,
+ NULL);
+ if (conv_smb_fname == NULL) {
+ TALLOC_FREE(conv);
+ errno = ENOMEM;
+ return NULL;
+ }
+
+ ret = SMB_VFS_NEXT_OPENDIR(handle, conv_smb_fname, mask, attr);
saved_errno = errno;
TALLOC_FREE(conv);
+ TALLOC_FREE(conv_smb_fname);
errno = saved_errno;
return ret;
}
diff --git a/source3/modules/vfs_streams_depot.c b/source3/modules/vfs_streams_depot.c
index f6226e75aba..d998dc51a34 100644
--- a/source3/modules/vfs_streams_depot.c
+++ b/source3/modules/vfs_streams_depot.c
@@ -420,6 +420,7 @@ static NTSTATUS walk_streams(vfs_handle_struct *handle,
void *private_data)
{
char *dirname;
+ struct smb_filename *dir_smb_fname = NULL;
DIR *dirhandle = NULL;
const char *dirent = NULL;
char *talloced = NULL;
@@ -439,7 +440,18 @@ static NTSTATUS walk_streams(vfs_handle_struct *handle,
DEBUG(10, ("walk_streams: dirname=%s\n", dirname));
- dirhandle = SMB_VFS_NEXT_OPENDIR(handle, dirname, NULL, 0);
+ dir_smb_fname = synthetic_smb_fname(talloc_tos(),
+ dirname,
+ NULL,
+ NULL);
+ if (dir_smb_fname == NULL) {
+ TALLOC_FREE(dirname);
+ return NT_STATUS_NO_MEMORY;
+ }
+
+ dirhandle = SMB_VFS_NEXT_OPENDIR(handle, dir_smb_fname, NULL, 0);
+
+ TALLOC_FREE(dir_smb_fname);
if (dirhandle == NULL) {
TALLOC_FREE(dirname);
diff --git a/source3/modules/vfs_time_audit.c b/source3/modules/vfs_time_audit.c
index 11866fa2f66..7998baca693 100644
--- a/source3/modules/vfs_time_audit.c
+++ b/source3/modules/vfs_time_audit.c
@@ -347,7 +347,7 @@ static NTSTATUS smb_time_audit_snap_delete(struct vfs_handle_struct *handle,
}
static DIR *smb_time_audit_opendir(vfs_handle_struct *handle,
- const char *fname,
+ const struct smb_filename *smb_fname,
const char *mask, uint32_t attr)
{
DIR *result;
@@ -355,12 +355,12 @@ static DIR *smb_time_audit_opendir(vfs_handle_struct *handle,
double timediff;
clock_gettime_mono(&ts1);
- result = SMB_VFS_NEXT_OPENDIR(handle, fname, mask, attr);
+ result = SMB_VFS_NEXT_OPENDIR(handle, smb_fname, mask, attr);
clock_gettime_mono(&ts2);
timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
if (timediff > audit_timeout) {
- smb_time_audit_log_fname("opendir", timediff, fname);
+ smb_time_audit_log_smb_fname("opendir", timediff, smb_fname);
}
return result;
diff --git a/source3/modules/vfs_unityed_media.c b/source3/modules/vfs_unityed_media.c
index 2e581e3cda4..191d39feab9 100644
--- a/source3/modules/vfs_unityed_media.c
+++ b/source3/modules/vfs_unityed_media.c
@@ -551,24 +551,35 @@ err:
* Failure: set errno, return NULL
*/
static DIR *um_opendir(vfs_handle_struct *handle,
- const char *fname,
+ const struct smb_filename *smb_fname,
const char *mask,
uint32_t attr)
{
struct um_dirinfo_struct *dirInfo;
- DEBUG(10, ("Entering with fname '%s'\n", fname));
+ DEBUG(10, ("Entering with fname '%s'\n", smb_fname->base_name));
- if (alloc_set_client_dirinfo(handle, fname, &dirInfo)) {
+ if (alloc_set_client_dirinfo(handle, smb_fname->base_name, &dirInfo)) {
goto err;
}
if (!dirInfo->isInMediaFiles) {
dirInfo->dirstream = SMB_VFS_NEXT_OPENDIR(
- handle, fname, mask, attr);
+ handle, smb_fname, mask, attr);
} else {
+ struct smb_filename *client_smb_fname =
+ synthetic_smb_fname(talloc_tos(),
+ dirInfo->clientPath,
+ NULL,
+ NULL);
+ if (client_smb_fname == NULL) {
+ goto err;
+ }
+
dirInfo->dirstream = SMB_VFS_NEXT_OPENDIR(
- handle, dirInfo->clientPath, mask, attr);
+ handle, client_smb_fname, mask, attr);
+
+ TALLOC_FREE(client_smb_fname);
}
if (dirInfo->dirstream == NULL) {
@@ -582,7 +593,7 @@ static DIR *um_opendir(vfs_handle_struct *handle,
return (DIR*)dirInfo;
err:
- DEBUG(1, ("Failing with fname '%s'\n", fname));
+ DEBUG(1, ("Failing with fname '%s'\n", smb_fname->base_name));
TALLOC_FREE(dirInfo);
return NULL;
}
diff --git a/source3/smbd/dir.c b/source3/smbd/dir.c
index a586edf8aa9..bdd79ca08eb 100644
--- a/source3/smbd/dir.c
+++ b/source3/smbd/dir.c
@@ -1595,6 +1595,7 @@ struct smb_Dir *OpenDir(TALLOC_CTX *mem_ctx, connection_struct *conn,
{
struct smb_Dir *dirp = talloc_zero(mem_ctx, struct smb_Dir);
struct smbd_server_connection *sconn = conn->sconn;
+ struct smb_filename *smb_fname = NULL;
if (!dirp) {
return NULL;
@@ -1614,7 +1615,19 @@ struct smb_Dir *OpenDir(TALLOC_CTX *mem_ctx, connection_struct *conn,
}
talloc_set_destructor(dirp, smb_Dir_destructor);
- dirp->dir = SMB_VFS_OPENDIR(conn, dirp->dir_path, mask, attr);
+ smb_fname = synthetic_smb_fname(talloc_tos(),
+ dirp->dir_path,
+ NULL,
+ NULL);
+ if (smb_fname == NULL) {
+ errno = ENOMEM;
+ goto fail;
+ }
+
+ dirp->dir = SMB_VFS_OPENDIR(conn, smb_fname, mask, attr);
+
+ TALLOC_FREE(smb_fname);
+
if (!dirp->dir) {
DEBUG(5,("OpenDir: Can't open %s. %s\n", dirp->dir_path,
strerror(errno) ));
@@ -1675,7 +1688,7 @@ static struct smb_Dir *OpenDir_fsp(TALLOC_CTX *mem_ctx, connection_struct *conn,
if (dirp->dir == NULL) {
/* FDOPENDIR didn't work. Use OPENDIR instead. */
- dirp->dir = SMB_VFS_OPENDIR(conn, dirp->dir_path, mask, attr);
+ dirp->dir = SMB_VFS_OPENDIR(conn, fsp->fsp_name, mask, attr);
}
if (!dirp->dir) {
diff --git a/source3/smbd/msdfs.c b/source3/smbd/msdfs.c
index e895c1f7acc..fe95877fe8d 100644
--- a/source3/smbd/msdfs.c
+++ b/source3/smbd/msdfs.c
@@ -1385,6 +1385,7 @@ static int count_dfs_links(TALLOC_CTX *ctx, int snum)
connection_struct *conn;
NTSTATUS status;
char *cwd;
+ struct smb_filename *smb_fname = NULL;
if(*connect_path == '\0') {
return 0;
@@ -1413,8 +1414,16 @@ static int count_dfs_links(TALLOC_CTX *ctx, int snum)
goto out;
}
+ smb_fname = synthetic_smb_fname(talloc_tos(),
+ ".",
+ NULL,
+ NULL);
+ if (smb_fname == NULL) {
+ goto out;
+ }
+
/* Now enumerate all dfs links */
- dirp = SMB_VFS_OPENDIR(conn, ".", NULL, 0);
+ dirp = SMB_VFS_OPENDIR(conn, smb_fname, NULL, 0);
if(!dirp) {
goto out;
}
@@ -1432,6 +1441,7 @@ static int count_dfs_links(TALLOC_CTX *ctx, int snum)
SMB_VFS_CLOSEDIR(conn,dirp);
out:
+ TALLOC_FREE(smb_fname);
vfs_ChDir(conn, cwd);
SMB_VFS_DISCONNECT(conn);
conn_free(conn);
@@ -1456,6 +1466,7 @@ static int form_junctions(TALLOC_CTX *ctx,
connection_struct *conn;
struct referral *ref = NULL;
char *cwd;
+ struct smb_filename *smb_fname = NULL;
NTSTATUS status;
if (jn_remain == 0) {
@@ -1520,8 +1531,16 @@ static int form_junctions(TALLOC_CTX *ctx,
goto out;
}
+ smb_fname = synthetic_smb_fname(talloc_tos(),
+ ".",
+ NULL,
+ NULL);
+ if (smb_fname == NULL) {
+ goto out;
+ }
+
/* Now enumerate all dfs links */
- dirp = SMB_VFS_OPENDIR(conn, ".", NULL, 0);
+ dirp = SMB_VFS_OPENDIR(conn, smb_fname, NULL, 0);
if(!dirp) {
goto out;
}
@@ -1567,6 +1586,7 @@ out:
SMB_VFS_CLOSEDIR(conn,dirp);
}
+ TALLOC_FREE(smb_fname);
vfs_ChDir(conn, cwd);
conn_free(conn);
return cnt;
diff --git a/source3/smbd/vfs.c b/source3/smbd/vfs.c
index dfc22be9179..d29586b3cc5 100644
--- a/source3/smbd/vfs.c
+++ b/source3/smbd/vfs.c
@@ -1452,11 +1452,12 @@ NTSTATUS smb_vfs_call_get_dfs_referrals(struct vfs_handle_struct *handle,
}
DIR *smb_vfs_call_opendir(struct vfs_handle_struct *handle,
- const char *fname, const char *mask,
- uint32_t attributes)
+ const struct smb_filename *smb_fname,
+ const char *mask,
+ uint32_t attributes)
{
VFS_FIND(opendir);
- return handle->fns->opendir_fn(handle, fname, mask, attributes);
+ return handle->fns->opendir_fn(handle, smb_fname, mask, attributes);
}
DIR *smb_vfs_call_fdopendir(struct vfs_handle_struct *handle,
diff --git a/source3/torture/cmd_vfs.c b/source3/torture/cmd_vfs.c
index 6dcf80544d5..0bc6dbcd5ac 100644
--- a/source3/torture/cmd_vfs.c
+++ b/source3/torture/cmd_vfs.c
@@ -129,17 +129,29 @@ static NTSTATUS cmd_disk_free(struct vfs_state *vfs, TALLOC_CTX *mem_ctx, int ar
static NTSTATUS cmd_opendir(struct vfs_state *vfs, TALLOC_CTX *mem_ctx, int argc, const char **argv)
{
+ struct smb_filename *smb_fname = NULL;
+
if (argc != 2) {
printf("Usage: opendir <fname>\n");
return NT_STATUS_OK;
}
- vfs->currentdir = SMB_VFS_OPENDIR(vfs->conn, argv[1], NULL, 0);
+ smb_fname = synthetic_smb_fname(talloc_tos(),
+ argv[1],
+ NULL,
+ NULL);
+ if (smb_fname == NULL) {
+ return NT_STATUS_NO_MEMORY;
+ }
+
+ vfs->currentdir = SMB_VFS_OPENDIR(vfs->conn, smb_fname, NULL, 0);
if (vfs->currentdir == NULL) {
printf("opendir error=%d (%s)\n", errno, strerror(errno));
+ TALLOC_FREE(smb_fname);
return NT_STATUS_UNSUCCESSFUL;
}
+ TALLOC_FREE(smb_fname);
printf("opendir: ok\n");
return NT_STATUS_OK;
}
@@ -1729,6 +1741,7 @@ static NTSTATUS cmd_translate_name(struct vfs_state *vfs, TALLOC_CTX *mem_ctx,
SMB_STRUCT_STAT st;
bool found = false;
char *translated = NULL;
+ struct smb_filename *smb_fname = NULL;
NTSTATUS status;
if (argc != 2) {
@@ -1736,10 +1749,19 @@ static NTSTATUS cmd_translate_name(struct vfs_state *vfs, TALLOC_CTX *mem_ctx,
return NT_STATUS_UNSUCCESSFUL;
}
- vfs->currentdir = SMB_VFS_OPENDIR(vfs->conn, ".", NULL, 0);
+ smb_fname = synthetic_smb_fname(talloc_tos(),
+ ".",
+ NULL,
+ NULL);
+ if (smb_fname == NULL) {
+ return NT_STATUS_NO_MEMORY;
+ }
+
+ vfs->currentdir = SMB_VFS_OPENDIR(vfs->conn, smb_fname, NULL, 0);
if (vfs->currentdir == NULL) {
DEBUG(0, ("cmd_translate_name: opendir error=%d (%s)\n",
errno, strerror(errno)));
+ TALLOC_FREE(smb_fname);
return NT_STATUS_UNSUCCESSFUL;
}
@@ -1775,9 +1797,11 @@ static NTSTATUS cmd_translate_name(struct vfs_state *vfs, TALLOC_CTX *mem_ctx,
DEBUG(0, ("cmd_translate_name: file '%s' --> '%s'\n",
argv[1], translated));
+ TALLOC_FREE(smb_fname);
TALLOC_FREE(translated);
cleanup:
+ TALLOC_FREE(smb_fname);
ret = SMB_VFS_CLOSEDIR(vfs->conn, vfs->currentdir);
if (ret == -1) {
DEBUG(0, ("cmd_translate_name: closedir failure: %s\n",