The branch, master has been updated via 5eac92697ed1781e83be460d6ed7b29a154464a2 (commit) via 4e3656b8d1d0bf8c0c4ade01332e7384ea890810 (commit) via 5cfac1a1bd59712d7a771d3631e869c5d078a0f3 (commit) from 78e316ddbc15c37604c84cb08dd13c95e2539d68 (commit)
http://gitweb.samba.org/?p=samba.git;a=shortlog;h=master - Log ----------------------------------------------------------------- commit 5eac92697ed1781e83be460d6ed7b29a154464a2 Author: Tim Prouty <tpro...@samba.org> Date: Wed Jun 17 19:54:12 2009 -0700 s3 onefs: Remove dfs resolution from create_file() now that it's being done at a higher level commit 4e3656b8d1d0bf8c0c4ade01332e7384ea890810 Author: Tim Prouty <tpro...@samba.org> Date: Tue Jun 16 12:01:13 2009 -0700 s3: Change SMB_VFS_OPEN to take an smb_filename struct This was a little messy because of all of the vfs modules I had to touch. Most of them were pretty straight forward, but the streams modules required a little attention to handle smb_filename. Since the use of smb_filename enables the vfs modules to access the raw, over-the-wire stream, a little bit of the handling that was being done by split_ntfs_stream_name has now been shifted into the individual stream modules. It may be a little more code, but overall it gives more flexibility to the streams modules, while also allowing correct stream handling. commit 5cfac1a1bd59712d7a771d3631e869c5d078a0f3 Author: Tim Prouty <tpro...@samba.org> Date: Mon Jun 15 14:14:31 2009 -0700 s3: Plumb smb_filename from create_file all of the way down to fd_open I used the smb_filename struct everywhere that was feasible for the first pass. There are still some places in this path that need to be changed to use smb_filename, but this is a good start. I also: - Removed fname/path arguments from a few functions that weren't really using them. - Added a utility function for detecting whether an smb_filename is a stream. ----------------------------------------------------------------------- Summary of changes: examples/VFS/skel_opaque.c | 5 +- examples/VFS/skel_transparent.c | 5 +- source3/include/proto.h | 8 +- source3/include/vfs.h | 7 +- source3/modules/onefs_open.c | 32 +-- source3/modules/vfs_acl_tdb.c | 20 +- source3/modules/vfs_acl_xattr.c | 20 +- source3/modules/vfs_audit.c | 10 +- source3/modules/vfs_cap.c | 22 ++- source3/modules/vfs_catia.c | 18 +- source3/modules/vfs_commit.c | 6 +- source3/modules/vfs_default.c | 22 ++- source3/modules/vfs_extd_audit.c | 12 +- source3/modules/vfs_full_audit.c | 9 +- source3/modules/vfs_onefs.c | 5 +- source3/modules/vfs_onefs_shadow_copy.c | 11 +- source3/modules/vfs_prealloc.c | 13 +- source3/modules/vfs_preopen.c | 17 +- source3/modules/vfs_shadow_copy2.c | 31 ++- source3/modules/vfs_streams_depot.c | 111 ++++++-- source3/modules/vfs_streams_xattr.c | 117 ++++++--- source3/modules/vfs_syncops.c | 25 ++- source3/smbd/file_access.c | 25 ++- source3/smbd/filename.c | 5 +- source3/smbd/nttrans.c | 28 ++ source3/smbd/open.c | 443 +++++++++++++++++-------------- source3/torture/cmd_vfs.c | 13 +- 27 files changed, 681 insertions(+), 359 deletions(-) Changeset truncated at 500 lines: diff --git a/examples/VFS/skel_opaque.c b/examples/VFS/skel_opaque.c index 118a5b9..d1000f1 100644 --- a/examples/VFS/skel_opaque.c +++ b/examples/VFS/skel_opaque.c @@ -122,9 +122,10 @@ static int skel_closedir(vfs_handle_struct *handle, SMB_STRUCT_DIR *dir) return vfswrap_closedir(NULL, dir); } -static int skel_open(vfs_handle_struct *handle, const char *fname, files_struct *fsp, int flags, mode_t mode) +static int skel_open(vfs_handle_struct *handle, struct smb_fname *smb_fname, + files_struct *fsp, int flags, mode_t mode) { - return vfswrap_open(NULL, fname, flags, mode); + return vfswrap_open(NULL, smb_fname, flags, mode); } static int skel_close(vfs_handle_struct *handle, files_struct *fsp) diff --git a/examples/VFS/skel_transparent.c b/examples/VFS/skel_transparent.c index a95b5ae..101951b 100644 --- a/examples/VFS/skel_transparent.c +++ b/examples/VFS/skel_transparent.c @@ -116,9 +116,10 @@ static int skel_closedir(vfs_handle_struct *handle, SMB_STRUCT_DIR *dir) return SMB_VFS_NEXT_CLOSEDIR(handle, dir); } -static int skel_open(vfs_handle_struct *handle, const char *fname, files_struct *fsp, int flags, mode_t mode) +static int skel_open(vfs_handle_struct *handle, struct smb_filename *smb_fname, + files_struct *fsp, int flags, mode_t mode) { - return SMB_VFS_NEXT_OPEN(handle, fname, fsp, flags, mode); + return SMB_VFS_NEXT_OPEN(handle, smb_fname, fsp, flags, mode); } static int skel_close(vfs_handle_struct *handle, files_struct *fsp) diff --git a/source3/include/proto.h b/source3/include/proto.h index 1c7ba87..4ae141e 100644 --- a/source3/include/proto.h +++ b/source3/include/proto.h @@ -6337,7 +6337,8 @@ NTSTATUS close_fake_file(struct smb_request *req, files_struct *fsp); bool can_access_file_acl(struct connection_struct *conn, const char * fname, uint32_t access_mask); -bool can_delete_file_in_directory(connection_struct *conn, const char *fname); +bool can_delete_file_in_directory(connection_struct *conn, + const struct smb_filename *smb_fname); bool can_access_file_data(connection_struct *conn, const char *fname, SMB_STRUCT_STAT *psbuf, uint32 access_mask); bool can_write_to_file(connection_struct *conn, const char *fname, SMB_STRUCT_STAT *psbuf); bool directory_has_default_acl(connection_struct *conn, const char *fname); @@ -6581,6 +6582,8 @@ void send_nt_replies(connection_struct *conn, char *params, int paramsize, char *pdata, int datasize); bool is_ntfs_stream_name(const char *fname); +bool is_ntfs_stream_smb_fname(const struct smb_filename *smb_fname); +bool is_ntfs_default_stream_smb_fname(const struct smb_filename *smb_fname); void reply_ntcreate_and_X(struct smb_request *req); void reply_ntcancel(struct smb_request *req); void reply_ntrename(struct smb_request *req); @@ -6606,7 +6609,6 @@ bool is_stat_open(uint32 access_mask); bool request_timed_out(struct timeval request_time, struct timeval timeout); bool open_match_attributes(connection_struct *conn, - const char *path, uint32 old_dos_attr, uint32 new_dos_attr, mode_t existing_unx_mode, @@ -6662,7 +6664,7 @@ NTSTATUS create_file_default(connection_struct *conn, NTSTATUS get_relative_fid_filename(connection_struct *conn, struct smb_request *req, uint16_t root_dir_fid, - const char *fname, char **new_fname); + struct smb_filename *smb_fname); /* The following definitions come from smbd/oplock.c */ diff --git a/source3/include/vfs.h b/source3/include/vfs.h index e0e0228..53a4798 100644 --- a/source3/include/vfs.h +++ b/source3/include/vfs.h @@ -117,7 +117,8 @@ /* Leave at 25 - not yet released. Add init_search_op call. - sdann */ /* Leave at 25 - not yet released. Add locking calls. -- zkirsch. */ /* Leave at 25 - not yet released. Add strict locking calls. -- drichards. */ -/* Changed to version 26 - Plumb struct smb_filename to SMB_VFS_CREATE_FILE. */ +/* Changed to version 26 - Plumb struct smb_filename to SMB_VFS_CREATE_FILE, + SMB_VFS_OPEN. */ #define SMB_VFS_INTERFACE_VERSION 26 @@ -330,7 +331,9 @@ struct vfs_ops { /* File operations */ - int (*open)(struct vfs_handle_struct *handle, const char *fname, files_struct *fsp, int flags, mode_t mode); + int (*open)(struct vfs_handle_struct *handle, + struct smb_filename *smb_fname, files_struct *fsp, + int flags, mode_t mode); NTSTATUS (*create_file)(struct vfs_handle_struct *handle, struct smb_request *req, uint16_t root_dir_fid, diff --git a/source3/modules/onefs_open.c b/source3/modules/onefs_open.c index c773f9e..8b6ae20 100644 --- a/source3/modules/onefs_open.c +++ b/source3/modules/onefs_open.c @@ -685,8 +685,7 @@ NTSTATUS onefs_open_file_ntcreate(connection_struct *conn, if (!posix_open && file_existed && ((create_disposition == FILE_OVERWRITE) || (create_disposition == FILE_OVERWRITE_IF))) { - if (!open_match_attributes(conn, fname, - existing_dos_attributes, + if (!open_match_attributes(conn, existing_dos_attributes, new_dos_attributes, psbuf->st_ex_mode, unx_mode, &new_unx_mode)) { DEBUG(5, ("onefs_open_file_ntcreate: attributes " @@ -2018,36 +2017,11 @@ NTSTATUS onefs_create_file(vfs_handle_struct *handle, /* Get the file name if root_dir_fid was specified. */ if (root_dir_fid != 0) { - char *new_fname; - status = get_relative_fid_filename(conn, req, root_dir_fid, - fname, &new_fname); - if (!NT_STATUS_IS_OK(status)) { - goto fail; - } - - fname = new_fname; - } - - /* Resolve the file name if this was a DFS pathname. */ - if ((req != NULL) && (req->flags2 & FLAGS2_DFS_PATHNAMES)) { - char *resolved_fname; - - status = resolve_dfspath(talloc_tos(), conn, true, - smb_fname->base_name, - &resolved_fname); - + smb_fname); if (!NT_STATUS_IS_OK(status)) { - /* - * For PATH_NOT_COVERED we had - * reply_botherror(req, NT_STATUS_PATH_NOT_COVERED, - * ERRSRV, ERRbadpath); - * Need to fix in callers - */ goto fail; } - TALLOC_FREE(smb_fname->base_name); - smb_fname->base_name = resolved_fname; } status = get_full_smb_filename(talloc_tos(), smb_fname, &fname); @@ -2056,7 +2030,7 @@ NTSTATUS onefs_create_file(vfs_handle_struct *handle, } /* All file access must go through check_name() */ - status = check_name(conn, fname); + status = check_name(conn, smb_fname->base_name); if (!NT_STATUS_IS_OK(status)) { goto fail; } diff --git a/source3/modules/vfs_acl_tdb.c b/source3/modules/vfs_acl_tdb.c index 463250a..e0a5b14 100644 --- a/source3/modules/vfs_acl_tdb.c +++ b/source3/modules/vfs_acl_tdb.c @@ -549,7 +549,7 @@ static NTSTATUS inherit_new_acl(vfs_handle_struct *handle, *********************************************************************/ static int open_acl_tdb(vfs_handle_struct *handle, - const char *fname, + struct smb_filename *smb_fname, files_struct *fsp, int flags, mode_t mode) @@ -557,7 +557,17 @@ static int open_acl_tdb(vfs_handle_struct *handle, uint32_t access_granted = 0; struct security_descriptor *pdesc = NULL; bool file_existed = true; - NTSTATUS status = get_nt_acl_tdb_internal(handle, + char *fname = NULL; + NTSTATUS status; + + status = get_full_smb_filename(talloc_tos(), smb_fname, + &fname); + if (!NT_STATUS_IS_OK(status)) { + errno = map_errno_from_nt_status(status); + return -1; + } + + status = get_nt_acl_tdb_internal(handle, NULL, fname, (OWNER_SECURITY_INFORMATION | @@ -573,7 +583,7 @@ static int open_acl_tdb(vfs_handle_struct *handle, if (!NT_STATUS_IS_OK(status)) { DEBUG(10,("open_acl_tdb: file %s open " "refused with error %s\n", - fname, + smb_fname_str_dbg(smb_fname), nt_errstr(status) )); errno = map_errno_from_nt_status(status); return -1; @@ -584,10 +594,10 @@ static int open_acl_tdb(vfs_handle_struct *handle, DEBUG(10,("open_acl_tdb: get_nt_acl_attr_internal for " "file %s returned %s\n", - fname, + smb_fname_str_dbg(smb_fname), nt_errstr(status) )); - fsp->fh->fd = SMB_VFS_NEXT_OPEN(handle, fname, fsp, flags, mode); + fsp->fh->fd = SMB_VFS_NEXT_OPEN(handle, smb_fname, fsp, flags, mode); if (!file_existed && fsp->fh->fd != -1) { /* File was created. Inherit from parent directory. */ diff --git a/source3/modules/vfs_acl_xattr.c b/source3/modules/vfs_acl_xattr.c index 05156f8..efcc877 100644 --- a/source3/modules/vfs_acl_xattr.c +++ b/source3/modules/vfs_acl_xattr.c @@ -417,7 +417,7 @@ static NTSTATUS inherit_new_acl(vfs_handle_struct *handle, *********************************************************************/ static int open_acl_xattr(vfs_handle_struct *handle, - const char *fname, + struct smb_filename *smb_fname, files_struct *fsp, int flags, mode_t mode) @@ -425,7 +425,17 @@ static int open_acl_xattr(vfs_handle_struct *handle, uint32_t access_granted = 0; struct security_descriptor *pdesc = NULL; bool file_existed = true; - NTSTATUS status = get_nt_acl_xattr_internal(handle, + char *fname = NULL; + NTSTATUS status; + + status = get_full_smb_filename(talloc_tos(), smb_fname, + &fname); + if (!NT_STATUS_IS_OK(status)) { + errno = map_errno_from_nt_status(status); + return -1; + } + + status = get_nt_acl_xattr_internal(handle, NULL, fname, (OWNER_SECURITY_INFORMATION | @@ -441,7 +451,7 @@ static int open_acl_xattr(vfs_handle_struct *handle, if (!NT_STATUS_IS_OK(status)) { DEBUG(10,("open_acl_xattr: file %s open " "refused with error %s\n", - fname, + smb_fname_str_dbg(smb_fname), nt_errstr(status) )); errno = map_errno_from_nt_status(status); return -1; @@ -452,10 +462,10 @@ static int open_acl_xattr(vfs_handle_struct *handle, DEBUG(10,("open_acl_xattr: get_nt_acl_attr_internal for " "file %s returned %s\n", - fname, + smb_fname_str_dbg(smb_fname), nt_errstr(status) )); - fsp->fh->fd = SMB_VFS_NEXT_OPEN(handle, fname, fsp, flags, mode); + fsp->fh->fd = SMB_VFS_NEXT_OPEN(handle, smb_fname, fsp, flags, mode); if (!file_existed && fsp->fh->fd != -1) { /* File was created. Inherit from parent directory. */ diff --git a/source3/modules/vfs_audit.c b/source3/modules/vfs_audit.c index 4000580..2897cef 100644 --- a/source3/modules/vfs_audit.c +++ b/source3/modules/vfs_audit.c @@ -33,7 +33,7 @@ static void audit_disconnect(vfs_handle_struct *handle); static SMB_STRUCT_DIR *audit_opendir(vfs_handle_struct *handle, const char *fname, const char *mask, uint32 attr); static int audit_mkdir(vfs_handle_struct *handle, const char *path, mode_t mode); static int audit_rmdir(vfs_handle_struct *handle, const char *path); -static int audit_open(vfs_handle_struct *handle, const char *fname, files_struct *fsp, int flags, mode_t mode); +static int audit_open(vfs_handle_struct *handle, struct smb_filename *smb_fname, files_struct *fsp, int flags, mode_t mode); static int audit_close(vfs_handle_struct *handle, files_struct *fsp); static int audit_rename(vfs_handle_struct *handle, const char *oldname, const char *newname); static int audit_unlink(vfs_handle_struct *handle, const char *path); @@ -187,14 +187,16 @@ static int audit_rmdir(vfs_handle_struct *handle, const char *path) return result; } -static int audit_open(vfs_handle_struct *handle, const char *fname, files_struct *fsp, int flags, mode_t mode) +static int audit_open(vfs_handle_struct *handle, + struct smb_filename *smb_fname, files_struct *fsp, + int flags, mode_t mode) { int result; - result = SMB_VFS_NEXT_OPEN(handle, fname, fsp, flags, mode); + result = SMB_VFS_NEXT_OPEN(handle, smb_fname, fsp, flags, mode); syslog(audit_syslog_priority(handle), "open %s (fd %d) %s%s%s\n", - fname, result, + smb_fname_str_dbg(smb_fname), result, ((flags & O_WRONLY) || (flags & O_RDWR)) ? "for writing " : "", (result < 0) ? "failed: " : "", (result < 0) ? strerror(errno) : ""); diff --git a/source3/modules/vfs_cap.c b/source3/modules/vfs_cap.c index e26d29d..4525fa1 100644 --- a/source3/modules/vfs_cap.c +++ b/source3/modules/vfs_cap.c @@ -106,16 +106,30 @@ static int cap_rmdir(vfs_handle_struct *handle, const char *path) return SMB_VFS_NEXT_RMDIR(handle, cappath); } -static int cap_open(vfs_handle_struct *handle, const char *fname, files_struct *fsp, int flags, mode_t mode) +static int cap_open(vfs_handle_struct *handle, struct smb_filename *smb_fname, + files_struct *fsp, int flags, mode_t mode) { - char *cappath = capencode(talloc_tos(), fname); + char *cappath; + char *tmp_base_name = NULL; + int ret; + + cappath = capencode(talloc_tos(), smb_fname->base_name); if (!cappath) { errno = ENOMEM; return -1; } - DEBUG(3,("cap: cap_open for %s\n", fname)); - return SMB_VFS_NEXT_OPEN(handle, cappath, fsp, flags, mode); + + tmp_base_name = smb_fname->base_name; + smb_fname->base_name = cappath; + + DEBUG(3,("cap: cap_open for %s\n", smb_fname_str_dbg(smb_fname))); + ret = SMB_VFS_NEXT_OPEN(handle, smb_fname, fsp, flags, mode); + + smb_fname->base_name = tmp_base_name; + TALLOC_FREE(cappath); + + return ret; } static int cap_rename(vfs_handle_struct *handle, const char *oldname, const char *newname) diff --git a/source3/modules/vfs_catia.c b/source3/modules/vfs_catia.c index 2870254..8d1c87a 100644 --- a/source3/modules/vfs_catia.c +++ b/source3/modules/vfs_catia.c @@ -133,18 +133,30 @@ static SMB_STRUCT_DIRENT *catia_readdir(vfs_handle_struct *handle, } static int catia_open(vfs_handle_struct *handle, - const char *fname, + struct smb_filename *smb_fname, files_struct *fsp, int flags, mode_t mode) { - char *name = to_unix(talloc_tos(), fname); + char *name; + char *tmp_base_name; + int ret; + name = to_unix(talloc_tos(), smb_fname->base_name); if (!name) { errno = ENOMEM; return -1; } - return SMB_VFS_NEXT_OPEN(handle, name, fsp, flags, mode); + + tmp_base_name = smb_fname->base_name; + smb_fname->base_name = name; + + ret = SMB_VFS_NEXT_OPEN(handle, name, fsp, flags, mode); + + smb_fname->base_name = tmp_base_name; + TALLOC_FREE(name); + + return ret; } static int catia_rename(vfs_handle_struct *handle, diff --git a/source3/modules/vfs_commit.c b/source3/modules/vfs_commit.c index c22e816..6c36322 100644 --- a/source3/modules/vfs_commit.c +++ b/source3/modules/vfs_commit.c @@ -167,7 +167,7 @@ static int commit_connect( static int commit_open( vfs_handle_struct * handle, - const char * fname, + struct smb_filename *smb_fname, files_struct * fsp, int flags, mode_t mode) @@ -179,7 +179,7 @@ static int commit_open( /* Don't bother with read-only files. */ if ((flags & O_ACCMODE) == O_RDONLY) { - return SMB_VFS_NEXT_OPEN(handle, fname, fsp, flags, mode); + return SMB_VFS_NEXT_OPEN(handle, smb_fname, fsp, flags, mode); } /* Read and check module configuration */ @@ -208,7 +208,7 @@ static int commit_open( } } - fd = SMB_VFS_NEXT_OPEN(handle, fname, fsp, flags, mode); + fd = SMB_VFS_NEXT_OPEN(handle, smb_fname, fsp, flags, mode); if (fd == -1) { VFS_REMOVE_FSP_EXTENSION(handle, fsp); return fd; diff --git a/source3/modules/vfs_default.c b/source3/modules/vfs_default.c index 28adce5..0e7ba05 100644 --- a/source3/modules/vfs_default.c +++ b/source3/modules/vfs_default.c @@ -214,13 +214,31 @@ static void vfswrap_init_search_op(vfs_handle_struct *handle, /* File operations */ -static int vfswrap_open(vfs_handle_struct *handle, const char *fname, - files_struct *fsp, int flags, mode_t mode) +static int vfswrap_open(vfs_handle_struct *handle, + struct smb_filename *smb_fname, + files_struct *fsp, int flags, mode_t mode) { int result; + NTSTATUS status; + char *fname = NULL; START_PROFILE(syscall_open); + + /* + * XXX: Should an error be returned if there is a stream rather than + * trying to open a filename with a ':'? + */ + status = get_full_smb_filename(talloc_tos(), smb_fname, + &fname); + if (!NT_STATUS_IS_OK(status)) { + errno = map_errno_from_nt_status(status); + return -1; + } + result = sys_open(fname, flags, mode); + + TALLOC_FREE(fname); + END_PROFILE(syscall_open); return result; } diff --git a/source3/modules/vfs_extd_audit.c b/source3/modules/vfs_extd_audit.c index b59a780..763f154 100644 --- a/source3/modules/vfs_extd_audit.c +++ b/source3/modules/vfs_extd_audit.c @@ -36,7 +36,7 @@ static void audit_disconnect(vfs_handle_struct *handle); static SMB_STRUCT_DIR *audit_opendir(vfs_handle_struct *handle, const char *fname, const char *mask, uint32 attr); static int audit_mkdir(vfs_handle_struct *handle, const char *path, mode_t mode); static int audit_rmdir(vfs_handle_struct *handle, const char *path); -static int audit_open(vfs_handle_struct *handle, const char *fname, files_struct *fsp, int flags, mode_t mode); +static int audit_open(vfs_handle_struct *handle, struct smb_filename *smb_fname, files_struct *fsp, int flags, mode_t mode); static int audit_close(vfs_handle_struct *handle, files_struct *fsp); static int audit_rename(vfs_handle_struct *handle, const char *oldname, const char *newname); static int audit_unlink(vfs_handle_struct *handle, const char *path); @@ -216,21 +216,23 @@ static int audit_rmdir(vfs_handle_struct *handle, const char *path) return result; } -static int audit_open(vfs_handle_struct *handle, const char *fname, files_struct *fsp, int flags, mode_t mode) +static int audit_open(vfs_handle_struct *handle, + struct smb_filename *smb_fname, files_struct *fsp, + int flags, mode_t mode) { int result; - result = SMB_VFS_NEXT_OPEN(handle, fname, fsp, flags, mode); + result = SMB_VFS_NEXT_OPEN(handle, smb_fname, fsp, flags, mode); if (lp_syslog() > 0) { syslog(audit_syslog_priority(handle), "open %s (fd %d) %s%s%s\n", - fname, result, + smb_fname_str_dbg(smb_fname), result, ((flags & O_WRONLY) || (flags & O_RDWR)) ? "for writing " : "", (result < 0) ? "failed: " : "", (result < 0) ? strerror(errno) : ""); } DEBUG(2, ("vfs_extd_audit: open %s %s %s\n", - fname, + smb_fname_str_dbg(smb_fname), (result < 0) ? "failed: " : "", (result < 0) ? strerror(errno) : "")); diff --git a/source3/modules/vfs_full_audit.c b/source3/modules/vfs_full_audit.c index e2d08b4..5558b2f 100644 --- a/source3/modules/vfs_full_audit.c +++ b/source3/modules/vfs_full_audit.c @@ -111,7 +111,7 @@ static int smb_full_audit_closedir(vfs_handle_struct *handle, static void smb_full_audit_init_search_op(vfs_handle_struct *handle, SMB_STRUCT_DIR *dirp); static int smb_full_audit_open(vfs_handle_struct *handle, - const char *fname, files_struct *fsp, int flags, mode_t mode); + struct smb_filename *smb_fnmae, files_struct *fsp, int flags, mode_t mode); static NTSTATUS smb_full_audit_create_file(vfs_handle_struct *handle, struct smb_request *req, -- Samba Shared Repository