spf13 / afero

A FileSystem Abstraction System for Go
Apache License 2.0
5.8k stars 498 forks source link

OsFs not checking for permissions on Windows #336

Closed staticdev closed 2 years ago

staticdev commented 2 years ago

How to reproduce:

package main

import (
    "log"

    "github.com/spf13/afero"
)

func main() {
    folderName := "secret"
    fsys := afero.NewOsFs()
    fsys.Mkdir(folderName, 0700)
    afero.WriteFile(fsys, "secret/filename", []byte(""), 0700)

    _, err := fsys.Stat("secret/filename")
    if err != nil {
        log.Fatal(err)
    }
    fsys.Chmod("secret", 0000)
    _, err = fsys.Stat("secret/filename")
    if err != nil {
        log.Fatal(err)
    }
}

You should get the error on second Stat (which is the intended behavior since the secret folder has no read permissions). It works on Linux and Mac, but not on Windows.

jxsl13 commented 2 years ago

this might be a Go standard library issue instead of an afero one. As it simply uses the os package. It might be simply that windows does not allow for such behavior.

staticdev commented 2 years ago

@jxsl13 fair enough, will close this one.