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

OsFs not checking for permissions on Windows #336

Closed
staticdev opened this issue Jan 30, 2022 · 2 comments
Closed

OsFs not checking for permissions on Windows #336

staticdev opened this issue Jan 30, 2022 · 2 comments

Comments

@staticdev
Copy link

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
Copy link

jxsl13 commented Mar 1, 2022

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
Copy link
Author

@jxsl13 fair enough, will close this one.

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