]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
s3/smbd: replace get_ea_list_from_file_path with get_ea_list_from_fsp
authorNoel Power <noel.power@suse.com>
Wed, 10 Feb 2021 10:13:46 +0000 (10:13 +0000)
committerJeremy Allison <jra@samba.org>
Fri, 26 Feb 2021 21:28:33 +0000 (21:28 +0000)
Additionally remove the old get_ea_list_from_file_path.

get_ea_list_from_file_path & new get_ea_list_from_fsp are identical
except for test for an addition test

+       if (is_ntfs_stream_smb_fname(fsp->fsp_name)) {
+               return NT_STATUS_INVALID_PARAMETER;
+       }

This test should should be fine here too.

Signed-off-by: Noel Power <noel.power@suse.com>
Reviewed-by: Jeremy Allison <jra@samba.org>
source3/smbd/trans2.c

index 41dc4aaf526a2e6f33d5f3e5b8e607699a9d8810..ef254aca525bab57e190be9ffc30d71432d7e83d 100644 (file)
@@ -418,122 +418,6 @@ NTSTATUS get_ea_names_from_file(TALLOC_CTX *mem_ctx,
  Return a linked list of the total EA's. Plus the total size
 ****************************************************************************/
 
-static NTSTATUS get_ea_list_from_file_path(TALLOC_CTX *mem_ctx,
-                               files_struct *fsp,
-                               size_t *pea_total_len,
-                               struct ea_list **ea_list)
-{
-       /* Get a list of all xattrs. Max namesize is 64k. */
-       size_t i, num_names;
-       char **names;
-       struct ea_list *ea_list_head = NULL;
-       bool posix_pathnames = false;
-       NTSTATUS status;
-
-       *pea_total_len = 0;
-       *ea_list = NULL;
-
-       /* symlink */
-       if (fsp == NULL) {
-               return NT_STATUS_OK;
-       }
-
-       if (!lp_ea_support(SNUM(fsp->conn))) {
-               return NT_STATUS_OK;
-       }
-
-       if (is_ntfs_stream_smb_fname(fsp->fsp_name)) {
-               return NT_STATUS_INVALID_PARAMETER;
-       }
-
-       posix_pathnames = (fsp->fsp_name->flags & SMB_FILENAME_POSIX_PATH);
-
-       status = get_ea_names_from_file(talloc_tos(),
-                               fsp->conn,
-                               fsp,
-                               &names,
-                               &num_names);
-
-       if (!NT_STATUS_IS_OK(status)) {
-               return status;
-       }
-
-       if (num_names == 0) {
-               return NT_STATUS_OK;
-       }
-
-       for (i=0; i<num_names; i++) {
-               struct ea_list *listp;
-               fstring dos_ea_name;
-
-               if (strnequal(names[i], "system.", 7)
-                   || samba_private_attr_name(names[i]))
-                       continue;
-
-               /*
-                * Filter out any underlying POSIX EA names
-                * that a Windows client can't handle.
-                */
-               if (!posix_pathnames &&
-                               is_invalid_windows_ea_name(names[i])) {
-                       continue;
-               }
-
-               listp = talloc(mem_ctx, struct ea_list);
-               if (listp == NULL) {
-                       return NT_STATUS_NO_MEMORY;
-               }
-
-               status = get_ea_value(listp,
-                                       fsp->conn,
-                                       fsp,
-                                       fsp->fsp_name,
-                                       names[i],
-                                       &listp->ea);
-
-               if (!NT_STATUS_IS_OK(status)) {
-                       TALLOC_FREE(listp);
-                       return status;
-               }
-
-               if (listp->ea.value.length == 0) {
-                       /*
-                        * We can never return a zero length EA.
-                        * Windows reports the EA's as corrupted.
-                        */
-                       TALLOC_FREE(listp);
-                       continue;
-               }
-
-               push_ascii_fstring(dos_ea_name, listp->ea.name);
-
-               *pea_total_len +=
-                       4 + strlen(dos_ea_name) + 1 + listp->ea.value.length;
-
-               DEBUG(10,("get_ea_list_from_file: total_len = %u, %s, val len "
-                         "= %u\n", (unsigned int)*pea_total_len, dos_ea_name,
-                         (unsigned int)listp->ea.value.length));
-
-               DLIST_ADD_END(ea_list_head, listp);
-
-       }
-
-       /* Add on 4 for total length. */
-       if (*pea_total_len) {
-               *pea_total_len += 4;
-       }
-
-       DEBUG(10, ("get_ea_list_from_file: total_len = %u\n",
-                  (unsigned int)*pea_total_len));
-
-       *ea_list = ea_list_head;
-       return NT_STATUS_OK;
-}
-
-/****************************************************************************
- Return a linked list of the total EA's. Plus the total size
-****************************************************************************/
-
 static NTSTATUS get_ea_list_from_fsp(TALLOC_CTX *mem_ctx,
                                files_struct *fsp,
                                size_t *pea_total_len,
@@ -796,10 +680,10 @@ static unsigned int estimate_ea_size(connection_struct *conn, files_struct *fsp)
        if (is_ntfs_stream_smb_fname(fsp->fsp_name)) {
                fsp = fsp->base_fsp;
        }
-       (void)get_ea_list_from_file_path(mem_ctx,
-                                        fsp,
-                                        &total_ea_len,
-                                        &ea_list);
+       (void)get_ea_list_from_fsp(mem_ctx,
+                                  fsp,
+                                  &total_ea_len,
+                                  &ea_list);
 
        if(conn->sconn->using_smb2) {
                unsigned int ret_data_size;
@@ -836,10 +720,10 @@ static void canonicalize_ea_name(connection_struct *conn,
        size_t total_ea_len;
        TALLOC_CTX *mem_ctx = talloc_tos();
        struct ea_list *ea_list;
-       NTSTATUS status = get_ea_list_from_file_path(mem_ctx,
-                                       smb_fname->fsp,
-                                       &total_ea_len,
-                                       &ea_list);
+       NTSTATUS status = get_ea_list_from_fsp(mem_ctx,
+                                              smb_fname->fsp,
+                                              &total_ea_len,
+                                              &ea_list);
        if (!NT_STATUS_IS_OK(status)) {
                return;
        }