awalker89 / openxlsx

R package for .xlsx file reading and writing.
Other
363 stars 79 forks source link

Files written should do according to directory default ACLs #540

Closed finalspy closed 2 years ago

finalspy commented 2 years ago

Expected Behavior

Files should be written using the system acls

Actual Behavior

For example it works properly with writexl package, But it doesn't using openxlsx. Need to set Sys.umask("0007") in .Rprofile in my case to have proper acls

Steps to Reproduce the Problem

(please attach an example xlsx file if possible)

  1. Mount an NFS directory with specific acls

  2. Make a script to write an xls file to this directory

  3. Check the file rights

sessionInfo()

I don't know if this is linked to the NFS mount but I prefer to mention this specificity. What seems odd to me is that the behaviour is different from writexl and openxlsx. The former one seems right ...

Here's a file with right acls written with writexl package :

library(writexl)
cars <- mtcars[1:6, ]
write_xlsx(x = cars, path = "test_writexl.xlsx", col_names = TRUE)

Here's another script with wrong acls with openxlsx package :

library("openxlsx")
wb <- createWorkbook()
cars <- mtcars[1:6, ]
addWorksheet(wb, "Cars")
writeData(wb, "Cars", cars, startCol = 2, startRow = 3, rowNames = TRUE)
saveWorkbook(wb, "test_write_openxlsx.xlsx", overwrite = TRUE)

Here are the results :

-rw-------  1 myuser test-projet 6875 Mar  2 19:22 test_write_openxlsx.xlsx
-rw-rw-rw-  1 myuser test-projet 5438 Mar  2 19:23 test_writexl.xlsx

And here are the ACLs for my current directory on the NFS server :

user::rwx
group::---
group:test-projet:rwx
other::---
default:user::rwx
default:group::---
default:group:test-projet:rwx
default:other::rwx

And here are the ACLs on the mounted directory (same directory but client side)

user::rwx
group::rwx
other::---
finalspy commented 2 years ago

Oh I noticed that the default system umask is 077 which could explain the openxlsx behavior.

jmbarbone commented 2 years ago

@finalspy

Can you try this with the developmental version:

remotes::install_github("ycphs/openxlsx")

If that still doesn't work, you'll want to open an issue here instead: https://github.com/ycphs/openxlsx/issues

finalspy commented 2 years ago

I'm currently using version 4.2.4 but this is a secured environment and I can't use remotes like github or update the version easily unfortunately. I'm trying to obtain an update.

finalspy commented 2 years ago

Using version 4.2.5.9000 problem is still here. I'll post to the other repo.

finalspy commented 2 years ago

Issue submitted here : https://github.com/ycphs/openxlsx/issues/333