Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Default file-creation mode differs from Linux default #16466

Closed
micahjsmith opened this issue May 19, 2016 · 2 comments
Closed

Default file-creation mode differs from Linux default #16466

micahjsmith opened this issue May 19, 2016 · 2 comments

Comments

@micahjsmith
Copy link
Contributor

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.)

@micahjsmith micahjsmith changed the title Default file-creation mode has unexpected properties Default file-creation mode differs from Linux default May 19, 2016
@vtjnash
Copy link
Member

vtjnash commented May 20, 2016

Agreed. Would you be interested in making a PR to fix this?

@micahjsmith
Copy link
Contributor Author

Great, yes, I can take care of it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants