Fork / exec rejection error

I recently installed Go on our server with CentOS 6.3. Installation seems to have gone fine. However, I did a test of the "hello world" script, and when I ran it, I got the following output.

fork/exec /tmp/go-build967564990/command-line-arguments/_obj/a.out: permission denied

Now go go env or other go commands work. At first I realized that this is a permission problem, however, as the root user, I get the same thing.

+5
source share
4 answers

Just guessing: your nix might shut down for security reasons by running programs in / tmp. It can be configured on CentOS, but I don't know that.

. , go run Go ( script, C script). ( $GOPATH=~, ) , ..

me:~/src/foo$ go run main.go

me:~/src/foo$ go build # main.go should not be necessary here
me:~/src/foo$ ./foo

/tmp -whatever , IIRC, .

PS: root. .

+10

, . :

$ export TMPDIR=~/tmp/

script :

$ go run hello.go
hello, world

- export TMPDIR , .

+8

To fix this problem on my Chromebook, I just unmounted it ~/tmpas an executable. This may have security implications, but since it go runworks on other platforms, I think it’s not so bad (especially on the local development machine):

sudo mount -i -o remount,exec /tmp/

I have added this to my .bash_profilescript.

0
source

Consider the attempt:

sudo mount -o remount exec /tmp
-4
source

All Articles