[SCM] Samba Shared Repository - branch master updated

Jeremy Allison jra at samba.org
Thu May 14 19:44:08 UTC 2020


The branch, master has been updated
       via  7215669d297 vfs: remove root_dir_fid arg from SMB_VFS_CREATE_FILE()
       via  54883d4b3a1 smbd: move processing of root_dir_fid outside of SMB_VFS_CREATE_FILE()
       via  f0df11ce9dd s4/torture: add a *real* root_dir_fid test
      from  ab70153c200 testprogs: Add 'net ads join' test for fips

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


- Log -----------------------------------------------------------------
commit 7215669d2978019c80f7eaea2a712fb8dd98894b
Author: Ralph Boehme <slow at samba.org>
Date:   Thu May 14 15:59:33 2020 +0200

    vfs: remove root_dir_fid arg from SMB_VFS_CREATE_FILE()
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>
    
    Autobuild-User(master): Jeremy Allison <jra at samba.org>
    Autobuild-Date(master): Thu May 14 19:43:27 UTC 2020 on sn-devel-184

commit 54883d4b3a12e234414cc78ecd7b25252f48463c
Author: Ralph Boehme <slow at samba.org>
Date:   Thu May 14 13:42:05 2020 +0200

    smbd: move processing of root_dir_fid outside of SMB_VFS_CREATE_FILE()
    
    The only two callers that pass a root_dir_fid != 0 are reply_ntcreate_and_X()
    and call_nt_transact_create(). By moving root_dir_fid processing outside of
    SMB_VFS_CREATE_FILE() we can avoid rewriting get_relative_fid_filename() to work
    with *AT semantics and dirfsps.
    
    Bonus points: the previous code in both functions passed fname to
    filename_convert() which can't really have worked as it is relative to
    root_dir_fid so filename_convert() will not be able to stat() the relative path
    and it's components.
    
    The only test I can find that uses a root dir_fid is raw.samba3rootdirfid and
    that uses a handle on the share root which will work.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=14380
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit f0df11ce9dd9bbbc8cee9122e06e2b3c1954b7e7
Author: Ralph Boehme <slow at samba.org>
Date:   Thu May 14 14:22:16 2020 +0200

    s4/torture: add a *real* root_dir_fid test
    
    raw.samba3rootdirfid tests with the share root directory as root_dir_fid handle,
    that doesn't cover the case where the relative name has more then one path
    component. It only works because in unix_convert() we run into the creating file
    optimasation.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=14380
    
    Signed-off-by: Ralph Boehme <slow at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

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

Summary of changes:
 examples/VFS/skel_opaque.c                |   1 -
 examples/VFS/skel_transparent.c           |   2 -
 source3/include/vfs.h                     |   4 +-
 source3/include/vfs_macros.h              |   8 +-
 source3/lib/adouble.c                     |   6 --
 source3/modules/vfs_default.c             |   3 +-
 source3/modules/vfs_fruit.c               |   5 +-
 source3/modules/vfs_full_audit.c          |   2 -
 source3/modules/vfs_media_harmony.c       |   3 -
 source3/modules/vfs_not_implemented.c     |   1 -
 source3/modules/vfs_time_audit.c          |   2 -
 source3/modules/vfs_unityed_media.c       |   3 -
 source3/modules/vfs_worm.c                |   3 +-
 source3/printing/nt_printing.c            |   3 -
 source3/rpc_server/srvsvc/srv_srvsvc_nt.c |   2 -
 source3/selftest/tests.py                 |   3 +-
 source3/smbd/dosmode.c                    |   1 -
 source3/smbd/nttrans.c                    | 106 +++++++++++++++++++++-
 source3/smbd/open.c                       | 141 +-----------------------------
 source3/smbd/proto.h                      |   1 -
 source3/smbd/reply.c                      |  11 ---
 source3/smbd/smb2_create.c                |   1 -
 source3/smbd/trans2.c                     |   8 --
 source3/smbd/vfs.c                        |   3 +-
 source3/utils/net_vfs.c                   |   1 -
 source4/torture/raw/raw.c                 |   2 +
 source4/torture/raw/samba3misc.c          |  74 ++++++++++++++++
 27 files changed, 190 insertions(+), 210 deletions(-)


Changeset truncated at 500 lines:

diff --git a/examples/VFS/skel_opaque.c b/examples/VFS/skel_opaque.c
index 6eb68df3e1e..cd04de0dab0 100644
--- a/examples/VFS/skel_opaque.c
+++ b/examples/VFS/skel_opaque.c
@@ -200,7 +200,6 @@ static int skel_open(vfs_handle_struct *handle, struct smb_filename *smb_fname,
 
 static NTSTATUS skel_create_file(struct vfs_handle_struct *handle,
 				 struct smb_request *req,
-				 uint16_t root_dir_fid,
 				 struct smb_filename *smb_fname,
 				 uint32_t access_mask,
 				 uint32_t share_access,
diff --git a/examples/VFS/skel_transparent.c b/examples/VFS/skel_transparent.c
index 2eb7a7dbcd9..b95ba1b858d 100644
--- a/examples/VFS/skel_transparent.c
+++ b/examples/VFS/skel_transparent.c
@@ -208,7 +208,6 @@ static int skel_open(vfs_handle_struct *handle, struct smb_filename *smb_fname,
 
 static NTSTATUS skel_create_file(struct vfs_handle_struct *handle,
 				 struct smb_request *req,
-				 uint16_t root_dir_fid,
 				 struct smb_filename *smb_fname,
 				 uint32_t access_mask,
 				 uint32_t share_access,
@@ -227,7 +226,6 @@ static NTSTATUS skel_create_file(struct vfs_handle_struct *handle,
 {
 	return SMB_VFS_NEXT_CREATE_FILE(handle,
 					req,
-					root_dir_fid,
 					smb_fname,
 					access_mask,
 					share_access,
diff --git a/source3/include/vfs.h b/source3/include/vfs.h
index 5861b9065f0..4780d87c3c2 100644
--- a/source3/include/vfs.h
+++ b/source3/include/vfs.h
@@ -319,6 +319,7 @@
  * Version 43 - convert link_contents arg of SMB_VFS_SYMLINKAT()
  *              to struct smb_filename
  * Version 43 - Move SMB_VFS_GET_NT_ACL() -> SMB_VFS_GET_NT_ACL_AT().
+ * Version 43 - Remove root_dir_fid from SMB_VFS_CREATE_FILE().
  */
 
 #define SMB_VFS_INTERFACE_VERSION 43
@@ -761,7 +762,6 @@ struct vfs_fn_pointers {
 		       int flags, mode_t mode);
 	NTSTATUS (*create_file_fn)(struct vfs_handle_struct *handle,
 				   struct smb_request *req,
-				   uint16_t root_dir_fid,
 				   struct smb_filename *smb_fname,
 				   uint32_t access_mask,
 				   uint32_t share_access,
@@ -1273,7 +1273,6 @@ int smb_vfs_call_open(struct vfs_handle_struct *handle,
 		      int flags, mode_t mode);
 NTSTATUS smb_vfs_call_create_file(struct vfs_handle_struct *handle,
 				  struct smb_request *req,
-				  uint16_t root_dir_fid,
 				  struct smb_filename *smb_fname,
 				  uint32_t access_mask,
 				  uint32_t share_access,
@@ -1728,7 +1727,6 @@ int vfs_not_implemented_open(vfs_handle_struct *handle,
 			     files_struct *fsp, int flags, mode_t mode);
 NTSTATUS vfs_not_implemented_create_file(struct vfs_handle_struct *handle,
 				struct smb_request *req,
-				uint16_t root_dir_fid,
 				struct smb_filename *smb_fname,
 				uint32_t access_mask,
 				uint32_t share_access,
diff --git a/source3/include/vfs_macros.h b/source3/include/vfs_macros.h
index 20fe6f9a0cf..65de31af08d 100644
--- a/source3/include/vfs_macros.h
+++ b/source3/include/vfs_macros.h
@@ -147,14 +147,14 @@
 #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, \
+#define SMB_VFS_CREATE_FILE(conn, req, smb_fname, access_mask, share_access, create_disposition, \
         create_options, file_attributes, oplock_request, lease, allocation_size, private_flags, sd, ea_list, result, pinfo, in_context_blobs, out_context_blobs) \
-        smb_vfs_call_create_file((conn)->vfs_handles, (req), (root_dir_fid), (smb_fname), (access_mask), (share_access), (create_disposition), \
+        smb_vfs_call_create_file((conn)->vfs_handles, (req), (smb_fname), (access_mask), (share_access), (create_disposition), \
         (create_options), (file_attributes), (oplock_request), (lease), (allocation_size), (private_flags), (sd), (ea_list), (result), (pinfo), \
 	(in_context_blobs), (out_context_blobs))
-#define SMB_VFS_NEXT_CREATE_FILE(handle, req, root_dir_fid, smb_fname, access_mask, share_access, create_disposition, \
+#define SMB_VFS_NEXT_CREATE_FILE(handle, req, smb_fname, access_mask, share_access, create_disposition, \
 	create_options, file_attributes, oplock_request, lease, allocation_size, private_flags, sd, ea_list, result, pinfo, in_context_blobs, out_context_blobs) \
-	smb_vfs_call_create_file((handle)->next, (req), (root_dir_fid), (smb_fname), (access_mask), (share_access), (create_disposition), \
+	smb_vfs_call_create_file((handle)->next, (req), (smb_fname), (access_mask), (share_access), (create_disposition), \
         (create_options), (file_attributes), (oplock_request), (lease), (allocation_size), (private_flags), (sd), (ea_list), (result), (pinfo), \
 	(in_context_blobs), (out_context_blobs))
 
diff --git a/source3/lib/adouble.c b/source3/lib/adouble.c
index b5b88e2404b..8e8b6a77503 100644
--- a/source3/lib/adouble.c
+++ b/source3/lib/adouble.c
@@ -1109,7 +1109,6 @@ static bool ad_convert_xattr(vfs_handle_struct *handle,
 		status = SMB_VFS_CREATE_FILE(
 			handle->conn,			/* conn */
 			NULL,				/* req */
-			0,				/* root_dir_fid */
 			stream_name,			/* fname */
 			FILE_GENERIC_WRITE,		/* access_mask */
 			FILE_SHARE_READ | FILE_SHARE_WRITE, /* share_access */
@@ -1239,7 +1238,6 @@ static bool ad_convert_finderinfo(vfs_handle_struct *handle,
 	status = SMB_VFS_CREATE_FILE(
 		handle->conn,			/* conn */
 		NULL,				/* req */
-		0,				/* root_dir_fid */
 		stream_name,			/* fname */
 		FILE_GENERIC_WRITE,		/* access_mask */
 		FILE_SHARE_READ | FILE_SHARE_WRITE, /* share_access */
@@ -1470,7 +1468,6 @@ static bool ad_unconvert_open_ad(TALLOC_CTX *mem_ctx,
 	status = SMB_VFS_CREATE_FILE(
 		handle->conn,
 		NULL,				/* req */
-		0,				/* root_dir_fid */
 		adpath,
 		FILE_READ_DATA|FILE_WRITE_DATA,
 		FILE_SHARE_READ|FILE_SHARE_WRITE|FILE_SHARE_DELETE,
@@ -1522,7 +1519,6 @@ static bool ad_unconvert_get_streams(struct vfs_handle_struct *handle,
 	status = SMB_VFS_CREATE_FILE(
 		handle->conn,				/* conn */
 		NULL,					/* req */
-		0,					/* root_dir_fid */
 		smb_fname,				/* fname */
 		FILE_READ_ATTRIBUTES,			/* access_mask */
 		(FILE_SHARE_READ | FILE_SHARE_WRITE |	/* share_access */
@@ -1622,7 +1618,6 @@ static bool ad_collect_one_stream(struct vfs_handle_struct *handle,
 	status = SMB_VFS_CREATE_FILE(
 		handle->conn,
 		NULL,				/* req */
-		0,				/* root_dir_fid */
 		sname,
 		FILE_READ_DATA|DELETE_ACCESS,
 		FILE_SHARE_READ,
@@ -2084,7 +2079,6 @@ static int ad_open_rsrc(vfs_handle_struct *handle,
 	status = SMB_VFS_CREATE_FILE(
 		handle->conn,			/* conn */
 		NULL,				/* req */
-		0,				/* root_dir_fid */
 		adp_smb_fname,
 		access_mask,
 		share_access,
diff --git a/source3/modules/vfs_default.c b/source3/modules/vfs_default.c
index 386a34f81d1..5512938d6a6 100644
--- a/source3/modules/vfs_default.c
+++ b/source3/modules/vfs_default.c
@@ -690,7 +690,6 @@ static int vfswrap_open(vfs_handle_struct *handle,
 
 static NTSTATUS vfswrap_create_file(vfs_handle_struct *handle,
 				    struct smb_request *req,
-				    uint16_t root_dir_fid,
 				    struct smb_filename *smb_fname,
 				    uint32_t access_mask,
 				    uint32_t share_access,
@@ -708,7 +707,7 @@ static NTSTATUS vfswrap_create_file(vfs_handle_struct *handle,
 				    const struct smb2_create_blobs *in_context_blobs,
 				    struct smb2_create_blobs *out_context_blobs)
 {
-	return create_file_default(handle->conn, req, root_dir_fid, smb_fname,
+	return create_file_default(handle->conn, req, smb_fname,
 				   access_mask, share_access,
 				   create_disposition, create_options,
 				   file_attributes, oplock_request, lease,
diff --git a/source3/modules/vfs_fruit.c b/source3/modules/vfs_fruit.c
index a9785e5b4a2..7d77393e99a 100644
--- a/source3/modules/vfs_fruit.c
+++ b/source3/modules/vfs_fruit.c
@@ -898,7 +898,6 @@ static bool readdir_attr_meta_finderi_stream(
 	status = SMB_VFS_CREATE_FILE(
 		handle->conn,                           /* conn */
 		NULL,                                   /* req */
-		0,                                      /* root_dir_fid */
 		stream_name,				/* fname */
 		FILE_READ_DATA,                         /* access_mask */
 		(FILE_SHARE_READ | FILE_SHARE_WRITE |   /* share_access */
@@ -3884,7 +3883,6 @@ static int fruit_ftruncate(struct vfs_handle_struct *handle,
 
 static NTSTATUS fruit_create_file(vfs_handle_struct *handle,
 				  struct smb_request *req,
-				  uint16_t root_dir_fid,
 				  struct smb_filename *smb_fname,
 				  uint32_t access_mask,
 				  uint32_t share_access,
@@ -3939,7 +3937,7 @@ static NTSTATUS fruit_create_file(vfs_handle_struct *handle,
 	}
 
 	status = SMB_VFS_NEXT_CREATE_FILE(
-		handle, req, root_dir_fid, smb_fname,
+		handle, req, smb_fname,
 		access_mask, share_access,
 		create_disposition, create_options,
 		file_attributes, oplock_request,
@@ -4704,7 +4702,6 @@ static bool fruit_get_bandsize(vfs_handle_struct *handle,
 	status = SMB_VFS_NEXT_CREATE_FILE(
 		handle,				/* conn */
 		NULL,				/* req */
-		0,				/* root_dir_fid */
 		smb_fname,			/* fname */
 		FILE_GENERIC_READ,		/* access_mask */
 		FILE_SHARE_READ | FILE_SHARE_WRITE, /* share_access */
diff --git a/source3/modules/vfs_full_audit.c b/source3/modules/vfs_full_audit.c
index c9b294975f2..07bbfcce9a7 100644
--- a/source3/modules/vfs_full_audit.c
+++ b/source3/modules/vfs_full_audit.c
@@ -1093,7 +1093,6 @@ static int smb_full_audit_open(vfs_handle_struct *handle,
 
 static NTSTATUS smb_full_audit_create_file(vfs_handle_struct *handle,
 				      struct smb_request *req,
-				      uint16_t root_dir_fid,
 				      struct smb_filename *smb_fname,
 				      uint32_t access_mask,
 				      uint32_t share_access,
@@ -1140,7 +1139,6 @@ static NTSTATUS smb_full_audit_create_file(vfs_handle_struct *handle,
 	result = SMB_VFS_NEXT_CREATE_FILE(
 		handle,					/* handle */
 		req,					/* req */
-		root_dir_fid,				/* root_dir_fid */
 		smb_fname,				/* fname */
 		access_mask,				/* access_mask */
 		share_access,				/* share_access */
diff --git a/source3/modules/vfs_media_harmony.c b/source3/modules/vfs_media_harmony.c
index 325a5446295..cb1b1398214 100644
--- a/source3/modules/vfs_media_harmony.c
+++ b/source3/modules/vfs_media_harmony.c
@@ -1105,7 +1105,6 @@ out:
  */
 static NTSTATUS mh_create_file(vfs_handle_struct *handle,
 		struct smb_request *req,
-		uint16_t root_dir_fid,
 		struct smb_filename *smb_fname,
 		uint32_t access_mask,
 		uint32_t share_access,
@@ -1135,7 +1134,6 @@ static NTSTATUS mh_create_file(vfs_handle_struct *handle,
 		status = SMB_VFS_NEXT_CREATE_FILE(
 			handle,
 			req,
-			root_dir_fid,
 			smb_fname,
 			access_mask,
 			share_access,
@@ -1174,7 +1172,6 @@ static NTSTATUS mh_create_file(vfs_handle_struct *handle,
 	status = SMB_VFS_NEXT_CREATE_FILE(
 		handle,
 		req,
-		root_dir_fid,
 		clientFname,
 		access_mask,
 		share_access,
diff --git a/source3/modules/vfs_not_implemented.c b/source3/modules/vfs_not_implemented.c
index 6b4abf8de67..0cb59abcb31 100644
--- a/source3/modules/vfs_not_implemented.c
+++ b/source3/modules/vfs_not_implemented.c
@@ -198,7 +198,6 @@ int vfs_not_implemented_open(vfs_handle_struct *handle,
 
 NTSTATUS vfs_not_implemented_create_file(struct vfs_handle_struct *handle,
 				struct smb_request *req,
-				uint16_t root_dir_fid,
 				struct smb_filename *smb_fname,
 				uint32_t access_mask,
 				uint32_t share_access,
diff --git a/source3/modules/vfs_time_audit.c b/source3/modules/vfs_time_audit.c
index c173359c086..a442e5af315 100644
--- a/source3/modules/vfs_time_audit.c
+++ b/source3/modules/vfs_time_audit.c
@@ -607,7 +607,6 @@ static int smb_time_audit_open(vfs_handle_struct *handle,
 
 static NTSTATUS smb_time_audit_create_file(vfs_handle_struct *handle,
 					   struct smb_request *req,
-					   uint16_t root_dir_fid,
 					   struct smb_filename *fname,
 					   uint32_t access_mask,
 					   uint32_t share_access,
@@ -633,7 +632,6 @@ static NTSTATUS smb_time_audit_create_file(vfs_handle_struct *handle,
 	result = SMB_VFS_NEXT_CREATE_FILE(
 		handle,					/* handle */
 		req,					/* req */
-		root_dir_fid,				/* root_dir_fid */
 		fname,					/* fname */
 		access_mask,				/* access_mask */
 		share_access,				/* share_access */
diff --git a/source3/modules/vfs_unityed_media.c b/source3/modules/vfs_unityed_media.c
index 4bbabfdbb1d..70db8f182d1 100644
--- a/source3/modules/vfs_unityed_media.c
+++ b/source3/modules/vfs_unityed_media.c
@@ -826,7 +826,6 @@ err:
 
 static NTSTATUS um_create_file(vfs_handle_struct *handle,
 			       struct smb_request *req,
-			       uint16_t root_dir_fid,
 			       struct smb_filename *smb_fname,
 			       uint32_t access_mask,
 			       uint32_t share_access,
@@ -854,7 +853,6 @@ static NTSTATUS um_create_file(vfs_handle_struct *handle,
 		return SMB_VFS_NEXT_CREATE_FILE(
 			handle,
 			req,
-			root_dir_fid,
 			smb_fname,
 			access_mask,
 			share_access,
@@ -889,7 +887,6 @@ static NTSTATUS um_create_file(vfs_handle_struct *handle,
 	status = SMB_VFS_NEXT_CREATE_FILE(
 		handle,
 		req,
-		root_dir_fid,
 		client_fname,
 		access_mask,
 		share_access,
diff --git a/source3/modules/vfs_worm.c b/source3/modules/vfs_worm.c
index 9b1a5facae7..3ae1f9f39e6 100644
--- a/source3/modules/vfs_worm.c
+++ b/source3/modules/vfs_worm.c
@@ -24,7 +24,6 @@
 
 static NTSTATUS vfs_worm_create_file(vfs_handle_struct *handle,
 				     struct smb_request *req,
-				     uint16_t root_dir_fid,
 				     struct smb_filename *smb_fname,
 				     uint32_t access_mask,
 				     uint32_t share_access,
@@ -63,7 +62,7 @@ static NTSTATUS vfs_worm_create_file(vfs_handle_struct *handle,
 	}
 
 	status = SMB_VFS_NEXT_CREATE_FILE(
-		handle, req, root_dir_fid, smb_fname, access_mask,
+		handle, req, smb_fname, access_mask,
 		share_access, create_disposition, create_options,
 		file_attributes, oplock_request, lease, allocation_size,
 		private_flags, sd, ea_list, result, pinfo,
diff --git a/source3/printing/nt_printing.c b/source3/printing/nt_printing.c
index 4c7bc481b5a..b36b9a28329 100644
--- a/source3/printing/nt_printing.c
+++ b/source3/printing/nt_printing.c
@@ -843,7 +843,6 @@ static int file_version_is_newer(connection_struct *conn, fstring new_file, fstr
 	status = SMB_VFS_CREATE_FILE(
 		conn,					/* conn */
 		NULL,					/* req */
-		0,					/* root_dir_fid */
 		smb_fname,				/* fname */
 		FILE_GENERIC_READ,			/* access_mask */
 		FILE_SHARE_READ | FILE_SHARE_WRITE,	/* share_access */
@@ -898,7 +897,6 @@ static int file_version_is_newer(connection_struct *conn, fstring new_file, fstr
 	status = SMB_VFS_CREATE_FILE(
 		conn,					/* conn */
 		NULL,					/* req */
-		0,					/* root_dir_fid */
 		smb_fname,				/* fname */
 		FILE_GENERIC_READ,			/* access_mask */
 		FILE_SHARE_READ | FILE_SHARE_WRITE,	/* share_access */
@@ -1102,7 +1100,6 @@ static uint32_t get_correct_cversion(const struct auth_session_info *session_inf
 	nt_status = SMB_VFS_CREATE_FILE(
 		conn,					/* conn */
 		NULL,					/* req */
-		0,					/* root_dir_fid */
 		smb_fname,				/* fname */
 		FILE_GENERIC_READ,			/* access_mask */
 		FILE_SHARE_READ | FILE_SHARE_WRITE,	/* share_access */
diff --git a/source3/rpc_server/srvsvc/srv_srvsvc_nt.c b/source3/rpc_server/srvsvc/srv_srvsvc_nt.c
index f178ada9b8c..17391424fc0 100644
--- a/source3/rpc_server/srvsvc/srv_srvsvc_nt.c
+++ b/source3/rpc_server/srvsvc/srv_srvsvc_nt.c
@@ -2414,7 +2414,6 @@ WERROR _srvsvc_NetGetFileSecurity(struct pipes_struct *p,
 	nt_status = SMB_VFS_CREATE_FILE(
 		conn,					/* conn */
 		NULL,					/* req */
-		0,					/* root_dir_fid */
 		smb_fname,				/* fname */
 		FILE_READ_ATTRIBUTES,			/* access_mask */
 		FILE_SHARE_READ|FILE_SHARE_WRITE,	/* share_access */
@@ -2550,7 +2549,6 @@ WERROR _srvsvc_NetSetFileSecurity(struct pipes_struct *p,
 	nt_status = SMB_VFS_CREATE_FILE(
 		conn,					/* conn */
 		NULL,					/* req */
-		0,					/* root_dir_fid */
 		smb_fname,				/* fname */
 		FILE_WRITE_ATTRIBUTES,			/* access_mask */
 		FILE_SHARE_READ|FILE_SHARE_WRITE,	/* share_access */
diff --git a/source3/selftest/tests.py b/source3/selftest/tests.py
index b5d7c367883..7309c05a7a5 100755
--- a/source3/selftest/tests.py
+++ b/source3/selftest/tests.py
@@ -553,7 +553,7 @@ raw = ["raw.acls", "raw.chkpath", "raw.close", "raw.composite", "raw.context", "
        "raw.sfileinfo.base", "raw.sfileinfo.bug", "raw.streams", "raw.unlink", "raw.write",
        "raw.samba3hide", "raw.samba3badpath", "raw.sfileinfo.rename", "raw.session",
        "raw.samba3caseinsensitive", "raw.samba3posixtimedlock",
-       "raw.samba3rootdirfid", "raw.sfileinfo.end-of-file",
+       "raw.samba3rootdirfid", "raw.samba3rootdirfid2", "raw.sfileinfo.end-of-file",
        "raw.bench-oplock", "raw.bench-lock", "raw.bench-open", "raw.bench-tcon",
        "raw.samba3checkfsp", "raw.samba3closeerr", "raw.samba3oplocklogoff", "raw.samba3badnameblob"]
 
@@ -832,6 +832,7 @@ for t in tests:
                   "raw.samba3oplocklogoff",
                   "raw.samba3posixtimedlock",
                   "raw.samba3rootdirfid",
+                  "raw.samba3rootdirfid2",
                   "raw.seek",
                   "raw.sfileinfo.bug",
                   "raw.sfileinfo.end-of-file",
diff --git a/source3/smbd/dosmode.c b/source3/smbd/dosmode.c
index 9bb8d1c1941..f336416b07c 100644
--- a/source3/smbd/dosmode.c
+++ b/source3/smbd/dosmode.c
@@ -1410,7 +1410,6 @@ static NTSTATUS get_file_handle_for_metadata(connection_struct *conn,
 	status = SMB_VFS_CREATE_FILE(
 		conn,                                   /* conn */
 		NULL,                                   /* req */
-		0,                                      /* root_dir_fid */
 		smb_fname_cp,				/* fname */
 		FILE_WRITE_ATTRIBUTES,			/* access_mask */
 		(FILE_SHARE_READ | FILE_SHARE_WRITE |   /* share_access */
diff --git a/source3/smbd/nttrans.c b/source3/smbd/nttrans.c
index 5f82c30f0df..307f1254978 100644
--- a/source3/smbd/nttrans.c
+++ b/source3/smbd/nttrans.c
@@ -431,6 +431,78 @@ static struct case_semantics_state *set_posix_case_semantics(TALLOC_CTX *mem_ctx
 	return result;
 }
 
+/*
+ * Calculate the full path name given a relative fid.
+ */
+static NTSTATUS get_relative_fid_filename(connection_struct *conn,
+					  struct smb_request *req,
+					  uint16_t root_dir_fid,
+					  char *path,
+					  char **path_out)
+{
+	struct files_struct *dir_fsp = NULL;
+	char *new_path = NULL;
+
+	if (root_dir_fid == 0 || path == NULL) {
+		return NT_STATUS_INTERNAL_ERROR;
+	}
+
+	dir_fsp = file_fsp(req, root_dir_fid);
+	if (dir_fsp == NULL) {
+		return NT_STATUS_INVALID_HANDLE;
+	}
+
+	if (is_ntfs_stream_smb_fname(dir_fsp->fsp_name)) {
+		return NT_STATUS_INVALID_HANDLE;
+	}
+
+	if (!dir_fsp->fsp_flags.is_directory) {
+		/*
+		 * Check to see if this is a mac fork of some kind.
+		 */
+		if (conn->fs_capabilities & FILE_NAMED_STREAMS) {
+			char *stream = NULL;
+
+			stream = strchr_m(path, ':');
+			if (stream != NULL) {
+				return NT_STATUS_OBJECT_PATH_NOT_FOUND;
+			}
+		}
+
+		/*
+		 * We need to handle the case when we get a relative open
+		 * relative to a file and the pathname is blank - this is a
+		 * reopen! (hint from demyn plantenberg)
+		 */
+		return NT_STATUS_INVALID_HANDLE;
+	}
+
+	if (ISDOT(dir_fsp->fsp_name->base_name)) {
+		/*
+		 * We're at the toplevel dir, the final file name
+		 * must not contain ./, as this is filtered out
+		 * normally by srvstr_get_path and unix_convert
+		 * explicitly rejects paths containing ./.
+		 */
+		new_path = talloc_strdup(talloc_tos(), path);
+	} else {
+		/*
+		 * Copy in the base directory name.
+		 */
+
+		new_path = talloc_asprintf(talloc_tos(),
+					   "%s/%s",
+					   dir_fsp->fsp_name->base_name,
+					   path);
+	}
+	if (new_path == NULL) {
+		return NT_STATUS_NO_MEMORY;
+	}
+
+	*path_out = new_path;
+	return NT_STATUS_OK;
+}
+
 /****************************************************************************
  Reply to an NT create and X call.
 ****************************************************************************/
@@ -537,6 +609,21 @@ void reply_ntcreate_and_X(struct smb_request *req)
 		}
 	}
 
+	if (root_dir_fid != 0) {
+		char *new_fname = NULL;


-- 
Samba Shared Repository



More information about the samba-cvs mailing list