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

fwrite does not follow system-level umask #2049

Closed
gnguy opened this issue Mar 1, 2017 · 0 comments
Closed

fwrite does not follow system-level umask #2049

gnguy opened this issue Mar 1, 2017 · 0 comments
Labels
Milestone

Comments

@gnguy
Copy link

@gnguy gnguy commented Mar 1, 2017

It appears that when using fwrite to write files, it does not follow the system-level umask settings. My global umask settings have been set to 002, so I expect that R should write files with rw-rw-r-- permissions.

When writing files using fwrite, they appear to write files with rw-r--r-- permissions, which I would associate with a umask of 022. When I write files immediately after that while using write.csv, they write appropriately with rw-rw-r-- permissions.

library(data.table)
Sys.umask()

2

Sys.umask("002") # Not needed, but just to make sure
filename <- "~/Desktop/umask_test.csv"

system(paste0("rm ", filename))
test_df <- data.frame(x=c(0,1))
fwrite(test_df, filename)
system(paste0("ls -la ",filename))

-rw-r--r-- 1 myuser 50513 6 Mar 1 15:34 /Users/myuser/Desktop/umask_test.csv

system(paste0("rm ", filename))
write.csv(test_df, filename)
system(paste0("ls -la ", filename))

-rw-rw-r-- 1 myuser 50513 19 Mar 1 15:34 /Users/myuser/Desktop/umask_test.csv

sessionInfo()

R version 3.3.2 (2016-10-31)
Platform: x86_64-apple-darwin13.4.0 (64-bit)
Running under: macOS Sierra 10.12.3

locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

attached base packages:
[1] stats graphics grDevices utils datasets methods base

other attached packages:
[1] data.table_1.10.4

loaded via a namespace (and not attached):
[1] tools_3.3.2

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

Successfully merging a pull request may close this issue.

None yet
3 participants