s4-pvfs: move the private ntcreatex flags to private_flags
authorAndrew Tridgell <tridge@samba.org>
Fri, 5 Mar 2010 03:57:50 +0000 (14:57 +1100)
committerAndrew Tridgell <tridge@samba.org>
Fri, 5 Mar 2010 05:12:05 +0000 (16:12 +1100)
Re-using two of the create_options bits was bound to eventually
cause problems, and indeed, Windows7 now uses one of those bits
when opening text files.

Fixes bug 7189

source4/libcli/raw/interfaces.h
source4/libcli/raw/smb.h
source4/ntvfs/ntvfs_generic.c
source4/ntvfs/posix/pvfs_open.c
source4/ntvfs/posix/vfs_posix.h
source4/smb_server/smb/nttrans.c
source4/smb_server/smb/reply.c

index f159074783396b6ce71c1d797c4dec187b2b6c47..f6d090539c4e02a21f9c87a1af38bd69b69db1b0 100644 (file)
@@ -1439,6 +1439,9 @@ union smb_open {
                        
                        /* some optional parameters from the SMB2 varient */
                        bool query_maximal_access;
+
+                       /* private flags for internal use only */
+                       uint8_t private_flags;
                } in;
                struct {
                        union smb_handle file;
index 349705d2dfacc0d7f47e202167ddcb5e2161ef18..7291821faea830ea99226df08f9c066bebe73735 100644 (file)
 #define NTCREATEX_OPTIONS_INVALID_PARAM_MASK    (NTCREATEX_OPTIONS_OPFILTER | \
                                                 NTCREATEX_OPTIONS_SYNC_ALERT | \
                                                 NTCREATEX_OPTIONS_ASYNC_ALERT | \
-                                                NTCREATEX_OPTIONS_OPFILTER | \
                                                 0xFF000000)
 
 /*
- * We reuse some ignored flags for private use.
+ * private_flags field in ntcreatex
  * This values have different meaning for some ntvfs backends.
- *
- * TODO: use values that are ignore for sure...
  */
-#define NTCREATEX_OPTIONS_PRIVATE_DENY_DOS      0x00010000
-#define NTCREATEX_OPTIONS_PRIVATE_DENY_FCB      0x00020000
-#define NTCREATEX_OPTIONS_PRIVATE_MASK          (NTCREATEX_OPTIONS_PRIVATE_DENY_DOS | \
-                                                NTCREATEX_OPTIONS_PRIVATE_DENY_FCB)
+#define NTCREATEX_OPTIONS_PRIVATE_DENY_DOS      0x0001
+#define NTCREATEX_OPTIONS_PRIVATE_DENY_FCB      0x0002
+
 
 /* ntcreatex impersonation field */
 #define NTCREATEX_IMPERSONATION_ANONYMOUS      0
index 547d038738fdc3c047a5338cf1f4371646d9ac79..8e1eb0bc66832b88bb6c907ab616c622c88a4253 100644 (file)
@@ -284,6 +284,7 @@ static NTSTATUS map_openx_open(uint16_t flags, uint16_t open_mode,
                               union smb_open *io2)
 {
        io2->generic.in.create_options = NTCREATEX_OPTIONS_NON_DIRECTORY_FILE;
+       io2->generic.in.private_flags = 0;
 
        if (flags & OPENX_FLAGS_REQUEST_OPLOCK) {
                io2->generic.in.flags |= NTCREATEX_FLAGS_REQUEST_OPLOCK;
@@ -327,7 +328,7 @@ static NTSTATUS map_openx_open(uint16_t flags, uint16_t open_mode,
                break;
        case OPENX_MODE_DENY_DOS:
                /* DENY_DOS is quite strange - it depends on the filename! */
-               io2->generic.in.create_options |= 
+               io2->generic.in.private_flags |=
                        NTCREATEX_OPTIONS_PRIVATE_DENY_DOS;
                if (is_exe_filename(fname)) {
                        io2->generic.in.share_access = 
@@ -342,7 +343,7 @@ static NTSTATUS map_openx_open(uint16_t flags, uint16_t open_mode,
                }
                break;
        case OPENX_MODE_DENY_FCB:
-               io2->generic.in.create_options |= NTCREATEX_OPTIONS_PRIVATE_DENY_FCB;
+               io2->generic.in.private_flags |= NTCREATEX_OPTIONS_PRIVATE_DENY_FCB;
                io2->generic.in.share_access = NTCREATEX_SHARE_ACCESS_NONE;
                break;
        default:
@@ -528,6 +529,7 @@ NTSTATUS ntvfs_map_open(struct ntvfs_module_context *ntvfs,
                io2->generic.in.sec_desc        = io->smb2.in.sec_desc;
                io2->generic.in.ea_list         = &io->smb2.in.eas;
                io2->generic.in.query_maximal_access = io->smb2.in.query_maximal_access; 
+               io2->generic.in.private_flags   = 0;
 
                /* we don't support timewarp yet */
                if (io->smb2.in.timewarp != 0) {
index aa66ad782d12906853e331efcb2308dede3dccf5..7901ef577b98f17fd776fb8e4c33e0f872c84d46 100644 (file)
@@ -276,6 +276,7 @@ static NTSTATUS pvfs_open_directory(struct pvfs_state *pvfs,
        f->handle->fd                = -1;
        f->handle->odb_locking_key   = data_blob(NULL, 0);
        f->handle->create_options    = io->generic.in.create_options;
+       f->handle->private_flags     = io->generic.in.private_flags;
        f->handle->seek_offset       = 0;
        f->handle->position          = 0;
        f->handle->mode              = 0;
@@ -776,6 +777,7 @@ static NTSTATUS pvfs_create_file(struct pvfs_state *pvfs,
        f->handle->name              = talloc_steal(f->handle, name);
        f->handle->fd                = fd;
        f->handle->create_options    = io->generic.in.create_options;
+       f->handle->private_flags     = io->generic.in.private_flags;
        f->handle->seek_offset       = 0;
        f->handle->position          = 0;
        f->handle->mode              = 0;
@@ -1061,7 +1063,7 @@ static NTSTATUS pvfs_open_deny_dos(struct ntvfs_module_context *ntvfs,
                if (f2 != f &&
                    f2->ntvfs->session_info == req->session_info &&
                    f2->ntvfs->smbpid == req->smbpid &&
-                   (f2->handle->create_options & 
+                   (f2->handle->private_flags &
                     (NTCREATEX_OPTIONS_PRIVATE_DENY_DOS |
                      NTCREATEX_OPTIONS_PRIVATE_DENY_FCB)) &&
                    (f2->access_mask & SEC_FILE_WRITE_DATA) &&
@@ -1077,7 +1079,7 @@ static NTSTATUS pvfs_open_deny_dos(struct ntvfs_module_context *ntvfs,
 
        /* quite an insane set of semantics ... */
        if (is_exe_filename(io->generic.in.fname) &&
-           (f2->handle->create_options & NTCREATEX_OPTIONS_PRIVATE_DENY_DOS)) {
+           (f2->handle->private_flags & NTCREATEX_OPTIONS_PRIVATE_DENY_DOS)) {
                return NT_STATUS_SHARING_VIOLATION;
        }
 
@@ -1129,7 +1131,7 @@ static NTSTATUS pvfs_open_setup_retry(struct ntvfs_module_context *ntvfs,
        struct timeval end_time;
        struct timeval *final_timeout = NULL;
 
-       if (io->generic.in.create_options & 
+       if (io->generic.in.private_flags &
            (NTCREATEX_OPTIONS_PRIVATE_DENY_DOS | NTCREATEX_OPTIONS_PRIVATE_DENY_FCB)) {
                /* see if we can satisfy the request using the special DENY_DOS
                   code */
@@ -1219,7 +1221,6 @@ NTSTATUS pvfs_open(struct ntvfs_module_context *ntvfs,
         * but we reuse some of them as private values for the generic mapping
         */
        create_options_must_ignore_mask = NTCREATEX_OPTIONS_MUST_IGNORE_MASK;
-       create_options_must_ignore_mask &= ~NTCREATEX_OPTIONS_PRIVATE_MASK;
        create_options &= ~create_options_must_ignore_mask;
 
        if (create_options & NTCREATEX_OPTIONS_NOT_SUPPORTED_MASK) {
@@ -1438,6 +1439,7 @@ NTSTATUS pvfs_open(struct ntvfs_module_context *ntvfs,
        f->handle->fd                = -1;
        f->handle->name              = talloc_steal(f->handle, name);
        f->handle->create_options    = io->generic.in.create_options;
+       f->handle->private_flags     = io->generic.in.private_flags;
        f->handle->seek_offset       = 0;
        f->handle->position          = 0;
        f->handle->mode              = 0;
index 6354f7558fae6bc433ecbfd65147b019417a2cf8..86e95327c1bab02a432cf4b188e551f39718a145 100644 (file)
@@ -182,6 +182,8 @@ struct pvfs_file_handle {
 
        /* the open went through to completion */
        bool open_completed;
+
+       uint8_t private_flags;
 };
 
 /* open file state */
index 74c98ea738b03fb343faffedb1cd538f4637fc5c..5fba041e1eb5f4ce38dc8d9db1c5ca810d823b2d 100644 (file)
@@ -134,6 +134,7 @@ static NTSTATUS nttrans_create(struct smbsrv_request *req,
        io->ntcreatex.in.sec_desc         = NULL;
        io->ntcreatex.in.ea_list          = NULL;
        io->ntcreatex.in.query_maximal_access = false;
+       io->ntcreatex.in.private_flags    = 0;
 
        req_pull_string(&req->in.bufinfo, &io->ntcreatex.in.fname, 
                        params + 53, 
index ef7cbbf936b8c38b97b2557a1f0418c0559b3bab..7d33a37b4d13b7fee1c18ee3cbbc56135faf766f 100644 (file)
@@ -2228,12 +2228,7 @@ void smbsrv_reply_ntcreate_and_X(struct smbsrv_request *req)
        io->ntcreatex.in.ea_list          = NULL;
        io->ntcreatex.in.sec_desc         = NULL;
        io->ntcreatex.in.query_maximal_access = false;
-
-       /* we use a couple of bits of the create options internally */
-       if (io->ntcreatex.in.create_options & NTCREATEX_OPTIONS_PRIVATE_MASK) {
-               smbsrv_send_error(req, NT_STATUS_INVALID_PARAMETER);
-               return;
-       }
+       io->ntcreatex.in.private_flags    = 0;
 
        /* we need a neater way to handle this alignment */
        if ((req->flags2 & FLAGS2_UNICODE_STRINGS) &&