In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-09-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)05/31 Report--
Go run permission denied problem analysis and solution is how, many novices are not very clear about this, in order to help you solve this problem, the following editor will explain in detail for you, people with this need can come to learn, I hope you can gain something.
0x01 problem
Once a colleague reported that the following exception occurred when go run xx.go was executed in the environment.
Fork/exec / tmp/go-build104992250/b001/exe/h: permission denied
I was a little interested, so I checked it out. The process of checking is relatively simple. I hope it will be helpful.
0x02 analysis
This problem occurs because the executable generated by go in the / tmp directory does not have execute permissions and will report an error when Go goes to execute it. Why is there no executive authority? After consulting colleagues, confirm that the mount options for / tmp in the development environment are shown below.
Tmpfs on / run/shm type tmpfs (rw,nosuid,nodev,noexec,relatime,size=524288k)
One of the options is noexec. As described in mount's man page, this option can disable binary executable permissions, which will improve the security of the system. This option is also effective for executable scripts in scripting languages such as Shell and Python.
Noexec Do not permit direct execution of any binaries on the mounted filesystem.0x03 solution
Since this option is a security requirement, it cannot be modified. Change your mind, can you let Go go somewhere else? My gut tells me that there should be an environment variable that controls this behavior. It is a pity that it has not been found in China.
Since it is an environment variable, go to the source directory to search. Through the GOROOT environment variable, it is confirmed that the environment variable in Go has the following characteristics. Env GOROOT=$WORK/parent/goroot has a prefix of env. Grep 'env'-rIn. | after grep-I tmp is executed, the environment variable GOTMPDIR is found. After trying it in the environment and GOTMPDIR=/root go run xxx.go, it runs successfully. Our problem's solved.
Is it helpful for you to read the above content? If you want to know more about the relevant knowledge or read more related articles, please follow the industry information channel, thank you for your support.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
The market share of Chrome browser on the desktop has exceeded 70%, and users are complaining about
The world's first 2nm mobile chip: Samsung Exynos 2600 is ready for mass production.According to a r
A US federal judge has ruled that Google can keep its Chrome browser, but it will be prohibited from
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
About us Contact us Product review car news thenatureplanet
More Form oMedia: AutoTimes. Bestcoffee. SL News. Jarebook. Coffee Hunters. Sundaily. Modezone. NNB. Coffee. Game News. FrontStreet. GGAMEN
© 2024 shulou.com SLNews company. All rights reserved.