Description
The default file-creation mode using Julia's open
is to give the file u=rw, g=w, o=w
permissions (src/support/ios.c):
fd = open_cloexec(fname, flags, S_IRUSR | S_IWUSR /* 0600 */ | S_IRGRP | S_IROTH /* 0644 */);
On the other hand, Linux's default (or "usual case") seems to be u=rw, g=rw, o=rw
:
S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH
Given that Linux's default umask is 0022, the resulting Linux permissions match Julia. But if the user has a more permissible umask set, then Julia will not match Linux:
shell> umask 0000
julia> open("testjl", "w") do f
println(f, "hello")
end
shell> echo "hello" > test
shell> ls -l test*
-rw-r--r-- 1 username group 6 May 19 19:01 testjl
-rw-rw-r-- 1 username group 6 May 19 19:01 test
On a multi-user system, teams may use umask to ensure that files are appropriately accessible. My background here is that I created a file in a shared data directory using writetable
; my coworker was unable to overwrite it because the file did not have group write permissions even though in other usage, the value of umask
we have set would have allowed that. So my only recourse would be to continuously do chmod
on the file.
So I'm wondering why Julia doesn't act like Linux here and set the same default file creation mode.
(See also #16237 for previous discussion.)