]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
smbd: move calling fsctl_get_reparse_tag() into smb3_file_posix_information_init()
authorRalph Boehme <slow@samba.org>
Wed, 27 Nov 2024 14:27:14 +0000 (15:27 +0100)
committerRalph Boehme <slow@samba.org>
Wed, 27 Nov 2024 18:22:29 +0000 (18:22 +0000)
This already fixes SMB2-GETINFO with POSIX infolevel to return the reparse tag
of reparse points.

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Volker Lendecke <vl@samba.org>
selftest/knownfail.d/samba.tests.reparsepoints
source3/smbd/proto.h
source3/smbd/smb2_posix.c
source3/smbd/smb2_trans2.c

index 357149c9b55449b40f8bcb14db3a31515c4a2a21..4266aa50861ac2961b51452de2884e0daec02127 100644 (file)
@@ -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\)
index fe2ad67a03b07a94d7636ab206282dfefc9f1124..e7de9df4683774c330eb333c10c3f09ed5d74b20 100644 (file)
@@ -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);
 
index 7f2aadb173f836594cbda1d89c9d4e34aaea6c71..7d184988ca3bb9dfb84567ec13ebf71750d106f2 100644 (file)
 #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;
 }
index 60b9b92e4807848c39508236a03692799c7776f8..8277e9815148df63a3fdf482bae2d2cc6f9e19e6 100644 (file)
@@ -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);