Fix for bug #7189 - Open txt files with notepad on samba shares creates problem.
authorJeremy Allison <jra@samba.org>
Fri, 5 Mar 2010 23:10:30 +0000 (15:10 -0800)
committerJeremy Allison <jra@samba.org>
Fri, 5 Mar 2010 23:13:37 +0000 (15:13 -0800)
Ensure we don't use any of the create_options for Samba private
use. Add a new parameter to the VFS_CREATE call (private_flags)
which is only used internally. Renumber NTCREATEX_OPTIONS_PRIVATE_DENY_DOS
and NTCREATEX_OPTIONS_PRIVATE_DENY_FCB to match the S4 code).
Rev. the VFS interface to version 28.

Jeremy.

21 files changed:
examples/VFS/skel_opaque.c
examples/VFS/skel_transparent.c
source3/include/proto.h
source3/include/smb.h
source3/include/vfs.h
source3/include/vfs_macros.h
source3/modules/onefs_open.c
source3/modules/vfs_acl_common.c
source3/modules/vfs_default.c
source3/modules/vfs_full_audit.c
source3/modules/vfs_onefs_shadow_copy.c
source3/printing/nt_printing.c
source3/printing/printfsp.c
source3/rpc_server/srv_srvsvc_nt.c
source3/smbd/nttrans.c
source3/smbd/open.c
source3/smbd/reply.c
source3/smbd/smb2_create.c
source3/smbd/smb2_setinfo.c
source3/smbd/trans2.c
source3/smbd/vfs.c

index 380b3b6f1afe207eae37d48d36972cd5912f2097..a7814957de0d6c8c2554d9620c42b2c05912f3d9 100644 (file)
@@ -150,6 +150,7 @@ static NTSTATUS skel_create_file(struct vfs_handle_struct *handle,
                                 uint32_t file_attributes,
                                 uint32_t oplock_request,
                                 uint64_t allocation_size,
+                               uint32_t private_flags,
                                 struct security_descriptor *sd,
                                 struct ea_list *ea_list,
                                 files_struct **result,
index 27363ff570a129a71930e1d828a9eced5746b188..3be5cf93369b6cd40721bb281094b791a5eb17af 100644 (file)
@@ -143,6 +143,7 @@ static NTSTATUS skel_create_file(struct vfs_handle_struct *handle,
                                 uint32_t file_attributes,
                                 uint32_t oplock_request,
                                 uint64_t allocation_size,
+                               uint32_t private_flags,
                                 struct security_descriptor *sd,
                                 struct ea_list *ea_list,
                                 files_struct **result,
@@ -159,6 +160,7 @@ static NTSTATUS skel_create_file(struct vfs_handle_struct *handle,
                                file_attributes,
                                oplock_request,
                                allocation_size,
+                               private_flags,
                                sd,
                                ea_list,
                                result,
index 35f4703fc2bc857e0c6a6250e5c8e3b0b27a6eef..7c1f8fa92c2ca53c8fffc1e7cd3b5f9b165a6db1 100644 (file)
@@ -6631,7 +6631,8 @@ bool map_open_params_to_ntcreate(const struct smb_filename *smb_fname,
                                 uint32 *paccess_mask,
                                 uint32 *pshare_mode,
                                 uint32 *pcreate_disposition,
-                                uint32 *pcreate_options);
+                                uint32 *pcreate_options,
+                                uint32_t *pprivate_flags);
 NTSTATUS open_file_fchmod(struct smb_request *req, connection_struct *conn,
                          struct smb_filename *smb_fname,
                          files_struct **result);
@@ -6656,6 +6657,7 @@ NTSTATUS create_file_default(connection_struct *conn,
                             uint32_t file_attributes,
                             uint32_t oplock_request,
                             uint64_t allocation_size,
+                            uint32_t private_flags,
                             struct security_descriptor *sd,
                             struct ea_list *ea_list,
 
index de998cbe0a77b9bea2a913cdba76573566211efe..8d1e1482591f2465f5cd97ece4f85a113c4c44af 100644 (file)
@@ -344,7 +344,8 @@ struct fd_handle {
        SMB_OFF_T pos;
        uint32 private_options; /* NT Create options, but we only look at
                                 * NTCREATEX_OPTIONS_PRIVATE_DENY_DOS and
-                                * NTCREATEX_OPTIONS_PRIVATE_DENY_FCB (Except
+                                * NTCREATEX_OPTIONS_PRIVATE_DENY_FCB and
+                                * NTCREATEX_OPTIONS_PRIVATE_DELETE_ON_CLOSE
                                 * for print files *only*, where
                                 * DELETE_ON_CLOSE is not stored in the share
                                 * mode database.
@@ -1372,13 +1373,17 @@ struct bitmap {
 
 /*
  * Private create options used by the ntcreatex processing code. From Samba4.
- * We reuse some ignored flags for private use.
+ * We reuse some ignored flags for private use. Passed in the private_flags
+ * argument.
  */
-#define NTCREATEX_OPTIONS_PRIVATE_DENY_DOS     0x00010000
-#define NTCREATEX_OPTIONS_PRIVATE_DENY_FCB     0x00020000
+#define NTCREATEX_OPTIONS_PRIVATE_DENY_DOS     0x0001
+#define NTCREATEX_OPTIONS_PRIVATE_DENY_FCB     0x0002
 
 /* Private options for streams support */
-#define NTCREATEX_OPTIONS_PRIVATE_STREAM_DELETE 0x00040000
+#define NTCREATEX_OPTIONS_PRIVATE_STREAM_DELETE 0x0004
+
+/* Private options for printer support */
+#define NTCREATEX_OPTIONS_PRIVATE_DELETE_ON_CLOSE 0x0008
 
 /* Responses when opening a file. */
 #define FILE_WAS_SUPERSEDED 0
index aee84a70b7d9c48554d175d1a84fce56ad4a6966..9ec4c3ec69cdab80fd27597ae256e882bb86dbf9 100644 (file)
  *                        return to fs_capabilities call. JRA. */
 /* Leave at 27 - not yet released. Add translate_name VFS call to convert
                 UNIX names to Windows supported names -- asrinivasan. */
-#define SMB_VFS_INTERFACE_VERSION 27
+/* Changed to version 28 - Add private_flags uint32_t to CREATE call. */
+#define SMB_VFS_INTERFACE_VERSION 28
 
 
 /* to bug old modules which are trying to compile with the old functions */
@@ -213,6 +214,7 @@ struct vfs_fn_pointers {
                                uint32_t file_attributes,
                                uint32_t oplock_request,
                                uint64_t allocation_size,
+                               uint32_t private_flags,
                                struct security_descriptor *sd,
                                struct ea_list *ea_list,
                                files_struct **result,
@@ -538,6 +540,7 @@ NTSTATUS smb_vfs_call_create_file(struct vfs_handle_struct *handle,
                                  uint32_t file_attributes,
                                  uint32_t oplock_request,
                                  uint64_t allocation_size,
+                                 uint32_t private_flags,
                                  struct security_descriptor *sd,
                                  struct ea_list *ea_list,
                                  files_struct **result,
index c6f83bda07a9efacecfe1031d2ad9174c199c20b..4472e3a52ab9bca3fa36e82709ac946a27a9a306 100644 (file)
 #define SMB_VFS_NEXT_OPEN(handle, fname, fsp, flags, mode) \
        smb_vfs_call_open((handle)->next, (fname), (fsp), (flags), (mode))
 
-#define SMB_VFS_CREATE_FILE(conn, req, root_dir_fid, smb_fname, access_mask, share_access, create_disposition, create_options, file_attributes, oplock_request, allocation_size, sd, ea_list, result, pinfo) \
-       smb_vfs_call_create_file((conn)->vfs_handles, (req), (root_dir_fid), (smb_fname), (access_mask), (share_access), (create_disposition), (create_options), (file_attributes), (oplock_request), (allocation_size), (sd), (ea_list), (result), (pinfo))
-#define SMB_VFS_NEXT_CREATE_FILE(handle, req, root_dir_fid, smb_fname, access_mask, share_access, create_disposition, create_options, file_attributes, oplock_request, allocation_size, sd, ea_list, result, pinfo) \
-       smb_vfs_call_create_file((handle)->next, (req), (root_dir_fid), (smb_fname), (access_mask), (share_access), (create_disposition), (create_options), (file_attributes), (oplock_request), (allocation_size), (sd), (ea_list), (result), (pinfo))
+#define SMB_VFS_CREATE_FILE(conn, req, root_dir_fid, smb_fname, access_mask, share_access, create_disposition, \
+        create_options, file_attributes, oplock_request, allocation_size, private_flags, sd, ea_list, result, pinfo) \
+       smb_vfs_call_create_file((conn)->vfs_handles, (req), (root_dir_fid), (smb_fname), (access_mask), (share_access), (create_disposition), \
+        (create_options), (file_attributes), (oplock_request), (allocation_size), (private_flags), (sd), (ea_list), (result), (pinfo))
+#define SMB_VFS_NEXT_CREATE_FILE(handle, req, root_dir_fid, smb_fname, access_mask, share_access, create_disposition, \
+        create_options, file_attributes, oplock_request, allocation_size, private_flags, sd, ea_list, result, pinfo) \
+       smb_vfs_call_create_file((handle)->next, (req), (root_dir_fid), (smb_fname), (access_mask), (share_access), (create_disposition), \
+        (create_options), (file_attributes), (oplock_request), (allocation_size), (private_flags), (sd), (ea_list), (result), (pinfo))
 
 #define SMB_VFS_CLOSE(fsp) \
        smb_vfs_call_close_fn((fsp)->conn->vfs_handles, (fsp))
index 2b4e106f910630be6e8fcb7e45cc1479f0cc5f3f..378d9f69f758306936763cf9d27c5cd0b8b6e287 100644 (file)
@@ -54,6 +54,7 @@ static NTSTATUS onefs_create_file_unixpath(connection_struct *conn,
                              uint32_t file_attributes,
                              uint32_t oplock_request,
                              uint64_t allocation_size,
+                             uint32_t private_flags,
                              struct security_descriptor *sd,
                              struct ea_list *ea_list,
                              files_struct **result,
@@ -438,6 +439,7 @@ NTSTATUS onefs_open_file_ntcreate(connection_struct *conn,
                                  uint32 create_options,
                                  uint32 new_dos_attributes,
                                  int oplock_request,
+                                 uint32_t private_flags,
                                  struct security_descriptor *sd,
                                  files_struct *fsp,
                                  int *pinfo,
@@ -818,7 +820,7 @@ NTSTATUS onefs_open_file_ntcreate(connection_struct *conn,
        DEBUG(10, ("fsp = %p\n", fsp));
 
        fsp->share_access = share_access;
-       fsp->fh->private_options = create_options;
+       fsp->fh->private_options = private_flags;
        fsp->access_mask = open_access_mask; /* We change this to the
                                              * requested access_mask after
                                              * the open is done. */
@@ -992,7 +994,7 @@ NTSTATUS onefs_open_file_ntcreate(connection_struct *conn,
                         * calls. */
 
                        /* Try to find dup fsp if possible. */
-                       if (create_options &
+                       if (private_flags &
                            (NTCREATEX_OPTIONS_PRIVATE_DENY_DOS|
                             NTCREATEX_OPTIONS_PRIVATE_DENY_FCB)) {
 
@@ -1261,9 +1263,6 @@ NTSTATUS onefs_open_file_ntcreate(connection_struct *conn,
         * deny mode is compatible with all current opens.
         */
 
-       /* Record the options we were opened with. */
-       fsp->share_access = share_access;
-       fsp->fh->private_options = create_options;
        /*
         * According to Samba4, SEC_FILE_READ_ATTRIBUTE is always granted,
         */
@@ -1629,7 +1628,7 @@ static NTSTATUS onefs_open_directory(connection_struct *conn,
        fsp->can_write = False;
 
        fsp->share_access = share_access;
-       fsp->fh->private_options = create_options;
+       fsp->fh->private_options = 0;
        /*
         * According to Samba4, SEC_FILE_READ_ATTRIBUTE is always granted,
         */
@@ -1718,6 +1717,7 @@ static NTSTATUS onefs_create_file_unixpath(connection_struct *conn,
                                           uint32_t file_attributes,
                                           uint32_t oplock_request,
                                           uint64_t allocation_size,
+                                          uint32_t private_flags,
                                           struct security_descriptor *sd,
                                           struct ea_list *ea_list,
                                           files_struct **result,
@@ -1732,7 +1732,8 @@ static NTSTATUS onefs_create_file_unixpath(connection_struct *conn,
        DEBUG(10,("onefs_create_file_unixpath: access_mask = 0x%x "
                  "file_attributes = 0x%x, share_access = 0x%x, "
                  "create_disposition = 0x%x create_options = 0x%x "
-                 "oplock_request = 0x%x ea_list = 0x%p, sd = 0x%p, "
+                 "oplock_request = 0x%x private_flags = 0x%x "
+                 "ea_list = 0x%p, sd = 0x%p, "
                  "fname = %s\n",
                  (unsigned int)access_mask,
                  (unsigned int)file_attributes,
@@ -1740,6 +1741,7 @@ static NTSTATUS onefs_create_file_unixpath(connection_struct *conn,
                  (unsigned int)create_disposition,
                  (unsigned int)create_options,
                  (unsigned int)oplock_request,
+                 (unsigned int)private_flags,
                  ea_list, sd, smb_fname_str_dbg(smb_fname)));
 
        if (create_options & FILE_OPEN_BY_FILE_ID) {
@@ -1823,6 +1825,7 @@ static NTSTATUS onefs_create_file_unixpath(connection_struct *conn,
                        file_attributes,                /* file_attributes */
                        NO_OPLOCK,                      /* oplock_request */
                        0,                              /* allocation_size */
+                       0,                              /* private_flags */
                        NULL,                           /* sd */
                        NULL,                           /* ea_list */
                        &base_fsp,                      /* result */
@@ -2066,6 +2069,7 @@ NTSTATUS onefs_create_file(vfs_handle_struct *handle,
                           uint32_t file_attributes,
                           uint32_t oplock_request,
                           uint64_t allocation_size,
+                          uint32_t private_flags,
                           struct security_descriptor *sd,
                           struct ea_list *ea_list,
                           files_struct **result,
@@ -2080,7 +2084,7 @@ NTSTATUS onefs_create_file(vfs_handle_struct *handle,
        DEBUG(10,("onefs_create_file: access_mask = 0x%x "
                  "file_attributes = 0x%x, share_access = 0x%x, "
                  "create_disposition = 0x%x create_options = 0x%x "
-                 "oplock_request = 0x%x "
+                 "oplock_request = 0x%x private_flags = 0x%x"
                  "root_dir_fid = 0x%x, ea_list = 0x%p, sd = 0x%p, "
                  "fname = %s\n",
                  (unsigned int)access_mask,
@@ -2089,6 +2093,7 @@ NTSTATUS onefs_create_file(vfs_handle_struct *handle,
                  (unsigned int)create_disposition,
                  (unsigned int)create_options,
                  (unsigned int)oplock_request,
+                 (unsigned int)private_flags,
                  (unsigned int)root_dir_fid,
                  ea_list, sd, smb_fname_str_dbg(smb_fname)));
 
@@ -2118,6 +2123,7 @@ NTSTATUS onefs_create_file(vfs_handle_struct *handle,
                file_attributes,                        /* file_attributes */
                oplock_request,                         /* oplock_request */
                allocation_size,                        /* allocation_size */
+               private_flags,
                sd,                                     /* sd */
                ea_list,                                /* ea_list */
                &fsp,                                   /* result */
index 1f1e40343b012bccb079daac8cb2c271d3143891..5d6cfe7f3e69630ce41bde7152de48995154e94c 100644 (file)
@@ -873,6 +873,7 @@ static NTSTATUS create_file_acl_common(struct vfs_handle_struct *handle,
                                uint32_t file_attributes,
                                uint32_t oplock_request,
                                uint64_t allocation_size,
+                               uint32_t private_flags,
                                struct security_descriptor *sd,
                                struct ea_list *ea_list,
                                files_struct **result,
@@ -894,6 +895,7 @@ static NTSTATUS create_file_acl_common(struct vfs_handle_struct *handle,
                                        file_attributes,
                                        oplock_request,
                                        allocation_size,
+                                       private_flags,
                                        sd,
                                        ea_list,
                                        result,
index 6e2a5712c83fe6d8209934f13d3921a42ee1abb6..ed9bb36d485d1f4eec8567a44aa035655d58815f 100644 (file)
@@ -298,6 +298,7 @@ static NTSTATUS vfswrap_create_file(vfs_handle_struct *handle,
                                    uint32_t file_attributes,
                                    uint32_t oplock_request,
                                    uint64_t allocation_size,
+                                   uint32_t private_flags,
                                    struct security_descriptor *sd,
                                    struct ea_list *ea_list,
                                    files_struct **result,
@@ -307,7 +308,8 @@ static NTSTATUS vfswrap_create_file(vfs_handle_struct *handle,
                                   access_mask, share_access,
                                   create_disposition, create_options,
                                   file_attributes, oplock_request,
-                                  allocation_size, sd, ea_list, result,
+                                  allocation_size, private_flags,
+                                  sd, ea_list, result,
                                   pinfo);
 }
 
index 8a40f6712c805678bc3483d1ac047f58d05e5f87..7e7a4f415891fb3bed5e27b5cc67b45cf6c44bb3 100644 (file)
@@ -868,6 +868,7 @@ static NTSTATUS smb_full_audit_create_file(vfs_handle_struct *handle,
                                      uint32_t file_attributes,
                                      uint32_t oplock_request,
                                      uint64_t allocation_size,
+                                     uint32_t private_flags,
                                      struct security_descriptor *sd,
                                      struct ea_list *ea_list,
                                      files_struct **result_fsp,
@@ -911,6 +912,7 @@ static NTSTATUS smb_full_audit_create_file(vfs_handle_struct *handle,
                file_attributes,                        /* file_attributes */
                oplock_request,                         /* oplock_request */
                allocation_size,                        /* allocation_size */
+               private_flags,
                sd,                                     /* sd */
                ea_list,                                /* ea_list */
                result_fsp,                             /* result */
index c733392d2774732e215d9789136abd9e660c2c15..cf84e581713c0151a282650e942bd1f98d41fd09 100644 (file)
@@ -233,6 +233,7 @@ onefs_shadow_copy_create_file(vfs_handle_struct *handle,
                              uint32_t file_attributes,
                              uint32_t oplock_request,
                              uint64_t allocation_size,
+                             uint32_t private_flags,
                              struct security_descriptor *sd,
                              struct ea_list *ea_list,
                              files_struct **result,
@@ -243,7 +244,8 @@ onefs_shadow_copy_create_file(vfs_handle_struct *handle,
                                  access_mask, share_access,
                                  create_disposition, create_options,
                                  file_attributes, oplock_request,
-                                 allocation_size, sd, ea_list, result, pinfo),
+                                 allocation_size, private_flags,
+                                 sd, ea_list, result, pinfo),
                              NTSTATUS);
 }
 
index 7aef4249617fc9bb31c43b4ddb585fcbfe064022..d7fe272ea7c831b2b819b7f18eaa0b855fe477f1 100644 (file)
@@ -1315,6 +1315,7 @@ static int file_version_is_newer(connection_struct *conn, fstring new_file, fstr
                FILE_ATTRIBUTE_NORMAL,                  /* file_attributes */
                INTERNAL_OPEN_ONLY,                     /* oplock_request */
                0,                                      /* allocation_size */
+               0,                                      /* private_flags */
                NULL,                                   /* sd */
                NULL,                                   /* ea_list */
                &fsp,                                   /* result */
@@ -1367,6 +1368,7 @@ static int file_version_is_newer(connection_struct *conn, fstring new_file, fstr
                FILE_ATTRIBUTE_NORMAL,                  /* file_attributes */
                INTERNAL_OPEN_ONLY,                     /* oplock_request */
                0,                                      /* allocation_size */
+               0,                                      /* private_flags */
                NULL,                                   /* sd */
                NULL,                                   /* ea_list */
                &fsp,                                   /* result */
@@ -1524,6 +1526,7 @@ static uint32 get_correct_cversion(struct pipes_struct *p,
                0,                                      /* create_options */
                FILE_ATTRIBUTE_NORMAL,                  /* file_attributes */
                INTERNAL_OPEN_ONLY,                     /* oplock_request */
+               0,                                      /* private_flags */
                0,                                      /* allocation_size */
                NULL,                                   /* sd */
                NULL,                                   /* ea_list */
index b9fe49226eaba5774c7f9b716a5069448bc2d28f..756a314dd77d88a0fae54d1813a1bb46ad57307f 100644 (file)
@@ -94,7 +94,7 @@ void print_fsp_end(files_struct *fsp, enum file_close_type close_type)
 {
        uint32 jobid;
 
-       if (fsp->fh->private_options & FILE_DELETE_ON_CLOSE) {
+       if (fsp->fh->private_options & NTCREATEX_OPTIONS_PRIVATE_DELETE_ON_CLOSE) {
                /*
                 * Truncate the job. print_job_end will take
                 * care of deleting it for us. JRA.
index a2d1d0716d2fc6804ec7743dcb193381b1eb9eb3..0681ca30f72e72df8a12efaf83943c24f3e7299c 100644 (file)
@@ -2130,6 +2130,7 @@ WERROR _srvsvc_NetGetFileSecurity(pipes_struct *p,
                0,                                      /* file_attributes */
                INTERNAL_OPEN_ONLY,                     /* oplock_request */
                0,                                      /* allocation_size */
+               0,                                      /* private_flags */
                NULL,                                   /* sd */
                NULL,                                   /* ea_list */
                &fsp,                                   /* result */
@@ -2260,6 +2261,7 @@ WERROR _srvsvc_NetSetFileSecurity(pipes_struct *p,
                0,                                      /* file_attributes */
                INTERNAL_OPEN_ONLY,                     /* oplock_request */
                0,                                      /* allocation_size */
+               0,                                      /* private_flags */
                NULL,                                   /* sd */
                NULL,                                   /* ea_list */
                &fsp,                                   /* result */
index 656375499f5efde690b59170bd3c439e08a247f1..93621dde618f028b7c525247507e0c55d3abcf11 100644 (file)
@@ -570,6 +570,7 @@ void reply_ntcreate_and_X(struct smb_request *req)
                file_attributes,                        /* file_attributes */
                oplock_request,                         /* oplock_request */
                allocation_size,                        /* allocation_size */
+               0,                                      /* private_flags */
                NULL,                                   /* sd */
                NULL,                                   /* ea_list */
                &fsp,                                   /* result */
@@ -1105,6 +1106,7 @@ static void call_nt_transact_create(connection_struct *conn,
                file_attributes,                        /* file_attributes */
                oplock_request,                         /* oplock_request */
                allocation_size,                        /* allocation_size */
+               0,                                      /* private_flags */
                sd,                                     /* sd */
                ea_list,                                /* ea_list */
                &fsp,                                   /* result */
@@ -1331,6 +1333,7 @@ static NTSTATUS copy_internals(TALLOC_CTX *ctx,
                FILE_ATTRIBUTE_NORMAL,                  /* file_attributes */
                NO_OPLOCK,                              /* oplock_request */
                0,                                      /* allocation_size */
+               0,                                      /* private_flags */
                NULL,                                   /* sd */
                NULL,                                   /* ea_list */
                &fsp1,                                  /* result */
@@ -1353,6 +1356,7 @@ static NTSTATUS copy_internals(TALLOC_CTX *ctx,
                fattr,                                  /* file_attributes */
                NO_OPLOCK,                              /* oplock_request */
                0,                                      /* allocation_size */
+               0,                                      /* private_flags */
                NULL,                                   /* sd */
                NULL,                                   /* ea_list */
                &fsp2,                                  /* result */
index 120de0f21abcc59da61401f81ed49ebce7710ccc..fd9796dbf4fdf1562374caa044d8e0aad376100b 100644 (file)
@@ -39,6 +39,7 @@ static NTSTATUS create_file_unixpath(connection_struct *conn,
                                     uint32_t file_attributes,
                                     uint32_t oplock_request,
                                     uint64_t allocation_size,
+                                    uint32_t private_flags,
                                     struct security_descriptor *sd,
                                     struct ea_list *ea_list,
 
@@ -1205,12 +1206,14 @@ bool map_open_params_to_ntcreate(const struct smb_filename *smb_fname,
                                 uint32 *paccess_mask,
                                 uint32 *pshare_mode,
                                 uint32 *pcreate_disposition,
-                                uint32 *pcreate_options)
+                                uint32 *pcreate_options,
+                                uint32_t *pprivate_flags)
 {
        uint32 access_mask;
        uint32 share_mode;
        uint32 create_disposition;
        uint32 create_options = FILE_NON_DIRECTORY_FILE;
+       uint32_t private_flags = 0;
 
        DEBUG(10,("map_open_params_to_ntcreate: fname = %s, deny_mode = 0x%x, "
                  "open_func = 0x%x\n",
@@ -1288,7 +1291,7 @@ bool map_open_params_to_ntcreate(const struct smb_filename *smb_fname,
                        break;
 
                case DENY_DOS:
-                       create_options |= NTCREATEX_OPTIONS_PRIVATE_DENY_DOS;
+                       private_flags |= NTCREATEX_OPTIONS_PRIVATE_DENY_DOS;
                        if (is_executable(smb_fname->base_name)) {
                                share_mode = FILE_SHARE_READ|FILE_SHARE_WRITE;
                        } else {
@@ -1301,7 +1304,7 @@ bool map_open_params_to_ntcreate(const struct smb_filename *smb_fname,
                        break;
 
                case DENY_FCB:
-                       create_options |= NTCREATEX_OPTIONS_PRIVATE_DENY_FCB;
+                       private_flags |= NTCREATEX_OPTIONS_PRIVATE_DENY_FCB;
                        share_mode = FILE_SHARE_NONE;
                        break;
 
@@ -1313,12 +1316,13 @@ bool map_open_params_to_ntcreate(const struct smb_filename *smb_fname,
 
        DEBUG(10,("map_open_params_to_ntcreate: file %s, access_mask = 0x%x, "
                  "share_mode = 0x%x, create_disposition = 0x%x, "
-                 "create_options = 0x%x\n",
+                 "create_options = 0x%x private_flags = 0x%x\n",
                  smb_fname_str_dbg(smb_fname),
                  (unsigned int)access_mask,
                  (unsigned int)share_mode,
                  (unsigned int)create_disposition,
-                 (unsigned int)create_options ));
+                 (unsigned int)create_options,
+                 (unsigned int)private_flags));
 
        if (paccess_mask) {
                *paccess_mask = access_mask;
@@ -1332,6 +1336,9 @@ bool map_open_params_to_ntcreate(const struct smb_filename *smb_fname,
        if (pcreate_options) {
                *pcreate_options = create_options;
        }
+       if (pprivate_flags) {
+               *pprivate_flags = private_flags;
+       }
 
        return True;
 
@@ -1449,6 +1456,7 @@ static NTSTATUS open_file_ntcreate(connection_struct *conn,
                            uint32 new_dos_attributes,  /* attributes used for new file. */
                            int oplock_request,         /* internal Samba oplock codes. */
                                                        /* Information (FILE_EXISTS etc.) */
+                           uint32_t private_flags,     /* Samba specific flags. */
                            int *pinfo,
                            files_struct *fsp)
 {
@@ -1517,10 +1525,11 @@ static NTSTATUS open_file_ntcreate(connection_struct *conn,
        DEBUG(10, ("open_file_ntcreate: fname=%s, dos_attrs=0x%x "
                   "access_mask=0x%x share_access=0x%x "
                   "create_disposition = 0x%x create_options=0x%x "
-                  "unix mode=0%o oplock_request=%d\n",
+                  "unix mode=0%o oplock_request=%d private_flags = 0x%x\n",
                   smb_fname_str_dbg(smb_fname), new_dos_attributes,
                   access_mask, share_access, create_disposition,
-                  create_options, (unsigned int)unx_mode, oplock_request));
+                  create_options, (unsigned int)unx_mode, oplock_request,
+                  (unsigned int)private_flags));
 
        if ((req == NULL) && ((oplock_request & INTERNAL_OPEN_ONLY) == 0)) {
                DEBUG(0, ("No smb request but not an internal only open!\n"));
@@ -1714,7 +1723,7 @@ static NTSTATUS open_file_ntcreate(connection_struct *conn,
                /* DENY_DOS opens are always underlying read-write on the
                   file handle, no matter what the requested access mask
                    says. */
-               if ((create_options & NTCREATEX_OPTIONS_PRIVATE_DENY_DOS) ||
+               if ((private_flags & NTCREATEX_OPTIONS_PRIVATE_DENY_DOS) ||
                        access_mask & (FILE_READ_ATTRIBUTES|FILE_READ_DATA|FILE_READ_EA|FILE_EXECUTE)) {
                        flags = O_RDWR;
                } else {
@@ -1763,7 +1772,7 @@ static NTSTATUS open_file_ntcreate(connection_struct *conn,
 
        fsp->file_id = vfs_file_id_from_sbuf(conn, &smb_fname->st);
        fsp->share_access = share_access;
-       fsp->fh->private_options = create_options;
+       fsp->fh->private_options = private_flags;
        fsp->access_mask = open_access_mask; /* We change this to the
                                              * requested access_mask after
                                              * the open is done. */
@@ -1831,7 +1840,7 @@ static NTSTATUS open_file_ntcreate(connection_struct *conn,
 
                        /* Check if this can be done with the deny_dos and fcb
                         * calls. */
-                       if (create_options &
+                       if (private_flags &
                            (NTCREATEX_OPTIONS_PRIVATE_DENY_DOS|
                             NTCREATEX_OPTIONS_PRIVATE_DENY_FCB)) {
                                if (req == NULL) {
@@ -2126,9 +2135,6 @@ static NTSTATUS open_file_ntcreate(connection_struct *conn,
                }
        }
 
-       /* Record the options we were opened with. */
-       fsp->share_access = share_access;
-       fsp->fh->private_options = create_options;
        /*
         * According to Samba4, SEC_FILE_READ_ATTRIBUTE is always granted,
         */
@@ -2290,6 +2296,7 @@ NTSTATUS open_file_fchmod(struct smb_request *req, connection_struct *conn,
                0,                                      /* file_attributes */
                0,                                      /* oplock_request */
                0,                                      /* allocation_size */
+               0,                                      /* private_flags */
                NULL,                                   /* sd */
                NULL,                                   /* ea_list */
                &fsp,                                   /* result */
@@ -2594,7 +2601,7 @@ static NTSTATUS open_directory(connection_struct *conn,
        fsp->can_write = False;
 
        fsp->share_access = share_access;
-       fsp->fh->private_options = create_options;
+       fsp->fh->private_options = 0;
        /*
         * According to Samba4, SEC_FILE_READ_ATTRIBUTE is always granted,
         */
@@ -2678,6 +2685,7 @@ NTSTATUS create_directory(connection_struct *conn, struct smb_request *req,
                FILE_ATTRIBUTE_DIRECTORY,               /* file_attributes */
                0,                                      /* oplock_request */
                0,                                      /* allocation_size */
+               0,                                      /* private_flags */
                NULL,                                   /* sd */
                NULL,                                   /* ea_list */
                &fsp,                                   /* result */
@@ -2847,10 +2855,11 @@ NTSTATUS open_streams_for_delete(connection_struct *conn,
                         (FILE_SHARE_READ |     /* share_access */
                             FILE_SHARE_WRITE | FILE_SHARE_DELETE),
                         FILE_OPEN,             /* create_disposition*/
-                        NTCREATEX_OPTIONS_PRIVATE_STREAM_DELETE, /* create_options */
+                        0,                     /* create_options */
                         FILE_ATTRIBUTE_NORMAL, /* file_attributes */
                         0,                     /* oplock_request */
                         0,                     /* allocation_size */
+                        NTCREATEX_OPTIONS_PRIVATE_STREAM_DELETE, /* private_flags */
                         NULL,                  /* sd */
                         NULL,                  /* ea_list */
                         &streams[i],           /* result */
@@ -2900,6 +2909,7 @@ static NTSTATUS create_file_unixpath(connection_struct *conn,
                                     uint32_t file_attributes,
                                     uint32_t oplock_request,
                                     uint64_t allocation_size,
+                                    uint32_t private_flags,
                                     struct security_descriptor *sd,
                                     struct ea_list *ea_list,
 
@@ -2914,7 +2924,8 @@ static NTSTATUS create_file_unixpath(connection_struct *conn,
        DEBUG(10,("create_file_unixpath: access_mask = 0x%x "
                  "file_attributes = 0x%x, share_access = 0x%x, "
                  "create_disposition = 0x%x create_options = 0x%x "
-                 "oplock_request = 0x%x ea_list = 0x%p, sd = 0x%p, "
+                 "oplock_request = 0x%x private_flags = 0x%x "
+                 "ea_list = 0x%p, sd = 0x%p, "
                  "fname = %s\n",
                  (unsigned int)access_mask,
                  (unsigned int)file_attributes,
@@ -2922,6 +2933,7 @@ static NTSTATUS create_file_unixpath(connection_struct *conn,
                  (unsigned int)create_disposition,
                  (unsigned int)create_options,
                  (unsigned int)oplock_request,
+                 (unsigned int)private_flags,
                  ea_list, sd, smb_fname_str_dbg(smb_fname)));
 
        if (create_options & FILE_OPEN_BY_FILE_ID) {
@@ -3000,7 +3012,7 @@ static NTSTATUS create_file_unixpath(connection_struct *conn,
 
        if ((conn->fs_capabilities & FILE_NAMED_STREAMS)
            && is_ntfs_stream_smb_fname(smb_fname)
-           && (!(create_options & NTCREATEX_OPTIONS_PRIVATE_STREAM_DELETE))) {
+           && (!(private_flags & NTCREATEX_OPTIONS_PRIVATE_STREAM_DELETE))) {
                uint32 base_create_disposition;
                struct smb_filename *smb_fname_base = NULL;
 
@@ -3038,7 +3050,7 @@ static NTSTATUS create_file_unixpath(connection_struct *conn,
                                              | FILE_SHARE_WRITE
                                              | FILE_SHARE_DELETE,
                                              base_create_disposition,
-                                             0, 0, 0, 0, NULL, NULL,
+                                             0, 0, 0, 0, 0, NULL, NULL,
                                              &base_fsp, NULL);
                TALLOC_FREE(smb_fname_base);
 
@@ -3113,6 +3125,7 @@ static NTSTATUS create_file_unixpath(connection_struct *conn,
                                            create_options,
                                            file_attributes,
                                            oplock_request,
+                                           private_flags,
                                            &info,
                                            fsp);
 
@@ -3382,6 +3395,7 @@ NTSTATUS create_file_default(connection_struct *conn,
                             uint32_t file_attributes,
                             uint32_t oplock_request,
                             uint64_t allocation_size,
+                            uint32_t private_flags,
                             struct security_descriptor *sd,
                             struct ea_list *ea_list,
                             files_struct **result,
@@ -3395,6 +3409,7 @@ NTSTATUS create_file_default(connection_struct *conn,
                  "file_attributes = 0x%x, share_access = 0x%x, "
                  "create_disposition = 0x%x create_options = 0x%x "
                  "oplock_request = 0x%x "
+                 "private_flags = 0x%x "
                  "root_dir_fid = 0x%x, ea_list = 0x%p, sd = 0x%p, "
                  "fname = %s\n",
                  (unsigned int)access_mask,
@@ -3403,6 +3418,7 @@ NTSTATUS create_file_default(connection_struct *conn,
                  (unsigned int)create_disposition,
                  (unsigned int)create_options,
                  (unsigned int)oplock_request,
+                 (unsigned int)private_flags,
                  (unsigned int)root_dir_fid,
                  ea_list, sd, smb_fname_str_dbg(smb_fname)));
 
@@ -3467,7 +3483,8 @@ NTSTATUS create_file_default(connection_struct *conn,
        status = create_file_unixpath(
                conn, req, smb_fname, access_mask, share_access,
                create_disposition, create_options, file_attributes,
-               oplock_request, allocation_size, sd, ea_list,
+               oplock_request, allocation_size, private_flags,
+               sd, ea_list,
                &fsp, &info);
 
        if (!NT_STATUS_IS_OK(status)) {
index b1a4e31951f3a0bf2f159fe6430e6828cb74ed47..7147fbe1f2dcfc289e65f27834cce9d8c7bfe4d5 100644 (file)
@@ -1694,6 +1694,7 @@ void reply_open(struct smb_request *req)
        uint32 share_mode;
        uint32 create_disposition;
        uint32 create_options = 0;
+       uint32_t private_flags = 0;
        NTSTATUS status;
        bool ask_sharemode = lp_parm_bool(SNUM(conn), "smbd", "search ask sharemode", true);
        TALLOC_CTX *ctx = talloc_tos();
@@ -1737,7 +1738,7 @@ void reply_open(struct smb_request *req)
        if (!map_open_params_to_ntcreate(smb_fname, deny_mode,
                                         OPENX_FILE_EXISTS_OPEN, &access_mask,
                                         &share_mode, &create_disposition,
-                                        &create_options)) {
+                                        &create_options, &private_flags)) {
                reply_force_doserror(req, ERRDOS, ERRbadaccess);
                goto out;
        }
@@ -1754,6 +1755,7 @@ void reply_open(struct smb_request *req)
                dos_attr,                               /* file_attributes */
                oplock_request,                         /* oplock_request */
                0,                                      /* allocation_size */
+               private_flags,
                NULL,                                   /* sd */
                NULL,                                   /* ea_list */
                &fsp,                                   /* result */
@@ -1853,6 +1855,7 @@ void reply_open_and_X(struct smb_request *req)
        uint32 share_mode;
        uint32 create_disposition;
        uint32 create_options = 0;
+       uint32_t private_flags = 0;
        TALLOC_CTX *ctx = talloc_tos();
 
        START_PROFILE(SMBopenX);
@@ -1910,7 +1913,8 @@ void reply_open_and_X(struct smb_request *req)
        if (!map_open_params_to_ntcreate(smb_fname, deny_mode, smb_ofun,
                                         &access_mask, &share_mode,
                                         &create_disposition,
-                                        &create_options)) {
+                                        &create_options,
+                                        &private_flags)) {
                reply_force_doserror(req, ERRDOS, ERRbadaccess);
                goto out;
        }
@@ -1927,6 +1931,7 @@ void reply_open_and_X(struct smb_request *req)
                smb_attr,                               /* file_attributes */
                oplock_request,                         /* oplock_request */
                0,                                      /* allocation_size */
+               private_flags,
                NULL,                                   /* sd */
                NULL,                                   /* ea_list */
                &fsp,                                   /* result */
@@ -2144,6 +2149,7 @@ void reply_mknew(struct smb_request *req)
                fattr,                                  /* file_attributes */
                oplock_request,                         /* oplock_request */
                0,                                      /* allocation_size */
+               0,                                      /* private_flags */
                NULL,                                   /* sd */
                NULL,                                   /* ea_list */
                &fsp,                                   /* result */
@@ -2272,6 +2278,7 @@ void reply_ctemp(struct smb_request *req)
                fattr,                                  /* file_attributes */
                oplock_request,                         /* oplock_request */
                0,                                      /* allocation_size */
+               0,                                      /* private_flags */
                NULL,                                   /* sd */
                NULL,                                   /* ea_list */
                &fsp,                                   /* result */
@@ -2472,6 +2479,7 @@ static NTSTATUS do_unlink(connection_struct *conn,
                                FILE_ATTRIBUTE_NORMAL,
                 0,                     /* oplock_request */
                 0,                     /* allocation_size */
+                0,                     /* private_flags */
                 NULL,                  /* sd */
                 NULL,                  /* ea_list */
                 &fsp,                  /* result */
@@ -5341,6 +5349,7 @@ void reply_rmdir(struct smb_request *req)
                FILE_ATTRIBUTE_DIRECTORY,               /* file_attributes */
                0,                                      /* oplock_request */
                0,                                      /* allocation_size */
+               0,                                      /* private_flags */
                NULL,                                   /* sd */
                NULL,                                   /* ea_list */
                &fsp,                                   /* result */
@@ -6038,6 +6047,7 @@ NTSTATUS rename_internals(TALLOC_CTX *ctx,
                        posix_pathnames ? FILE_FLAG_POSIX_SEMANTICS|0777 : 0, /* file_attributes */
                        0,                              /* oplock_request */
                        0,                              /* allocation_size */
+                       0,                              /* private_flags */
                        NULL,                           /* sd */
                        NULL,                           /* ea_list */
                        &fsp,                           /* result */
@@ -6176,6 +6186,7 @@ NTSTATUS rename_internals(TALLOC_CTX *ctx,
                        posix_pathnames ? FILE_FLAG_POSIX_SEMANTICS|0777 : 0, /* file_attributes */
                        0,                              /* oplock_request */
                        0,                              /* allocation_size */
+                       0,                              /* private_flags */
                        NULL,                           /* sd */
                        NULL,                           /* ea_list */
                        &fsp,                           /* result */
@@ -6396,6 +6407,7 @@ NTSTATUS copy_file(TALLOC_CTX *ctx,
                if (!map_open_params_to_ntcreate(smb_fname_dst_tmp, 0, ofun,
                                                 NULL, NULL,
                                                 &new_create_disposition,
+                                                NULL,
                                                 NULL)) {
                        status = NT_STATUS_INVALID_PARAMETER;
                        goto out;
@@ -6415,6 +6427,7 @@ NTSTATUS copy_file(TALLOC_CTX *ctx,
                FILE_ATTRIBUTE_NORMAL,                  /* file_attributes */
                INTERNAL_OPEN_ONLY,                     /* oplock_request */
                0,                                      /* allocation_size */
+               0,                                      /* private_flags */
                NULL,                                   /* sd */
                NULL,                                   /* ea_list */
                &fsp1,                                  /* result */
@@ -6443,6 +6456,7 @@ NTSTATUS copy_file(TALLOC_CTX *ctx,
                dosattrs,                               /* file_attributes */
                INTERNAL_OPEN_ONLY,                     /* oplock_request */
                0,                                      /* allocation_size */
+               0,                                      /* private_flags */
                NULL,                                   /* sd */
                NULL,                                   /* ea_list */
                &fsp2,                                  /* result */
index 3cf8b185b08caba28deb622d369ef32fdd091a48..bad0377226c5b776e90efc5a7dd8fa7764ae6114 100644 (file)
@@ -611,6 +611,7 @@ static struct tevent_req *smbd_smb2_create_send(TALLOC_CTX *mem_ctx,
                                             in_file_attributes,
                                             0, /* oplock_request */
                                             allocation_size,
+                                            0, /* private_flags */
                                             sec_desc,
                                             ea_list,
                                             &result,
index a5193eba7a0f1d5e4933a98408597047da24fee6..f6dbf78c21445ddfe780f87a30b10bf931d5c211 100644 (file)
@@ -252,7 +252,7 @@ static struct tevent_req *smbd_smb2_setinfo_send(TALLOC_CTX *mem_ctx,
                        if ((file_info_level == SMB_SET_FILE_DISPOSITION_INFO)
                            && in_input_buffer.length >= 1
                            && CVAL(in_input_buffer.data,0)) {
-                               fsp->fh->private_options |= FILE_DELETE_ON_CLOSE;
+                               fsp->fh->private_options |= NTCREATEX_OPTIONS_PRIVATE_DELETE_ON_CLOSE;
 
                                DEBUG(3,("smbd_smb2_setinfo_send: "
                                         "Cancelling print job (%s)\n",
index d24efc4dd06bbd9d1c1ca02e683b133250582003..1870cbca6ef1f1b23a160d60f9fc462c7ea7029d 100644 (file)
@@ -983,6 +983,7 @@ static void call_trans2open(connection_struct *conn,
        uint32 share_mode;
        uint32 create_disposition;
        uint32 create_options = 0;
+       uint32_t private_flags = 0;
        TALLOC_CTX *ctx = talloc_tos();
 
        /*
@@ -1054,7 +1055,8 @@ static void call_trans2open(connection_struct *conn,
        if (!map_open_params_to_ntcreate(smb_fname, deny_mode, open_ofun,
                                         &access_mask, &share_mode,
                                         &create_disposition,
-                                        &create_options)) {
+                                        &create_options,
+                                        &private_flags)) {
                reply_nterror(req, NT_STATUS_ACCESS_DENIED);
                goto out;
        }
@@ -1101,6 +1103,7 @@ static void call_trans2open(connection_struct *conn,
                open_attr,                              /* file_attributes */
                oplock_request,                         /* oplock_request */
                open_size,                              /* allocation_size */
+               private_flags,
                NULL,                                   /* sd */
                ea_list,                                /* ea_list */
                &fsp,                                   /* result */
@@ -5581,6 +5584,7 @@ static NTSTATUS smb_set_file_size(connection_struct *conn,
                FILE_ATTRIBUTE_NORMAL,                  /* file_attributes */
                FORCE_OPLOCK_BREAK_TO_NONE,             /* oplock_request */
                0,                                      /* allocation_size */
+               0,                                      /* private_flags */
                NULL,                                   /* sd */
                NULL,                                   /* ea_list */
                &new_fsp,                               /* result */
@@ -6494,6 +6498,7 @@ static NTSTATUS smb_set_file_allocation_info(connection_struct *conn,
                FILE_ATTRIBUTE_NORMAL,                  /* file_attributes */
                FORCE_OPLOCK_BREAK_TO_NONE,             /* oplock_request */
                0,                                      /* allocation_size */
+               0,                                      /* private_flags */
                NULL,                                   /* sd */
                NULL,                                   /* ea_list */
                &new_fsp,                               /* result */
@@ -7003,6 +7008,7 @@ static NTSTATUS smb_posix_mkdir(connection_struct *conn,
                mod_unixmode,                           /* file_attributes */
                0,                                      /* oplock_request */
                0,                                      /* allocation_size */
+               0,                                      /* private_flags */
                NULL,                                   /* sd */
                NULL,                                   /* ea_list */
                &fsp,                                   /* result */
@@ -7177,6 +7183,7 @@ static NTSTATUS smb_posix_open(connection_struct *conn,
                mod_unixmode,                           /* file_attributes */
                oplock_request,                         /* oplock_request */
                0,                                      /* allocation_size */
+               0,                                      /* private_flags */
                NULL,                                   /* sd */
                NULL,                                   /* ea_list */
                &fsp,                                   /* result */
@@ -7306,6 +7313,7 @@ static NTSTATUS smb_posix_unlink(connection_struct *conn,
                FILE_FLAG_POSIX_SEMANTICS|0777,         /* file_attributes */
                0,                                      /* oplock_request */
                0,                                      /* allocation_size */
+               0,                                      /* private_flags */
                NULL,                                   /* sd */
                NULL,                                   /* ea_list */
                &fsp,                                   /* result */
@@ -7717,7 +7725,7 @@ static void call_trans2setfilepathinfo(connection_struct *conn,
                         * Doing a DELETE_ON_CLOSE should cancel a print job.
                         */
                        if ((info_level == SMB_SET_FILE_DISPOSITION_INFO) && CVAL(pdata,0)) {
-                               fsp->fh->private_options |= FILE_DELETE_ON_CLOSE;
+                               fsp->fh->private_options |= NTCREATEX_OPTIONS_PRIVATE_DELETE_ON_CLOSE;
 
                                DEBUG(3,("call_trans2setfilepathinfo: "
                                         "Cancelling print job (%s)\n",
index 94bdb1f495c423ce3eb0c252ec3e0c6b3f0308b1..e34454b08f8125b9e9843d0c8e080f228351fc90 100644 (file)
@@ -1230,6 +1230,7 @@ NTSTATUS smb_vfs_call_create_file(struct vfs_handle_struct *handle,
                                  uint32_t file_attributes,
                                  uint32_t oplock_request,
                                  uint64_t allocation_size,
+                                 uint32_t private_flags,
                                  struct security_descriptor *sd,
                                  struct ea_list *ea_list,
                                  files_struct **result,
@@ -1239,7 +1240,8 @@ NTSTATUS smb_vfs_call_create_file(struct vfs_handle_struct *handle,
        return handle->fns->create_file(
                handle, req, root_dir_fid, smb_fname, access_mask,
                share_access, create_disposition, create_options,
-               file_attributes, oplock_request, allocation_size, sd, ea_list,
+               file_attributes, oplock_request, allocation_size,
+               private_flags, sd, ea_list,
                result, pinfo);
 }