]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
Fix bug #6421 - POSIX read-only open fails on read-only shares. The change to smbd...
authorJeremy Allison <jra@samba.org>
Sat, 30 May 2009 20:28:03 +0000 (13:28 -0700)
committerKarolin Seeger <kseeger@samba.org>
Wed, 17 Jun 2009 08:46:35 +0000 (10:46 +0200)
(cherry picked from commit 79f26472b4ae561ec00c30f31dd63ccab6dfc0c4)

source/smbd/open.c
source/smbd/trans2.c

index 535abcc26d61a112265f7b9dc63ad93e4dd832a8..8f45aabf6bbed99a83e45fcf02afa727cd1f711f 100644 (file)
@@ -250,7 +250,7 @@ static NTSTATUS open_file(files_struct *fsp,
 
        if (!CAN_WRITE(conn)) {
                /* It's a read-only share - fail if we wanted to write. */
-               if(accmode != O_RDONLY) {
+               if(accmode != O_RDONLY || (flags & O_TRUNC) || (flags & O_APPEND)) {
                        DEBUG(3,("Permission denied opening %s\n", path));
                        return NT_STATUS_ACCESS_DENIED;
                } else if(flags & O_CREAT) {
@@ -258,8 +258,8 @@ static NTSTATUS open_file(files_struct *fsp,
                           O_CREAT doesn't create the file if we have write
                           access into the directory.
                        */
-                       flags &= ~O_CREAT;
-                       local_flags &= ~O_CREAT;
+                       flags &= ~(O_CREAT|O_EXCL);
+                       local_flags &= ~(O_CREAT|O_EXCL);
                }
        }
 
index 25b0c1304b2bf6ac2cd29f88b6f2a468794a99b9..4aa61d1cf5d18c7e75d7d8e7e18f0f83804cb4d0 100644 (file)
@@ -6756,16 +6756,20 @@ static void call_trans2setfilepathinfo(connection_struct *conn,
                }
        }
 
-       if (!CAN_WRITE(conn)) {
-               reply_doserror(req, ERRSRV, ERRaccess);
-               return;
-       }
-
        if (INFO_LEVEL_IS_UNIX(info_level) && !lp_unix_extensions()) {
                reply_nterror(req, NT_STATUS_INVALID_LEVEL);
                return;
        }
 
+       if (!CAN_WRITE(conn)) {
+               /* Allow POSIX opens. The open path will deny
+                * any non-readonly opens. */
+               if (info_level != SMB_POSIX_PATH_OPEN) {
+                       reply_doserror(req, ERRSRV, ERRaccess);
+                       return;
+               }
+       }
+
        DEBUG(3,("call_trans2setfilepathinfo(%d) %s (fnum %d) info_level=%d totdata=%d\n",
                tran_call,fname, fsp ? fsp->fnum : -1, info_level,total_data));