Navigation Menu

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

os: RemoveAll no longer able to remove empty directory without read permission #29178

Closed
dmitshur opened this issue Dec 11, 2018 · 2 comments
Closed
Labels
FrozenDueToAge NeedsFix The path to resolution is known, but the work has not been done.
Milestone

Comments

@dmitshur
Copy link
Contributor

dmitshur commented Dec 11, 2018

There is a change in behavior of os.RemoveAll on tip compared to 1.11.2, on macOS (and Linux, BSDs), caused by CL 146020, in a specific scenario. I can't definitively say whether this change should considered a bug/regression, or if it's a normal intentional new behavior, so marking as NeedsDecision.

Prior to CL 146020, it was possible to use os.RemoveAll to remove an empty directory without read permissions, because its code had a "Simple case" as the first thing it tried:

func RemoveAll(path string) error {
	// Simple case: if Remove works, we're done.
	err := Remove(path)
	if err == nil || IsNotExist(err) {
		return nil
	}

	...

So the Go program https://play.golang.org/p/68OMhP1VS7G printed temp file was removed: true.

The new os.RemoveAll code after CL 146020 tries to read the directory before performing the "simple case", and returns a permission error instead:

$ go run .
temp file was removed: true
$ gotip run .
2018/12/11 16:14:39 os.RemoveAll: permission denied
exit status 1

/cc @ostenbom @ianlancetaylor

@dmitshur dmitshur added the NeedsDecision Feedback is required from experts, contributors, and/or the community before a change can be made. label Dec 11, 2018
@dmitshur dmitshur added this to the Go1.12 milestone Dec 11, 2018
@bradfitz
Copy link
Contributor

I think this is worth fixing for Go 1.12.

@gopherbot
Copy link

Change https://golang.org/cl/153720 mentions this issue: os: in RemoveAll, try Remove first

@dmitshur dmitshur added NeedsFix The path to resolution is known, but the work has not been done. and removed NeedsDecision Feedback is required from experts, contributors, and/or the community before a change can be made. labels Dec 12, 2018
@golang golang locked and limited conversation to collaborators Dec 12, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge NeedsFix The path to resolution is known, but the work has not been done.
Projects
None yet
Development

No branches or pull requests

3 participants