From f38d7f20a865b1ff5f7b039dd284d91b2ba7ec26 Mon Sep 17 00:00:00 2001 From: Tim Prouty Date: Mon, 20 Oct 2008 17:43:45 -0700 Subject: s3: Add SMB_VFS_CREATE_FILE to the vfs layer Modify all callers of create_file to go through SMB_VFS_CREATE_FILE --- source3/smbd/reply.c | 99 +++++++++++++++++++++++++++------------------------- 1 file changed, 51 insertions(+), 48 deletions(-) (limited to 'source3/smbd/reply.c') diff --git a/source3/smbd/reply.c b/source3/smbd/reply.c index 11c713ab4a..dfd4b47608 100644 --- a/source3/smbd/reply.c +++ b/source3/smbd/reply.c @@ -1630,22 +1630,23 @@ void reply_open(struct smb_request *req) return; } - status = create_file(conn, /* conn */ - req, /* req */ - 0, /* root_dir_fid */ - fname, /* fname */ - access_mask, /* access_mask */ - share_mode, /* share_access */ - create_disposition, /* create_disposition*/ - create_options, /* create_options */ - dos_attr, /* file_attributes */ - oplock_request, /* oplock_request */ - 0, /* allocation_size */ - NULL, /* sd */ - NULL, /* ea_list */ - &fsp, /* result */ - &info, /* pinfo */ - &sbuf); /* psbuf */ + status = SMB_VFS_CREATE_FILE( + conn, /* conn */ + req, /* req */ + 0, /* root_dir_fid */ + fname, /* fname */ + access_mask, /* access_mask */ + share_mode, /* share_access */ + create_disposition, /* create_disposition*/ + create_options, /* create_options */ + dos_attr, /* file_attributes */ + oplock_request, /* oplock_request */ + 0, /* allocation_size */ + NULL, /* sd */ + NULL, /* ea_list */ + &fsp, /* result */ + &info, /* pinfo */ + &sbuf); /* psbuf */ if (!NT_STATUS_IS_OK(status)) { if (open_was_deferred(req->mid)) { @@ -1774,22 +1775,23 @@ void reply_open_and_X(struct smb_request *req) return; } - status = create_file(conn, /* conn */ - req, /* req */ - 0, /* root_dir_fid */ - fname, /* fname */ - access_mask, /* access_mask */ - share_mode, /* share_access */ - create_disposition, /* create_disposition*/ - create_options, /* create_options */ - smb_attr, /* file_attributes */ - oplock_request, /* oplock_request */ - 0, /* allocation_size */ - NULL, /* sd */ - NULL, /* ea_list */ - &fsp, /* result */ - &smb_action, /* pinfo */ - &sbuf); /* psbuf */ + status = SMB_VFS_CREATE_FILE( + conn, /* conn */ + req, /* req */ + 0, /* root_dir_fid */ + fname, /* fname */ + access_mask, /* access_mask */ + share_mode, /* share_access */ + create_disposition, /* create_disposition*/ + create_options, /* create_options */ + smb_attr, /* file_attributes */ + oplock_request, /* oplock_request */ + 0, /* allocation_size */ + NULL, /* sd */ + NULL, /* ea_list */ + &fsp, /* result */ + &smb_action, /* pinfo */ + &sbuf); /* psbuf */ if (!NT_STATUS_IS_OK(status)) { END_PROFILE(SMBopenX); @@ -1972,22 +1974,23 @@ void reply_mknew(struct smb_request *req) create_disposition = FILE_OVERWRITE_IF; } - status = create_file(conn, /* conn */ - req, /* req */ - 0, /* root_dir_fid */ - fname, /* fname */ - access_mask, /* access_mask */ - share_mode, /* share_access */ - create_disposition, /* create_disposition*/ - create_options, /* create_options */ - fattr, /* file_attributes */ - oplock_request, /* oplock_request */ - 0, /* allocation_size */ - NULL, /* sd */ - NULL, /* ea_list */ - &fsp, /* result */ - NULL, /* pinfo */ - &sbuf); /* psbuf */ + status = SMB_VFS_CREATE_FILE( + conn, /* conn */ + req, /* req */ + 0, /* root_dir_fid */ + fname, /* fname */ + access_mask, /* access_mask */ + share_mode, /* share_access */ + create_disposition, /* create_disposition*/ + create_options, /* create_options */ + fattr, /* file_attributes */ + oplock_request, /* oplock_request */ + 0, /* allocation_size */ + NULL, /* sd */ + NULL, /* ea_list */ + &fsp, /* result */ + NULL, /* pinfo */ + &sbuf); /* psbuf */ if (!NT_STATUS_IS_OK(status)) { END_PROFILE(SMBcreate); -- cgit From f995a7af2a06ccff29f23f1b099e0a84bc948f6e Mon Sep 17 00:00:00 2001 From: Tim Prouty Date: Wed, 19 Nov 2008 17:55:28 -0800 Subject: s3: Add new "is_dos_path" argument to SMB_VFS_CREATE_FILE Now unix paths can be differentiated from windows paths so the underlying create_file implementations can convert paths correctly. --- source3/smbd/reply.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'source3/smbd/reply.c') diff --git a/source3/smbd/reply.c b/source3/smbd/reply.c index dfd4b47608..80292636a6 100644 --- a/source3/smbd/reply.c +++ b/source3/smbd/reply.c @@ -1635,6 +1635,7 @@ void reply_open(struct smb_request *req) req, /* req */ 0, /* root_dir_fid */ fname, /* fname */ + true, /* is_dos_path */ access_mask, /* access_mask */ share_mode, /* share_access */ create_disposition, /* create_disposition*/ @@ -1780,6 +1781,7 @@ void reply_open_and_X(struct smb_request *req) req, /* req */ 0, /* root_dir_fid */ fname, /* fname */ + true, /* is_dos_path */ access_mask, /* access_mask */ share_mode, /* share_access */ create_disposition, /* create_disposition*/ @@ -1979,6 +1981,7 @@ void reply_mknew(struct smb_request *req) req, /* req */ 0, /* root_dir_fid */ fname, /* fname */ + true, /* is_dos_path */ access_mask, /* access_mask */ share_mode, /* share_access */ create_disposition, /* create_disposition*/ -- cgit From 2caa4fe08e157a01012b425a68cc25c381d5f354 Mon Sep 17 00:00:00 2001 From: Tim Prouty Date: Wed, 19 Nov 2008 18:03:27 -0800 Subject: s3: Modify direct callers of create_file_unix_path to call SMB_VFS_CREATE_FILE --- source3/smbd/reply.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'source3/smbd/reply.c') diff --git a/source3/smbd/reply.c b/source3/smbd/reply.c index 80292636a6..2465e73a18 100644 --- a/source3/smbd/reply.c +++ b/source3/smbd/reply.c @@ -2315,10 +2315,12 @@ static NTSTATUS do_unlink(connection_struct *conn, /* On open checks the open itself will check the share mode, so don't do it here as we'll get it wrong. */ - status = create_file_unixpath + status = SMB_VFS_CREATE_FILE (conn, /* conn */ req, /* req */ + 0, /* root_dir_fid */ fname, /* fname */ + false, /* is_dos_path */ DELETE_ACCESS, /* access_mask */ FILE_SHARE_NONE, /* share_access */ FILE_OPEN, /* create_disposition*/ @@ -2333,7 +2335,7 @@ static NTSTATUS do_unlink(connection_struct *conn, &sbuf); /* psbuf */ if (!NT_STATUS_IS_OK(status)) { - DEBUG(10, ("create_file_unixpath failed: %s\n", + DEBUG(10, ("SMB_VFS_CREATEFILE failed: %s\n", nt_errstr(status))); return status; } -- cgit From 08ce0604757315367f26a2c0869d59dd229c3ffe Mon Sep 17 00:00:00 2001 From: Tim Prouty Date: Thu, 20 Nov 2008 18:55:24 -0800 Subject: s3: Modify direct callers of open_file_ntcreate and open_directory to call SMB_VFS_CREATE_FILE --- source3/smbd/reply.c | 151 +++++++++++++++++++++++++++++++++++---------------- 1 file changed, 104 insertions(+), 47 deletions(-) (limited to 'source3/smbd/reply.c') diff --git a/source3/smbd/reply.c b/source3/smbd/reply.c index 2465e73a18..728753bc3b 100644 --- a/source3/smbd/reply.c +++ b/source3/smbd/reply.c @@ -2123,14 +2123,24 @@ void reply_ctemp(struct smb_request *req) SMB_VFS_STAT(conn,fname,&sbuf); /* We should fail if file does not exist. */ - status = open_file_ntcreate(conn, req, fname, &sbuf, - FILE_GENERIC_READ | FILE_GENERIC_WRITE, - FILE_SHARE_READ|FILE_SHARE_WRITE, - FILE_OPEN, - 0, - fattr, - oplock_request, - NULL, &fsp); + status = SMB_VFS_CREATE_FILE( + conn, /* conn */ + req, /* req */ + 0, /* root_dir_fid */ + fname, /* fname */ + false, /* is_dos_path */ + FILE_GENERIC_READ | FILE_GENERIC_WRITE, /* access_mask */ + FILE_SHARE_READ | FILE_SHARE_WRITE, /* share_access */ + FILE_OPEN, /* create_disposition*/ + 0, /* create_options */ + fattr, /* file_attributes */ + oplock_request, /* oplock_request */ + 0, /* allocation_size */ + NULL, /* sd */ + NULL, /* ea_list */ + &fsp, /* result */ + NULL, /* pinfo */ + &sbuf); /* psbuf */ /* close fd from smb_mkstemp() */ close(tmpfd); @@ -5631,6 +5641,7 @@ NTSTATUS rename_internals(TALLOC_CTX *ctx, struct smb_Dir *dir_hnd = NULL; const char *dname; long offset = 0; + int create_options = 0; ZERO_STRUCT(sbuf1); ZERO_STRUCT(sbuf2); @@ -5744,17 +5755,29 @@ NTSTATUS rename_internals(TALLOC_CTX *ctx, ZERO_STRUCT(sbuf1); SMB_VFS_STAT(conn, directory, &sbuf1); - status = S_ISDIR(sbuf1.st_mode) ? - open_directory(conn, req, directory, &sbuf1, - access_mask, - FILE_SHARE_READ|FILE_SHARE_WRITE, - FILE_OPEN, 0, 0, NULL, - &fsp) - : open_file_ntcreate(conn, req, directory, &sbuf1, - access_mask, - FILE_SHARE_READ|FILE_SHARE_WRITE, - FILE_OPEN, 0, 0, 0, NULL, - &fsp); + if (S_ISDIR(sbuf1.st_mode)) { + create_options |= FILE_DIRECTORY_FILE; + } + + status = SMB_VFS_CREATE_FILE( + conn, /* conn */ + req, /* req */ + 0, /* root_dir_fid */ + directory, /* fname */ + false, /* is_dos_path */ + access_mask, /* access_mask */ + (FILE_SHARE_READ | /* share_access */ + FILE_SHARE_WRITE), + FILE_OPEN, /* create_disposition*/ + create_options, /* create_options */ + 0, /* file_attributes */ + 0, /* oplock_request */ + 0, /* allocation_size */ + NULL, /* sd */ + NULL, /* ea_list */ + &fsp, /* result */ + NULL, /* pinfo */ + &sbuf1); /* psbuf */ if (!NT_STATUS_IS_OK(status)) { DEBUG(3, ("Could not open rename source %s: %s\n", @@ -5848,20 +5871,34 @@ NTSTATUS rename_internals(TALLOC_CTX *ctx, ZERO_STRUCT(sbuf1); SMB_VFS_STAT(conn, fname, &sbuf1); - status = S_ISDIR(sbuf1.st_mode) ? - open_directory(conn, req, fname, &sbuf1, - access_mask, - FILE_SHARE_READ|FILE_SHARE_WRITE, - FILE_OPEN, 0, 0, NULL, - &fsp) - : open_file_ntcreate(conn, req, fname, &sbuf1, - access_mask, - FILE_SHARE_READ|FILE_SHARE_WRITE, - FILE_OPEN, 0, 0, 0, NULL, - &fsp); + create_options = 0; + + if (S_ISDIR(sbuf1.st_mode)) { + create_options |= FILE_DIRECTORY_FILE; + } + + status = SMB_VFS_CREATE_FILE( + conn, /* conn */ + req, /* req */ + 0, /* root_dir_fid */ + fname, /* fname */ + false, /* is_dos_path */ + access_mask, /* access_mask */ + (FILE_SHARE_READ | /* share_access */ + FILE_SHARE_WRITE), + FILE_OPEN, /* create_disposition*/ + create_options, /* create_options */ + 0, /* file_attributes */ + 0, /* oplock_request */ + 0, /* allocation_size */ + NULL, /* sd */ + NULL, /* ea_list */ + &fsp, /* result */ + NULL, /* pinfo */ + &sbuf1); /* psbuf */ if (!NT_STATUS_IS_OK(status)) { - DEBUG(3,("rename_internals: open_file_ntcreate " + DEBUG(3,("rename_internals: SMB_VFS_CREATE_FILE " "returned %s rename %s -> %s\n", nt_errstr(status), directory, newname)); break; @@ -6052,14 +6089,24 @@ NTSTATUS copy_file(TALLOC_CTX *ctx, } } - status = open_file_ntcreate(conn, NULL, src, &src_sbuf, - FILE_GENERIC_READ, - FILE_SHARE_READ|FILE_SHARE_WRITE, - FILE_OPEN, - 0, - FILE_ATTRIBUTE_NORMAL, - INTERNAL_OPEN_ONLY, - NULL, &fsp1); + status = SMB_VFS_CREATE_FILE( + conn, /* conn */ + NULL, /* req */ + 0, /* root_dir_fid */ + src, /* fname */ + false, /* is_dos_path */ + FILE_GENERIC_READ, /* access_mask */ + FILE_SHARE_READ | FILE_SHARE_WRITE, /* share_access */ + FILE_OPEN, /* create_disposition*/ + 0, /* create_options */ + FILE_ATTRIBUTE_NORMAL, /* file_attributes */ + INTERNAL_OPEN_ONLY, /* oplock_request */ + 0, /* allocation_size */ + NULL, /* sd */ + NULL, /* ea_list */ + &fsp1, /* result */ + NULL, /* pinfo */ + &src_sbuf); /* psbuf */ if (!NT_STATUS_IS_OK(status)) { TALLOC_FREE(dest); @@ -6071,14 +6118,24 @@ NTSTATUS copy_file(TALLOC_CTX *ctx, ZERO_STRUCTP(&sbuf2); } - status = open_file_ntcreate(conn, NULL, dest, &sbuf2, - FILE_GENERIC_WRITE, - FILE_SHARE_READ|FILE_SHARE_WRITE, - new_create_disposition, - 0, - dosattrs, - INTERNAL_OPEN_ONLY, - NULL, &fsp2); + status = SMB_VFS_CREATE_FILE( + conn, /* conn */ + NULL, /* req */ + 0, /* root_dir_fid */ + dest, /* fname */ + false, /* is_dos_path */ + FILE_GENERIC_WRITE, /* access_mask */ + FILE_SHARE_READ | FILE_SHARE_WRITE, /* share_access */ + new_create_disposition, /* create_disposition*/ + 0, /* create_options */ + dosattrs, /* file_attributes */ + INTERNAL_OPEN_ONLY, /* oplock_request */ + 0, /* allocation_size */ + NULL, /* sd */ + NULL, /* ea_list */ + &fsp2, /* result */ + NULL, /* pinfo */ + &sbuf2); /* psbuf */ TALLOC_FREE(dest); -- cgit From 58440122853b65048793efd90ee45916e25c08c1 Mon Sep 17 00:00:00 2001 From: Tim Prouty Date: Mon, 1 Dec 2008 12:47:31 -0800 Subject: s3: Change SMB_VFS_CREATE_FILE to take a create_file_flags argument This replaces the is_dos_path bool with a more future-proof argument. The next step is to plumb INTERNAL_OPEN_ONLY through this flag instead of overridding the oplock_request. --- source3/smbd/reply.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'source3/smbd/reply.c') diff --git a/source3/smbd/reply.c b/source3/smbd/reply.c index 728753bc3b..00c744ce1a 100644 --- a/source3/smbd/reply.c +++ b/source3/smbd/reply.c @@ -1635,7 +1635,7 @@ void reply_open(struct smb_request *req) req, /* req */ 0, /* root_dir_fid */ fname, /* fname */ - true, /* is_dos_path */ + CFF_DOS_PATH, /* create_file_flags */ access_mask, /* access_mask */ share_mode, /* share_access */ create_disposition, /* create_disposition*/ @@ -1781,7 +1781,7 @@ void reply_open_and_X(struct smb_request *req) req, /* req */ 0, /* root_dir_fid */ fname, /* fname */ - true, /* is_dos_path */ + CFF_DOS_PATH, /* create_file_flags */ access_mask, /* access_mask */ share_mode, /* share_access */ create_disposition, /* create_disposition*/ @@ -1981,7 +1981,7 @@ void reply_mknew(struct smb_request *req) req, /* req */ 0, /* root_dir_fid */ fname, /* fname */ - true, /* is_dos_path */ + CFF_DOS_PATH, /* create_file_flags */ access_mask, /* access_mask */ share_mode, /* share_access */ create_disposition, /* create_disposition*/ @@ -2128,7 +2128,7 @@ void reply_ctemp(struct smb_request *req) req, /* req */ 0, /* root_dir_fid */ fname, /* fname */ - false, /* is_dos_path */ + 0, /* create_file_flags */ FILE_GENERIC_READ | FILE_GENERIC_WRITE, /* access_mask */ FILE_SHARE_READ | FILE_SHARE_WRITE, /* share_access */ FILE_OPEN, /* create_disposition*/ @@ -2330,7 +2330,7 @@ static NTSTATUS do_unlink(connection_struct *conn, req, /* req */ 0, /* root_dir_fid */ fname, /* fname */ - false, /* is_dos_path */ + 0, /* create_file_flags */ DELETE_ACCESS, /* access_mask */ FILE_SHARE_NONE, /* share_access */ FILE_OPEN, /* create_disposition*/ @@ -5764,7 +5764,7 @@ NTSTATUS rename_internals(TALLOC_CTX *ctx, req, /* req */ 0, /* root_dir_fid */ directory, /* fname */ - false, /* is_dos_path */ + 0, /* create_file_flags */ access_mask, /* access_mask */ (FILE_SHARE_READ | /* share_access */ FILE_SHARE_WRITE), @@ -5882,7 +5882,7 @@ NTSTATUS rename_internals(TALLOC_CTX *ctx, req, /* req */ 0, /* root_dir_fid */ fname, /* fname */ - false, /* is_dos_path */ + 0, /* create_file_flags */ access_mask, /* access_mask */ (FILE_SHARE_READ | /* share_access */ FILE_SHARE_WRITE), @@ -6094,7 +6094,7 @@ NTSTATUS copy_file(TALLOC_CTX *ctx, NULL, /* req */ 0, /* root_dir_fid */ src, /* fname */ - false, /* is_dos_path */ + 0, /* create_file_flags */ FILE_GENERIC_READ, /* access_mask */ FILE_SHARE_READ | FILE_SHARE_WRITE, /* share_access */ FILE_OPEN, /* create_disposition*/ @@ -6123,7 +6123,7 @@ NTSTATUS copy_file(TALLOC_CTX *ctx, NULL, /* req */ 0, /* root_dir_fid */ dest, /* fname */ - false, /* is_dos_path */ + 0, /* create_file_flags */ FILE_GENERIC_WRITE, /* access_mask */ FILE_SHARE_READ | FILE_SHARE_WRITE, /* share_access */ new_create_disposition, /* create_disposition*/ -- cgit From 7b9f6dda131f471ae61c12e7eb06d67b8f02b1cf Mon Sep 17 00:00:00 2001 From: Tim Prouty Date: Sat, 6 Dec 2008 16:08:35 -0800 Subject: s3: [3/3]: Fix a delete on close divergence from windows and the associated torture test This third patch cleans up by removing all of the code that is made obsolete by the first patch. It should cause no functional changes. --- source3/smbd/reply.c | 2 -- 1 file changed, 2 deletions(-) (limited to 'source3/smbd/reply.c') diff --git a/source3/smbd/reply.c b/source3/smbd/reply.c index 00c744ce1a..9f7a1896b8 100644 --- a/source3/smbd/reply.c +++ b/source3/smbd/reply.c @@ -5583,8 +5583,6 @@ NTSTATUS rename_internals_fsp(connection_struct *conn, * depends on these semantics. JRA. */ - set_allow_initial_delete_on_close(lck, fsp, True); - if (create_options & FILE_DELETE_ON_CLOSE) { status = can_set_delete_on_close(fsp, True, 0); -- cgit