From e046b382f24f507a19bfb020b145ea2ec8acafcb Mon Sep 17 00:00:00 2001 From: Aravind Srinivasan Date: Wed, 26 Aug 2009 14:56:09 -0700 Subject: s3: Add a new VFS op called SMB_VFS_TRANSLATE_NAME This vop is designed to work in tandem with SMB_VFS_READDIR to allow vfs modules to make modifications to arbitrary filenames before they're consumed by callers. Subsequently the core directory enumeration code in smbd is now changed to free the memory that may be allocated in a module. This vop enables the new version of catia in the following patch. Signed-off-by: Tim Prouty --- source3/modules/vfs_default.c | 11 +++++++++++ source3/modules/vfs_full_audit.c | 15 +++++++++++++++ source3/modules/vfs_streams_depot.c | 5 ++++- 3 files changed, 30 insertions(+), 1 deletion(-) (limited to 'source3/modules') diff --git a/source3/modules/vfs_default.c b/source3/modules/vfs_default.c index b70868eb9f..e78ddf242c 100644 --- a/source3/modules/vfs_default.c +++ b/source3/modules/vfs_default.c @@ -651,6 +651,16 @@ static int vfswrap_lstat(vfs_handle_struct *handle, return result; } +static NTSTATUS vfswrap_translate_name(vfs_handle_struct *handle, + char **mapped_name) +{ + /* Default behavior is a NOOP */ + + if (*mapped_name != NULL) + return NT_STATUS_OK; + + return NT_STATUS_INVALID_PARAMETER; +} /******************************************************************** Given a stat buffer return the allocated size on disk, taking into account sparse files. @@ -1725,6 +1735,7 @@ static struct vfs_fn_pointers vfs_default_fns = { .brl_cancel_windows = vfswrap_brl_cancel_windows, .strict_lock = vfswrap_strict_lock, .strict_unlock = vfswrap_strict_unlock, + .translate_name = vfswrap_translate_name, /* NT ACL operations. */ diff --git a/source3/modules/vfs_full_audit.c b/source3/modules/vfs_full_audit.c index 0f6de79bcf..b5c9e6bd9c 100644 --- a/source3/modules/vfs_full_audit.c +++ b/source3/modules/vfs_full_audit.c @@ -143,6 +143,7 @@ typedef enum _vfs_op_type { SMB_VFS_OP_BRL_CANCEL_WINDOWS, SMB_VFS_OP_STRICT_LOCK, SMB_VFS_OP_STRICT_UNLOCK, + SMB_VFS_OP_TRANSLATE_NAME, /* NT ACL operations. */ @@ -280,6 +281,7 @@ static struct { { SMB_VFS_OP_BRL_CANCEL_WINDOWS, "brl_cancel_windows" }, { SMB_VFS_OP_STRICT_LOCK, "strict_lock" }, { SMB_VFS_OP_STRICT_UNLOCK, "strict_unlock" }, + { SMB_VFS_OP_TRANSLATE_NAME, "translate_name" }, { SMB_VFS_OP_FGET_NT_ACL, "fget_nt_acl" }, { SMB_VFS_OP_GET_NT_ACL, "get_nt_acl" }, { SMB_VFS_OP_FSET_NT_ACL, "fset_nt_acl" }, @@ -1515,6 +1517,18 @@ static void smb_full_audit_strict_unlock(struct vfs_handle_struct *handle, return; } +static NTSTATUS smb_full_audit_translate_name(vfs_handle_struct *handle, + char **mapped_name) +{ + NTSTATUS result; + + result = SMB_VFS_NEXT_TRANSLATE_NAME(handle, mapped_name); + + do_log(SMB_VFS_OP_TRANSLATE_NAME, NT_STATUS_IS_OK(result), handle, ""); + + return result; +} + static NTSTATUS smb_full_audit_fget_nt_acl(vfs_handle_struct *handle, files_struct *fsp, uint32 security_info, SEC_DESC **ppdesc) @@ -2229,6 +2243,7 @@ static struct vfs_fn_pointers vfs_full_audit_fns = { .brl_cancel_windows = smb_full_audit_brl_cancel_windows, .strict_lock = smb_full_audit_strict_lock, .strict_unlock = smb_full_audit_strict_unlock, + .translate_name = smb_full_audit_translate_name, .fget_nt_acl = smb_full_audit_fget_nt_acl, .get_nt_acl = smb_full_audit_get_nt_acl, .fset_nt_acl = smb_full_audit_fset_nt_acl, diff --git a/source3/modules/vfs_streams_depot.c b/source3/modules/vfs_streams_depot.c index aa0189123b..51cd56e8fb 100644 --- a/source3/modules/vfs_streams_depot.c +++ b/source3/modules/vfs_streams_depot.c @@ -384,7 +384,7 @@ static NTSTATUS walk_streams(vfs_handle_struct *handle, { char *dirname; SMB_STRUCT_DIR *dirhandle = NULL; - char *dirent; + char *dirent = NULL; dirname = stream_dir(handle, smb_fname_base, &smb_fname_base->st, false); @@ -411,14 +411,17 @@ static NTSTATUS walk_streams(vfs_handle_struct *handle, while ((dirent = vfs_readdirname(handle->conn, dirhandle, NULL)) != NULL) { if (ISDOT(dirent) || ISDOTDOT(dirent)) { + TALLOC_FREE(dirent); continue; } DEBUG(10, ("walk_streams: dirent=%s\n", dirent)); if (!fn(dirname, dirent, private_data)) { + TALLOC_FREE(dirent); break; } + TALLOC_FREE(dirent); } SMB_VFS_NEXT_CLOSEDIR(handle, dirhandle); -- cgit