a cleanup of the receive_smb() usage, adding timeouts in some places
[samba.git] / source3 / smbd / reply.c
index b5fa86a8d7d2cb9d3d26c2cfb3cfab98c32268c1..4cfa001ec2144b3567e4fe833f7ca7dec62b8902 100644 (file)
@@ -25,7 +25,6 @@
 
 
 #include "includes.h"
-#include "loadparm.h"
 #include "trans2.h"
 
 /* look in server.c for some explanation of these variables */
@@ -1181,7 +1180,9 @@ static BOOL can_delete(char *fname,int cnum,int dirtype)
   if (sys_lstat(fname,&sbuf) != 0) return(False);
   fmode = dos_mode(cnum,fname,&sbuf);
   if (fmode & aDIR) return(False);
-  if (fmode & aRONLY) return(False);
+  if (!lp_delete_readonly(SNUM(cnum))) {
+    if (fmode & aRONLY) return(False);
+  }
   if ((fmode & ~dirtype) & (aHIDDEN | aSYSTEM))
     return(False);
   if (!check_file_sharing(cnum,fname)) return(False);
@@ -1589,7 +1590,7 @@ int reply_writebraw(char *inbuf,char *outbuf)
   send_smb(Client,outbuf);
   
   /* Now read the raw data into the buffer and write it */
-  if(read_smb_length(Client,inbuf,0) == -1) {
+  if (read_smb_length(Client,inbuf,SMB_SECONDARY_WAIT) == -1) {
     exit_server("secondary writebraw failed");
   }
   
@@ -1926,11 +1927,11 @@ int reply_close(char *inbuf,char *outbuf)
 
   mtime = make_unix_date3(inbuf+smb_vwv1);
 
-  close_file(fnum);
-
   /* try and set the date */
   set_filetime(Files[fnum].name,mtime);
 
+  close_file(fnum);
+
   /* We have a cached error */
   if(eclass || err)
     return(ERROR(eclass,err));
@@ -1974,10 +1975,10 @@ int reply_writeclose(char *inbuf,char *outbuf)
       
   nwritten = write_file(fnum,data,numtowrite);
 
-  close_file(fnum);
-
   set_filetime(Files[fnum].name,mtime);
   
+  close_file(fnum);
+
   DEBUG(3,("%s writeclose fnum=%d cnum=%d num=%d wrote=%d (numopen=%d)\n",
           timestring(),fnum,cnum,numtowrite,nwritten,
           Connections[cnum].num_files_open));