From b51a827e4745f3c330fa24fd876ee190b0519e67 Mon Sep 17 00:00:00 2001 From: Ralph Boehme Date: Wed, 27 Nov 2024 15:27:14 +0100 Subject: [PATCH] smbd: move calling fsctl_get_reparse_tag() into smb3_file_posix_information_init() This already fixes SMB2-GETINFO with POSIX infolevel to return the reparse tag of reparse points. Signed-off-by: Ralph Boehme Reviewed-by: Volker Lendecke --- .../knownfail.d/samba.tests.reparsepoints | 2 -- source3/smbd/proto.h | 5 ++-- source3/smbd/smb2_posix.c | 23 ++++++++++++++--- source3/smbd/smb2_trans2.c | 25 +++++++------------ 4 files changed, 31 insertions(+), 24 deletions(-) diff --git a/selftest/knownfail.d/samba.tests.reparsepoints b/selftest/knownfail.d/samba.tests.reparsepoints index 357149c9b55..4266aa50861 100644 --- a/selftest/knownfail.d/samba.tests.reparsepoints +++ b/selftest/knownfail.d/samba.tests.reparsepoints @@ -1,3 +1 @@ -^samba.tests.reparsepoints.samba.tests.reparsepoints.ReparsePoints.test_fifo_reparse\(fileserver_smb1\) -^samba.tests.reparsepoints.samba.tests.reparsepoints.ReparsePoints.test_sock_reparse\(fileserver_smb1\) ^samba.tests.reparsepoints.samba.tests.reparsepoints.ReparsePoints.test_reparsepoint_posix_type\(fileserver_smb1\) diff --git a/source3/smbd/proto.h b/source3/smbd/proto.h index fe2ad67a03b..e7de9df4683 100644 --- a/source3/smbd/proto.h +++ b/source3/smbd/proto.h @@ -1223,10 +1223,9 @@ NTSTATUS vfs_default_durable_reconnect(struct connection_struct *conn, DATA_BLOB *new_cookie); struct smb3_file_posix_information; -void smb3_file_posix_information_init( +NTSTATUS smb3_file_posix_information_init( connection_struct *conn, - const struct stat_ex *st, - uint32_t reparse_tag, + const struct smb_filename *smb_fname, uint32_t dos_attributes, struct smb3_file_posix_information *dst); diff --git a/source3/smbd/smb2_posix.c b/source3/smbd/smb2_posix.c index 7f2aadb173f..7d184988ca3 100644 --- a/source3/smbd/smb2_posix.c +++ b/source3/smbd/smb2_posix.c @@ -23,14 +23,18 @@ #include "librpc/gen_ndr/ndr_security.h" #include "librpc/gen_ndr/smb3posix.h" #include "libcli/security/security.h" +#include "source3/modules/util_reparse.h" -void smb3_file_posix_information_init( +NTSTATUS smb3_file_posix_information_init( connection_struct *conn, - const struct stat_ex *st, - uint32_t reparse_tag, + const struct smb_filename *smb_fname, uint32_t dos_attributes, struct smb3_file_posix_information *dst) { + const struct stat_ex *st = &smb_fname->st; + uint32_t reparse_tag = 0; + NTSTATUS status; + switch (st->st_ex_mode & S_IFMT) { case S_IFREG: case S_IFDIR: @@ -46,6 +50,18 @@ void smb3_file_posix_information_init( break; } + if (dos_attributes & FILE_ATTRIBUTE_REPARSE_POINT) { + status = fsctl_get_reparse_tag(smb_fname->fsp, + &reparse_tag); + if (!NT_STATUS_IS_OK(status)) { + DBG_DEBUG("Could not get reparse " + "tag for %s: %s\n", + smb_fname_str_dbg(smb_fname), + nt_errstr(status)); + return status; + } + } + *dst = (struct smb3_file_posix_information) { .end_of_file = get_file_size_stat(st), .allocation_size = SMB_VFS_GET_ALLOC_SIZE(conn,NULL,st), @@ -69,4 +85,5 @@ void smb3_file_posix_information_init( if (st->st_ex_gid != (uid_t)-1) { gid_to_sid(&dst->cc.group, st->st_ex_gid); } + return NT_STATUS_OK; } diff --git a/source3/smbd/smb2_trans2.c b/source3/smbd/smb2_trans2.c index 60b9b92e480..8277e981514 100644 --- a/source3/smbd/smb2_trans2.c +++ b/source3/smbd/smb2_trans2.c @@ -1690,7 +1690,6 @@ static NTSTATUS smbd_marshall_dir_entry(TALLOC_CTX *ctx, .fixed_buf_size = true, }; enum ndr_err_code ndr_err; - uint32_t tag = 0; DBG_DEBUG("FSCC_FILE_POSIX_INFORMATION\n"); @@ -1701,21 +1700,12 @@ static NTSTATUS smbd_marshall_dir_entry(TALLOC_CTX *ctx, return NT_STATUS_INVALID_LEVEL; } - if (mode & FILE_ATTRIBUTE_REPARSE_POINT) { - status = fsctl_get_reparse_tag(smb_fname->fsp, - &tag); - if (!NT_STATUS_IS_OK(status)) { - DBG_DEBUG("Could not get reparse " - "tag for %s: %s\n", - smb_fname_str_dbg(smb_fname), - nt_errstr(status)); - return status; - } + status = smb3_file_posix_information_init( + conn, smb_fname, mode, &info); + if (!NT_STATUS_IS_OK(status)) { + return status; } - smb3_file_posix_information_init( - conn, &smb_fname->st, tag, mode, &info); - ndr_err = ndr_push_smb3_file_posix_information( &ndr, NDR_SCALARS|NDR_BUFFERS, &info); if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) { @@ -3669,8 +3659,11 @@ NTSTATUS smbd_do_qfilepathinfo(connection_struct *conn, return NT_STATUS_INVALID_LEVEL; } - smb3_file_posix_information_init( - conn, &smb_fname->st, 0, mode, &info); + status = smb3_file_posix_information_init( + conn, smb_fname, mode, &info); + if (!NT_STATUS_IS_OK(status)) { + return status; + } ndr_err = ndr_push_smb3_file_posix_information( &ndr, NDR_SCALARS|NDR_BUFFERS, &info); -- 2.47.2