The branch, master has been updated via a27bbfc8a96 streams_depot: Simplify stream_dir() via d79194b2586 streams_depot: Only create the subdirectories with O_CREAT via 7ad4047b602 streams_depot: Pass base_sbuf to stream_smb_fname() via f1765f91b01 s3: smbget: Fix auth_fn, order of //server/share parameters is mixed in prompt. from 39f70481bbd WHATSNEW: Document some CTDB changes
https://git.samba.org/?p=samba.git;a=shortlog;h=master - Log ----------------------------------------------------------------- commit a27bbfc8a961968976649aa4db71b37a0db98b38 Author: Volker Lendecke <v...@samba.org> Date: Tue Apr 5 15:32:08 2022 +0200 streams_depot: Simplify stream_dir() The only place where we could have entered the mark_valid() code path is via openat(). In openat(":stream") with O_CREAT fsp->base_fsp() is fully opened from within create_file_unixpath(). Change streams_depot_openat() to call the FSETXATTR from mark_file_valid() directly. This means we don't need the expensive synthetic_pathref() call from stream_dir() anymore. Signed-off-by: Volker Lendecke <v...@samba.org> Reviewed-by: Jeremy Allison <j...@samba.org> Autobuild-User(master): Jeremy Allison <j...@samba.org> Autobuild-Date(master): Wed Apr 6 17:09:59 UTC 2022 on sn-devel-184 commit d79194b2586c3435f11d650d8b4694b928dbf525 Author: Volker Lendecke <v...@samba.org> Date: Tue Apr 5 16:58:41 2022 +0200 streams_depot: Only create the subdirectories with O_CREAT Signed-off-by: Volker Lendecke <v...@samba.org> Reviewed-by: Jeremy Allison <j...@samba.org> commit 7ad4047b602a977e3df126b36d92ab344d95d110 Author: Volker Lendecke <v...@samba.org> Date: Tue Apr 5 16:08:43 2022 +0200 streams_depot: Pass base_sbuf to stream_smb_fname() In streams_depot_openat() we're sure to have a valid base_fsp with a valid stat around. We don't need the additional SMB_VFS_NEXT_STAT() in stream_dir() in this case. Signed-off-by: Volker Lendecke <v...@samba.org> Reviewed-by: Jeremy Allison <j...@samba.org> commit f1765f91b015d64122e74c01c7c6d0984cc7af87 Author: Jeremy Allison <j...@samba.org> Date: Tue Apr 5 13:24:19 2022 -0700 s3: smbget: Fix auth_fn, order of //server/share parameters is mixed in prompt. Found by <voetel...@nrg.eu> BUG: https://bugzilla.samba.org/show_bug.cgi?id=14831 Signed-off-by: Jeremy Allison <j...@samba.org> Reviewed-by: Andreas Schneider <a...@samba.org> ----------------------------------------------------------------------- Summary of changes: source3/modules/vfs_streams_depot.c | 103 +++++++++++++++++------------------- source3/utils/smbget.c | 2 +- 2 files changed, 50 insertions(+), 55 deletions(-) Changeset truncated at 500 lines: diff --git a/source3/modules/vfs_streams_depot.c b/source3/modules/vfs_streams_depot.c index cc2d25a36f6..107543f6bbc 100644 --- a/source3/modules/vfs_streams_depot.c +++ b/source3/modules/vfs_streams_depot.c @@ -110,25 +110,6 @@ static bool file_is_valid(vfs_handle_struct *handle, return true; } -static bool mark_file_valid(vfs_handle_struct *handle, - const struct smb_filename *smb_fname) -{ - char buf = '1'; - int ret; - - DEBUG(10, ("marking file %s as valid\n", smb_fname->base_name)); - - ret = SMB_VFS_FSETXATTR(smb_fname->fsp, SAMBA_XATTR_MARKER, - &buf, sizeof(buf), 0); - - if (ret == -1) { - DEBUG(10, ("SETXATTR failed: %s\n", strerror(errno))); - return false; - } - - return true; -} - /* * Return the root of the stream directory. Can be * external to the share definition but by default @@ -183,8 +164,6 @@ static char *stream_dir(vfs_handle_struct *handle, char *rootdir = NULL; struct smb_filename *rootdir_fname = NULL; struct smb_filename *tmp_fname = NULL; - struct smb_filename *tmpref = NULL; - const struct smb_filename *pathref = NULL; int ret; check_valid = lp_parm_bool(SNUM(handle->conn), @@ -424,27 +403,7 @@ static char *stream_dir(vfs_handle_struct *handle, if ((ret != 0) && (errno != EEXIST)) { goto fail; } - pathref = smb_fname; - if (smb_fname->fsp == NULL) { - NTSTATUS status; - status = synthetic_pathref(talloc_tos(), - handle->conn->cwd_fsp, - smb_fname->base_name, - NULL, - NULL, - smb_fname->twrp, - smb_fname->flags, - &tmpref); - if (!NT_STATUS_IS_OK(status)) { - goto fail; - } - pathref = tmpref; - } - if (check_valid && !mark_file_valid(handle, pathref)) { - goto fail; - } - TALLOC_FREE(tmpref); TALLOC_FREE(rootdir_fname); TALLOC_FREE(rootdir); TALLOC_FREE(tmp_fname); @@ -452,7 +411,6 @@ static char *stream_dir(vfs_handle_struct *handle, return result; fail: - TALLOC_FREE(tmpref); TALLOC_FREE(rootdir_fname); TALLOC_FREE(rootdir); TALLOC_FREE(tmp_fname); @@ -465,6 +423,7 @@ static char *stream_dir(vfs_handle_struct *handle, * stream. */ static NTSTATUS stream_smb_fname(vfs_handle_struct *handle, + const struct stat_ex *base_sbuf, const struct smb_filename *smb_fname, struct smb_filename **smb_fname_out, bool create_dir) @@ -483,7 +442,7 @@ static NTSTATUS stream_smb_fname(vfs_handle_struct *handle, } } - dirname = stream_dir(handle, smb_fname, NULL, create_dir); + dirname = stream_dir(handle, smb_fname, base_sbuf, create_dir); if (dirname == NULL) { status = map_nt_error_from_unix(errno); @@ -653,8 +612,8 @@ static int streams_depot_stat(vfs_handle_struct *handle, } /* Stat the actual stream now. */ - status = stream_smb_fname(handle, smb_fname, &smb_fname_stream, - false); + status = stream_smb_fname( + handle, NULL, smb_fname, &smb_fname_stream, false); if (!NT_STATUS_IS_OK(status)) { ret = -1; errno = map_errno_from_nt_status(status); @@ -687,8 +646,8 @@ static int streams_depot_lstat(vfs_handle_struct *handle, } /* Stat the actual stream now. */ - status = stream_smb_fname(handle, smb_fname, &smb_fname_stream, - false); + status = stream_smb_fname( + handle, NULL, smb_fname, &smb_fname_stream, false); if (!NT_STATUS_IS_OK(status)) { ret = -1; errno = map_errno_from_nt_status(status); @@ -712,6 +671,7 @@ static int streams_depot_openat(struct vfs_handle_struct *handle, struct smb_filename *smb_fname_stream = NULL; struct files_struct *fspcwd = NULL; NTSTATUS status; + bool create_it; int ret = -1; if (!is_named_stream(smb_fname)) { @@ -726,14 +686,49 @@ static int streams_depot_openat(struct vfs_handle_struct *handle, SMB_ASSERT(fsp_is_alternate_stream(fsp)); SMB_ASSERT(VALID_STAT(fsp->base_fsp->fsp_name->st)); + create_it = (mode & O_CREAT); + /* Determine the stream name, and then open it. */ - status = stream_smb_fname(handle, smb_fname, &smb_fname_stream, true); + status = stream_smb_fname( + handle, + &fsp->base_fsp->fsp_name->st, + fsp->fsp_name, + &smb_fname_stream, + create_it); if (!NT_STATUS_IS_OK(status)) { ret = -1; errno = map_errno_from_nt_status(status); goto done; } + if (create_it) { + bool check_valid = lp_parm_bool( + SNUM(handle->conn), + "streams_depot", + "check_valid", + true); + + if (check_valid) { + char buf = '1'; + + DBG_DEBUG("marking file %s as valid\n", + fsp->base_fsp->fsp_name->base_name); + + ret = SMB_VFS_FSETXATTR( + fsp->base_fsp, + SAMBA_XATTR_MARKER, + &buf, + sizeof(buf), + 0); + + if (ret == -1) { + DBG_DEBUG("FSETXATTR failed: %s\n", + strerror(errno)); + return -1; + } + } + } + status = vfs_at_fspcwd(talloc_tos(), handle->conn, &fspcwd); if (!NT_STATUS_IS_OK(status)) { ret = -1; @@ -778,8 +773,8 @@ static int streams_depot_unlink_internal(vfs_handle_struct *handle, struct smb_filename *smb_fname_stream = NULL; NTSTATUS status; - status = stream_smb_fname(handle, full_fname, &smb_fname_stream, - false); + status = stream_smb_fname( + handle, NULL, full_fname, &smb_fname_stream, false); TALLOC_FREE(full_fname); if (!NT_STATUS_IS_OK(status)) { errno = map_errno_from_nt_status(status); @@ -1014,15 +1009,15 @@ static int streams_depot_renameat(vfs_handle_struct *handle, goto done; } - status = stream_smb_fname(handle, full_src, &smb_fname_src_stream, - false); + status = stream_smb_fname( + handle, NULL, full_src, &smb_fname_src_stream, false); if (!NT_STATUS_IS_OK(status)) { errno = map_errno_from_nt_status(status); goto done; } - status = stream_smb_fname(handle, full_dst, - &smb_fname_dst_stream, false); + status = stream_smb_fname( + handle, NULL, full_dst, &smb_fname_dst_stream, false); if (!NT_STATUS_IS_OK(status)) { errno = map_errno_from_nt_status(status); goto done; diff --git a/source3/utils/smbget.c b/source3/utils/smbget.c index 19958f35afa..3e7c5687d83 100644 --- a/source3/utils/smbget.c +++ b/source3/utils/smbget.c @@ -129,7 +129,7 @@ static void get_auth_data(const char *srv, const char *shr, char *wg, int wglen, rc = asprintf(&prompt, "Password for [%s] connecting to //%s/%s: ", - un, shr, srv); + un, srv, shr); if (rc == -1) { return; } -- Samba Shared Repository