summaryrefslogtreecommitdiff
path: root/source3/smbd/reply.c
diff options
context:
space:
mode:
Diffstat (limited to 'source3/smbd/reply.c')
-rw-r--r--source3/smbd/reply.c374
1 files changed, 184 insertions, 190 deletions
diff --git a/source3/smbd/reply.c b/source3/smbd/reply.c
index 6933533672..25480c6e3b 100644
--- a/source3/smbd/reply.c
+++ b/source3/smbd/reply.c
@@ -29,7 +29,6 @@
/* look in server.c for some explanation of these variables */
extern enum protocol_types Protocol;
extern int max_recv;
-unsigned int smb_echo_count = 0;
extern uint32 global_client_caps;
extern bool global_encrypted_passwords_negotiated;
@@ -340,8 +339,7 @@ bool check_fsp_open(connection_struct *conn, struct smb_request *req,
}
/****************************************************************************
- Check if we have a correct fsp pointing to a file. Replacement for the
- CHECK_FSP macro.
+ Check if we have a correct fsp pointing to a file.
****************************************************************************/
bool check_fsp(connection_struct *conn, struct smb_request *req,
@@ -426,22 +424,22 @@ void reply_special(char *inbuf)
* header.
*/
char outbuf[smb_size];
-
+
static bool already_got_session = False;
*name1 = *name2 = 0;
-
+
memset(outbuf, '\0', sizeof(outbuf));
smb_setlen(outbuf,0);
-
+
switch (msg_type) {
case 0x81: /* session request */
-
+
if (already_got_session) {
exit_server_cleanly("multiple session request not permitted");
}
-
+
SCVAL(outbuf,0,0x82);
SCVAL(outbuf,3,0);
if (name_len(inbuf+4) > 50 ||
@@ -480,24 +478,24 @@ void reply_special(char *inbuf)
already_got_session = True;
break;
-
+
case 0x89: /* session keepalive request
(some old clients produce this?) */
SCVAL(outbuf,0,SMBkeepalive);
SCVAL(outbuf,3,0);
break;
-
+
case 0x82: /* positive session response */
case 0x83: /* negative session response */
case 0x84: /* retarget session response */
DEBUG(0,("Unexpected session response\n"));
break;
-
+
case SMBkeepalive: /* session keepalive */
default:
return;
}
-
+
DEBUG(5,("init msg_type=0x%x msg_flags=0x%x\n",
msg_type, msg_flags));
@@ -749,7 +747,12 @@ void reply_tcon_and_X(struct smb_request *req)
SSVAL(req->outbuf, smb_vwv2, SMB_SUPPORT_SEARCH_BITS|
(lp_csc_policy(SNUM(conn)) << 2));
- init_dfsroot(conn, req->inbuf, req->outbuf);
+ if (lp_msdfs_root(SNUM(conn)) && lp_host_msdfs()) {
+ DEBUG(2,("Serving %s as a Dfs root\n",
+ lp_servicename(SNUM(conn)) ));
+ SSVAL(req->outbuf, smb_vwv2,
+ SMB_SHARE_IN_DFS | SVAL(req->outbuf, smb_vwv2));
+ }
}
@@ -827,8 +830,8 @@ void reply_ioctl(struct smb_request *req)
switch (ioctl_code) {
case IOCTL_QUERY_JOB_INFO:
{
- files_struct *fsp = file_fsp(SVAL(req->inbuf,
- smb_vwv0));
+ files_struct *fsp = file_fsp(
+ req, SVAL(req->inbuf, smb_vwv0));
if (!fsp) {
reply_doserror(req, ERRDOS, ERRbadfid);
END_PROFILE(SMBioctl);
@@ -1059,7 +1062,7 @@ void reply_getatr(struct smb_request *req)
SSVAL(req->outbuf, smb_flg2,
SVAL(req->outbuf, smb_flg2) | FLAGS2_IS_LONG_NAME);
}
-
+
DEBUG(3,("reply_getatr: name=%s mode=%d size=%u\n", fname, mode, (unsigned int)size ) );
END_PROFILE(SMBgetatr);
@@ -1166,9 +1169,9 @@ void reply_setatr(struct smb_request *req)
}
reply_outbuf(req, 0, 0);
-
+
DEBUG( 3, ( "setatr name=%s mode=%d\n", fname, mode ) );
-
+
END_PROFILE(SMBsetatr);
return;
}
@@ -1180,17 +1183,17 @@ void reply_setatr(struct smb_request *req)
void reply_dskattr(struct smb_request *req)
{
connection_struct *conn = req->conn;
- SMB_BIG_UINT dfree,dsize,bsize;
+ uint64_t dfree,dsize,bsize;
START_PROFILE(SMBdskattr);
- if (get_dfree_info(conn,".",True,&bsize,&dfree,&dsize) == (SMB_BIG_UINT)-1) {
+ if (get_dfree_info(conn,".",True,&bsize,&dfree,&dsize) == (uint64_t)-1) {
reply_unixerror(req, ERRHRD, ERRgeneral);
END_PROFILE(SMBdskattr);
return;
}
reply_outbuf(req, 5, 0);
-
+
if (Protocol <= PROTOCOL_LANMAN2) {
double total_space, free_space;
/* we need to scale this to a number that DOS6 can handle. We
@@ -1202,9 +1205,9 @@ void reply_dskattr(struct smb_request *req)
total_space = dsize * (double)bsize;
free_space = dfree * (double)bsize;
- dsize = (SMB_BIG_UINT)((total_space+63*512) / (64*512));
- dfree = (SMB_BIG_UINT)((free_space+63*512) / (64*512));
-
+ dsize = (uint64_t)((total_space+63*512) / (64*512));
+ dfree = (uint64_t)((free_space+63*512) / (64*512));
+
if (dsize > 0xFFFF) dsize = 0xFFFF;
if (dfree > 0xFFFF) dfree = 0xFFFF;
@@ -1689,7 +1692,7 @@ void reply_open(struct smb_request *req)
if (fattr & aDIR) {
DEBUG(3,("attempt to open a directory %s\n",fsp->fsp_name));
- close_file(fsp,ERROR_CLOSE);
+ close_file(req, fsp, ERROR_CLOSE);
reply_doserror(req, ERRDOS,ERRnoaccess);
END_PROFILE(SMBopen);
return;
@@ -1710,7 +1713,7 @@ void reply_open(struct smb_request *req)
SCVAL(req->outbuf,smb_flg,
CVAL(req->outbuf,smb_flg)|CORE_OPLOCK_GRANTED);
}
-
+
if(EXCLUSIVE_OPLOCK_TYPE(fsp->oplock_type)) {
SCVAL(req->outbuf,smb_flg,
CVAL(req->outbuf,smb_flg)|CORE_OPLOCK_GRANTED);
@@ -1746,7 +1749,7 @@ void reply_open_and_X(struct smb_request *req)
int smb_action = 0;
files_struct *fsp;
NTSTATUS status;
- SMB_BIG_UINT allocation_size;
+ uint64_t allocation_size;
ssize_t retval = -1;
uint32 access_mask;
uint32 share_mode;
@@ -1769,7 +1772,7 @@ void reply_open_and_X(struct smb_request *req)
core_oplock_request = CORE_OPLOCK_REQUEST(req->inbuf);
oplock_request = ex_oplock_request | core_oplock_request;
smb_ofun = SVAL(req->inbuf,smb_vwv8);
- allocation_size = (SMB_BIG_UINT)IVAL(req->inbuf,smb_vwv9);
+ allocation_size = (uint64_t)IVAL(req->inbuf,smb_vwv9);
/* If it's an IPC, pass off the pipe handler. */
if (IS_IPC(conn)) {
@@ -1832,14 +1835,14 @@ void reply_open_and_X(struct smb_request *req)
if (((smb_action == FILE_WAS_CREATED) || (smb_action == FILE_WAS_OVERWRITTEN)) && allocation_size) {
fsp->initial_allocation_size = smb_roundup(fsp->conn, allocation_size);
if (vfs_allocate_file_space(fsp, fsp->initial_allocation_size) == -1) {
- close_file(fsp,ERROR_CLOSE);
+ close_file(req, fsp, ERROR_CLOSE);
reply_nterror(req, NT_STATUS_DISK_FULL);
END_PROFILE(SMBopenX);
return;
}
retval = vfs_set_filelen(fsp, (SMB_OFF_T)allocation_size);
if (retval < 0) {
- close_file(fsp,ERROR_CLOSE);
+ close_file(req, fsp, ERROR_CLOSE);
reply_nterror(req, NT_STATUS_DISK_FULL);
END_PROFILE(SMBopenX);
return;
@@ -1850,7 +1853,7 @@ void reply_open_and_X(struct smb_request *req)
fattr = dos_mode(conn,fsp->fsp_name,&sbuf);
mtime = sbuf.st_mtime;
if (fattr & aDIR) {
- close_file(fsp,ERROR_CLOSE);
+ close_file(req, fsp, ERROR_CLOSE);
reply_doserror(req, ERRDOS, ERRnoaccess);
END_PROFILE(SMBopenX);
return;
@@ -2198,7 +2201,7 @@ void reply_ctemp(struct smb_request *req)
SCVAL(req->outbuf, smb_flg,
CVAL(req->outbuf,smb_flg)|CORE_OPLOCK_GRANTED);
}
-
+
if (EXCLUSIVE_OPLOCK_TYPE(fsp->oplock_type)) {
SCVAL(req->outbuf, smb_flg,
CVAL(req->outbuf,smb_flg)|CORE_OPLOCK_GRANTED);
@@ -2365,11 +2368,11 @@ static NTSTATUS do_unlink(connection_struct *conn,
/* The set is across all open files on this dev/inode pair. */
if (!set_delete_on_close(fsp, True, &conn->server_info->utok)) {
- close_file(fsp, NORMAL_CLOSE);
+ close_file(req, fsp, NORMAL_CLOSE);
return NT_STATUS_ACCESS_DENIED;
}
- return close_file(fsp,NORMAL_CLOSE);
+ return close_file(req, fsp, NORMAL_CLOSE);
}
/****************************************************************************
@@ -2810,7 +2813,7 @@ void reply_readbraw(struct smb_request *req)
* return a zero length response here.
*/
- fsp = file_fsp(SVAL(req->inbuf,smb_vwv0));
+ fsp = file_fsp(req, SVAL(req->inbuf,smb_vwv0));
/*
* We have to do a check_fsp by hand here, as
@@ -2889,8 +2892,8 @@ void reply_readbraw(struct smb_request *req)
maxcount = MIN(65535,maxcount);
if (is_locked(fsp,(uint32)req->smbpid,
- (SMB_BIG_UINT)maxcount,
- (SMB_BIG_UINT)startpos,
+ (uint64_t)maxcount,
+ (uint64_t)startpos,
READ_LOCK)) {
reply_readbraw_error();
END_PROFILE(SMBreadbraw);
@@ -2911,14 +2914,14 @@ void reply_readbraw(struct smb_request *req)
if (nread < mincount)
nread = 0;
#endif
-
+
DEBUG( 3, ( "reply_readbraw: fnum=%d start=%.0f max=%lu "
"min=%lu nread=%lu\n",
fsp->fnum, (double)startpos,
(unsigned long)maxcount,
(unsigned long)mincount,
(unsigned long)nread ) );
-
+
send_file_readbraw(conn, fsp, startpos, nread, mincount);
DEBUG(5,("reply_readbraw finished\n"));
@@ -2952,7 +2955,7 @@ void reply_lockread(struct smb_request *req)
return;
}
- fsp = file_fsp(SVAL(req->inbuf,smb_vwv0));
+ fsp = file_fsp(req, SVAL(req->inbuf,smb_vwv0));
if (!check_fsp(conn, req, fsp)) {
END_PROFILE(SMBlockread);
@@ -2975,7 +2978,7 @@ void reply_lockread(struct smb_request *req)
reply_outbuf(req, 5, numtoread + 3);
data = smb_buf(req->outbuf) + 3;
-
+
/*
* NB. Discovered by Menny Hamburger at Mainsoft. This is a core+
* protocol request that predates the read/write lock concept.
@@ -2983,12 +2986,12 @@ void reply_lockread(struct smb_request *req)
* for a write lock. JRA.
* Note that the requested lock size is unaffected by max_recv.
*/
-
+
br_lck = do_lock(smbd_messaging_context(),
fsp,
req->smbpid,
- (SMB_BIG_UINT)numtoread,
- (SMB_BIG_UINT)startpos,
+ (uint64_t)numtoread,
+ (uint64_t)startpos,
WRITE_LOCK,
WINDOWS_LOCK,
False, /* Non-blocking lock. */
@@ -3019,7 +3022,7 @@ Returning short read of maximum allowed for compatibility with Windows 2000.\n",
END_PROFILE(SMBlockread);
return;
}
-
+
srv_set_message((char *)req->outbuf, 5, nread+3, False);
SSVAL(req->outbuf,smb_vwv0,nread);
@@ -3027,7 +3030,7 @@ Returning short read of maximum allowed for compatibility with Windows 2000.\n",
p = smb_buf(req->outbuf);
SCVAL(p,0,0); /* pad byte. */
SSVAL(p,1,nread);
-
+
DEBUG(3,("lockread fnum=%d num=%d nread=%d\n",
fsp->fnum, (int)numtoread, (int)nread));
@@ -3060,7 +3063,7 @@ void reply_read(struct smb_request *req)
return;
}
- fsp = file_fsp(SVAL(req->inbuf,smb_vwv0));
+ fsp = file_fsp(req, SVAL(req->inbuf,smb_vwv0));
if (!check_fsp(conn, req, fsp)) {
END_PROFILE(SMBread);
@@ -3091,9 +3094,9 @@ Returning short read of maximum allowed for compatibility with Windows 2000.\n",
reply_outbuf(req, 5, numtoread+3);
data = smb_buf(req->outbuf) + 3;
-
- if (is_locked(fsp, (uint32)req->smbpid, (SMB_BIG_UINT)numtoread,
- (SMB_BIG_UINT)startpos, READ_LOCK)) {
+
+ if (is_locked(fsp, (uint32)req->smbpid, (uint64_t)numtoread,
+ (uint64_t)startpos, READ_LOCK)) {
reply_doserror(req, ERRDOS,ERRlock);
END_PROFILE(SMBread);
return;
@@ -3114,7 +3117,7 @@ Returning short read of maximum allowed for compatibility with Windows 2000.\n",
SSVAL(req->outbuf,smb_vwv5,nread+3);
SCVAL(smb_buf(req->outbuf),0,1);
SSVAL(smb_buf(req->outbuf),1,nread);
-
+
DEBUG( 3, ( "read fnum=%d num=%d nread=%d\n",
fsp->fnum, (int)numtoread, (int)nread ) );
@@ -3304,7 +3307,7 @@ void reply_read_and_X(struct smb_request *req)
return;
}
- fsp = file_fsp(SVAL(req->inbuf,smb_vwv2));
+ fsp = file_fsp(req, SVAL(req->inbuf,smb_vwv2));
startpos = IVAL_TO_SMB_OFF_T(req->inbuf,smb_vwv3);
smb_maxcnt = SVAL(req->inbuf,smb_vwv5);
@@ -3379,8 +3382,8 @@ void reply_read_and_X(struct smb_request *req)
}
- if (is_locked(fsp, (uint32)req->smbpid, (SMB_BIG_UINT)smb_maxcnt,
- (SMB_BIG_UINT)startpos, READ_LOCK)) {
+ if (is_locked(fsp, (uint32)req->smbpid, (uint64_t)smb_maxcnt,
+ (uint64_t)startpos, READ_LOCK)) {
END_PROFILE(SMBreadX);
reply_doserror(req, ERRDOS, ERRlock);
return;
@@ -3452,7 +3455,7 @@ void reply_writebraw(struct smb_request *req)
return;
}
- fsp = file_fsp(SVAL(req->inbuf,smb_vwv0));
+ fsp = file_fsp(req, SVAL(req->inbuf,smb_vwv0));
if (!check_fsp(conn, req, fsp)) {
error_to_writebrawerr(req);
END_PROFILE(SMBwritebraw);
@@ -3489,8 +3492,8 @@ void reply_writebraw(struct smb_request *req)
return;
}
- if (is_locked(fsp,(uint32)req->smbpid,(SMB_BIG_UINT)tcount,
- (SMB_BIG_UINT)startpos, WRITE_LOCK)) {
+ if (is_locked(fsp,(uint32)req->smbpid,(uint64_t)tcount,
+ (uint64_t)startpos, WRITE_LOCK)) {
reply_doserror(req, ERRDOS, ERRlock);
error_to_writebrawerr(req);
END_PROFILE(SMBwritebraw);
@@ -3656,8 +3659,8 @@ void reply_writeunlock(struct smb_request *req)
END_PROFILE(SMBwriteunlock);
return;
}
-
- fsp = file_fsp(SVAL(req->inbuf,smb_vwv0));
+
+ fsp = file_fsp(req, SVAL(req->inbuf,smb_vwv0));
if (!check_fsp(conn, req, fsp)) {
END_PROFILE(SMBwriteunlock);
@@ -3673,10 +3676,10 @@ void reply_writeunlock(struct smb_request *req)
numtowrite = SVAL(req->inbuf,smb_vwv1);
startpos = IVAL_TO_SMB_OFF_T(req->inbuf,smb_vwv2);
data = smb_buf(req->inbuf) + 3;
-
+
if (numtowrite
- && is_locked(fsp, (uint32)req->smbpid, (SMB_BIG_UINT)numtowrite,
- (SMB_BIG_UINT)startpos, WRITE_LOCK)) {
+ && is_locked(fsp, (uint32)req->smbpid, (uint64_t)numtowrite,
+ (uint64_t)startpos, WRITE_LOCK)) {
reply_doserror(req, ERRDOS, ERRlock);
END_PROFILE(SMBwriteunlock);
return;
@@ -3690,7 +3693,7 @@ void reply_writeunlock(struct smb_request *req)
} else {
nwritten = write_file(req,fsp,data,startpos,numtowrite);
}
-
+
status = sync_file(conn, fsp, False /* write through */);
if (!NT_STATUS_IS_OK(status)) {
DEBUG(5,("reply_writeunlock: sync_file for %s returned %s\n",
@@ -3710,8 +3713,8 @@ void reply_writeunlock(struct smb_request *req)
status = do_unlock(smbd_messaging_context(),
fsp,
req->smbpid,
- (SMB_BIG_UINT)numtowrite,
- (SMB_BIG_UINT)startpos,
+ (uint64_t)numtowrite,
+ (uint64_t)startpos,
WINDOWS_LOCK);
if (NT_STATUS_V(status)) {
@@ -3722,12 +3725,12 @@ void reply_writeunlock(struct smb_request *req)
}
reply_outbuf(req, 1, 0);
-
+
SSVAL(req->outbuf,smb_vwv0,nwritten);
-
+
DEBUG(3,("writeunlock fnum=%d num=%d wrote=%d\n",
fsp->fnum, (int)numtowrite, (int)nwritten));
-
+
END_PROFILE(SMBwriteunlock);
return;
}
@@ -3764,7 +3767,7 @@ void reply_write(struct smb_request *req)
return;
}
- fsp = file_fsp(SVAL(req->inbuf,smb_vwv0));
+ fsp = file_fsp(req, SVAL(req->inbuf,smb_vwv0));
if (!check_fsp(conn, req, fsp)) {
END_PROFILE(SMBwrite);
@@ -3780,9 +3783,9 @@ void reply_write(struct smb_request *req)
numtowrite = SVAL(req->inbuf,smb_vwv1);
startpos = IVAL_TO_SMB_OFF_T(req->inbuf,smb_vwv2);
data = smb_buf(req->inbuf) + 3;
-
- if (is_locked(fsp, (uint32)req->smbpid, (SMB_BIG_UINT)numtowrite,
- (SMB_BIG_UINT)startpos, WRITE_LOCK)) {
+
+ if (is_locked(fsp, (uint32)req->smbpid, (uint64_t)numtowrite,
+ (uint64_t)startpos, WRITE_LOCK)) {
reply_doserror(req, ERRDOS, ERRlock);
END_PROFILE(SMBwrite);
return;
@@ -3831,14 +3834,14 @@ void reply_write(struct smb_request *req)
}
reply_outbuf(req, 1, 0);
-
+
SSVAL(req->outbuf,smb_vwv0,nwritten);
if (nwritten < (ssize_t)numtowrite) {
SCVAL(req->outbuf,smb_rcls,ERRHRD);
SSVAL(req->outbuf,smb_err,ERRdiskfull);
}
-
+
DEBUG(3,("write fnum=%d num=%d wrote=%d\n", fsp->fnum, (int)numtowrite, (int)nwritten));
END_PROFILE(SMBwrite);
@@ -3994,7 +3997,7 @@ void reply_write_and_X(struct smb_request *req)
return;
}
- fsp = file_fsp(SVAL(req->inbuf,smb_vwv2));
+ fsp = file_fsp(req, SVAL(req->inbuf,smb_vwv2));
startpos = IVAL_TO_SMB_OFF_T(req->inbuf,smb_vwv3);
write_through = BITSETW(req->inbuf+smb_vwv7,0);
@@ -4037,8 +4040,8 @@ void reply_write_and_X(struct smb_request *req)
}
if (is_locked(fsp,(uint32)req->smbpid,
- (SMB_BIG_UINT)numtowrite,
- (SMB_BIG_UINT)startpos, WRITE_LOCK)) {
+ (uint64_t)numtowrite,
+ (uint64_t)startpos, WRITE_LOCK)) {
reply_doserror(req, ERRDOS, ERRlock);
END_PROFILE(SMBwriteX);
return;
@@ -4059,7 +4062,7 @@ void reply_write_and_X(struct smb_request *req)
END_PROFILE(SMBwriteX);
return;
}
-
+
nwritten = write_file(req,fsp,data,startpos,numtowrite);
}
@@ -4115,7 +4118,7 @@ void reply_lseek(struct smb_request *req)
return;
}
- fsp = file_fsp(SVAL(req->inbuf,smb_vwv0));
+ fsp = file_fsp(req, SVAL(req->inbuf,smb_vwv0));
if (!check_fsp(conn, req, fsp)) {
return;
@@ -4175,7 +4178,7 @@ void reply_lseek(struct smb_request *req)
reply_outbuf(req, 2, 0);
SIVAL(req->outbuf,smb_vwv0,res);
-
+
DEBUG(3,("lseek fnum=%d ofs=%.0f newpos = %.0f mode=%d\n",
fsp->fnum, (double)startpos, (double)res, mode));
@@ -4201,12 +4204,12 @@ void reply_flush(struct smb_request *req)
}
fnum = SVAL(req->inbuf,smb_vwv0);
- fsp = file_fsp(fnum);
+ fsp = file_fsp(req, fnum);
if ((fnum != 0xFFFF) && !check_fsp(conn, req, fsp)) {
return;
}
-
+
if (!fsp) {
file_sync_all(conn);
} else {
@@ -4219,7 +4222,7 @@ void reply_flush(struct smb_request *req)
return;
}
}
-
+
reply_outbuf(req, 0, 0);
DEBUG(3,("flush\n"));
@@ -4263,17 +4266,10 @@ void reply_close(struct smb_request *req)
return;
}
- /* If it's an IPC, pass off to the pipe handler. */
- if (IS_IPC(conn)) {
- reply_pipe_close(conn, req);
- END_PROFILE(SMBclose);
- return;
- }
-
- fsp = file_fsp(SVAL(req->inbuf,smb_vwv0));
+ fsp = file_fsp(req, SVAL(req->inbuf,smb_vwv0));
/*
- * We can only use CHECK_FSP if we know it's not a directory.
+ * We can only use check_fsp if we know it's not a directory.
*/
if(!fsp || (fsp->conn != conn) || (fsp->vuid != req->vuid)) {
@@ -4287,7 +4283,7 @@ void reply_close(struct smb_request *req)
* Special case - close NT SMB directory handle.
*/
DEBUG(3,("close directory fnum=%d\n", fsp->fnum));
- status = close_file(fsp,NORMAL_CLOSE);
+ status = close_file(req, fsp, NORMAL_CLOSE);
} else {
time_t t;
/*
@@ -4297,7 +4293,7 @@ void reply_close(struct smb_request *req)
DEBUG(3,("close fd=%d fnum=%d (numopen=%d)\n",
fsp->fh->fd, fsp->fnum,
conn->num_files_open));
-
+
/*
* Take care of any time sent in the close.
*/
@@ -4310,8 +4306,8 @@ void reply_close(struct smb_request *req)
* was detected on close - normally this is due to
* a disk full error. If not then it was probably an I/O error.
*/
-
- status = close_file(fsp,NORMAL_CLOSE);
+
+ status = close_file(req, fsp, NORMAL_CLOSE);
}
if (!NT_STATUS_IS_OK(status)) {
@@ -4348,7 +4344,7 @@ void reply_writeclose(struct smb_request *req)
return;
}
- fsp = file_fsp(SVAL(req->inbuf,smb_vwv0));
+ fsp = file_fsp(req, SVAL(req->inbuf,smb_vwv0));
if (!check_fsp(conn, req, fsp)) {
END_PROFILE(SMBwriteclose);
@@ -4365,15 +4361,15 @@ void reply_writeclose(struct smb_request *req)
mtime = convert_time_t_to_timespec(srv_make_unix_date3(
req->inbuf+smb_vwv4));
data = smb_buf(req->inbuf) + 1;
-
+
if (numtowrite
- && is_locked(fsp, (uint32)req->smbpid, (SMB_BIG_UINT)numtowrite,
- (SMB_BIG_UINT)startpos, WRITE_LOCK)) {
+ && is_locked(fsp, (uint32)req->smbpid, (uint64_t)numtowrite,
+ (uint64_t)startpos, WRITE_LOCK)) {
reply_doserror(req, ERRDOS,ERRlock);
END_PROFILE(SMBwriteclose);
return;
}
-
+
nwritten = write_file(req,fsp,data,startpos,numtowrite);
set_close_write_time(fsp, mtime);
@@ -4386,19 +4382,19 @@ void reply_writeclose(struct smb_request *req)
if (numtowrite) {
DEBUG(3,("reply_writeclose: zero length write doesn't close file %s\n",
fsp->fsp_name ));
- close_status = close_file(fsp,NORMAL_CLOSE);
+ close_status = close_file(req, fsp, NORMAL_CLOSE);
}
DEBUG(3,("writeclose fnum=%d num=%d wrote=%d (numopen=%d)\n",
fsp->fnum, (int)numtowrite, (int)nwritten,
conn->num_files_open));
-
+
if(((nwritten == 0) && (numtowrite != 0))||(nwritten < 0)) {
reply_doserror(req, ERRHRD, ERRdiskfull);
END_PROFILE(SMBwriteclose);
return;
}
-
+
if(!NT_STATUS_IS_OK(close_status)) {
reply_nterror(req, close_status);
END_PROFILE(SMBwriteclose);
@@ -4406,7 +4402,7 @@ void reply_writeclose(struct smb_request *req)
}
reply_outbuf(req, 1, 0);
-
+
SSVAL(req->outbuf,smb_vwv0,nwritten);
END_PROFILE(SMBwriteclose);
return;
@@ -4422,7 +4418,7 @@ void reply_writeclose(struct smb_request *req)
void reply_lock(struct smb_request *req)
{
connection_struct *conn = req->conn;
- SMB_BIG_UINT count,offset;
+ uint64_t count,offset;
NTSTATUS status;
files_struct *fsp;
struct byte_range_lock *br_lck = NULL;
@@ -4435,7 +4431,7 @@ void reply_lock(struct smb_request *req)
return;
}
- fsp = file_fsp(SVAL(req->inbuf,smb_vwv0));
+ fsp = file_fsp(req, SVAL(req->inbuf,smb_vwv0));
if (!check_fsp(conn, req, fsp)) {
END_PROFILE(SMBlock);
@@ -4444,8 +4440,8 @@ void reply_lock(struct smb_request *req)
release_level_2_oplocks_on_change(fsp);
- count = (SMB_BIG_UINT)IVAL(req->inbuf,smb_vwv1);
- offset = (SMB_BIG_UINT)IVAL(req->inbuf,smb_vwv3);
+ count = (uint64_t)IVAL(req->inbuf,smb_vwv1);
+ offset = (uint64_t)IVAL(req->inbuf,smb_vwv3);
DEBUG(3,("lock fd=%d fnum=%d offset=%.0f count=%.0f\n",
fsp->fh->fd, fsp->fnum, (double)offset, (double)count));
@@ -4482,7 +4478,7 @@ void reply_lock(struct smb_request *req)
void reply_unlock(struct smb_request *req)
{
connection_struct *conn = req->conn;
- SMB_BIG_UINT count,offset;
+ uint64_t count,offset;
NTSTATUS status;
files_struct *fsp;
@@ -4494,16 +4490,16 @@ void reply_unlock(struct smb_request *req)
return;
}
- fsp = file_fsp(SVAL(req->inbuf,smb_vwv0));
+ fsp = file_fsp(req, SVAL(req->inbuf,smb_vwv0));
if (!check_fsp(conn, req, fsp)) {
END_PROFILE(SMBunlock);
return;
}
-
- count = (SMB_BIG_UINT)IVAL(req->inbuf,smb_vwv1);
- offset = (SMB_BIG_UINT)IVAL(req->inbuf,smb_vwv3);
-
+
+ count = (uint64_t)IVAL(req->inbuf,smb_vwv1);
+ offset = (uint64_t)IVAL(req->inbuf,smb_vwv3);
+
status = do_unlock(smbd_messaging_context(),
fsp,
req->smbpid,
@@ -4611,8 +4607,6 @@ void reply_echo(struct smb_request *req)
TALLOC_FREE(req->outbuf);
- smb_echo_count++;
-
END_PROFILE(SMBecho);
return;
}
@@ -4626,7 +4620,7 @@ void reply_printopen(struct smb_request *req)
connection_struct *conn = req->conn;
files_struct *fsp;
NTSTATUS status;
-
+
START_PROFILE(SMBsplopen);
if (req->wct < 2) {
@@ -4642,7 +4636,7 @@ void reply_printopen(struct smb_request *req)
}
/* Open for exclusive use, write only. */
- status = print_fsp_open(conn, NULL, req->vuid, &fsp);
+ status = print_fsp_open(req, conn, NULL, req->vuid, &fsp);
if (!NT_STATUS_IS_OK(status)) {
reply_nterror(req, status);
@@ -4652,7 +4646,7 @@ void reply_printopen(struct smb_request *req)
reply_outbuf(req, 1, 0);
SSVAL(req->outbuf,smb_vwv0,fsp->fnum);
-
+
DEBUG(3,("openprint fd=%d fnum=%d\n",
fsp->fh->fd, fsp->fnum));
@@ -4678,7 +4672,7 @@ void reply_printclose(struct smb_request *req)
return;
}
- fsp = file_fsp(SVAL(req->inbuf,smb_vwv0));
+ fsp = file_fsp(req, SVAL(req->inbuf,smb_vwv0));
if (!check_fsp(conn, req, fsp)) {
END_PROFILE(SMBsplclose);
@@ -4690,11 +4684,11 @@ void reply_printclose(struct smb_request *req)
END_PROFILE(SMBsplclose);
return;
}
-
+
DEBUG(3,("printclose fd=%d fnum=%d\n",
fsp->fh->fd,fsp->fnum));
-
- status = close_file(fsp,NORMAL_CLOSE);
+
+ status = close_file(req, fsp, NORMAL_CLOSE);
if(!NT_STATUS_IS_OK(status)) {
reply_nterror(req, status);
@@ -4744,7 +4738,7 @@ void reply_printqueue(struct smb_request *req)
SSVAL(req->outbuf,smb_vwv1,0);
SCVAL(smb_buf(req->outbuf),0,1);
SSVAL(smb_buf(req->outbuf),1,0);
-
+
DEBUG(3,("printqueue start_index=%d max_count=%d\n",
start_index, max_count));
@@ -4760,7 +4754,7 @@ void reply_printqueue(struct smb_request *req)
num_to_get = 0;
else
num_to_get = MIN(num_to_get,count-first);
-
+
for (i=first;i<first+num_to_get;i++) {
char blob[28];
@@ -4793,10 +4787,10 @@ void reply_printqueue(struct smb_request *req)
}
SAFE_FREE(queue);
-
+
DEBUG(3,("%d entries returned in queue\n",count));
}
-
+
END_PROFILE(SMBsplretq);
return;
}
@@ -4819,8 +4813,8 @@ void reply_printwrite(struct smb_request *req)
END_PROFILE(SMBsplwr);
return;
}
-
- fsp = file_fsp(SVAL(req->inbuf,smb_vwv0));
+
+ fsp = file_fsp(req, SVAL(req->inbuf,smb_vwv0));
if (!check_fsp(conn, req, fsp)) {
END_PROFILE(SMBsplwr);
@@ -5217,7 +5211,7 @@ static bool resolve_wildcards(TALLOC_CTX *ctx,
char *ext1 = NULL;
char *ext2 = NULL;
char *p,*p2, *pname1, *pname2;
-
+
name2_copy = talloc_strdup(ctx, name2);
if (!name2_copy) {
return False;
@@ -5229,7 +5223,7 @@ static bool resolve_wildcards(TALLOC_CTX *ctx,
if (!pname1 || !pname2) {
return False;
}
-
+
/* Truncate the copy of name2 at the last '/' */
*pname2 = '\0';
@@ -5583,10 +5577,10 @@ NTSTATUS rename_internals_fsp(connection_struct *conn,
DEBUG(3,("rename_internals_fsp: succeeded doing rename on %s -> %s\n",
fsp->fsp_name,newname));
- rename_open_files(conn, lck, newname);
-
notify_rename(conn, fsp->is_directory, fsp->fsp_name, newname);
+ rename_open_files(conn, lck, newname);
+
/*
* A rename acts as a new file create w.r.t. allowing an initial delete
* on close, probably because in Windows there is a new handle to the
@@ -5789,7 +5783,7 @@ NTSTATUS rename_internals(TALLOC_CTX *ctx,
last_component_dest,
attrs, replace_if_exists);
- close_file(fsp, NORMAL_CLOSE);
+ close_file(req, fsp, NORMAL_CLOSE);
DEBUG(3, ("rename_internals: Error %s rename %s -> %s\n",
nt_errstr(status), directory,newname));
@@ -5893,7 +5887,7 @@ NTSTATUS rename_internals(TALLOC_CTX *ctx,
status = rename_internals_fsp(conn, fsp, destname, dname,
attrs, replace_if_exists);
- close_file(fsp, NORMAL_CLOSE);
+ close_file(req, fsp, NORMAL_CLOSE);
if (!NT_STATUS_IS_OK(status)) {
DEBUG(3, ("rename_internals_fsp returned %s for "
@@ -6108,7 +6102,7 @@ NTSTATUS copy_file(TALLOC_CTX *ctx,
TALLOC_FREE(dest);
if (!NT_STATUS_IS_OK(status)) {
- close_file(fsp1,ERROR_CLOSE);
+ close_file(NULL, fsp1, ERROR_CLOSE);
return status;
}
@@ -6127,7 +6121,7 @@ NTSTATUS copy_file(TALLOC_CTX *ctx,
ret = vfs_transfer_file(fsp1, fsp2, src_sbuf.st_size);
}
- close_file(fsp1,NORMAL_CLOSE);
+ close_file(NULL, fsp1, NORMAL_CLOSE);
/* Ensure the modtime is set correctly on the destination file. */
set_close_write_time(fsp2, get_mtimespec(&src_sbuf));
@@ -6138,7 +6132,7 @@ NTSTATUS copy_file(TALLOC_CTX *ctx,
* Thus we don't look at the error return from the
* close of fsp1.
*/
- status = close_file(fsp2,NORMAL_CLOSE);
+ status = close_file(NULL, fsp2, NORMAL_CLOSE);
if (!NT_STATUS_IS_OK(status)) {
return status;
@@ -6502,17 +6496,17 @@ uint32 get_lock_pid( char *data, int data_offset, bool large_file_format)
Get a lock count, dealing with large count requests.
****************************************************************************/
-SMB_BIG_UINT get_lock_count( char *data, int data_offset, bool large_file_format)
+uint64_t get_lock_count( char *data, int data_offset, bool large_file_format)
{
- SMB_BIG_UINT count = 0;
+ uint64_t count = 0;
if(!large_file_format) {
- count = (SMB_BIG_UINT)IVAL(data,SMB_LKLEN_OFFSET(data_offset));
+ count = (uint64_t)IVAL(data,SMB_LKLEN_OFFSET(data_offset));
} else {
#if defined(HAVE_LONGLONG)
- count = (((SMB_BIG_UINT) IVAL(data,SMB_LARGE_LKLEN_OFFSET_HIGH(data_offset))) << 32) |
- ((SMB_BIG_UINT) IVAL(data,SMB_LARGE_LKLEN_OFFSET_LOW(data_offset)));
+ count = (((uint64_t) IVAL(data,SMB_LARGE_LKLEN_OFFSET_HIGH(data_offset))) << 32) |
+ ((uint64_t) IVAL(data,SMB_LARGE_LKLEN_OFFSET_LOW(data_offset)));
#else /* HAVE_LONGLONG */
/*
@@ -6529,7 +6523,7 @@ SMB_BIG_UINT get_lock_count( char *data, int data_offset, bool large_file_format
SIVAL(data,SMB_LARGE_LKLEN_OFFSET_HIGH(data_offset),0);
}
- count = (SMB_BIG_UINT)IVAL(data,SMB_LARGE_LKLEN_OFFSET_LOW(data_offset));
+ count = (uint64_t)IVAL(data,SMB_LARGE_LKLEN_OFFSET_LOW(data_offset));
#endif /* HAVE_LONGLONG */
}
@@ -6546,26 +6540,26 @@ static uint32 map_lock_offset(uint32 high, uint32 low)
unsigned int i;
uint32 mask = 0;
uint32 highcopy = high;
-
+
/*
* Try and find out how many significant bits there are in high.
*/
-
+
for(i = 0; highcopy; i++)
highcopy >>= 1;
-
+
/*
* We use 31 bits not 32 here as POSIX
* lock offsets may not be negative.
*/
-
+
mask = (~0) << (31 - i);
-
+
if(low & mask)
return 0; /* Fail. */
-
+
high <<= (31 - i);
-
+
return (high|low);
}
#endif /* !defined(HAVE_LONGLONG) */
@@ -6574,19 +6568,19 @@ static uint32 map_lock_offset(uint32 high, uint32 low)
Get a lock offset, dealing with large offset requests.
****************************************************************************/
-SMB_BIG_UINT get_lock_offset( char *data, int data_offset, bool large_file_format, bool *err)
+uint64_t get_lock_offset( char *data, int data_offset, bool large_file_format, bool *err)
{
- SMB_BIG_UINT offset = 0;
+ uint64_t offset = 0;
*err = False;
if(!large_file_format) {
- offset = (SMB_BIG_UINT)IVAL(data,SMB_LKOFF_OFFSET(data_offset));
+ offset = (uint64_t)IVAL(data,SMB_LKOFF_OFFSET(data_offset));
} else {
#if defined(HAVE_LONGLONG)
- offset = (((SMB_BIG_UINT) IVAL(data,SMB_LARGE_LKOFF_OFFSET_HIGH(data_offset))) << 32) |
- ((SMB_BIG_UINT) IVAL(data,SMB_LARGE_LKOFF_OFFSET_LOW(data_offset)));
+ offset = (((uint64_t) IVAL(data,SMB_LARGE_LKOFF_OFFSET_HIGH(data_offset))) << 32) |
+ ((uint64_t) IVAL(data,SMB_LARGE_LKOFF_OFFSET_LOW(data_offset)));
#else /* HAVE_LONGLONG */
/*
@@ -6595,7 +6589,7 @@ SMB_BIG_UINT get_lock_offset( char *data, int data_offset, bool large_file_forma
* negotiated. For boxes without large unsigned ints mangle the
* lock offset by mapping the top 32 bits onto the lower 32.
*/
-
+
if(IVAL(data,SMB_LARGE_LKOFF_OFFSET_HIGH(data_offset)) != 0) {
uint32 low = IVAL(data,SMB_LARGE_LKOFF_OFFSET_LOW(data_offset));
uint32 high = IVAL(data,SMB_LARGE_LKOFF_OFFSET_HIGH(data_offset));
@@ -6603,7 +6597,7 @@ SMB_BIG_UINT get_lock_offset( char *data, int data_offset, bool large_file_forma
if((new_low = map_lock_offset(high, low)) == 0) {
*err = True;
- return (SMB_BIG_UINT)-1;
+ return (uint64_t)-1;
}
DEBUG(3,("get_lock_offset: truncating lock offset (high)0x%x (low)0x%x to offset 0x%x.\n",
@@ -6612,7 +6606,7 @@ SMB_BIG_UINT get_lock_offset( char *data, int data_offset, bool large_file_forma
SIVAL(data,SMB_LARGE_LKOFF_OFFSET_LOW(data_offset),new_low);
}
- offset = (SMB_BIG_UINT)IVAL(data,SMB_LARGE_LKOFF_OFFSET_LOW(data_offset));
+ offset = (uint64_t)IVAL(data,SMB_LARGE_LKOFF_OFFSET_LOW(data_offset));
#endif /* HAVE_LONGLONG */
}
@@ -6631,7 +6625,7 @@ void reply_lockingX(struct smb_request *req)
unsigned char oplocklevel;
uint16 num_ulocks;
uint16 num_locks;
- SMB_BIG_UINT count = 0, offset = 0;
+ uint64_t count = 0, offset = 0;
uint32 lock_pid;
int32 lock_timeout;
int i;
@@ -6647,8 +6641,8 @@ void reply_lockingX(struct smb_request *req)
END_PROFILE(SMBlockingX);
return;
}
-
- fsp = file_fsp(SVAL(req->inbuf,smb_vwv2));
+
+ fsp = file_fsp(req, SVAL(req->inbuf,smb_vwv2));
locktype = CVAL(req->inbuf,smb_vwv3);
oplocklevel = CVAL(req->inbuf,smb_vwv3+1);
num_ulocks = SVAL(req->inbuf,smb_vwv6);
@@ -6660,7 +6654,7 @@ void reply_lockingX(struct smb_request *req)
END_PROFILE(SMBlockingX);
return;
}
-
+
data = smb_buf(req->inbuf);
if (locktype & LOCKING_ANDX_CHANGE_LOCKTYPE) {
@@ -6671,7 +6665,7 @@ void reply_lockingX(struct smb_request *req)
END_PROFILE(SMBlockingX);
return;
}
-
+
/* Check if this is an oplock break on a file
we have granted an oplock on.
*/
@@ -6688,7 +6682,7 @@ void reply_lockingX(struct smb_request *req)
* Make sure we have granted an exclusive or batch oplock on
* this file.
*/
-
+
if (fsp->oplock_type == 0) {
/* The Samba4 nbench simulator doesn't understand
@@ -6720,7 +6714,7 @@ void reply_lockingX(struct smb_request *req)
} else {
result = downgrade_oplock(fsp);
}
-
+
if (!result) {
DEBUG(0, ("reply_lockingX: error in removing "
"oplock on file %s\n", fsp->fsp_name));
@@ -6749,7 +6743,7 @@ void reply_lockingX(struct smb_request *req)
* We do this check *after* we have checked this is not a oplock break
* response message. JRA.
*/
-
+
release_level_2_oplocks_on_change(fsp);
if (smb_buflen(req->inbuf) <
@@ -6758,14 +6752,14 @@ void reply_lockingX(struct smb_request *req)
END_PROFILE(SMBlockingX);
return;
}
-
+
/* Data now points at the beginning of the list
of smb_unlkrng structs */
for(i = 0; i < (int)num_ulocks; i++) {
lock_pid = get_lock_pid( data, i, large_file_format);
count = get_lock_count( data, i, large_file_format);
offset = get_lock_offset( data, i, large_file_format, &err);
-
+
/*
* There is no error code marked "stupid client bug".... :-).
*/
@@ -6778,7 +6772,7 @@ void reply_lockingX(struct smb_request *req)
DEBUG(10,("reply_lockingX: unlock start=%.0f, len=%.0f for "
"pid %u, file %s\n", (double)offset, (double)count,
(unsigned int)lock_pid, fsp->fsp_name ));
-
+
status = do_unlock(smbd_messaging_context(),
fsp,
lock_pid,
@@ -6798,20 +6792,20 @@ void reply_lockingX(struct smb_request *req)
if (!lp_blocking_locks(SNUM(conn))) {
lock_timeout = 0;
}
-
+
/* Now do any requested locks */
data += ((large_file_format ? 20 : 10)*num_ulocks);
-
+
/* Data now points at the beginning of the list
of smb_lkrng structs */
-
+
for(i = 0; i < (int)num_locks; i++) {
enum brl_type lock_type = ((locktype & LOCKING_ANDX_SHARED_LOCK) ?
READ_LOCK:WRITE_LOCK);
lock_pid = get_lock_pid( data, i, large_file_format);
count = get_lock_count( data, i, large_file_format);
offset = get_lock_offset( data, i, large_file_format, &err);
-
+
/*
* There is no error code marked "stupid client bug".... :-).
*/
@@ -6820,12 +6814,12 @@ void reply_lockingX(struct smb_request *req)
reply_doserror(req, ERRDOS, ERRnoaccess);
return;
}
-
+
DEBUG(10,("reply_lockingX: lock start=%.0f, len=%.0f for pid "
"%u, file %s timeout = %d\n", (double)offset,
(double)count, (unsigned int)lock_pid,
fsp->fsp_name, (int)lock_timeout ));
-
+
if (locktype & LOCKING_ANDX_CANCEL_LOCK) {
if (lp_blocking_locks(SNUM(conn))) {
@@ -6924,7 +6918,7 @@ void reply_lockingX(struct smb_request *req)
return;
}
}
-
+
/* If any of the above locks failed, then we must unlock
all of the previous locks (X/Open spec). */
@@ -6941,7 +6935,7 @@ void reply_lockingX(struct smb_request *req)
count = get_lock_count( data, i, large_file_format);
offset = get_lock_offset( data, i, large_file_format,
&err);
-
+
/*
* There is no error code marked "stupid client
* bug".... :-).
@@ -6951,7 +6945,7 @@ void reply_lockingX(struct smb_request *req)
reply_doserror(req, ERRDOS, ERRnoaccess);
return;
}
-
+
do_unlock(smbd_messaging_context(),
fsp,
lock_pid,
@@ -6965,10 +6959,10 @@ void reply_lockingX(struct smb_request *req)
}
reply_outbuf(req, 2, 0);
-
+
DEBUG(3, ("lockingX fnum=%d type=%d num_locks=%d num_ulocks=%d\n",
fsp->fnum, (unsigned int)locktype, num_locks, num_ulocks));
-
+
END_PROFILE(SMBlockingX);
chain_reply(req);
}
@@ -7024,7 +7018,7 @@ void reply_setattrE(struct smb_request *req)
return;
}
- fsp = file_fsp(SVAL(req->inbuf,smb_vwv0));
+ fsp = file_fsp(req, SVAL(req->inbuf,smb_vwv0));
if(!fsp || (fsp->conn != conn)) {
reply_doserror(req, ERRDOS, ERRbadfid);
@@ -7042,7 +7036,7 @@ void reply_setattrE(struct smb_request *req)
srv_make_unix_date2(req->inbuf+smb_vwv3)); /* atime. */
ts[1] = convert_time_t_to_timespec(
srv_make_unix_date2(req->inbuf+smb_vwv5)); /* mtime. */
-
+
reply_outbuf(req, 0, 0);
/*
@@ -7074,7 +7068,7 @@ void reply_setattrE(struct smb_request *req)
END_PROFILE(SMBsetattrE);
return;
}
-
+
DEBUG( 3, ( "reply_setattrE fnum=%d actime=%u modtime=%u\n",
fsp->fnum,
(unsigned int)ts[0].tv_sec,
@@ -7135,7 +7129,7 @@ void reply_getattrE(struct smb_request *req)
return;
}
- fsp = file_fsp(SVAL(req->inbuf,smb_vwv0));
+ fsp = file_fsp(req, SVAL(req->inbuf,smb_vwv0));
if(!fsp || (fsp->conn != conn)) {
reply_doserror(req, ERRDOS, ERRbadfid);
@@ -7149,9 +7143,9 @@ void reply_getattrE(struct smb_request *req)
END_PROFILE(SMBgetattrE);
return;
}
-
+
mode = dos_mode(conn,fsp->fsp_name,&sbuf);
-
+
/*
* Convert the times into dos times. Set create
* date to be last modify date as UNIX doesn't save
@@ -7176,9 +7170,9 @@ void reply_getattrE(struct smb_request *req)
SIVAL(req->outbuf, smb_vwv8, allocation_size);
}
SSVAL(req->outbuf,smb_vwv10, mode);
-
+
DEBUG( 3, ( "reply_getattrE fnum=%d\n", fsp->fnum));
-
+
END_PROFILE(SMBgetattrE);
return;
}