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

cmd/go: go build should honor umask #12692

Closed
0xmohit opened this issue Sep 19, 2015 · 3 comments
Closed

cmd/go: go build should honor umask #12692

0xmohit opened this issue Sep 19, 2015 · 3 comments
Milestone

Comments

@0xmohit
Copy link
Contributor

0xmohit commented Sep 19, 2015

No matter what the umask, go build would always create a binary with perms 0755.

$  ( umask 0022; go build -o foo foo.go ; ls -l foo )
-rwxr-xr-x 1 ubuntu ubuntu 2848496 Sep 19 12:00 foo
$  ( umask 0000; go build -o foo foo.go ; ls -l foo )
-rwxr-xr-x 1 ubuntu ubuntu 2848496 Sep 19 12:00 foo
$  ( umask 0077; go build -o foo foo.go ; ls -l foo )
-rwxr-xr-x 1 ubuntu ubuntu 2848496 Sep 19 12:00 foo

Compilers (including gcc, ghc, dmd) usually respect umask while creating executables.

@ianlancetaylor ianlancetaylor added this to the Go1.6 milestone Sep 19, 2015
@ianlancetaylor
Copy link
Contributor

I think this happens because moveOrCopyFile in cmd/go/build.go calls os.Chmod without considering umask.

@AndersKOlsson
Copy link

+1. This is really irritating, for example when building through the golang Docker image, and ending up with root owned, undeletable files on the host.

@gopherbot
Copy link

CL https://golang.org/cl/17950 mentions this issue.

@rsc rsc closed this as completed in 0cb68ac Dec 17, 2015
@golang golang locked and limited conversation to collaborators Dec 29, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants