local.h: Fix spelling mistake :-).
[kai/samba.git] / source3 / smbd / reply.c
index 1a896aa02aa31921eba8a50f77ed16966bdd76ce..baccb76291146b9714eb1d8bab6ca6c46b8f5c7a 100644 (file)
@@ -252,7 +252,7 @@ int reply_tcon_and_X(char *inbuf,char *outbuf,int length,int bufsize)
   if ((SVAL(inbuf,smb_vwv2) & 0x1) != 0)
     close_cnum(SVAL(inbuf,smb_tid),vuid);
 
-  if (passlen > MAX_PASSWORD_LENGTH) {
+  if (passlen > MAX_PASS_LEN) {
          overflow_attack(passlen);
   }
   
@@ -388,7 +388,7 @@ int reply_sesssetup_and_X(char *inbuf,char *outbuf,int length,int bufsize)
 
   if (Protocol < PROTOCOL_NT1) {
     smb_apasslen = SVAL(inbuf,smb_vwv7);
-    if (smb_apasslen > MAX_PASSWORD_LENGTH)
+    if (smb_apasslen > MAX_PASS_LEN)
     {
            overflow_attack(smb_apasslen);
     }
@@ -423,12 +423,12 @@ int reply_sesssetup_and_X(char *inbuf,char *outbuf,int length,int bufsize)
     if (passlen1 != 24 && passlen2 != 24)
       doencrypt = False;
 
-    if (passlen1 > MAX_PASSWORD_LENGTH) {
+    if (passlen1 > MAX_PASS_LEN) {
            overflow_attack(passlen1);
     }
 
-    passlen1 = MIN(passlen1, MAX_PASSWORD_LENGTH);
-    passlen2 = MIN(passlen2, MAX_PASSWORD_LENGTH);
+    passlen1 = MIN(passlen1, MAX_PASS_LEN);
+    passlen2 = MIN(passlen2, MAX_PASS_LEN);
 
     if(doencrypt) {
       /* Save the lanman2 password and the NT md4 password. */
@@ -599,7 +599,7 @@ int reply_sesssetup_and_X(char *inbuf,char *outbuf,int length,int bufsize)
   if (!done_sesssetup)
     max_send = MIN(max_send,smb_bufsize);
 
-  DEBUG(1,(" Client requested max send size of %d\n", max_send));
+  DEBUG(6,("Client requested max send size of %d\n", max_send));
 
   done_sesssetup = True;
 
@@ -640,6 +640,17 @@ int reply_chkpth(char *inbuf,char *outbuf)
       unix_ERR_class = ERRDOS;
       unix_ERR_code = ERRbadpath;
     }
+
+#if 0
+    /* Ugly - NT specific hack - maybe not needed ? (JRA) */
+    if((errno == ENOTDIR) && (Protocol >= PROTOCOL_NT1) &&
+       (get_remote_arch() == RA_WINNT))
+    {
+      unix_ERR_class = ERRDOS;
+      unix_ERR_code = ERRbaddirectory;
+    }
+#endif
+
     return(UNIXERROR(ERRDOS,ERRbadpath));
   }
  
@@ -1612,7 +1623,6 @@ int reply_readbraw(char *inbuf, char *outbuf)
   int fd;
   char *fname;
 
-#ifdef USE_OPLOCKS
   /*
    * Special check if an oplock break has been issued
    * and the readraw request croses on the wire, we must
@@ -1626,7 +1636,6 @@ int reply_readbraw(char *inbuf, char *outbuf)
     DEBUG(5,("readbraw - oplock break finished\n"));
     return -1;
   }
-#endif
 
   cnum = SVAL(inbuf,smb_tid);
   fnum = GETFNUM(inbuf,smb_vwv0);
@@ -3364,7 +3373,7 @@ int reply_lockingX(char *inbuf,char *outbuf,int length,int bufsize)
   unsigned char locktype = CVAL(inbuf,smb_vwv3);
 #if 0
   unsigned char oplocklevel = CVAL(inbuf,smb_vwv3+1);
-#endif /* USE_OPLOCKS */
+#endif
   uint16 num_ulocks = SVAL(inbuf,smb_vwv6);
   uint16 num_locks = SVAL(inbuf,smb_vwv7);
   uint32 count, offset;
@@ -3382,7 +3391,6 @@ int reply_lockingX(char *inbuf,char *outbuf,int length,int bufsize)
 
   data = smb_buf(inbuf);
 
-#ifdef USE_OPLOCKS
   /* Check if this is an oplock break on a file
      we have granted an oplock on.
    */
@@ -3390,25 +3398,39 @@ int reply_lockingX(char *inbuf,char *outbuf,int length,int bufsize)
      (num_ulocks == 0) && (num_locks == 0) &&
      (CVAL(inbuf,smb_vwv0) == 0xFF))
   {
+    share_lock_token token;
+    files_struct *fsp = &Files[fnum];
+    uint32 dev = fsp->fd_ptr->dev;
+    uint32 inode = fsp->fd_ptr->inode;
+
     DEBUG(5,("reply_lockingX: oplock break reply from client for fnum = %d\n",
               fnum));
     /*
      * Make sure we have granted an oplock on this file.
      */
-    if(!Files[fnum].granted_oplock)
+    if(!fsp->granted_oplock)
     {
       DEBUG(0,("reply_lockingX: Error : oplock break from client for fnum = %d and \
-oplock granted on this file.\n", fnum));
+no oplock granted on this file.\n", fnum));
       return ERROR(ERRDOS,ERRlock);
     }
 
-    /* Just clear the granted flag and return. oplock_break()
-       will handle changing the share_mode_entry. */
+    /* Remove the oplock flag from the sharemode. */
+    lock_share_entry(fsp->cnum, dev, inode, &token);
+    if(remove_share_oplock( fnum, token)==False)
+    {
+      DEBUG(0,("reply_lockingX: failed to remove share oplock for fnum %d, \
+dev = %x, inode = %x\n", fnum, dev, inode));
+      unlock_share_entry(fsp->cnum, dev, inode, token);
+      return -1;
+    }
+    unlock_share_entry(fsp->cnum, dev, inode, token);
+
+    /* Clear the granted flag and return. */
 
-    Files[fnum].granted_oplock = 0;
+    fsp->granted_oplock = False;
     return -1;
   }
-#endif /* USE_OPLOCKS */
 
   /* Data now points at the beginning of the list
      of smb_unlkrng structs */