summaryrefslogtreecommitdiff
path: root/source3/smbd
diff options
context:
space:
mode:
Diffstat (limited to 'source3/smbd')
-rw-r--r--source3/smbd/nttrans.c12
-rw-r--r--source3/smbd/reply.c27
-rw-r--r--source3/smbd/server.c16
3 files changed, 35 insertions, 20 deletions
diff --git a/source3/smbd/nttrans.c b/source3/smbd/nttrans.c
index 672e2c0802..9b6cfe1621 100644
--- a/source3/smbd/nttrans.c
+++ b/source3/smbd/nttrans.c
@@ -620,12 +620,12 @@ int reply_ntcreate_and_X(char *inbuf,char *outbuf,int length,int bufsize)
p += 8;
SIVAL(p,0,fmode); /* File Attributes. */
p += 12;
- if(sizeof(off_t) == 8) {
+#if OFF_T_IS_64_BITS
SIVAL(p,0, file_len & 0xFFFFFFFF);
SIVAL(p,4, file_len >> 32);
- } else {
+#else /* OFF_T_IS_64_BITS */
SIVAL(p,0,file_len);
- }
+#endif /* OFF_T_IS_64_BITS */
p += 12;
SCVAL(p,0,fsp->is_directory ? 1 : 0);
}
@@ -822,12 +822,12 @@ static int call_nt_transact_create(char *inbuf, char *outbuf, int length,
p += 8;
SIVAL(p,0,fmode); /* File Attributes. */
p += 12;
- if(sizeof(off_t) == 8) {
+#if OFF_T_IS_64_BITS
SIVAL(p,0, file_len & 0xFFFFFFFF);
SIVAL(p,4, (file_len >> 32));
- } else {
+#else /* OFF_T_IS_64_BITS */
SIVAL(p,0,file_len);
- }
+#endif /* OFF_T_IS_64_BITS */
}
/* Send the required number of replies */
diff --git a/source3/smbd/reply.c b/source3/smbd/reply.c
index f6fd2ccd90..35189883e2 100644
--- a/source3/smbd/reply.c
+++ b/source3/smbd/reply.c
@@ -1858,7 +1858,7 @@ int reply_readbraw(char *inbuf, char *outbuf, int dum_size, int dum_buffsize)
}
- if (!is_locked(fnum,cnum,maxcount,startpos))
+ if (!is_locked(fnum,cnum,maxcount,startpos, F_RDLCK))
{
int size = Files[fnum].size;
int sizeneeded = startpos + maxcount;
@@ -1943,7 +1943,7 @@ int reply_lockread(char *inbuf,char *outbuf, int dum_size, int dum_buffsiz)
numtoread = MIN(BUFFER_SIZE-outsize,numtoread);
data = smb_buf(outbuf) + 3;
- if(!do_lock( fnum, cnum, numtoread, startpos, &eclass, &ecode))
+ if(!do_lock( fnum, cnum, numtoread, startpos, F_RDLCK, &eclass, &ecode))
return (ERROR(eclass,ecode));
nread = read_file(fnum,data,startpos,numtoread);
@@ -1987,7 +1987,7 @@ int reply_read(char *inbuf,char *outbuf, int dum_size, int dum_buffsize)
numtoread = MIN(BUFFER_SIZE-outsize,numtoread);
data = smb_buf(outbuf) + 3;
- if (is_locked(fnum,cnum,numtoread,startpos))
+ if (is_locked(fnum,cnum,numtoread,startpos, F_RDLCK))
return(ERROR(ERRDOS,ERRlock));
if (numtoread > 0)
@@ -2035,7 +2035,7 @@ int reply_read_and_X(char *inbuf,char *outbuf,int length,int bufsize)
set_message(outbuf,12,0,True);
data = smb_buf(outbuf);
- if (is_locked(fnum,cnum,smb_maxcnt,smb_offs))
+ if (is_locked(fnum,cnum,smb_maxcnt,smb_offs, F_RDLCK))
return(ERROR(ERRDOS,ERRlock));
nread = read_file(fnum,data,smb_offs,smb_maxcnt);
ok = True;
@@ -2097,7 +2097,7 @@ int reply_writebraw(char *inbuf,char *outbuf, int dum_size, int dum_buffsize)
CVAL(inbuf,smb_com) = SMBwritec;
CVAL(outbuf,smb_com) = SMBwritec;
- if (is_locked(fnum,cnum,tcount,startpos))
+ if (is_locked(fnum,cnum,tcount,startpos, F_WRLCK))
return(ERROR(ERRDOS,ERRlock));
if (seek_file(fnum,startpos) != startpos)
@@ -2188,7 +2188,7 @@ int reply_writeunlock(char *inbuf,char *outbuf, int dum_size, int dum_buffsize)
startpos = IVAL(inbuf,smb_vwv2);
data = smb_buf(inbuf) + 3;
- if (is_locked(fnum,cnum,numtowrite,startpos))
+ if (is_locked(fnum,cnum,numtowrite,startpos, F_WRLCK))
return(ERROR(ERRDOS,ERRlock));
seek_file(fnum,startpos);
@@ -2243,7 +2243,7 @@ int reply_write(char *inbuf,char *outbuf,int dum_size,int dum_buffsize)
startpos = IVAL(inbuf,smb_vwv2);
data = smb_buf(inbuf) + 3;
- if (is_locked(fnum,cnum,numtowrite,startpos))
+ if (is_locked(fnum,cnum,numtowrite,startpos, F_WRLCK))
return(ERROR(ERRDOS,ERRlock));
seek_file(fnum,startpos);
@@ -2299,7 +2299,7 @@ int reply_write_and_X(char *inbuf,char *outbuf,int length,int bufsize)
data = smb_base(inbuf) + smb_doff;
- if (is_locked(fnum,cnum,smb_dsize,smb_offs))
+ if (is_locked(fnum,cnum,smb_dsize,smb_offs, F_WRLCK))
return(ERROR(ERRDOS,ERRlock));
seek_file(fnum,smb_offs);
@@ -2512,7 +2512,7 @@ int reply_writeclose(char *inbuf,char *outbuf, int dum_size, int dum_buffsize)
mtime = make_unix_date3(inbuf+smb_vwv4);
data = smb_buf(inbuf) + 1;
- if (is_locked(fnum,cnum,numtowrite,startpos))
+ if (is_locked(fnum,cnum,numtowrite,startpos, F_WRLCK))
return(ERROR(ERRDOS,ERRlock));
seek_file(fnum,startpos);
@@ -2559,7 +2559,7 @@ int reply_lock(char *inbuf,char *outbuf, int dum_size, int dum_buffsize)
DEBUG(3,("%s lock fd=%d fnum=%d cnum=%d ofs=%d cnt=%d\n",timestring(),Files[fnum].fd_ptr->fd,fnum,cnum,offset,count));
- if(!do_lock( fnum, cnum, count, offset, &eclass, &ecode))
+ if(!do_lock( fnum, cnum, count, offset, F_WRLCK, &eclass, &ecode))
return (ERROR(eclass,ecode));
return(outsize);
@@ -3729,7 +3729,8 @@ dev = %x, inode = %x\n",
for(i = 0; i < (int)num_locks; i++) {
count = IVAL(data,SMB_LKLEN_OFFSET(i));
offset = IVAL(data,SMB_LKOFF_OFFSET(i));
- if(!do_lock(fnum,cnum,count,offset, &eclass, &ecode))
+ if(!do_lock(fnum,cnum,count,offset, ((locktype & 1) ? F_RDLCK : F_WRLCK),
+ &eclass, &ecode))
break;
}
@@ -3796,7 +3797,7 @@ int reply_readbmpx(char *inbuf,char *outbuf,int length,int bufsize)
tcount = maxcount;
total_read = 0;
- if (is_locked(fnum,cnum,maxcount,startpos))
+ if (is_locked(fnum,cnum,maxcount,startpos, F_RDLCK))
return(ERROR(ERRDOS,ERRlock));
do
@@ -3858,7 +3859,7 @@ int reply_writebmpx(char *inbuf,char *outbuf, int dum_size, int dum_buffsize)
not an SMBwritebmpx - set this up now so we don't forget */
CVAL(outbuf,smb_com) = SMBwritec;
- if (is_locked(fnum,cnum,tcount,startpos))
+ if (is_locked(fnum,cnum,tcount,startpos,F_WRLCK))
return(ERROR(ERRDOS,ERRlock));
seek_file(fnum,startpos);
diff --git a/source3/smbd/server.c b/source3/smbd/server.c
index 9df2ed37bb..62ee75db0a 100644
--- a/source3/smbd/server.c
+++ b/source3/smbd/server.c
@@ -1948,7 +1948,7 @@ static void truncate_unless_locked(int fnum, int cnum, int token,
BOOL *share_locked)
{
if (Files[fnum].can_write){
- if (is_locked(fnum,cnum,0x3FFFFFFF,0)){
+ if (is_locked(fnum,cnum,0x3FFFFFFF,0,F_WRLCK)){
/* If share modes are in force for this connection we
have the share entry locked. Unlock it before closing. */
if (*share_locked && lp_share_modes(SNUM(cnum)))
@@ -2861,6 +2861,20 @@ max can be %d\n", num_interfaces, FD_SETSIZE));
return True;
}
close(Client); /* The parent doesn't need this socket */
+
+ /*
+ * Force parent to check log size after spawning child.
+ * Fix from klausr@ITAP.Physik.Uni-Stuttgart.De.
+ * The parent smbd will log to logserver.smb.
+ * It writes only two messages for each child
+ * started/finished. But each child writes, say, 50 messages also in
+ * logserver.smb, begining with the debug_count of the parent, before the
+ * child opens its own log file logserver.client. In a worst case
+ * scenario the size of logserver.smb would be checked after about
+ * 50*50=2500 messages (ca. 100kb).
+ */
+ force_check_log_size();
+
#endif /* NO_FORK_DEBUG */
} /* end for num */
} /* end while 1 */