summaryrefslogtreecommitdiff
path: root/source3/smbd/nttrans.c
diff options
context:
space:
mode:
authorVolker Lendecke <vlendec@samba.org>2007-07-05 16:26:27 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 12:23:48 -0500
commit0bc56a2e5ffd0e65e4770e10c80d9fec02950b36 (patch)
treee1d8ede295e811121e252e80c3313697246df29b /source3/smbd/nttrans.c
parent4ce65137d927a1f464dcd8f3e5b7b13c71adda27 (diff)
downloadsamba-0bc56a2e5ffd0e65e4770e10c80d9fec02950b36.tar.gz
samba-0bc56a2e5ffd0e65e4770e10c80d9fec02950b36.tar.bz2
samba-0bc56a2e5ffd0e65e4770e10c80d9fec02950b36.zip
r23724: Reduce access to the global inbuf a tiny bit. Add a struct smb_request
that contains some of the fields from the SMB header, removing the need to access inbuf directly. This right now is used only in the open file code & friends, and creating that header is only done when needed. This needs more work, but it is a start. Jeremy, I'm only checking this into 3_0, please review before I merge it to _26. Volker (This used to be commit ca988f4e79e977160d82e86486972afd15d4acf5)
Diffstat (limited to 'source3/smbd/nttrans.c')
-rw-r--r--source3/smbd/nttrans.c53
1 files changed, 31 insertions, 22 deletions
diff --git a/source3/smbd/nttrans.c b/source3/smbd/nttrans.c
index 2c259713c2..7e17e3b938 100644
--- a/source3/smbd/nttrans.c
+++ b/source3/smbd/nttrans.c
@@ -505,6 +505,7 @@ int reply_ntcreate_and_X(connection_struct *conn,
struct timespec m_timespec;
BOOL extended_oplock_granted = False;
NTSTATUS status;
+ struct smb_request req;
START_PROFILE(SMBntcreateX);
@@ -520,6 +521,8 @@ int reply_ntcreate_and_X(connection_struct *conn,
(unsigned int)create_options,
(unsigned int)root_dir_fid ));
+ init_smb_request(&req, (uint8 *)inbuf);
+
/*
* If it's an IPC, use the pipe handler.
*/
@@ -726,7 +729,7 @@ int reply_ntcreate_and_X(connection_struct *conn,
}
oplock_request = 0;
- status = open_directory(conn, fname, &sbuf,
+ status = open_directory(conn, &req, fname, &sbuf,
access_mask,
share_access,
create_disposition,
@@ -764,7 +767,7 @@ int reply_ntcreate_and_X(connection_struct *conn,
* before issuing an oplock break request to
* our client. JRA. */
- status = open_file_ntcreate(conn,fname,&sbuf,
+ status = open_file_ntcreate(conn, &req, fname, &sbuf,
access_mask,
share_access,
create_disposition,
@@ -807,7 +810,8 @@ int reply_ntcreate_and_X(connection_struct *conn,
}
oplock_request = 0;
- status = open_directory(conn, fname, &sbuf,
+ status = open_directory(conn, &req, fname,
+ &sbuf,
access_mask,
share_access,
create_disposition,
@@ -1199,6 +1203,7 @@ static int call_nt_transact_create(connection_struct *conn, char *inbuf, char *o
char *pdata = NULL;
NTSTATUS status;
size_t param_len;
+ struct smb_request req;
DEBUG(5,("call_nt_transact_create\n"));
@@ -1227,6 +1232,8 @@ static int call_nt_transact_create(connection_struct *conn, char *inbuf, char *o
return ERROR_NT(NT_STATUS_INVALID_PARAMETER);
}
+ init_smb_request(&req, (uint8 *)inbuf);
+
flags = IVAL(params,0);
access_mask = IVAL(params,8);
file_attributes = IVAL(params,20);
@@ -1389,16 +1396,6 @@ static int call_nt_transact_create(connection_struct *conn, char *inbuf, char *o
}
}
-#if 0
- /* We need to support SeSecurityPrivilege for this. */
- if ((access_mask & SEC_RIGHT_SYSTEM_SECURITY)) &&
- !user_has_privileges(current_user.nt_user_token,
- &se_security)) {
- restore_case_semantics(conn, file_attributes);
- return ERROR_NT(NT_STATUS_PRIVILEGE_NOT_HELD);
- }
-#endif
-
if (ea_len) {
pdata = data + sd_len;
@@ -1430,7 +1427,7 @@ static int call_nt_transact_create(connection_struct *conn, char *inbuf, char *o
*/
oplock_request = 0;
- status = open_directory(conn, fname, &sbuf,
+ status = open_directory(conn, &req, fname, &sbuf,
access_mask,
share_access,
create_disposition,
@@ -1448,7 +1445,7 @@ static int call_nt_transact_create(connection_struct *conn, char *inbuf, char *o
* Ordinary file case.
*/
- status = open_file_ntcreate(conn,fname,&sbuf,
+ status = open_file_ntcreate(conn,&req,fname,&sbuf,
access_mask,
share_access,
create_disposition,
@@ -1471,7 +1468,8 @@ static int call_nt_transact_create(connection_struct *conn, char *inbuf, char *o
}
oplock_request = 0;
- status = open_directory(conn, fname, &sbuf,
+ status = open_directory(conn, &req, fname,
+ &sbuf,
access_mask,
share_access,
create_disposition,
@@ -1691,7 +1689,9 @@ int reply_ntcancel(connection_struct *conn,
Copy a file.
****************************************************************************/
-static NTSTATUS copy_internals(connection_struct *conn, char *oldname, char *newname, uint32 attrs)
+static NTSTATUS copy_internals(connection_struct *conn,
+ struct smb_request *req,
+ char *oldname, char *newname, uint32 attrs)
{
SMB_STRUCT_STAT sbuf1, sbuf2;
pstring last_component_oldname;
@@ -1757,7 +1757,7 @@ static NTSTATUS copy_internals(connection_struct *conn, char *oldname, char *new
DEBUG(10,("copy_internals: doing file copy %s to %s\n", oldname, newname));
- status = open_file_ntcreate(conn,oldname,&sbuf1,
+ status = open_file_ntcreate(conn, req, oldname, &sbuf1,
FILE_READ_DATA, /* Read-only. */
FILE_SHARE_READ|FILE_SHARE_WRITE|FILE_SHARE_DELETE,
FILE_OPEN,
@@ -1770,7 +1770,7 @@ static NTSTATUS copy_internals(connection_struct *conn, char *oldname, char *new
return status;
}
- status = open_file_ntcreate(conn,newname,&sbuf2,
+ status = open_file_ntcreate(conn, req, newname, &sbuf2,
FILE_WRITE_DATA, /* Read-only. */
FILE_SHARE_READ|FILE_SHARE_WRITE|FILE_SHARE_DELETE,
FILE_CREATE,
@@ -1834,9 +1834,12 @@ int reply_ntrename(connection_struct *conn,
BOOL dest_has_wcard = False;
uint32 attrs = SVAL(inbuf,smb_vwv0);
uint16 rename_type = SVAL(inbuf,smb_vwv1);
+ struct smb_request req;
START_PROFILE(SMBntrename);
+ init_smb_request(&req, (uint8 *)inbuf);
+
p = smb_buf(inbuf) + 1;
p += srvstr_get_path_wcard(inbuf, oldname, p, sizeof(oldname), 0, STR_TERMINATE, &status, &src_has_wcard);
if (!NT_STATUS_IS_OK(status)) {
@@ -1884,7 +1887,9 @@ int reply_ntrename(connection_struct *conn,
switch(rename_type) {
case RENAME_FLAG_RENAME:
- status = rename_internals(conn, oldname, newname, attrs, False, src_has_wcard, dest_has_wcard);
+ status = rename_internals(conn, &req, oldname, newname,
+ attrs, False, src_has_wcard,
+ dest_has_wcard);
break;
case RENAME_FLAG_HARD_LINK:
if (src_has_wcard || dest_has_wcard) {
@@ -1899,7 +1904,8 @@ int reply_ntrename(connection_struct *conn,
/* No wildcards. */
status = NT_STATUS_OBJECT_PATH_SYNTAX_BAD;
} else {
- status = copy_internals(conn, oldname, newname, attrs);
+ status = copy_internals(conn, &req, oldname,
+ newname, attrs);
}
break;
case RENAME_FLAG_MOVE_CLUSTER_INFORMATION:
@@ -2036,6 +2042,9 @@ static int call_nt_transact_rename(connection_struct *conn, char *inbuf, char *o
BOOL replace_if_exists = False;
BOOL dest_has_wcard = False;
NTSTATUS status;
+ struct smb_request req;
+
+ init_smb_request(&req, (uint8 *)inbuf);
if(parameter_count < 5) {
return ERROR_DOS(ERRDOS,ERRbadfunc);
@@ -2050,7 +2059,7 @@ static int call_nt_transact_rename(connection_struct *conn, char *inbuf, char *o
return ERROR_NT(status);
}
- status = rename_internals(conn, fsp->fsp_name,
+ status = rename_internals(conn, &req, fsp->fsp_name,
new_name, 0, replace_if_exists, False, dest_has_wcard);
if (!NT_STATUS_IS_OK(status)) {