cryptomator / cryptofs

Java Filesystem Provider with integrated encryption
GNU Affero General Public License v3.0
94 stars 35 forks source link

File creation mode and umask are ignored when creating a new file #142

Closed ammmir closed 2 years ago

ammmir commented 2 years ago

On Cryptomator 1.6.14 on macOS, if you create an executable file the file is created but with the incorrect permissions. A quick Go program to demonstrate:

package main

import (
    "os"
)

func main() {
    w, err := os.OpenFile("exe", os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0755)
    if err != nil {
        panic(err)
    }
    w.Close()
}

The resulting file exe should have permissions of 0755 but instead has permissions of 0644:

$ go run bug.go
$ ls -l exe
-rw-r--r--  1 amir  staff  0 Sep 17 18:21 exe
$ chmod +x exe
$ ls -l exe
-rwxr-xr-x  1 amir  staff  0 Sep 17 18:21 exe

Is the initial mode of the open call being ignored and the default being used? It seems cryptofs is (also?) ignoring the umask when a file is created:

$ umask 0555
$ touch writeonly
$ ls -l writeonly
-rw-r--r--  1 amir  staff  0 Sep 17 18:25 writeonly

whereas it should have been created with the correct mode:

--w--w--w-  1 amir  staff  0 Sep 17 18:24 writeonly
overheadhunter commented 2 years ago

CryptoFS is only part of the software stack involved here. It is more likely that the VFS changes your desired permissions. Can you please use the bug form in the cryptomator repo so we know exactly what FS implementation you're using? Thanks!