Fixed deny mode bug :
authorJeremy Allison <jra@samba.org>
Sat, 8 Jan 2000 01:23:13 +0000 (01:23 +0000)
committerJeremy Allison <jra@samba.org>
Sat, 8 Jan 2000 01:23:13 +0000 (01:23 +0000)
: If a file is resident on NT and the first user opens it read/write with DENY_READ then a subsequent
: attempt by a second user (running under Windows 95) to open it read/write DENY_NONE fails.
: Under samba 2.0.5a the second open succeeds but the file is write only.
Jeremy.
(This used to be commit 974af581fe428fd0233c2516b16a5132b0e1b583)

source3/smbd/open.c

index a940eda85d89ab9e76be0e38aef351f9e81cf04d..2e4f54e40f1e2e6800211f922742c310f0118bc9 100644 (file)
@@ -631,7 +631,7 @@ static int access_table(int new_deny,int old_deny,int old_mode,
     if (old_deny == new_deny && share_pid == pid) 
        return(AALL);    
 
-    if (old_mode == 0) return(AREAD);
+    if (old_mode == DOS_OPEN_RDONLY) return(AREAD);
 
     /* the new smbpub.zip spec says that if the file extension is
        .com, .dll, .exe or .sym then allow the open. I will force
@@ -651,14 +651,14 @@ static int access_table(int new_deny,int old_deny,int old_mode,
   switch (new_deny) 
     {
     case DENY_WRITE:
-      if (old_deny==DENY_WRITE && old_mode==0) return(AREAD);
-      if (old_deny==DENY_READ && old_mode==0) return(AWRITE);
-      if (old_deny==DENY_NONE && old_mode==0) return(AALL);
+      if (old_deny==DENY_WRITE && old_mode==DOS_OPEN_RDONLY) return(AREAD);
+      if (old_deny==DENY_READ && old_mode==DOS_OPEN_RDONLY) return(AWRITE);
+      if (old_deny==DENY_NONE && old_mode==DOS_OPEN_RDONLY) return(AALL);
       return(AFAIL);
     case DENY_READ:
-      if (old_deny==DENY_WRITE && old_mode==1) return(AREAD);
-      if (old_deny==DENY_READ && old_mode==1) return(AWRITE);
-      if (old_deny==DENY_NONE && old_mode==1) return(AALL);
+      if (old_deny==DENY_WRITE && old_mode==DOS_OPEN_WRONLY) return(AREAD);
+      if (old_deny==DENY_READ && old_mode==DOS_OPEN_WRONLY) return(AWRITE);
+      if (old_deny==DENY_NONE && old_mode==DOS_OPEN_WRONLY) return(AALL);
       return(AFAIL);
     case DENY_NONE:
       if (old_deny==DENY_WRITE) return(AREAD);
@@ -711,8 +711,8 @@ static int check_share_mode( share_mode_entry *share, int deny_mode,
 
     if ((access_allowed == AFAIL) ||
         (!fcbopen && (access_allowed == AREAD && *flags == O_RDWR)) ||
-        (access_allowed == AREAD && *flags == O_WRONLY) ||
-        (access_allowed == AWRITE && *flags == O_RDONLY))
+        (access_allowed == AREAD && *flags != O_RDONLY) ||
+        (access_allowed == AWRITE && *flags != O_WRONLY))
     {
       DEBUG(2,("Share violation on file (%d,%d,%d,%d,%s,fcbopen = %d, flags = %d) = %d\n",
                 deny_mode,old_deny_mode,old_open_mode,