Open niw opened 4 years ago
Probably this is a bug introduced by
https://github.com/apple/swift-corelibs-foundation/pull/1876
The original code is using 0666
for mode
to open(2)
but it changed to 0600
.
cc: @spevans
The patch is available at https://github.com/apple/swift-corelibs-foundation/pull/2851
Environment
macOS 10.15.6 Ubuntu 18.04 (Official swift:latest Docker image)Additional Detail from JIRA
| | | |------------------|-----------------| |Votes | 0 | |Component/s | Foundation | |Labels | Bug | |Assignee | None | |Priority | Medium | md5: 915184f699d2e0392da90f9a7be55035Issue Description:
For example, with following code, users expected to create a new
file
(if it doesn’t exist) with permission that respects currentumask
.On macOS, In case
umask
is022
, it createsfile
with permission0644
on macOS.in case
umask
is0
, it createsfile
with permission0666
.Therefore, default
mode
toopen(2)
seems having0666
.However, on Linux, since corelibs Foundation is using default mode
0600
toopen(2)
(called via_CFOpenFileWithMode()
), in caseumask
is022
, it createsfile
with permission0600
instead of0644
.https://github.com/apple/swift-corelibs-foundation/blame/master/Sources/Foundation/NSData.swift#L438
This behavior's inconsistency surprising Foundation library users.