[SR-13307] Default mode
to open(2)
is not same between Foundation and corelibs Foundation
#3247
Labels
mode
to open(2)
is not same between Foundation and corelibs Foundation
#3247
Environment
macOS 10.15.6
Ubuntu 18.04 (Official swift:latest Docker image)
Additional Detail from JIRA
md5: 915184f699d2e0392da90f9a7be55035
Issue 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.
The text was updated successfully, but these errors were encountered: