The branch, master has been updated
       via  2d9841c9788 smbd: Remove overriding file_attributes with unix_mode 
in the VFS
       via  e0814dc5082 smbd: Allow a Posix create context to override the unix 
mode
       via  5bdad0fb068 smbd: Add posix create ctx to CREATE_FILE for posix 
operations
       via  3b92cbdfa90 smbd: Add a "done:" exit for get_posix_fsp()
       via  4776456ce4e smbd: Make unix_perms_from_wire() public
       via  8047876f4ac smbd: Add make_smb2_posix_create_ctx()
       via  54bd27167ce smbd: Ignore incoming POSIX create context
       via  f6fe7c39cda libsmb: Add smb2_create_blob_remove()
       via  23db7315936 libsmb: Allow passing in NULL to smb2_create_blob_find()
       via  d33d43f38ca libsmb: Add posix create context definition
       via  76803ecccc8 libsmb: Add required #includes to smb_util.h
       via  298dbc53321 libsmb: Add required includes to smb2_create_blob.h
       via  149217ce562 libsmb: Remove "const" from smb_create_blob->tag
      from  859a86b37ea s3: lib: Now remote_machine is static, we can depend on 
it being non-NULL.

https://git.samba.org/?p=samba.git;a=shortlog;h=master


- Log -----------------------------------------------------------------
commit 2d9841c9788835484c364b61507efdf8fe34aa9e
Author: Volker Lendecke <v...@samba.org>
Date:   Wed Feb 5 15:43:43 2020 +0200

    smbd: Remove overriding file_attributes with unix_mode in the VFS
    
    Internally to open.c this is still used, but that can go away next.
    
    Signed-off-by: Volker Lendecke <v...@samba.org>
    Reviewed-by: Jeremy Allison <j...@samba.org>
    
    Autobuild-User(master): Jeremy Allison <j...@samba.org>
    Autobuild-Date(master): Fri Feb  7 22:27:48 UTC 2020 on sn-devel-184

commit e0814dc5082dd4ecca8a155e0ce24b073158fd92
Author: Volker Lendecke <v...@samba.org>
Date:   Tue Feb 4 16:46:09 2020 +0200

    smbd: Allow a Posix create context to override the unix mode
    
    Signed-off-by: Volker Lendecke <v...@samba.org>
    Reviewed-by: Jeremy Allison <j...@samba.org>

commit 5bdad0fb068bfd896b868efa501b0ba3a1053318
Author: Volker Lendecke <v...@samba.org>
Date:   Tue Feb 4 14:58:02 2020 +0200

    smbd: Add posix create ctx to CREATE_FILE for posix operations
    
    This will replace overloading file attributes
    
    Signed-off-by: Volker Lendecke <v...@samba.org>
    Reviewed-by: Jeremy Allison <j...@samba.org>

commit 3b92cbdfa9057a89d404d808b5253bcc83c4f60d
Author: Volker Lendecke <v...@samba.org>
Date:   Wed Feb 5 15:25:12 2020 +0200

    smbd: Add a "done:" exit for get_posix_fsp()
    
    We'll have another exit with the next commit
    
    Signed-off-by: Volker Lendecke <v...@samba.org>
    Reviewed-by: Jeremy Allison <j...@samba.org>

commit 4776456ce4e99c26e5aecd2519ed69b984eca505
Author: Volker Lendecke <v...@samba.org>
Date:   Tue Feb 4 15:28:16 2020 +0200

    smbd: Make unix_perms_from_wire() public
    
    Signed-off-by: Volker Lendecke <v...@samba.org>
    Reviewed-by: Jeremy Allison <j...@samba.org>

commit 8047876f4ac71ed103fbc4aba8ace69fac45ece9
Author: Volker Lendecke <v...@samba.org>
Date:   Thu Jan 23 21:14:44 2020 +0100

    smbd: Add make_smb2_posix_create_ctx()
    
    Will be used internally to pass an artificial posix create context
    into VFS_CREATE_FILE from the SMB1 unix extension calls
    
    Pair programmed with: Jeremy Allison <j...@samba.org>
    Signed-off-by: Volker Lendecke <v...@samba.org>

commit 54bd27167ce2b2b6ca47396c4b2d03c458615f20
Author: Volker Lendecke <v...@samba.org>
Date:   Tue Feb 4 17:19:05 2020 +0200

    smbd: Ignore incoming POSIX create context
    
    We will use this internally and can only expose this once SMB3.11 unix
    extensions are activated for the client.
    
    Signed-off-by: Volker Lendecke <v...@samba.org>
    Reviewed-by: Jeremy Allison <j...@samba.org>

commit f6fe7c39cdaeb9b415c36f7ae9a8baf45dddc5b0
Author: Volker Lendecke <v...@samba.org>
Date:   Tue Feb 4 17:18:41 2020 +0200

    libsmb: Add smb2_create_blob_remove()
    
    Signed-off-by: Volker Lendecke <v...@samba.org>
    Reviewed-by: Jeremy Allison <j...@samba.org>

commit 23db731593614c1427066091090fd13ccebed2aa
Author: Volker Lendecke <v...@samba.org>
Date:   Tue Feb 4 15:03:48 2020 +0200

    libsmb: Allow passing in NULL to smb2_create_blob_find()
    
    Will simplify callers a bit, and it does not change semantics
    significantly. Zero create blobs won't find anything anyway.
    
    Signed-off-by: Volker Lendecke <v...@samba.org>
    Reviewed-by: Jeremy Allison <j...@samba.org>

commit d33d43f38ca01dab644ea209210c14a7fd600167
Author: Volker Lendecke <v...@samba.org>
Date:   Wed Feb 5 05:56:05 2020 +0100

    libsmb: Add posix create context definition
    
    Pair programmed with: Jeremy Allison <j...@samba.org>
    Signed-off-by: Volker Lendecke <v...@samba.org>

commit 76803ecccc8df9f99004342c1f459f711b219e1c
Author: Volker Lendecke <v...@samba.org>
Date:   Wed Feb 5 17:01:52 2020 +0200

    libsmb: Add required #includes to smb_util.h
    
    Signed-off-by: Volker Lendecke <v...@samba.org>
    Reviewed-by: Jeremy Allison <j...@samba.org>

commit 298dbc53321c0bfcc7003f5ad182be869f80c19a
Author: Volker Lendecke <v...@samba.org>
Date:   Wed Feb 5 06:08:15 2020 +0100

    libsmb: Add required includes to smb2_create_blob.h
    
    Signed-off-by: Volker Lendecke <v...@samba.org>
    Reviewed-by: Jeremy Allison <j...@samba.org>

commit 149217ce56219280236822c86f1d8e89b311dd86
Author: Volker Lendecke <v...@samba.org>
Date:   Wed Feb 5 17:00:48 2020 +0200

    libsmb: Remove "const" from smb_create_blob->tag
    
    I want to TALLOC_FREE that soon, and we do a talloc_strdup into this anyway.
    
    Signed-off-by: Volker Lendecke <v...@samba.org>
    Reviewed-by: Jeremy Allison <j...@samba.org>

-----------------------------------------------------------------------

Summary of changes:
 libcli/smb/smb2_constants.h                        |  1 +
 libcli/smb/smb2_create_blob.c                      | 19 +++++
 libcli/smb/smb2_create_blob.h                      |  9 ++-
 libcli/smb/smb2_posix.c                            | 51 +++++++++++++
 .../tstream_u32_read.h => smb/smb2_posix.h}        | 27 ++++---
 libcli/smb/smb_util.h                              |  5 ++
 libcli/smb/wscript                                 |  2 +
 source3/smbd/open.c                                | 31 ++++++++
 source3/smbd/proto.h                               | 13 ++++
 source3/smbd/reply.c                               | 42 ++++++++---
 source3/smbd/smb2_create.c                         |  8 +++
 source3/smbd/trans2.c                              | 84 ++++++++++++++++------
 12 files changed, 247 insertions(+), 45 deletions(-)
 create mode 100644 libcli/smb/smb2_posix.c
 copy libcli/{named_pipe_auth/tstream_u32_read.h => smb/smb2_posix.h} (65%)


Changeset truncated at 500 lines:

diff --git a/libcli/smb/smb2_constants.h b/libcli/smb/smb2_constants.h
index 5832c0e7f83..ea1a21c84e8 100644
--- a/libcli/smb/smb2_constants.h
+++ b/libcli/smb/smb2_constants.h
@@ -237,6 +237,7 @@
 #define SMB2_CREATE_TAG_AAPL "AAPL"
 #define SMB2_CREATE_TAG_APP_INSTANCE_ID 
"\x45\xBC\xA6\x6A\xEF\xA7\xF7\x4A\x90\x08\xFA\x46\x2E\x14\x4D\x74"
 #define SVHDX_OPEN_DEVICE_CONTEXT 
"\x9C\xCB\xCF\x9E\x04\xC1\xE6\x43\x98\x0E\x15\x8D\xA1\xF6\xEC\x83"
+#define SMB2_CREATE_TAG_POSIX 
"\x93\xAD\x25\x50\x9C\xB4\x11\xE7\xB4\x23\x83\xDE\x96\x8B\xCD\x7C"
 
 /* SMB2 notify flags */
 #define SMB2_WATCH_TREE 0x0001
diff --git a/libcli/smb/smb2_create_blob.c b/libcli/smb/smb2_create_blob.c
index bb994f28e2f..ecd61e0c9b2 100644
--- a/libcli/smb/smb2_create_blob.c
+++ b/libcli/smb/smb2_create_blob.c
@@ -213,6 +213,10 @@ struct smb2_create_blob *smb2_create_blob_find(const 
struct smb2_create_blobs *b
 {
        uint32_t i;
 
+       if (b == NULL) {
+               return NULL;
+       }
+
        for (i=0; i < b->num_blobs; i++) {
                if (strcmp(b->blobs[i].tag, tag) == 0) {
                        return &b->blobs[i];
@@ -221,3 +225,18 @@ struct smb2_create_blob *smb2_create_blob_find(const 
struct smb2_create_blobs *b
 
        return NULL;
 }
+
+void smb2_create_blob_remove(struct smb2_create_blobs *b, const char *tag)
+{
+       struct smb2_create_blob *blob = smb2_create_blob_find(b, tag);
+
+       if (blob == NULL) {
+               return;
+       }
+
+       TALLOC_FREE(blob->tag);
+       data_blob_free(&blob->data);
+
+       *blob = b->blobs[b->num_blobs-1];
+       b->num_blobs -= 1;
+}
diff --git a/libcli/smb/smb2_create_blob.h b/libcli/smb/smb2_create_blob.h
index 90697a70892..f41e77edc3d 100644
--- a/libcli/smb/smb2_create_blob.h
+++ b/libcli/smb/smb2_create_blob.h
@@ -23,8 +23,13 @@
 #ifndef _LIBCLI_SMB_SMB2_CREATE_BLOB_H_
 #define _LIBCLI_SMB_SMB2_CREATE_BLOB_H_
 
+#include "replace.h"
+#include "lib/util/data_blob.h"
+#include "lib/util/time.h"
+#include "libcli/util/ntstatus.h"
+
 struct smb2_create_blob {
-       const char *tag;
+       char *tag;
        DATA_BLOB data;
 };
 
@@ -66,4 +71,6 @@ NTSTATUS smb2_create_blob_add(TALLOC_CTX *mem_ctx, struct 
smb2_create_blobs *b,
 struct smb2_create_blob *smb2_create_blob_find(const struct smb2_create_blobs 
*b,
                                               const char *tag);
 
+void smb2_create_blob_remove(struct smb2_create_blobs *b, const char *tag);
+
 #endif /* _LIBCLI_SMB_SMB2_CREATE_BLOB_H_ */
diff --git a/libcli/smb/smb2_posix.c b/libcli/smb/smb2_posix.c
new file mode 100644
index 00000000000..60be3214da2
--- /dev/null
+++ b/libcli/smb/smb2_posix.c
@@ -0,0 +1,51 @@
+/*
+ * Unix SMB/CIFS implementation.
+ *
+ * SMB2 Posix context handling
+ *
+ * Copyright (C) Jeremy Allison 2019
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "replace.h"
+#include "libcli/smb/smb2_posix.h"
+#include "libcli/smb/smb2_constants.h"
+#include "lib/util/byteorder.h"
+
+NTSTATUS make_smb2_posix_create_ctx(
+       TALLOC_CTX *mem_ctx,
+       struct smb2_create_blobs **crb,
+       mode_t mode)
+{
+       struct smb2_create_blobs *cblobs = NULL;
+       uint8_t linear_mode[4];
+       DATA_BLOB blob = { .data=linear_mode, .length=sizeof(linear_mode) };
+       NTSTATUS status;
+
+       cblobs = talloc_zero(mem_ctx, struct smb2_create_blobs);
+       if (cblobs == NULL) {
+               return NT_STATUS_NO_MEMORY;
+       }
+       SIVAL(&linear_mode,0, unix_perms_to_wire(mode & ~S_IFMT));
+
+       status = smb2_create_blob_add(
+               cblobs, cblobs, SMB2_CREATE_TAG_POSIX, blob);
+       if (!NT_STATUS_IS_OK(status)) {
+               TALLOC_FREE(cblobs);
+               return status;
+       }
+       *crb = cblobs;
+       return NT_STATUS_OK;
+}
diff --git a/libcli/named_pipe_auth/tstream_u32_read.h b/libcli/smb/smb2_posix.h
similarity index 65%
copy from libcli/named_pipe_auth/tstream_u32_read.h
copy to libcli/smb/smb2_posix.h
index 1356ff03631..0751814e3dd 100644
--- a/libcli/named_pipe_auth/tstream_u32_read.h
+++ b/libcli/smb/smb2_posix.h
@@ -1,7 +1,9 @@
 /*
  * Unix SMB/CIFS implementation.
  *
- * Copyright (C) Volker Lendecke 2019
+ * SMB2 Posix context handling
+ *
+ * Copyright (C) Jeremy Allison 2019
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -17,21 +19,18 @@
  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  */
 
-#ifndef TSTREAM_U32_READ_H
-#define TSTREAM_U32_READ_H
+#ifndef _LIBCLI_SMB_SMB2_POSIX_H_
+#define _LIBCLI_SMB_SMB2_POSIX_H_
 
 #include "replace.h"
-#include "tsocket.h"
+#include "system/filesys.h"
+#include <talloc.h>
+#include "libcli/smb/smb2_create_blob.h"
+#include "libcli/smb/smb_util.h"
 
-struct tevent_req *tstream_u32_read_send(
-       TALLOC_CTX *mem_ctx,
-       struct tevent_context *ev,
-       uint32_t max_msglen,
-       struct tstream_context *stream);
-int tstream_u32_read_recv(
-       struct tevent_req *req,
+NTSTATUS make_smb2_posix_create_ctx(
        TALLOC_CTX *mem_ctx,
-       uint8_t **buf,
-       size_t *buflen);
+       struct smb2_create_blobs **crb,
+       mode_t mode);
 
-#endif
+#endif /* _LIBCLI_SMB_SMB2_POSIX_H_ */
diff --git a/libcli/smb/smb_util.h b/libcli/smb/smb_util.h
index 501b8dd1d3d..8861741c92f 100644
--- a/libcli/smb/smb_util.h
+++ b/libcli/smb/smb_util.h
@@ -19,6 +19,11 @@
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
 
+#include "replace.h"
+#include "system/filesys.h"
+#include "smb_constants.h"
+#include <talloc.h>
+
 const char *smb_protocol_types_string(enum protocol_types protocol);
 char *attrib_string(TALLOC_CTX *mem_ctx, uint32_t attrib);
 uint32_t unix_perms_to_wire(mode_t perms);
diff --git a/libcli/smb/wscript b/libcli/smb/wscript
index 66c2b9b7e70..86e377f570b 100644
--- a/libcli/smb/wscript
+++ b/libcli/smb/wscript
@@ -43,6 +43,7 @@ def build(bld):
            smb2cli_query_directory.c
            smb2cli_ioctl.c
            smb2cli_echo.c
+           smb2_posix.c
            tstream_smbXcli_np.c
     ''',
     deps='''
@@ -62,6 +63,7 @@ def build(bld):
                     smb2_lease.h
                     smb_util.h
                     smb_unix_ext.h
+                    smb_posix.h
                     tstream_smbXcli_np.h
     ''',
     )
diff --git a/source3/smbd/open.c b/source3/smbd/open.c
index e64e22581e0..709f963c277 100644
--- a/source3/smbd/open.c
+++ b/source3/smbd/open.c
@@ -5884,6 +5884,7 @@ NTSTATUS create_file_default(connection_struct *conn,
        files_struct *fsp = NULL;
        NTSTATUS status;
        bool stream_name = false;
+       struct smb2_create_blob *posx = NULL;
 
        DBG_DEBUG("create_file: access_mask = 0x%x "
                  "file_attributes = 0x%x, share_access = 0x%x, "
@@ -5985,6 +5986,36 @@ NTSTATUS create_file_default(connection_struct *conn,
                }
        }
 
+       posx = smb2_create_blob_find(
+               in_context_blobs, SMB2_CREATE_TAG_POSIX);
+       if (posx != NULL) {
+               uint32_t wire_mode_bits = 0;
+               mode_t mode_bits = 0;
+               SMB_STRUCT_STAT sbuf = { 0 };
+               enum perm_type ptype =
+                       (create_options & FILE_DIRECTORY_FILE) ?
+                       PERM_NEW_DIR : PERM_NEW_FILE;
+
+               if (posx->data.length != 4) {
+                       status = NT_STATUS_INVALID_PARAMETER;
+                       goto fail;
+               }
+
+               wire_mode_bits = IVAL(posx->data.data, 0);
+               status = unix_perms_from_wire(
+                       conn, &sbuf, wire_mode_bits, ptype, &mode_bits);
+               if (!NT_STATUS_IS_OK(status)) {
+                       goto fail;
+               }
+               /*
+                * Remove type info from mode, leaving only the
+                * permissions and setuid/gid bits.
+                */
+               mode_bits &= ~S_IFMT;
+
+               file_attributes = (FILE_FLAG_POSIX_SEMANTICS | mode_bits);
+       }
+
        status = create_file_unixpath(
                conn, req, smb_fname, access_mask, share_access,
                create_disposition, create_options, file_attributes,
diff --git a/source3/smbd/proto.h b/source3/smbd/proto.h
index d325f7d56e0..02a8c9873c3 100644
--- a/source3/smbd/proto.h
+++ b/source3/smbd/proto.h
@@ -1197,6 +1197,19 @@ void reply_findnclose(struct smb_request *req);
 void reply_trans2(struct smb_request *req);
 void reply_transs2(struct smb_request *req);
 
+enum perm_type {
+       PERM_NEW_FILE,
+       PERM_NEW_DIR,
+       PERM_EXISTING_FILE,
+       PERM_EXISTING_DIR
+};
+
+NTSTATUS unix_perms_from_wire(connection_struct *conn,
+                             const SMB_STRUCT_STAT *psbuf,
+                             uint32_t perms,
+                             enum perm_type ptype,
+                             mode_t *ret_perms);
+
 /* The following definitions come from smbd/uid.c  */
 
 bool change_to_guest(void);
diff --git a/source3/smbd/reply.c b/source3/smbd/reply.c
index 40cd7483750..aef34d9ede8 100644
--- a/source3/smbd/reply.c
+++ b/source3/smbd/reply.c
@@ -46,6 +46,7 @@
 #include "lib/util/sys_rw_data.h"
 #include "librpc/gen_ndr/open_files.h"
 #include "smb1_utils.h"
+#include "libcli/smb/smb2_posix.h"
 
 /****************************************************************************
  Ensure we check the path in *exactly* the same way as W2K for a 
findfirst/findnext
@@ -3035,6 +3036,7 @@ static NTSTATUS do_unlink(connection_struct *conn,
        NTSTATUS status;
        int ret;
        bool posix_paths = (req != NULL && req->posix_pathnames);
+       struct smb2_create_blobs *posx = NULL;
 
        DEBUG(10,("do_unlink: %s, dirtype = %d\n",
                  smb_fname_str_dbg(smb_fname),
@@ -3106,6 +3108,16 @@ static NTSTATUS do_unlink(connection_struct *conn,
                return NT_STATUS_OBJECT_NAME_INVALID;
 #endif /* JRATEST */
 
+       if (posix_paths) {
+               status = make_smb2_posix_create_ctx(
+                       talloc_tos(), &posx, 0777);
+               if (!NT_STATUS_IS_OK(status)) {
+                       DBG_WARNING("make_smb2_posix_create_ctx failed: %s\n",
+                                   nt_errstr(status));
+                       return status;
+               }
+       }
+
        /* On open checks the open itself will check the share mode, so
           don't do it here as we'll get it wrong. */
 
@@ -3118,9 +3130,7 @@ static NTSTATUS do_unlink(connection_struct *conn,
                 FILE_SHARE_NONE,       /* share_access */
                 FILE_OPEN,             /* create_disposition*/
                 FILE_NON_DIRECTORY_FILE, /* create_options */
-                                       /* file_attributes */
-                posix_paths ? FILE_FLAG_POSIX_SEMANTICS|0777 :
-                               FILE_ATTRIBUTE_NORMAL,
+                FILE_ATTRIBUTE_NORMAL, /* file_attributes */
                 0,                     /* oplock_request */
                 NULL,                  /* lease */
                 0,                     /* allocation_size */
@@ -3129,7 +3139,10 @@ static NTSTATUS do_unlink(connection_struct *conn,
                 NULL,                  /* ea_list */
                 &fsp,                  /* result */
                 NULL,                  /* pinfo */
-                NULL, NULL);           /* create context */
+                posx,                  /* in_context_blobs */
+                NULL);                 /* out_context_blobs */
+
+       TALLOC_FREE(posx);
 
        if (!NT_STATUS_IS_OK(status)) {
                DEBUG(10, ("SMB_VFS_CREATEFILE failed: %s\n",
@@ -7295,6 +7308,7 @@ NTSTATUS rename_internals(TALLOC_CTX *ctx,
        long offset = 0;
        int create_options = 0;
        bool posix_pathnames = (req != NULL && req->posix_pathnames);
+       struct smb2_create_blobs *posx = NULL;
        int rc;
 
        /*
@@ -7334,6 +7348,15 @@ NTSTATUS rename_internals(TALLOC_CTX *ctx,
                }
        }
 
+       if (posix_pathnames) {
+               status = make_smb2_posix_create_ctx(talloc_tos(), &posx, 0777);
+               if (!NT_STATUS_IS_OK(status)) {
+                       DBG_WARNING("make_smb2_posix_create_ctx failed: %s\n",
+                                   nt_errstr(status));
+                       goto out;
+               }
+       }
+
        if (!src_has_wild) {
                files_struct *fsp;
 
@@ -7411,7 +7434,7 @@ NTSTATUS rename_internals(TALLOC_CTX *ctx,
                            FILE_SHARE_WRITE),
                        FILE_OPEN,                      /* create_disposition*/
                        create_options,                 /* create_options */
-                       posix_pathnames ? FILE_FLAG_POSIX_SEMANTICS|0777 : 0, 
/* file_attributes */
+                       0,                              /* file_attributes */
                        0,                              /* oplock_request */
                        NULL,                           /* lease */
                        0,                              /* allocation_size */
@@ -7420,7 +7443,8 @@ NTSTATUS rename_internals(TALLOC_CTX *ctx,
                        NULL,                           /* ea_list */
                        &fsp,                           /* result */
                        NULL,                           /* pinfo */
-                       NULL, NULL);                    /* create context */
+                       posx,                           /* in_context_blobs */
+                       NULL);                          /* out_context_blobs */
 
                if (!NT_STATUS_IS_OK(status)) {
                        DEBUG(3, ("Could not open rename source %s: %s\n",
@@ -7569,7 +7593,7 @@ NTSTATUS rename_internals(TALLOC_CTX *ctx,
                            FILE_SHARE_WRITE),
                        FILE_OPEN,                      /* create_disposition*/
                        create_options,                 /* create_options */
-                       posix_pathnames ? FILE_FLAG_POSIX_SEMANTICS|0777 : 0, 
/* file_attributes */
+                       0,                              /* file_attributes */
                        0,                              /* oplock_request */
                        NULL,                           /* lease */
                        0,                              /* allocation_size */
@@ -7578,7 +7602,8 @@ NTSTATUS rename_internals(TALLOC_CTX *ctx,
                        NULL,                           /* ea_list */
                        &fsp,                           /* result */
                        NULL,                           /* pinfo */
-                       NULL, NULL);                    /* create context */
+                       posx,                           /* in_context_blobs */
+                       NULL);                          /* out_context_blobs */
 
                if (!NT_STATUS_IS_OK(status)) {
                        DEBUG(3,("rename_internals: SMB_VFS_CREATE_FILE "
@@ -7623,6 +7648,7 @@ NTSTATUS rename_internals(TALLOC_CTX *ctx,
        }
 
  out:
+       TALLOC_FREE(posx);
        TALLOC_FREE(talloced);
        TALLOC_FREE(smb_fname_src_dir);
        TALLOC_FREE(fname_src_dir);
diff --git a/source3/smbd/smb2_create.c b/source3/smbd/smb2_create.c
index bf0c3912c07..2221c4c7d0d 100644
--- a/source3/smbd/smb2_create.c
+++ b/source3/smbd/smb2_create.c
@@ -551,6 +551,14 @@ static NTSTATUS smbd_smb2_create_fetch_create_ctx(
        struct smbd_smb2_create_state *state = tevent_req_data(
                req, struct smbd_smb2_create_state);
 
+       /*
+        * For now, remove the posix create context from the wire. We
+        * are using it inside smbd and will properly use it once
+        * smb3.11 unix extensions will be done. So in the future we
+        * will remove it only if unix extensions are not negotiated.
+        */
+       smb2_create_blob_remove(in_context_blobs, SMB2_CREATE_TAG_POSIX);
+
        state->dhnq = smb2_create_blob_find(in_context_blobs,
                                            SMB2_CREATE_TAG_DHNQ);
        state->dhnc = smb2_create_blob_find(in_context_blobs,
diff --git a/source3/smbd/trans2.c b/source3/smbd/trans2.c
index 2cf669f4b4d..a7a4d32b2c3 100644
--- a/source3/smbd/trans2.c
+++ b/source3/smbd/trans2.c
@@ -43,6 +43,7 @@
 #include "lib/readdir_attr.h"
 #include "messages.h"
 #include "smb1_utils.h"
+#include "libcli/smb/smb2_posix.h"
 
 #define DIR_ENTRY_SAFETY_MARGIN 4096
 
@@ -118,11 +119,13 @@ static NTSTATUS get_posix_fsp(connection_struct *conn,
        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|FILE_FLAG_POSIX_SEMANTICS;
+       uint32_t file_attributes = 0664;
        uint32_t oplock = NO_OPLOCK;
        uint32_t create_options = FILE_NON_DIRECTORY_FILE;
 
@@ -140,7 +143,7 @@ static NTSTATUS get_posix_fsp(connection_struct *conn,
                 * Only FILE_FLAG_POSIX_SEMANTICS matters on existing
                 * directories, but set reasonable defaults.
                 */
-               file_attributes = 0775|FILE_FLAG_POSIX_SEMANTICS;
+               file_attributes = 0775;
                create_options = FILE_DIRECTORY_FILE;
        }
 
@@ -148,7 +151,16 @@ static NTSTATUS get_posix_fsp(connection_struct *conn,
        smb_fname_tmp = cp_smb_filename(talloc_tos(),
                                        smb_fname);
        if (smb_fname_tmp == NULL) {
-               return NT_STATUS_NO_MEMORY;
+               status = NT_STATUS_NO_MEMORY;
+               goto done;
+       }
+
+       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(
@@ -169,9 +181,11 @@ static NTSTATUS get_posix_fsp(connection_struct *conn,
                NULL,           /* ea_list */
                ret_fsp,        /* result */
                NULL,           /* pinfo */
-               NULL,           /* in_context */
+               posx,           /* in_context */
                NULL);          /* out_context */
 
+done:


-- 
Samba Shared Repository

Reply via email to