summaryrefslogtreecommitdiff
path: root/source3/smbd
diff options
context:
space:
mode:
authorTim Prouty <tprouty@samba.org>2008-11-20 18:55:24 -0800
committerTim Prouty <tprouty@samba.org>2008-12-03 17:51:16 -0800
commit08ce0604757315367f26a2c0869d59dd229c3ffe (patch)
treea37f92a43d5b23af1eed195d39b10a06ecec271e /source3/smbd
parent2caa4fe08e157a01012b425a68cc25c381d5f354 (diff)
downloadsamba-08ce0604757315367f26a2c0869d59dd229c3ffe.tar.gz
samba-08ce0604757315367f26a2c0869d59dd229c3ffe.tar.bz2
samba-08ce0604757315367f26a2c0869d59dd229c3ffe.zip
s3: Modify direct callers of open_file_ntcreate and open_directory to call SMB_VFS_CREATE_FILE
Diffstat (limited to 'source3/smbd')
-rw-r--r--source3/smbd/nttrans.c54
-rw-r--r--source3/smbd/open.c26
-rw-r--r--source3/smbd/posix_acls.c29
-rw-r--r--source3/smbd/reply.c151
-rw-r--r--source3/smbd/trans2.c159
5 files changed, 276 insertions, 143 deletions
diff --git a/source3/smbd/nttrans.c b/source3/smbd/nttrans.c
index b66aba5aac..a7b2cb6c31 100644
--- a/source3/smbd/nttrans.c
+++ b/source3/smbd/nttrans.c
@@ -1186,27 +1186,49 @@ static NTSTATUS copy_internals(TALLOC_CTX *ctx,
DEBUG(10,("copy_internals: doing file copy %s to %s\n",
oldname, newname));
- status = open_file_ntcreate(conn, req, oldname, &sbuf1,
- FILE_READ_DATA, /* Read-only. */
- FILE_SHARE_READ|FILE_SHARE_WRITE|FILE_SHARE_DELETE,
- FILE_OPEN,
- 0, /* No create options. */
- FILE_ATTRIBUTE_NORMAL,
- NO_OPLOCK,
- &info, &fsp1);
+ status = SMB_VFS_CREATE_FILE(
+ conn, /* conn */
+ req, /* req */
+ 0, /* root_dir_fid */
+ oldname, /* fname */
+ false, /* is_dos_path */
+ FILE_READ_DATA, /* access_mask */
+ (FILE_SHARE_READ | FILE_SHARE_WRITE | /* share_access */
+ FILE_SHARE_DELETE),
+ FILE_OPEN, /* create_disposition*/
+ 0, /* create_options */
+ FILE_ATTRIBUTE_NORMAL, /* file_attributes */
+ NO_OPLOCK, /* oplock_request */
+ 0, /* allocation_size */
+ NULL, /* sd */
+ NULL, /* ea_list */
+ &fsp1, /* result */
+ &info, /* pinfo */
+ &sbuf1); /* psbuf */
if (!NT_STATUS_IS_OK(status)) {
return status;
}
- status = open_file_ntcreate(conn, req, newname, &sbuf2,
- FILE_WRITE_DATA, /* Read-only. */
- FILE_SHARE_READ|FILE_SHARE_WRITE|FILE_SHARE_DELETE,
- FILE_CREATE,
- 0, /* No create options. */
- fattr,
- NO_OPLOCK,
- &info, &fsp2);
+ status = SMB_VFS_CREATE_FILE(
+ conn, /* conn */
+ req, /* req */
+ 0, /* root_dir_fid */
+ newname, /* fname */
+ false, /* is_dos_path */
+ FILE_WRITE_DATA, /* access_mask */
+ (FILE_SHARE_READ | FILE_SHARE_WRITE | /* share_access */
+ FILE_SHARE_DELETE),
+ FILE_CREATE, /* create_disposition*/
+ 0, /* create_options */
+ fattr, /* file_attributes */
+ NO_OPLOCK, /* oplock_request */
+ 0, /* allocation_size */
+ NULL, /* sd */
+ NULL, /* ea_list */
+ &fsp2, /* result */
+ &info, /* pinfo */
+ &sbuf2); /* psbuf */
if (!NT_STATUS_IS_OK(status)) {
close_file(NULL, fsp1, ERROR_CLOSE);
diff --git a/source3/smbd/open.c b/source3/smbd/open.c
index 989024f553..62d4827bb2 100644
--- a/source3/smbd/open.c
+++ b/source3/smbd/open.c
@@ -2493,14 +2493,24 @@ NTSTATUS create_directory(connection_struct *conn, struct smb_request *req, cons
SET_STAT_INVALID(sbuf);
- status = open_directory(conn, req, directory, &sbuf,
- FILE_READ_ATTRIBUTES, /* Just a stat open */
- FILE_SHARE_NONE, /* Ignored for stat opens */
- FILE_CREATE,
- 0,
- FILE_ATTRIBUTE_DIRECTORY,
- NULL,
- &fsp);
+ status = SMB_VFS_CREATE_FILE(
+ conn, /* conn */
+ req, /* req */
+ 0, /* root_dir_fid */
+ directory, /* fname */
+ false, /* is_dos_path */
+ FILE_READ_ATTRIBUTES, /* access_mask */
+ FILE_SHARE_NONE, /* share_access */
+ FILE_CREATE, /* create_disposition*/
+ FILE_DIRECTORY_FILE, /* create_options */
+ FILE_ATTRIBUTE_DIRECTORY, /* file_attributes */
+ 0, /* oplock_request */
+ 0, /* allocation_size */
+ NULL, /* sd */
+ NULL, /* ea_list */
+ &fsp, /* result */
+ NULL, /* pinfo */
+ &sbuf); /* psbuf */
if (NT_STATUS_IS_OK(status)) {
close_file(req, fsp, NORMAL_CLOSE);
diff --git a/source3/smbd/posix_acls.c b/source3/smbd/posix_acls.c
index 97fd3b2bbe..78a5d548c2 100644
--- a/source3/smbd/posix_acls.c
+++ b/source3/smbd/posix_acls.c
@@ -3248,17 +3248,24 @@ NTSTATUS append_parent_acl(files_struct *fsp,
return NT_STATUS_NO_MEMORY;
}
- status = open_directory(fsp->conn,
- NULL,
- parent_name,
- &sbuf,
- FILE_READ_ATTRIBUTES, /* Just a stat open */
- FILE_SHARE_NONE, /* Ignored for stat opens */
- FILE_OPEN,
- 0,
- INTERNAL_OPEN_ONLY,
- &info,
- &parent_fsp);
+ status = SMB_VFS_CREATE_FILE(
+ fsp->conn, /* conn */
+ NULL, /* req */
+ 0, /* root_dir_fid */
+ parent_name, /* fname */
+ false, /* is_dos_path */
+ FILE_READ_ATTRIBUTES, /* access_mask */
+ FILE_SHARE_NONE, /* share_access */
+ FILE_OPEN, /* create_disposition*/
+ FILE_DIRECTORY_FILE, /* create_options */
+ 0, /* file_attributes */
+ INTERNAL_OPEN_ONLY, /* oplock_request */
+ 0, /* allocation_size */
+ NULL, /* sd */
+ NULL, /* ea_list */
+ &parent_fsp, /* result */
+ &info, /* pinfo */
+ &sbuf); /* psbuf */
if (!NT_STATUS_IS_OK(status)) {
return status;
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);
diff --git a/source3/smbd/trans2.c b/source3/smbd/trans2.c
index 9ba6d198c4..b9a04e9b4f 100644
--- a/source3/smbd/trans2.c
+++ b/source3/smbd/trans2.c
@@ -5059,15 +5059,26 @@ static NTSTATUS smb_set_file_size(connection_struct *conn,
return NT_STATUS_OK;
}
- status = open_file_ntcreate(conn, req, fname, psbuf,
- FILE_WRITE_ATTRIBUTES,
- FILE_SHARE_READ|FILE_SHARE_WRITE|FILE_SHARE_DELETE,
- FILE_OPEN,
- 0,
- FILE_ATTRIBUTE_NORMAL,
- FORCE_OPLOCK_BREAK_TO_NONE,
- NULL, &new_fsp);
-
+ status = SMB_VFS_CREATE_FILE(
+ conn, /* conn */
+ req, /* req */
+ 0, /* root_dir_fid */
+ fname, /* fname */
+ false, /* is_dos_path */
+ FILE_WRITE_ATTRIBUTES, /* access_mask */
+ (FILE_SHARE_READ | FILE_SHARE_WRITE | /* share_access */
+ FILE_SHARE_DELETE),
+ FILE_OPEN, /* create_disposition*/
+ 0, /* create_options */
+ FILE_ATTRIBUTE_NORMAL, /* file_attributes */
+ FORCE_OPLOCK_BREAK_TO_NONE, /* oplock_request */
+ 0, /* allocation_size */
+ NULL, /* sd */
+ NULL, /* ea_list */
+ &new_fsp, /* result */
+ NULL, /* pinfo */
+ psbuf); /* psbuf */
+
if (!NT_STATUS_IS_OK(status)) {
/* NB. We check for open_was_deferred in the caller. */
return status;
@@ -5828,14 +5839,25 @@ static NTSTATUS smb_set_file_allocation_info(connection_struct *conn,
/* Pathname or stat or directory file. */
- status = open_file_ntcreate(conn, req, fname, psbuf,
- FILE_WRITE_DATA,
- FILE_SHARE_READ|FILE_SHARE_WRITE|FILE_SHARE_DELETE,
- FILE_OPEN,
- 0,
- FILE_ATTRIBUTE_NORMAL,
- FORCE_OPLOCK_BREAK_TO_NONE,
- NULL, &new_fsp);
+ status = SMB_VFS_CREATE_FILE(
+ conn, /* conn */
+ req, /* req */
+ 0, /* root_dir_fid */
+ fname, /* fname */
+ false, /* is_dos_path */
+ FILE_WRITE_DATA, /* access_mask */
+ (FILE_SHARE_READ | FILE_SHARE_WRITE | /* share_access */
+ FILE_SHARE_DELETE),
+ FILE_OPEN, /* create_disposition*/
+ 0, /* create_options */
+ FILE_ATTRIBUTE_NORMAL, /* file_attributes */
+ FORCE_OPLOCK_BREAK_TO_NONE, /* oplock_request */
+ 0, /* allocation_size */
+ NULL, /* sd */
+ NULL, /* ea_list */
+ &new_fsp, /* result */
+ NULL, /* pinfo */
+ psbuf); /* psbuf */
if (!NT_STATUS_IS_OK(status)) {
/* NB. We check for open_was_deferred in the caller. */
@@ -6259,16 +6281,24 @@ static NTSTATUS smb_posix_mkdir(connection_struct *conn,
DEBUG(10,("smb_posix_mkdir: file %s, mode 0%o\n",
fname, (unsigned int)unixmode ));
- status = open_directory(conn, req,
- fname,
- psbuf,
- FILE_READ_ATTRIBUTES, /* Just a stat open */
- FILE_SHARE_NONE, /* Ignored for stat opens */
- FILE_CREATE,
- 0,
- mod_unixmode,
- &info,
- &fsp);
+ status = SMB_VFS_CREATE_FILE(
+ conn, /* conn */
+ req, /* req */
+ 0, /* root_dir_fid */
+ fname, /* fname */
+ false, /* is_dos_path */
+ FILE_READ_ATTRIBUTES, /* access_mask */
+ FILE_SHARE_NONE, /* share_access */
+ FILE_CREATE, /* create_disposition*/
+ FILE_DIRECTORY_FILE, /* create_options */
+ mod_unixmode, /* file_attributes */
+ 0, /* oplock_request */
+ 0, /* allocation_size */
+ NULL, /* sd */
+ NULL, /* ea_list */
+ &fsp, /* result */
+ &info, /* pinfo */
+ psbuf); /* psbuf */
if (NT_STATUS_IS_OK(status)) {
close_file(req, fsp, NORMAL_CLOSE);
@@ -6425,17 +6455,25 @@ static NTSTATUS smb_posix_open(connection_struct *conn,
(unsigned int)wire_open_mode,
(unsigned int)unixmode ));
- status = open_file_ntcreate(conn, req,
- fname,
- psbuf,
- access_mask,
- FILE_SHARE_READ|FILE_SHARE_WRITE|FILE_SHARE_DELETE,
- create_disp,
- 0, /* no create options yet. */
- mod_unixmode,
- oplock_request,
- &info,
- &fsp);
+ 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 | FILE_SHARE_WRITE | /* share_access */
+ FILE_SHARE_DELETE),
+ create_disp, /* create_disposition*/
+ 0, /* create_options */
+ mod_unixmode, /* file_attributes */
+ oplock_request, /* oplock_request */
+ 0, /* allocation_size */
+ NULL, /* sd */
+ NULL, /* ea_list */
+ &fsp, /* result */
+ &info, /* pinfo */
+ psbuf); /* psbuf */
if (!NT_STATUS_IS_OK(status)) {
return status;
@@ -6520,6 +6558,7 @@ static NTSTATUS smb_posix_unlink(connection_struct *conn,
uint16 flags = 0;
char del = 1;
int info = 0;
+ int create_options = 0;
int i;
struct share_mode_lock *lck = NULL;
@@ -6543,31 +6582,29 @@ static NTSTATUS smb_posix_unlink(connection_struct *conn,
fname));
if (VALID_STAT_OF_DIR(*psbuf)) {
- status = open_directory(conn, req,
- fname,
- psbuf,
- DELETE_ACCESS,
- FILE_SHARE_READ|FILE_SHARE_WRITE|FILE_SHARE_DELETE,
- FILE_OPEN,
- 0,
- FILE_FLAG_POSIX_SEMANTICS|0777,
- &info,
- &fsp);
- } else {
-
- status = open_file_ntcreate(conn, req,
- fname,
- psbuf,
- DELETE_ACCESS,
- FILE_SHARE_READ|FILE_SHARE_WRITE|FILE_SHARE_DELETE,
- FILE_OPEN,
- 0,
- FILE_FLAG_POSIX_SEMANTICS|0777,
- 0, /* No oplock, but break existing ones. */
- &info,
- &fsp);
+ create_options |= FILE_DIRECTORY_FILE;
}
+ 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_READ | FILE_SHARE_WRITE | /* share_access */
+ FILE_SHARE_DELETE),
+ FILE_OPEN, /* create_disposition*/
+ create_options, /* create_options */
+ FILE_FLAG_POSIX_SEMANTICS|0777, /* file_attributes */
+ 0, /* oplock_request */
+ 0, /* allocation_size */
+ NULL, /* sd */
+ NULL, /* ea_list */
+ &fsp, /* result */
+ &info, /* pinfo */
+ psbuf); /* psbuf */
+
if (!NT_STATUS_IS_OK(status)) {
return status;
}