-
Notifications
You must be signed in to change notification settings - Fork 17.8k
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: file permissions from os.mkdir are incorrect #38282
Comments
What is your umask value? What does the command |
Directories must be executable in order to see what’s inside them. Changing the perms when creating the .sample dir to 0777 (though I’d be careful giving world rwx perms to anything) fixes the issue. If you check the The playground runs in its own sandbox with a fake filesystem. It may be that it doesn’t take this particular bit into account. |
Changing it to
|
It will fail on linux/amd64 with the same issue as well (altered to print
As far as I understand, you can’t stat a file within a directory without having executable permissions on the directory. @ianlancetaylor am I missing something? |
Ah I see the difference in permissions. Sorry for the confusion. Was focused on the file creation. |
No worries, was just about to point that out. |
What's wrong about these permissions? That looks like what I'd expect from |
I would've expected |
The purpose of umask is to be applied to the permissions of files created by a process. It's not an error to create a file or directory with permissions bits removed by the umask; the expected usage under most circumstances is for files to be created with maximal permissions and those permissions reduced to the desired set by the user's umask. For example, the $ umask
0022
$ mkdir foo
$ ls -ld foo
drwxr-xr-x 2 dneil wheel 64 Apr 6 13:02 foo
$ rmdir foo
$ umask 0002
$ mkdir foo
$ ls -ld foo
drwxrwxr-x 2 dneil wheel 64 Apr 6 13:03 foo |
The documentation for |
(and I should note that the umask handling of |
Guess, I didn't see that. Then I'd assume there's no issue here and we can close this. |
What version of Go are you using (
go version
)?I've tried before with a 1.13 release with the same result
Does this issue reproduce with the latest release?
Updated because I thought there might be a fix to 1.14.1.
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
Tried setting up a minimal example:
Using this piece of code I want to create a folder with mode 666 in the users home directory. On the playground it works fine, on my mac it fails:
What did you expect to see?
The permissions on the directory to be the same as reported from the playground, as well as the file generation to be successful.
What did you see instead?
Wrong file permissions on the directory.
The text was updated successfully, but these errors were encountered: