The branch, master has been updated via 1862561d1a1 smbd: Open file as REPARSE_POINT in unlink_internals() via 0fc160c6675 smbd: Open file as REPARSE_POINT in reply_rmdir() via 93f0a367125 smbd: Open file as REPARSE_POINT in rename_internals() via 879db14ff69 smbd: Open file as REPARSE_POINT in smb_posix_unlink() via bdc6d3be4ce smbd: Remove unused FAKE_FILE_TYPE_NAMED_PIPE enum via 92606a46b33 smbd: Move filename_convert_smb1_search_path() to smb1-only code via ea168705457 smbd: Fix previous_slash() via 170b67b3b06 manpages: Add a missing space via 45ec0f61fdc libcli: SMBntcreateX can return STOPPED_ON_SYMLINK via 9e5d752591b smbd: "have_proc_fds" can only work for a real fd via a181283f5ce smbd: Remove code #ifdef'ed out >23years ago via ba2bc30785a smbd: Fix some whitespace via 846adcb259b smbd: Save errno around unbecome_root() via 252d2cc76ab smbd: Fix a typo via d2afaf21c55 smbd: Fix whitespace via 28873a84d28 smbd: Fix whitespace via 32d15770da6 smbd: Simplify reopen_from_fsp() via 3c20ea9df2c smbd: Simplify reopen_from_fsp() via 9f63fad392f smbd: Simplify sys_proc_fd_path() from de20ee1adad WHATSNEW: Mention logged on users list removal
https://git.samba.org/?p=samba.git;a=shortlog;h=master - Log ----------------------------------------------------------------- commit 1862561d1a1dc56f76e02e2116e52239e48a8274 Author: Volker Lendecke <v...@samba.org> Date: Wed Oct 25 09:50:23 2023 +0200 smbd: Open file as REPARSE_POINT in unlink_internals() In the future we'll block opening symlinks as such in SMB_VFS_CREATE_FILE() unless we open as reparse points. 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 Nov 1 19:56:33 UTC 2023 on atb-devel-224 commit 0fc160c6675d786d2666878e3a5f6d7a71e3aba7 Author: Volker Lendecke <v...@samba.org> Date: Wed Oct 25 09:49:32 2023 +0200 smbd: Open file as REPARSE_POINT in reply_rmdir() In the future we'll block opening symlinks as such in SMB_VFS_CREATE_FILE() unless we open as reparse points. Signed-off-by: Volker Lendecke <v...@samba.org> Reviewed-by: Jeremy Allison <j...@samba.org> commit 93f0a3671256d7bb66c64e31607660611e83af59 Author: Volker Lendecke <v...@samba.org> Date: Wed Oct 25 09:36:58 2023 +0200 smbd: Open file as REPARSE_POINT in rename_internals() In the future we'll block opening symlinks as such in SMB_VFS_CREATE_FILE() unless we open as reparse points. Signed-off-by: Volker Lendecke <v...@samba.org> Reviewed-by: Jeremy Allison <j...@samba.org> commit 879db14ff69126af7b1c7336a36f33e003e8863c Author: Volker Lendecke <v...@samba.org> Date: Wed Oct 25 09:29:13 2023 +0200 smbd: Open file as REPARSE_POINT in smb_posix_unlink() In the future we'll block opening symlinks as such in SMB_VFS_CREATE_FILE() unless we open as reparse points. Signed-off-by: Volker Lendecke <v...@samba.org> Reviewed-by: Jeremy Allison <j...@samba.org> commit bdc6d3be4cee4319b8c3951eb29c37d89518553e Author: Volker Lendecke <v...@samba.org> Date: Mon Oct 16 17:17:46 2023 +0200 smbd: Remove unused FAKE_FILE_TYPE_NAMED_PIPE enum Signed-off-by: Volker Lendecke <v...@samba.org> Reviewed-by: Jeremy Allison <j...@samba.org> commit 92606a46b330c2a0f182a8f68c7c99d13acd7d81 Author: Volker Lendecke <v...@samba.org> Date: Tue Oct 10 15:36:56 2023 +0200 smbd: Move filename_convert_smb1_search_path() to smb1-only code Just general cleanup. Signed-off-by: Volker Lendecke <v...@samba.org> Reviewed-by: Jeremy Allison <j...@samba.org> commit ea1687054570d653b2f19197436ff00dc08089c2 Author: Volker Lendecke <v...@samba.org> Date: Tue Oct 24 13:18:32 2023 +0200 smbd: Fix previous_slash() Untested code is broken code... previous_slash() did not return a pointer to the slash but after it. This went undetected because so far we never call symlink_target_path() with "unparsed==0". Once we started doing that, we would find that the "unparsed==0" case actually puts parent on the "previous slash", not the character behind it. Signed-off-by: Volker Lendecke <v...@samba.org> Reviewed-by: Jeremy Allison <j...@samba.org> commit 170b67b3b06f0582de2d2463983ad5d1e08cbe37 Author: Volker Lendecke <v...@samba.org> Date: Fri Oct 27 09:55:54 2023 +0200 manpages: Add a missing space Signed-off-by: Volker Lendecke <v...@samba.org> Reviewed-by: Jeremy Allison <j...@samba.org> commit 45ec0f61fdcab7c0c4764f5e1c26faa06b02594e Author: Volker Lendecke <v...@samba.org> Date: Tue Oct 24 18:46:55 2023 +0200 libcli: SMBntcreateX can return STOPPED_ON_SYMLINK This does not count as NT_STATUS_IS_ERR, as it starts with 0x8 instead of 0xC. So we return NT_STATUS_INVALID_NETWORK_RESPONSE, which is wrong. Signed-off-by: Volker Lendecke <v...@samba.org> Reviewed-by: Jeremy Allison <j...@samba.org> commit 9e5d752591b8d3c3c9a9ab7992d68070ab275400 Author: Volker Lendecke <v...@samba.org> Date: Sun Oct 22 16:25:53 2023 +0200 smbd: "have_proc_fds" can only work for a real fd Signed-off-by: Volker Lendecke <v...@samba.org> Reviewed-by: Jeremy Allison <j...@samba.org> commit a181283f5ce0fbcdb83969d5ae25a9b6dd193390 Author: Volker Lendecke <v...@samba.org> Date: Mon Oct 16 17:42:37 2023 +0200 smbd: Remove code #ifdef'ed out >23years ago Signed-off-by: Volker Lendecke <v...@samba.org> Reviewed-by: Jeremy Allison <j...@samba.org> commit ba2bc30785a0b6c1d45efb3c21ebd84abe733777 Author: Volker Lendecke <v...@samba.org> Date: Mon Oct 16 17:38:02 2023 +0200 smbd: Fix some whitespace Signed-off-by: Volker Lendecke <v...@samba.org> Reviewed-by: Jeremy Allison <j...@samba.org> commit 846adcb259bae548f40f0c4bc7d8f2fec9d5e0fb Author: Volker Lendecke <v...@samba.org> Date: Mon Oct 16 12:00:39 2023 +0200 smbd: Save errno around unbecome_root() Probably not required, but better safe than sorry. Signed-off-by: Volker Lendecke <v...@samba.org> Reviewed-by: Jeremy Allison <j...@samba.org> commit 252d2cc76ab09b3d0c8ece2a6267f93ecf813b41 Author: Volker Lendecke <v...@samba.org> Date: Fri Oct 13 16:19:41 2023 +0200 smbd: Fix a typo Signed-off-by: Volker Lendecke <v...@samba.org> Reviewed-by: Jeremy Allison <j...@samba.org> commit d2afaf21c555db599415b50aff32ac03b36dc589 Author: Volker Lendecke <v...@samba.org> Date: Tue Oct 10 16:00:14 2023 +0200 smbd: Fix whitespace Signed-off-by: Volker Lendecke <v...@samba.org> Reviewed-by: Jeremy Allison <j...@samba.org> commit 28873a84d285366ba7bbe2edfd431104bb11564a Author: Volker Lendecke <v...@samba.org> Date: Tue Oct 10 15:10:06 2023 +0200 smbd: Fix whitespace Signed-off-by: Volker Lendecke <v...@samba.org> Reviewed-by: Jeremy Allison <j...@samba.org> commit 32d15770da6562871d93006a2ee383d4f68bc660 Author: Volker Lendecke <v...@samba.org> Date: Sun Oct 15 14:48:40 2023 +0200 smbd: Simplify reopen_from_fsp() Add the checks in reopen_from_procfd() into an if-condition, remove the MORE_PROCESSING_REQUIRED logic that confused me. Signed-off-by: Volker Lendecke <v...@samba.org> Reviewed-by: Jeremy Allison <j...@samba.org> commit 3c20ea9df2ce8ce1b5c0f7a9a067e64ef61158a6 Author: Volker Lendecke <v...@samba.org> Date: Sun Oct 15 14:31:03 2023 +0200 smbd: Simplify reopen_from_fsp() Pass down a dummy "file_created" variable in open_directory(), remove a unneeded if-condition. Signed-off-by: Volker Lendecke <v...@samba.org> Reviewed-by: Jeremy Allison <j...@samba.org> commit 9f63fad392f3cff34d6a8e318e0427499170c417 Author: Volker Lendecke <v...@samba.org> Date: Sun Oct 15 11:39:32 2023 +0200 smbd: Simplify sys_proc_fd_path() We know the buffer size up-front, create a struct for that. Also, I think if we ever hit another /proc pattern this is very likely on a different OS that could be handled by an #ifdef. Signed-off-by: Volker Lendecke <v...@samba.org> Reviewed-by: Jeremy Allison <j...@samba.org> ----------------------------------------------------------------------- Summary of changes: docs-xml/manpages/vfs_virusfilter.8.xml | 2 +- source3/include/fake_file.h | 1 - source3/include/proto.h | 5 +- source3/lib/system.c | 55 +++----------- source3/libsmb/async_smb.c | 5 ++ source3/modules/vfs_btrfs.c | 14 ++-- source3/modules/vfs_default.c | 106 +++++++++----------------- source3/modules/vfs_gpfs.c | 55 +++++--------- source3/modules/vfs_posixacl.c | 29 ++----- source3/smbd/close.c | 6 +- source3/smbd/dosmode.c | 2 +- source3/smbd/fake_file.c | 10 +-- source3/smbd/filename.c | 131 ++++++-------------------------- source3/smbd/ntquotas.c | 20 ++--- source3/smbd/open.c | 103 ++++++++----------------- source3/smbd/proto.h | 7 -- source3/smbd/smb1_pipes.c | 10 --- source3/smbd/smb1_reply.c | 3 +- source3/smbd/smb1_trans2.c | 2 +- source3/smbd/smb1_utils.c | 83 ++++++++++++++++++++ source3/smbd/smb1_utils.h | 7 ++ source3/smbd/smb2_reply.c | 5 +- 22 files changed, 258 insertions(+), 403 deletions(-) Changeset truncated at 500 lines: diff --git a/docs-xml/manpages/vfs_virusfilter.8.xml b/docs-xml/manpages/vfs_virusfilter.8.xml index 88f91d73a42..f73c41e1dcf 100644 --- a/docs-xml/manpages/vfs_virusfilter.8.xml +++ b/docs-xml/manpages/vfs_virusfilter.8.xml @@ -64,7 +64,7 @@ <para>If this option is not set, the default path depends on the configured AV scanning engine. </para> - <para>For the <emphasis>sophos</emphasis>backend the default is + <para>For the <emphasis>sophos</emphasis> backend the default is <emphasis>/var/run/savdi/sssp.sock</emphasis>.</para> <para>For the <emphasis>fsav</emphasis> backend the default is <emphasis>/tmp/.fsav-0</emphasis>.</para> diff --git a/source3/include/fake_file.h b/source3/include/fake_file.h index 434bc485d5e..f688ed296fd 100644 --- a/source3/include/fake_file.h +++ b/source3/include/fake_file.h @@ -23,7 +23,6 @@ enum FAKE_FILE_TYPE { FAKE_FILE_TYPE_NONE = 0, FAKE_FILE_TYPE_QUOTA, - FAKE_FILE_TYPE_NAMED_PIPE, FAKE_FILE_TYPE_NAMED_PIPE_PROXY }; diff --git a/source3/include/proto.h b/source3/include/proto.h index 8a6b944a0d6..bbb089a5908 100644 --- a/source3/include/proto.h +++ b/source3/include/proto.h @@ -208,8 +208,11 @@ char *sys_realpath(const char *path); int sys_get_number_of_cores(void); #endif +struct sys_proc_fd_path_buf { + char buf[35]; /* "/proc/self/fd/" + strlen(2^64) + 0-terminator */ +}; bool sys_have_proc_fds(void); -const char *sys_proc_fd_path(int fd, char *buf, size_t bufsize); +char *sys_proc_fd_path(int fd, struct sys_proc_fd_path_buf *buf); struct stat; void init_stat_ex_from_stat (struct stat_ex *dst, diff --git a/source3/lib/system.c b/source3/lib/system.c index 7c9a6b5fa08..132e5827b37 100644 --- a/source3/lib/system.c +++ b/source3/lib/system.c @@ -1016,22 +1016,10 @@ int sys_get_number_of_cores(void) } #endif -static struct proc_fd_pattern { - const char *pattern; - const char *test_path; -} proc_fd_patterns[] = { - /* Linux */ - { "/proc/self/fd/%d", "/proc/self/fd/0" }, - { NULL, NULL }, -}; - -static const char *proc_fd_pattern; - bool sys_have_proc_fds(void) { - static bool checked; - static bool have_proc_fds; - struct proc_fd_pattern *p = NULL; + static bool checked = false; + static bool have_proc_fds = false; struct stat sb; int ret; @@ -1039,42 +1027,19 @@ bool sys_have_proc_fds(void) return have_proc_fds; } - for (p = &proc_fd_patterns[0]; p->test_path != NULL; p++) { - ret = stat(p->test_path, &sb); - if (ret != 0) { - continue; - } - have_proc_fds = true; - proc_fd_pattern = p->pattern; - break; - } - + ret = stat("/proc/self/fd/0", &sb); + have_proc_fds = (ret == 0); checked = true; + return have_proc_fds; } -const char *sys_proc_fd_path(int fd, char *buf, size_t bufsize) +char *sys_proc_fd_path(int fd, struct sys_proc_fd_path_buf *buf) { - int written; + int written = + snprintf(buf->buf, sizeof(buf->buf), "/proc/self/fd/%d", fd); - if (!sys_have_proc_fds()) { - return NULL; - } - -#if defined(__clang__) -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Wformat-nonliteral" -#endif - written = snprintf(buf, - bufsize, - proc_fd_pattern, - fd); -#if defined(__clang__) -#pragma clang diagnostic pop -#endif - if (written >= bufsize) { - return NULL; - } + SMB_ASSERT(sys_have_proc_fds() && (written >= 0)); - return buf; + return buf->buf; } diff --git a/source3/libsmb/async_smb.c b/source3/libsmb/async_smb.c index bcb24a47943..38e0bb93ca5 100644 --- a/source3/libsmb/async_smb.c +++ b/source3/libsmb/async_smb.c @@ -201,6 +201,11 @@ NTSTATUS cli_smb_recv(struct tevent_req *req, is_expected = true; } + if ((state->smb_command == SMBntcreateX) && + NT_STATUS_EQUAL(status, NT_STATUS_STOPPED_ON_SYMLINK)) { + min_wct = 0; + } + map_dos_errors = state->cli->map_dos_errors; state->cli->raw_status = status; talloc_free(state->ptr); diff --git a/source3/modules/vfs_btrfs.c b/source3/modules/vfs_btrfs.c index 12517941ad0..90312524287 100644 --- a/source3/modules/vfs_btrfs.c +++ b/source3/modules/vfs_btrfs.c @@ -466,8 +466,7 @@ static NTSTATUS btrfs_fget_compression(struct vfs_handle_struct *handle, struct files_struct *fsp, uint16_t *_compression_fmt) { - char buf[PATH_MAX]; - const char *p = NULL; + struct sys_proc_fd_path_buf buf; int ret; long flags = 0; int fsp_fd = fsp_get_pathref_fd(fsp); @@ -493,14 +492,11 @@ static NTSTATUS btrfs_fget_compression(struct vfs_handle_struct *handle, return NT_STATUS_NOT_IMPLEMENTED; } - p = sys_proc_fd_path(fsp_fd, buf, sizeof(buf)); - if (p == NULL) { - return NT_STATUS_NO_MEMORY; - } - - fd = open(p, O_RDONLY); + fd = open(sys_proc_fd_path(fsp_fd, &buf), O_RDONLY); if (fd == -1) { - DBG_DEBUG("/proc open of %s failed: %s\n", p, strerror(errno)); + DBG_DEBUG("/proc open of %s failed: %s\n", + buf.buf, + strerror(errno)); return map_nt_error_from_unix(errno); } diff --git a/source3/modules/vfs_default.c b/source3/modules/vfs_default.c index 7fa6872d171..d1a19568e4e 100644 --- a/source3/modules/vfs_default.c +++ b/source3/modules/vfs_default.c @@ -738,11 +738,22 @@ static int vfswrap_openat(vfs_handle_struct *handle, mode); if (became_root) { + int err = errno; unbecome_root(); + errno = err; } done: - fsp->fsp_flags.have_proc_fds = fsp->conn->have_proc_fds; + if (result >= 0) { + fsp->fsp_flags.have_proc_fds = fsp->conn->have_proc_fds; + } else { + /* + * "/proc/self/fd/-1" never exists. Indicate to upper + * layers that for this fsp a possible name-based + * fallback is the only way to go. + */ + fsp->fsp_flags.have_proc_fds = false; + } out: END_PROFILE(syscall_openat); @@ -2677,15 +2688,10 @@ static int vfswrap_fchmod(vfs_handle_struct *handle, files_struct *fsp, mode_t m if (fsp->fsp_flags.have_proc_fds) { int fd = fsp_get_pathref_fd(fsp); - const char *p = NULL; - char buf[PATH_MAX]; + struct sys_proc_fd_path_buf buf; + + result = chmod(sys_proc_fd_path(fd, &buf), mode); - p = sys_proc_fd_path(fd, buf, sizeof(buf)); - if (p != NULL) { - result = chmod(p, mode); - } else { - result = -1; - } END_PROFILE(syscall_fchmod); return result; } @@ -2713,15 +2719,10 @@ static int vfswrap_fchown(vfs_handle_struct *handle, files_struct *fsp, uid_t ui if (fsp->fsp_flags.have_proc_fds) { int fd = fsp_get_pathref_fd(fsp); - const char *p = NULL; - char buf[PATH_MAX]; + struct sys_proc_fd_path_buf buf; + + result = chown(sys_proc_fd_path(fd, &buf), uid, gid); - p = sys_proc_fd_path(fd, buf, sizeof(buf)); - if (p != NULL) { - result = chown(p, uid, gid); - } else { - result = -1; - } END_PROFILE(syscall_fchown); return result; } @@ -2846,19 +2847,12 @@ static int vfswrap_fntimes(vfs_handle_struct *handle, if (fsp->fsp_flags.have_proc_fds) { int fd = fsp_get_pathref_fd(fsp); - const char *p = NULL; - char buf[PATH_MAX]; + struct sys_proc_fd_path_buf buf; - p = sys_proc_fd_path(fd, buf, sizeof(buf)); - if (p != NULL) { - /* - * The dirfd argument of utimensat is ignored when - * pathname is an absolute path - */ - result = utimensat(AT_FDCWD, p, times, 0); - } else { - result = -1; - } + result = utimensat(AT_FDCWD, + sys_proc_fd_path(fd, &buf), + times, + 0); goto out; } @@ -3274,15 +3268,9 @@ static int vfswrap_fchflags(vfs_handle_struct *handle, } if (fsp->fsp_flags.have_proc_fds) { - const char *p = NULL; - char buf[PATH_MAX]; + struct sys_proc_fd_path_buf buf; - p = sys_proc_fd_path(fd, buf, sizeof(buf)); - if (p == NULL) { - return -1; - } - - return chflags(p, flags); + return chflags(sys_proc_fd_path(fd, &buf), flags); } /* @@ -3521,15 +3509,9 @@ static ssize_t vfswrap_fgetxattr(struct vfs_handle_struct *handle, } if (fsp->fsp_flags.have_proc_fds) { - const char *p = NULL; - char buf[PATH_MAX]; - - p = sys_proc_fd_path(fd, buf, sizeof(buf)); - if (p == NULL) { - return -1; - } + struct sys_proc_fd_path_buf buf; - return getxattr(p, name, value, size); + return getxattr(sys_proc_fd_path(fd, &buf), name, value, size); } /* @@ -3847,15 +3829,9 @@ static ssize_t vfswrap_flistxattr(struct vfs_handle_struct *handle, struct files } if (fsp->fsp_flags.have_proc_fds) { - const char *p = NULL; - char buf[PATH_MAX]; + struct sys_proc_fd_path_buf buf; - p = sys_proc_fd_path(fd, buf, sizeof(buf)); - if (p == NULL) { - return -1; - } - - return listxattr(p, list, size); + return listxattr(sys_proc_fd_path(fd, &buf), list, size); } /* @@ -3875,15 +3851,9 @@ static int vfswrap_fremovexattr(struct vfs_handle_struct *handle, struct files_s } if (fsp->fsp_flags.have_proc_fds) { - const char *p = NULL; - char buf[PATH_MAX]; - - p = sys_proc_fd_path(fd, buf, sizeof(buf)); - if (p == NULL) { - return -1; - } + struct sys_proc_fd_path_buf buf; - return removexattr(p, name); + return removexattr(sys_proc_fd_path(fd, &buf), name); } /* @@ -3903,15 +3873,13 @@ static int vfswrap_fsetxattr(struct vfs_handle_struct *handle, struct files_stru } if (fsp->fsp_flags.have_proc_fds) { - const char *p = NULL; - char buf[PATH_MAX]; - - p = sys_proc_fd_path(fd, buf, sizeof(buf)); - if (p == NULL) { - return -1; - } + struct sys_proc_fd_path_buf buf; - return setxattr(p, name, value, size, flags); + return setxattr(sys_proc_fd_path(fd, &buf), + name, + value, + size, + flags); } /* diff --git a/source3/modules/vfs_gpfs.c b/source3/modules/vfs_gpfs.c index 21ede6cea5a..1c11809fb1b 100644 --- a/source3/modules/vfs_gpfs.c +++ b/source3/modules/vfs_gpfs.c @@ -1446,7 +1446,7 @@ static NTSTATUS vfs_gpfs_fget_dos_attributes(struct vfs_handle_struct *handle, { struct gpfs_config_data *config; int fd = fsp_get_pathref_fd(fsp); - char buf[PATH_MAX]; + struct sys_proc_fd_path_buf buf; const char *p = NULL; struct gpfs_iattr64 iattr = { }; unsigned int litemask = 0; @@ -1463,10 +1463,7 @@ static NTSTATUS vfs_gpfs_fget_dos_attributes(struct vfs_handle_struct *handle, if (fsp->fsp_flags.is_pathref && !config->pathref_ok.gpfs_fstat_x) { if (fsp->fsp_flags.have_proc_fds) { - p = sys_proc_fd_path(fd, buf, sizeof(buf)); - if (p == NULL) { - return NT_STATUS_NO_MEMORY; - } + p = sys_proc_fd_path(fd, &buf); } else { p = fsp->fsp_name->base_name; } @@ -1560,20 +1557,17 @@ static NTSTATUS vfs_gpfs_fset_dos_attributes(struct vfs_handle_struct *handle, if (fsp->fsp_flags.have_proc_fds) { int fd = fsp_get_pathref_fd(fsp); - const char *p = NULL; - char buf[PATH_MAX]; - - p = sys_proc_fd_path(fd, buf, sizeof(buf)); - if (p == NULL) { - return NT_STATUS_NO_MEMORY; - } + struct sys_proc_fd_path_buf buf; - ret = gpfswrap_set_winattrs_path(p, + ret = gpfswrap_set_winattrs_path(sys_proc_fd_path(fd, &buf), GPFS_WINATTR_SET_ATTRS, &attrs); if (ret == -1) { - DBG_WARNING("Setting winattrs failed for [%s][%s]: %s\n", - p, fsp_str_dbg(fsp), strerror(errno)); + DBG_WARNING("Setting winattrs failed for " + "[%s][%s]: %s\n", + buf.buf, + fsp_str_dbg(fsp), + strerror(errno)); return map_nt_error_from_unix(errno); } return NT_STATUS_OK; @@ -1728,18 +1722,16 @@ static int smbd_gpfs_set_times(struct files_struct *fsp, if (fsp->fsp_flags.have_proc_fds) { int fd = fsp_get_pathref_fd(fsp); - const char *p = NULL; - char buf[PATH_MAX]; - - p = sys_proc_fd_path(fd, buf, sizeof(buf)); - if (p == NULL) { - return -1; - } + struct sys_proc_fd_path_buf buf; - rc = gpfswrap_set_times_path(buf, flags, gpfs_times); + rc = gpfswrap_set_times_path(sys_proc_fd_path(fd, &buf), + flags, + gpfs_times); if (rc != 0) { DBG_WARNING("gpfs_set_times_path(%s,%s) failed: %s\n", - fsp_str_dbg(fsp), p, strerror(errno)); + fsp_str_dbg(fsp), + buf.buf, + strerror(errno)); } return rc; } @@ -1816,17 +1808,12 @@ static int vfs_gpfs_fntimes(struct vfs_handle_struct *handle, if (fsp->fsp_flags.have_proc_fds) { int fd = fsp_get_pathref_fd(fsp); - const char *p = NULL; - char buf[PATH_MAX]; - - p = sys_proc_fd_path(fd, buf, sizeof(buf)); - if (p == NULL) { - return -1; - } + struct sys_proc_fd_path_buf buf; - ret = gpfswrap_set_winattrs_path(p, - GPFS_WINATTR_SET_CREATION_TIME, - &attrs); + ret = gpfswrap_set_winattrs_path( + sys_proc_fd_path(fd, &buf), + GPFS_WINATTR_SET_CREATION_TIME, + &attrs); if (ret == -1 && errno != ENOSYS) { DBG_WARNING("Set GPFS ntimes failed %d\n", ret); return -1; diff --git a/source3/modules/vfs_posixacl.c b/source3/modules/vfs_posixacl.c index 2c2b68931a0..feb819de982 100644 --- a/source3/modules/vfs_posixacl.c +++ b/source3/modules/vfs_posixacl.c @@ -58,15 +58,9 @@ SMB_ACL_T posixacl_sys_acl_get_fd(vfs_handle_struct *handle, acl = acl_get_fd(fsp_get_io_fd(fsp)); } else if (fsp->fsp_flags.have_proc_fds) { int fd = fsp_get_pathref_fd(fsp); - const char *proc_fd_path = NULL; - char buf[PATH_MAX]; + struct sys_proc_fd_path_buf buf; - proc_fd_path = sys_proc_fd_path(fd, buf, sizeof(buf)); - if (proc_fd_path == NULL) { - return NULL; - } - - acl = acl_get_file(proc_fd_path, acl_type); + acl = acl_get_file(sys_proc_fd_path(fd, &buf), acl_type); } else { /* * This is no longer a handle based call. @@ -112,15 +106,9 @@ int posixacl_sys_acl_set_fd(vfs_handle_struct *handle, if (!fsp->fsp_flags.is_pathref && type == SMB_ACL_TYPE_ACCESS) { res = acl_set_fd(fd, acl); } else if (fsp->fsp_flags.have_proc_fds) { - const char *proc_fd_path = NULL; - char buf[PATH_MAX]; + struct sys_proc_fd_path_buf buf; - proc_fd_path = sys_proc_fd_path(fd, buf, sizeof(buf)); - if (proc_fd_path == NULL) { - acl_free(acl); - return -1; - } - res = acl_set_file(proc_fd_path, acl_type, acl); + res = acl_set_file(sys_proc_fd_path(fd, &buf), acl_type, acl); } else { /* * This is no longer a handle based call. @@ -139,14 +127,9 @@ int posixacl_sys_acl_delete_def_fd(vfs_handle_struct *handle, { -- Samba Shared Repository