[SCM] Samba Shared Repository - branch master updated

Andreas Schneider asn at samba.org
Tue Feb 1 17:26:01 UTC 2022


The branch, master has been updated
       via  2b2b41c8682 s3: smbd: Add two new functions in a new file, smb2_posix.c: smb2_posix_cc_info(), store_smb2_posix_info()
       via  85c6711104e s3: smbd: smbd_smb2_request_process_negprot() - Allow SMB2 unix extensions to be negotiated. Currently not allowed.
       via  f68fffa85d1 s3: smbd: Plumb in POSIX lock requests through SMB2 lock calls if done on a POSIX handle. Currently not allowed.
       via  fadb2d60ae3 s3: smbd: Update widelinks_warning() to cope with SMB1 and SMB2 unix extensions.
       via  7a5fea262f2 s3: smbd: lp_widelinks(). Turn off widelinks if either SMB1 or SMB2 unix extensions are turned on.
       via  955f08866d5 s3: smbd: Add lp_smb2_unix_extensions() function. Always returns false for now.
       via  2e72b9cd2d2 s3: smbd: Add the definition for SMB2_FIND_POSIX_INFORMATION info level.
       via  0711040dd58 s3: smbd: Add the definition for SMB2_FILE_POSIX_INFORMATION info level.
       via  722d0d3c55d libcli: Add SMB2 posix negotiate context flag.
       via  e9ad1896946 s3: smbd: Add an SMB2 server flag posix_extensions_negotiated.
      from  e4e5539e402 CVE-2021-44141: s3: smbd: Inside rename_internals_fsp(), we must use vfs_stat() for existence, not SMB_VFS_STAT().

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


- Log -----------------------------------------------------------------
commit 2b2b41c8682d0830786e3d69a9875af8b0c98175
Author: Jeremy Allison <jra at samba.org>
Date:   Thu Jan 27 14:17:36 2022 -0800

    s3: smbd: Add two new functions in a new file, smb2_posix.c: smb2_posix_cc_info(), store_smb2_posix_info()
    
    Not yet used.
    
    Signed-off-by: Jeremy Allison <jra at samba.org>
    Reviewed-by: Andreas Schneider <asn at samba.org>
    
    Autobuild-User(master): Andreas Schneider <asn at cryptomilk.org>
    Autobuild-Date(master): Tue Feb  1 17:25:45 UTC 2022 on sn-devel-184

commit 85c6711104e411c20077b69bf33748d6444abe61
Author: Jeremy Allison <jra at samba.org>
Date:   Thu Jan 27 11:36:19 2022 -0800

    s3: smbd: smbd_smb2_request_process_negprot() - Allow SMB2 unix extensions to be negotiated. Currently not allowed.
    
    As lp_smb2_unix_extensions() currently always returns false,
    this code path cannot be executed. This will change once the
    whole client and server fixes are in place and tests are passing.
    
    Signed-off-by: Jeremy Allison <jra at samba.org>
    Reviewed-by: Andreas Schneider <asn at samba.org>

commit f68fffa85d1de992384a210bb0b9261cda3fb168
Author: Jeremy Allison <jra at samba.org>
Date:   Thu Jan 27 09:49:45 2022 -0800

    s3: smbd: Plumb in POSIX lock requests through SMB2 lock calls if done on a POSIX handle. Currently not allowed.
    
    Note there is currently no way to create a POSIX file
    handle in SMB2 so this code can't be accessed.
    
    This will remain so until client and server code are ready to
    turn on SMB2 POSIX extensions and the tests are in place.
    
    Signed-off-by: Jeremy Allison <jra at samba.org>
    Reviewed-by: Andreas Schneider <asn at samba.org>

commit fadb2d60ae389b77a302402bd05f636262e178b5
Author: Jeremy Allison <jra at samba.org>
Date:   Thu Jan 27 10:11:58 2022 -0800

    s3: smbd: Update widelinks_warning() to cope with SMB1 and SMB2 unix extensions.
    
    Signed-off-by: Jeremy Allison <jra at samba.org>
    Reviewed-by: Andreas Schneider <asn at samba.org>

commit 7a5fea262f2456dcedf701bd743e59295044be4e
Author: Jeremy Allison <jra at samba.org>
Date:   Thu Jan 27 10:07:07 2022 -0800

    s3: smbd: lp_widelinks(). Turn off widelinks if either SMB1 or SMB2 unix extensions are turned on.
    
    NB. Currently it's impossible to turn on SMB2 unix extensions.
    
    Signed-off-by: Jeremy Allison <jra at samba.org>
    Reviewed-by: Andreas Schneider <asn at samba.org>

commit 955f08866d56fe2c232a2b7b2ca69b4421c8092b
Author: Jeremy Allison <jra at samba.org>
Date:   Thu Jan 27 10:03:36 2022 -0800

    s3: smbd: Add lp_smb2_unix_extensions() function. Always returns false for now.
    
    For now *always* returns false. This allows me to
    add code into smbd contingent on lp_smb2_unix_extensions()
    which I know will not be executed until all the parts
    are in place. Then the real parameter can be added
    (default to off) and testing added.
    
    Signed-off-by: Jeremy Allison <jra at samba.org>
    Reviewed-by: Andreas Schneider <asn at samba.org>

commit 2e72b9cd2d29da953a92c21204e79913ab83b99e
Author: Jeremy Allison <jra at samba.org>
Date:   Thu Jan 27 14:46:01 2022 -0800

    s3: smbd: Add the definition for SMB2_FIND_POSIX_INFORMATION info level.
    
    Will be used by smb2_query_directory. Not yet used or available.
    
    Signed-off-by: Jeremy Allison <jra at samba.org>
    Reviewed-by: Andreas Schneider <asn at samba.org>

commit 0711040dd584ac373c208656ea76b95dbd3ad078
Author: Jeremy Allison <jra at samba.org>
Date:   Thu Jan 27 14:43:27 2022 -0800

    s3: smbd: Add the definition for SMB2_FILE_POSIX_INFORMATION info level.
    
    Will be used by smb2_getinfo. Not yet used or available.
    
    Signed-off-by: Jeremy Allison <jra at samba.org>
    Reviewed-by: Andreas Schneider <asn at samba.org>

commit 722d0d3c55d76a4f59834722afebd71b6076cf5f
Author: Jeremy Allison <jra at samba.org>
Date:   Thu Jan 27 10:18:32 2022 -0800

    libcli: Add SMB2 posix negotiate context flag.
    
    Signed-off-by: Jeremy Allison <jra at samba.org>
    Reviewed-by: Andreas Schneider <asn at samba.org>

commit e9ad189694610134e3e887910c2a221655c6d642
Author: Jeremy Allison <jra at samba.org>
Date:   Thu Jan 27 10:55:18 2022 -0800

    s3: smbd: Add an SMB2 server flag posix_extensions_negotiated.
    
    This allows the server to only enable smb2 unix open handles if
    the smb.conf parameter is set and the client client correctly
    negotiated smb2 unix on the connection.
    
    Currently there is no "smb2 unix extensions" parameter so
    this can never be set to true.
    
    Signed-off-by: Jeremy Allison <jra at samba.org>
    Reviewed-by: Andreas Schneider <asn at samba.org>

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

Summary of changes:
 libcli/smb/smb2_constants.h |   4 ++
 source3/include/trans2.h    |   4 ++
 source3/param/loadparm.c    |  21 +++++-
 source3/param/loadparm.h    |   1 +
 source3/smbd/globals.h      |   1 +
 source3/smbd/proto.h        |  11 +++
 source3/smbd/smb2_lock.c    |  19 +++++
 source3/smbd/smb2_negprot.c |  53 ++++++++++++++
 source3/smbd/smb2_posix.c   | 170 ++++++++++++++++++++++++++++++++++++++++++++
 source3/wscript_build       |   1 +
 10 files changed, 282 insertions(+), 3 deletions(-)
 create mode 100644 source3/smbd/smb2_posix.c


Changeset truncated at 500 lines:

diff --git a/libcli/smb/smb2_constants.h b/libcli/smb/smb2_constants.h
index 886989d89ed..edc8ec04739 100644
--- a/libcli/smb/smb2_constants.h
+++ b/libcli/smb/smb2_constants.h
@@ -136,6 +136,7 @@
 #define SMB2_TRANSPORT_CAPABILITIES         0x0006
 #define SMB2_RDMA_TRANSFORM_CAPABILITIES    0x0007
 #define SMB2_SIGNING_CAPABILITIES           0x0008
+#define SMB2_POSIX_EXTENSIONS_AVAILABLE     0x0100
 
 /* Values for the SMB2_PREAUTH_INTEGRITY_CAPABILITIES Context (>= 0x310) */
 #define SMB2_PREAUTH_INTEGRITY_SHA512       0x0001
@@ -278,6 +279,9 @@
 #define SMB2_FIND_ID_BOTH_DIRECTORY_INFO 0x25
 #define SMB2_FIND_ID_FULL_DIRECTORY_INFO 0x26
 
+/* SMB2 UNIX Extensions. */
+#define SMB2_FIND_POSIX_INFORMATION	 0x64
+
 /* flags for SMB2 find */
 #define SMB2_CONTINUE_FLAG_RESTART    0x01
 #define SMB2_CONTINUE_FLAG_SINGLE     0x02
diff --git a/source3/include/trans2.h b/source3/include/trans2.h
index 637ed303e51..ff230171424 100644
--- a/source3/include/trans2.h
+++ b/source3/include/trans2.h
@@ -340,6 +340,9 @@ Byte offset   Type     name                description
 #define FSCC_FILE_STANDARD_LINK_INFORMATION		54
 #define FSCC_FILE_MAXIMUM_INFORMATION			55
 
+/* As yet undefined FSCC_ code for POSIX info level. */
+#define SMB2_FILE_POSIX_INFORMATION			100
+
 /* MS-FSCC 2.4 File System Information Classes */
 
 #define FSCC_FS_VOLUME_INFORMATION			1
@@ -408,6 +411,7 @@ Byte offset   Type     name                description
 #define SMB2_FILE_RENAME_INFORMATION_INTERNAL		(FSCC_FILE_RENAME_INFORMATION + SMB2_INFO_SPECIAL)
 #define SMB2_FILE_FULL_EA_INFORMATION			(FSCC_FILE_FULL_EA_INFORMATION + SMB2_INFO_SPECIAL)
 #define SMB2_FILE_ALL_INFORMATION			(FSCC_FILE_ALL_INFORMATION + SMB2_INFO_SPECIAL)
+#define SMB2_FILE_POSIX_INFORMATION_INTERNAL		(SMB2_FILE_POSIX_INFORMATION + SMB2_INFO_SPECIAL)
 
 /* NT passthough levels for qfsinfo. */
 
diff --git a/source3/param/loadparm.c b/source3/param/loadparm.c
index 199052c37a2..96b72c2dfe0 100644
--- a/source3/param/loadparm.c
+++ b/source3/param/loadparm.c
@@ -4660,18 +4660,27 @@ void widelinks_warning(int snum)
 		return;
 	}
 
-	if (lp_smb1_unix_extensions() && lp_wide_links(snum)) {
-		DBG_ERR("Share '%s' has wide links and unix extensions enabled. "
+	if (lp_wide_links(snum)) {
+		if (lp_smb1_unix_extensions()) {
+			DBG_ERR("Share '%s' has wide links and SMB1 unix "
+			"extensions enabled. "
 			"These parameters are incompatible. "
 			"Wide links will be disabled for this share.\n",
 			 lp_const_servicename(snum));
+		} else if (lp_smb2_unix_extensions()) {
+			DBG_ERR("Share '%s' has wide links and SMB2 unix "
+			"extensions enabled. "
+			"These parameters are incompatible. "
+			"Wide links will be disabled for this share.\n",
+			 lp_const_servicename(snum));
+		}
 	}
 }
 
 bool lp_widelinks(int snum)
 {
 	/* wide links is always incompatible with unix extensions */
-	if (lp_smb1_unix_extensions()) {
+	if (lp_smb1_unix_extensions() || lp_smb2_unix_extensions()) {
 		/*
 		 * Unless we have "allow insecure widelinks"
 		 * turned on.
@@ -4811,3 +4820,9 @@ uint32_t lp_get_async_dns_timeout(void)
 	 */
 	return MAX(Globals.async_dns_timeout, 1);
 }
+
+/* SMB2 POSIX extensions. For now, *always* disabled. */
+bool lp_smb2_unix_extensions(void)
+{
+	return false;
+}
diff --git a/source3/param/loadparm.h b/source3/param/loadparm.h
index 9f7b4bd1cdb..52197ae4979 100644
--- a/source3/param/loadparm.h
+++ b/source3/param/loadparm.h
@@ -183,6 +183,7 @@ void widelinks_warning(int snum);
 const char *lp_ncalrpc_dir(void);
 void _lp_set_server_role(int server_role);
 uint32_t lp_get_async_dns_timeout(void);
+bool lp_smb2_unix_extensions(void);
 
 /* The following definitions come from param/loadparm_ctx.c  */
 
diff --git a/source3/smbd/globals.h b/source3/smbd/globals.h
index eef38f00a4e..b5bb26d1e36 100644
--- a/source3/smbd/globals.h
+++ b/source3/smbd/globals.h
@@ -532,6 +532,7 @@ struct smbXsrv_connection {
 			uint32_t max_write;
 			uint16_t sign_algo;
 			uint16_t cipher;
+			bool posix_extensions_negotiated;
 		} server;
 
 		struct smbXsrv_preauth preauth;
diff --git a/source3/smbd/proto.h b/source3/smbd/proto.h
index c802b05a78f..59a1bbd3e80 100644
--- a/source3/smbd/proto.h
+++ b/source3/smbd/proto.h
@@ -1331,4 +1331,15 @@ NTSTATUS vfs_default_durable_reconnect(struct connection_struct *conn,
 				       files_struct **result,
 				       DATA_BLOB *new_cookie);
 
+/* The following definitions come from smbd/smb2_posix.c */
+DATA_BLOB smb2_posix_cc_info(TALLOC_CTX *mem_ctx,
+				connection_struct *conn,
+				uint32_t reparse_tag,
+				const SMB_STRUCT_STAT *psbuf);
+DATA_BLOB store_smb2_posix_info(TALLOC_CTX *mem_ctx,
+				connection_struct *conn,
+				const SMB_STRUCT_STAT *psbuf,
+				uint32_t reparse_tag,
+				uint32_t dos_attributes);
+
 #endif /* _SMBD_PROTO_H_ */
diff --git a/source3/smbd/smb2_lock.c b/source3/smbd/smb2_lock.c
index 8d4b8b2e853..48593af4790 100644
--- a/source3/smbd/smb2_lock.c
+++ b/source3/smbd/smb2_lock.c
@@ -381,6 +381,7 @@ static struct tevent_req *smbd_smb2_lock_send(TALLOC_CTX *mem_ctx,
 
 	for (i=0; i<in_lock_count; i++) {
 		bool invalid = false;
+		bool posix_handle =(fsp->posix_flags & FSP_POSIX_FLAGS_OPEN);
 
 		switch (in_locks[i].flags) {
 		case SMB2_LOCK_FLAG_SHARED:
@@ -426,7 +427,25 @@ static struct tevent_req *smbd_smb2_lock_send(TALLOC_CTX *mem_ctx,
 		locks[i].offset = in_locks[i].offset;
 		locks[i].count  = in_locks[i].length;
 
+		if (posix_handle) {
+			locks[i].lock_flav = POSIX_LOCK;
+		} else {
+			locks[i].lock_flav = WINDOWS_LOCK;
+		}
+
 		if (in_locks[i].flags & SMB2_LOCK_FLAG_EXCLUSIVE) {
+			if (posix_handle && fsp->fsp_flags.can_write == false) {
+				/*
+				 * Can't get a write lock on a posix
+				 * read-only handle.
+				 */
+				DBG_INFO("POSIX write lock requested "
+					"on read-only handle for file %s\n",
+					fsp_str_dbg(fsp));
+				tevent_req_nterror(req,
+					NT_STATUS_INVALID_HANDLE);
+				return tevent_req_post(req, ev);
+			}
 			locks[i].brltype = WRITE_LOCK;
 		} else if (in_locks[i].flags & SMB2_LOCK_FLAG_SHARED) {
 			locks[i].brltype = READ_LOCK;
diff --git a/source3/smbd/smb2_negprot.c b/source3/smbd/smb2_negprot.c
index c6c9e50e32a..56955fa78dc 100644
--- a/source3/smbd/smb2_negprot.c
+++ b/source3/smbd/smb2_negprot.c
@@ -158,6 +158,7 @@ NTSTATUS smbd_smb2_request_process_negprot(struct smbd_smb2_request *req)
 	struct smb2_negotiate_context *in_cipher = NULL;
 	struct smb2_negotiate_context *in_sign_algo = NULL;
 	struct smb2_negotiate_contexts out_c = { .num_contexts = 0, };
+	struct smb2_negotiate_context *in_posix = NULL;
 	const struct smb311_capabilities default_smb3_capabilities =
 		smb311_capabilities_parse("server",
 			lp_server_smb3_signing_algorithms(),
@@ -270,6 +271,43 @@ NTSTATUS smbd_smb2_request_process_negprot(struct smbd_smb2_request *req)
 		if (!NT_STATUS_IS_OK(status)) {
 			return smbd_smb2_request_error(req, status);
 		}
+
+		if (lp_smb2_unix_extensions()) {
+			in_posix = smb2_negotiate_context_find(&in_c,
+					SMB2_POSIX_EXTENSIONS_AVAILABLE);
+
+			if (in_posix != NULL) {
+				const uint8_t *inbuf = in_posix->data.data;
+				size_t inbuflen = in_posix->data.length;
+				bool posix_found = false;
+				/*
+				 * For now the server only supports one variant.
+				 * Check it's the right one.
+				 */
+				if ((inbuflen % 16) != 0) {
+					return smbd_smb2_request_error(req,
+						NT_STATUS_INVALID_PARAMETER);
+				}
+				SMB_ASSERT(strlen(SMB2_CREATE_TAG_POSIX) == 16);
+				for (ofs=0; ofs<inbuflen; ofs+=16) {
+					if (memcmp(inbuf+ofs,
+							SMB2_CREATE_TAG_POSIX,
+							16) == 0) {
+						posix_found = true;
+						break;
+					}
+				}
+				if (posix_found) {
+					DBG_DEBUG("Client requested SMB2 unix "
+						"extensions\n");
+				} else {
+					DBG_DEBUG("Client requested unknown "
+						"SMB2 unix extensions:\n");
+					dump_data(10, inbuf, inbuflen);
+					in_posix = NULL;
+				}
+			}
+		}
 	}
 
 	if ((dialect != SMB2_DIALECT_REVISION_2FF) &&
@@ -647,6 +685,21 @@ NTSTATUS smbd_smb2_request_process_negprot(struct smbd_smb2_request *req)
 	security_buffer = data_blob_const(NULL, 0);
 #endif
 
+	if (in_posix != NULL) {
+		/* Client correctly negotiated SMB2 unix extensions. */
+		const uint8_t *buf = (const uint8_t *)SMB2_CREATE_TAG_POSIX;
+		status = smb2_negotiate_context_add(
+				req,
+				&out_c,
+				SMB2_POSIX_EXTENSIONS_AVAILABLE,
+				buf,
+				16);
+		if (!NT_STATUS_IS_OK(status)) {
+			return smbd_smb2_request_error(req, status);
+		}
+		xconn->smb2.server.posix_extensions_negotiated = true;
+	}
+
 	if (out_c.num_contexts != 0) {
 		status = smb2_negotiate_context_push(req,
 						&out_negotiate_context_blob,
diff --git a/source3/smbd/smb2_posix.c b/source3/smbd/smb2_posix.c
new file mode 100644
index 00000000000..3d9e2a617e4
--- /dev/null
+++ b/source3/smbd/smb2_posix.c
@@ -0,0 +1,170 @@
+/*
+   Unix SMB/CIFS implementation.
+   SMB2 POSIX code.
+   Copyright (C) Jeremy Allison                 2022
+
+   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 "includes.h"
+#include "smbd/smbd.h"
+#include "passdb/lookup_sid.h"
+#include "librpc/gen_ndr/ndr_security.h"
+
+/*
+ * SMB2 POSIX create context return details.
+ */
+DATA_BLOB smb2_posix_cc_info(TALLOC_CTX *mem_ctx,
+				connection_struct *conn,
+				uint32_t reparse_tag,
+				const SMB_STRUCT_STAT *psbuf)
+{
+	DATA_BLOB ret_blob = data_blob_null;
+	struct dom_sid sid_owner;
+	struct dom_sid sid_group;
+	size_t owner_sid_size = 0;
+	size_t group_sid_size = 0;
+	size_t b_size = 12;
+
+	uid_to_sid(&sid_owner, psbuf->st_ex_uid);
+	owner_sid_size = ndr_size_dom_sid(&sid_owner, 0);
+	if (b_size + owner_sid_size < b_size) {
+		return data_blob_null;
+	}
+	b_size += owner_sid_size;
+
+	gid_to_sid(&sid_group, psbuf->st_ex_gid);
+	group_sid_size = ndr_size_dom_sid(&sid_group, 0);
+	if (b_size + group_sid_size < b_size) {
+		return data_blob_null;
+	}
+	b_size += group_sid_size;
+
+	ret_blob = data_blob_talloc(mem_ctx,
+				    NULL,
+				    b_size);
+	if (ret_blob.data == NULL) {
+		return data_blob_null;
+	}
+
+	/* number of hard links */
+	PUSH_LE_U32(ret_blob.data, 0, psbuf->st_ex_nlink);
+
+	/* Reparse tag if FILE_FLAG_REPARSE is set, else zero. */
+	PUSH_LE_U32(ret_blob.data, 4, reparse_tag);
+
+	/*
+	 * Remove type info from mode, leaving only the
+	 * permissions and setuid/gid bits.
+	 */
+	PUSH_LE_U32(ret_blob.data,
+		    8,
+		    unix_perms_to_wire(psbuf->st_ex_mode & ~S_IFMT));
+
+	/* Now add in the owner and group sids. */
+	sid_linearize(ret_blob.data + 12,
+		      b_size - 12,
+		      &sid_owner);
+	sid_linearize(ret_blob.data + 12 + owner_sid_size,
+		      b_size - owner_sid_size - 12,
+		      &sid_group);
+	return ret_blob;
+}
+
+/*
+ * SMB2 POSIX info level.
+ */
+DATA_BLOB store_smb2_posix_info(TALLOC_CTX *mem_ctx,
+				connection_struct *conn,
+				const SMB_STRUCT_STAT *psbuf,
+				uint32_t reparse_tag,
+				uint32_t dos_attributes)
+{
+	uint64_t file_id = SMB_VFS_FS_FILE_ID(conn, psbuf);
+	DATA_BLOB ret_blob = data_blob_null;
+	DATA_BLOB cc = smb2_posix_cc_info(mem_ctx,
+					conn,
+					reparse_tag,
+					psbuf);
+	if (cc.data == NULL) {
+		return data_blob_null;
+	}
+
+	if (cc.length + 68 < 68) {
+		data_blob_free(&cc);
+		return data_blob_null;
+	}
+
+	ret_blob = data_blob_talloc(mem_ctx,
+				NULL,
+				cc.length + 68);
+	if (ret_blob.data == NULL) {
+		data_blob_free(&cc);
+		return data_blob_null;
+	}
+
+	/* Timestamps. */
+
+	/* Birth (creation) time. */
+	put_long_date_timespec(TIMESTAMP_SET_NT_OR_BETTER,
+			       (char *)ret_blob.data+0,
+			       psbuf->st_ex_btime);
+	/* Access time. */
+	put_long_date_timespec(TIMESTAMP_SET_NT_OR_BETTER,
+			       (char *)ret_blob.data+8,
+			       psbuf->st_ex_atime);
+	/* Last write time. */
+	put_long_date_timespec(TIMESTAMP_SET_NT_OR_BETTER,
+			       (char *)ret_blob.data+16,
+			       psbuf->st_ex_mtime);
+	/* Change time. */
+	put_long_date_timespec(TIMESTAMP_SET_NT_OR_BETTER,
+			       (char *)ret_blob.data+24,
+			       psbuf->st_ex_ctime);
+
+	/* File size 64 Bit */
+	SOFF_T(ret_blob.data,32, get_file_size_stat(psbuf));
+
+	/* Number of bytes used on disk - 64 Bit */
+	SOFF_T(ret_blob.data,40,SMB_VFS_GET_ALLOC_SIZE(conn,NULL,psbuf));
+
+	/* DOS attributes */
+	if (S_ISREG(psbuf->st_ex_mode)) {
+		PUSH_LE_U32(ret_blob.data, 48, dos_attributes);
+	} else if (S_ISDIR(psbuf->st_ex_mode)) {
+		PUSH_LE_U32(ret_blob.data,
+			    48,
+			    dos_attributes|FILE_ATTRIBUTE_DIRECTORY);
+	} else {
+		/*
+		 * All non-directory or regular files are reported
+		 * as reparse points. Client may or may not be able
+		 * to access these.
+		 */
+		PUSH_LE_U32(ret_blob.data,
+			    48,
+			    FILE_ATTRIBUTE_REPARSE_POINT);
+	}
+
+	/* Add the inode and dev (16 bytes). */
+	PUSH_LE_U64(ret_blob.data, 52, file_id);
+	PUSH_LE_U64(ret_blob.data, 60, psbuf->st_ex_dev);
+
+	/*
+	 * Append a POSIX create context (variable bytes).
+	 */
+	memcpy(ret_blob.data + 68, cc.data, cc.length);
+	data_blob_free(&cc);
+	return ret_blob;
+}
diff --git a/source3/wscript_build b/source3/wscript_build
index acfc0c56f03..ce6892eb08d 100644
--- a/source3/wscript_build
+++ b/source3/wscript_build
@@ -675,6 +675,7 @@ bld.SAMBA3_LIBRARY('smbd_base',
                           smbd/smb2_getinfo.c
                           smbd/smb2_setinfo.c
                           smbd/smb2_break.c
+                          smbd/smb2_posix.c
                           smbd/smbXsrv_version.c
                           smbd/smbXsrv_client.c
                           smbd/smbXsrv_session.c


-- 
Samba Shared Repository



More information about the samba-cvs mailing list