You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Allow Foundation to create file with permissions respects process umask
**Problem**
`Data.write(to:)` is a only method in the Foundation that can create a
regular file.
However, it ignores `uamask` and always set 0600 permission unlike
macOS Foundation, which respects process `umask`.
**Solution**
1. With `.atomic` write option
It uses `mkstemp(3)` in `_NSCreateTemporaryFile`, which is always
creating a file with 0600 permission, if the system follows
the latest POSIX specification or the permission is undefined.
On macOS Foundation, therefore `_NSCreateTemporaryFile` uses
`mktemp(3)` and `open(2)` instead to respect `umask`.
2. Without `.atomic` write option
It uses `0o600` even if it uses `open(2)` that respects `umask`.
Simply gives `0o666` instead.
This is a bug caused by previous commit in
swiftlang#1876.
JIRA: https://bugs.swift.org/browse/SR-13307
0 commit comments