]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
smbd: Move get_posix_fsp() to smb1_trans2.c
authorVolker Lendecke <vl@samba.org>
Sat, 31 Dec 2022 16:41:16 +0000 (17:41 +0100)
committerRalph Boehme <slow@samba.org>
Wed, 4 Jan 2023 08:54:32 +0000 (08:54 +0000)
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
source3/smbd/proto.h
source3/smbd/smb1_trans2.c
source3/smbd/smb2_trans2.c

index 19414bfa7b029c98781717272d6befc302829a53..32e5c33896b6f880f802a88609e32ae8625d58e1 100644 (file)
@@ -1156,12 +1156,6 @@ bool map_info2_flags_to_sbuf(const SMB_STRUCT_STAT *psbuf,
                             const uint32_t smb_fmask,
                             int *stat_fflags);
 
-NTSTATUS get_posix_fsp(connection_struct *conn,
-                      struct smb_request *req,
-                      struct smb_filename *smb_fname,
-                      uint32_t access_mask,
-                      files_struct **ret_fsp);
-
 enum perm_type {
        PERM_NEW_FILE,
        PERM_NEW_DIR,
index 721145bbc384806598f2c8822aa2dfe8b5140888..538f60aeb9f8e31b1ac5e81ac71b9249c50af164 100644 (file)
@@ -2144,6 +2144,83 @@ static NTSTATUS smb_q_unix_info2(
 }
 
 #if defined(HAVE_POSIX_ACLS)
+/****************************************************************************
+ Utility function to open a fsp for a POSIX handle operation.
+****************************************************************************/
+
+static NTSTATUS get_posix_fsp(connection_struct *conn,
+                             struct smb_request *req,
+                             struct smb_filename *smb_fname,
+                             uint32_t access_mask,
+                             files_struct **ret_fsp)
+{
+       NTSTATUS status;
+       uint32_t create_disposition = FILE_OPEN;
+       uint32_t share_access = FILE_SHARE_READ|
+                               FILE_SHARE_WRITE|
+                               FILE_SHARE_DELETE;
+       struct smb2_create_blobs *posx = NULL;
+
+       /*
+        * Only FILE_FLAG_POSIX_SEMANTICS matters on existing files,
+        * but set reasonable defaults.
+        */
+       uint32_t file_attributes = 0664;
+       uint32_t oplock = NO_OPLOCK;
+       uint32_t create_options = FILE_NON_DIRECTORY_FILE;
+
+       /* File or directory must exist. */
+       if (!VALID_STAT(smb_fname->st)) {
+               return NT_STATUS_OBJECT_NAME_NOT_FOUND;
+       }
+       /* Cannot be a symlink. */
+       if (S_ISLNK(smb_fname->st.st_ex_mode)) {
+               return NT_STATUS_ACCESS_DENIED;
+       }
+       /* Set options correctly for directory open. */
+       if (S_ISDIR(smb_fname->st.st_ex_mode)) {
+               /*
+                * Only FILE_FLAG_POSIX_SEMANTICS matters on existing
+                * directories, but set reasonable defaults.
+                */
+               file_attributes = 0775;
+               create_options = FILE_DIRECTORY_FILE;
+       }
+
+       status = make_smb2_posix_create_ctx(
+               talloc_tos(), &posx, file_attributes);
+       if (!NT_STATUS_IS_OK(status)) {
+               DBG_WARNING("make_smb2_posix_create_ctx failed: %s\n",
+                           nt_errstr(status));
+               goto done;
+       }
+
+       status = SMB_VFS_CREATE_FILE(
+               conn,           /* conn */
+               req,            /* req */
+               NULL,           /* dirfsp */
+               smb_fname,      /* fname */
+               access_mask,    /* access_mask */
+               share_access,   /* share_access */
+               create_disposition,/* create_disposition*/
+               create_options, /* create_options */
+               file_attributes,/* file_attributes */
+               oplock,         /* oplock_request */
+               NULL,           /* lease */
+               0,              /* allocation_size */
+               0,              /* private_flags */
+               NULL,           /* sd */
+               NULL,           /* ea_list */
+               ret_fsp,        /* result */
+               NULL,           /* pinfo */
+               posx,           /* in_context */
+               NULL);          /* out_context */
+
+done:
+       TALLOC_FREE(posx);
+       return status;
+}
+
 /****************************************************************************
  Utility function to count the number of entries in a POSIX acl.
 ****************************************************************************/
index dd36351642f80d58f6ad5b683ed62e74e7ad3766..7b89c1dfe81f1bf8aa99da247ab592f61240706c 100644 (file)
@@ -87,85 +87,6 @@ NTSTATUS check_access_fsp(struct files_struct *fsp,
        return NT_STATUS_OK;
 }
 
-#if defined(HAVE_POSIX_ACLS)
-/****************************************************************************
- Utility function to open a fsp for a POSIX handle operation.
-****************************************************************************/
-
-NTSTATUS get_posix_fsp(connection_struct *conn,
-                      struct smb_request *req,
-                      struct smb_filename *smb_fname,
-                      uint32_t access_mask,
-                      files_struct **ret_fsp)
-{
-       NTSTATUS status;
-       uint32_t create_disposition = FILE_OPEN;
-       uint32_t share_access = FILE_SHARE_READ|
-                               FILE_SHARE_WRITE|
-                               FILE_SHARE_DELETE;
-       struct smb2_create_blobs *posx = NULL;
-
-       /*
-        * Only FILE_FLAG_POSIX_SEMANTICS matters on existing files,
-        * but set reasonable defaults.
-        */
-       uint32_t file_attributes = 0664;
-       uint32_t oplock = NO_OPLOCK;
-       uint32_t create_options = FILE_NON_DIRECTORY_FILE;
-
-       /* File or directory must exist. */
-       if (!VALID_STAT(smb_fname->st)) {
-               return NT_STATUS_OBJECT_NAME_NOT_FOUND;
-       }
-       /* Cannot be a symlink. */
-       if (S_ISLNK(smb_fname->st.st_ex_mode)) {
-               return NT_STATUS_ACCESS_DENIED;
-       }
-       /* Set options correctly for directory open. */
-       if (S_ISDIR(smb_fname->st.st_ex_mode)) {
-               /*
-                * Only FILE_FLAG_POSIX_SEMANTICS matters on existing
-                * directories, but set reasonable defaults.
-                */
-               file_attributes = 0775;
-               create_options = FILE_DIRECTORY_FILE;
-       }
-
-       status = make_smb2_posix_create_ctx(
-               talloc_tos(), &posx, file_attributes);
-       if (!NT_STATUS_IS_OK(status)) {
-               DBG_WARNING("make_smb2_posix_create_ctx failed: %s\n",
-                           nt_errstr(status));
-               goto done;
-       }
-
-       status = SMB_VFS_CREATE_FILE(
-               conn,           /* conn */
-               req,            /* req */
-               NULL,           /* dirfsp */
-               smb_fname,      /* fname */
-               access_mask,    /* access_mask */
-               share_access,   /* share_access */
-               create_disposition,/* create_disposition*/
-               create_options, /* create_options */
-               file_attributes,/* file_attributes */
-               oplock,         /* oplock_request */
-               NULL,           /* lease */
-               0,              /* allocation_size */
-               0,              /* private_flags */
-               NULL,           /* sd */
-               NULL,           /* ea_list */
-               ret_fsp,        /* result */
-               NULL,           /* pinfo */
-               posx,           /* in_context */
-               NULL);          /* out_context */
-
-done:
-       TALLOC_FREE(posx);
-       return status;
-}
-#endif
-
 /********************************************************************
  Roundup a value to the nearest allocation roundup size boundary.
  Only do this for Windows clients.