// 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>