Change default file permissions on Unix to 666 (#7995)
authorStephen Toub <stoub@microsoft.com>
Sat, 5 Nov 2016 18:36:00 +0000 (14:36 -0400)
committerJan Kotas <jkotas@microsoft.com>
Sat, 5 Nov 2016 18:36:00 +0000 (11:36 -0700)
src/mscorlib/corefx/System/IO/FileStream.Unix.cs

index aad3b46..ece1923 100644 (file)
@@ -47,17 +47,17 @@ namespace System.IO
             // Translate the arguments into arguments for an open call.
             Interop.Sys.OpenFlags openFlags = PreOpenConfigurationFromOptions(mode, _access, options); // FileShare currently ignored
 
-            // If the file gets created a new, we'll select the permissions for it.  Most utilities by default use 666 (read and 
-            // write for all). However, on Windows it's possible to write out a file and then execute it.  To maintain that similarity, 
-            // we use 766, so that in addition the user has execute privileges. No matter what we choose, it'll be subject to the umask 
-            // applied by the system, such that the actual permissions will typically be less than what we select here.
-            const Interop.Sys.Permissions openPermissions =
-                Interop.Sys.Permissions.S_IRWXU |
+            // If the file gets created a new, we'll select the permissions for it.  Most Unix utilities by default use 666 (read and 
+            // write for all), so we do the same (even though this doesn't match Windows, where by default it's possible to write out
+            // a file and then execute it). No matter what we choose, it'll be subject to the umask applied by the system, such that the
+            // actual permissions will typically be less than what we select here.
+            const Interop.Sys.Permissions OpenPermissions =
+                Interop.Sys.Permissions.S_IRUSR | Interop.Sys.Permissions.S_IWUSR |
                 Interop.Sys.Permissions.S_IRGRP | Interop.Sys.Permissions.S_IWGRP |
                 Interop.Sys.Permissions.S_IROTH | Interop.Sys.Permissions.S_IWOTH;
 
             // Open the file and store the safe handle.
-            return SafeFileHandle.Open(_path, openFlags, (int)openPermissions);
+            return SafeFileHandle.Open(_path, openFlags, (int)OpenPermissions);
         }
 
         /// <summary>Initializes a stream for reading or writing a Unix file.</summary>