1

I have a shared hosting provider who does not mount /proc for security reason. I want to execute a binary file written in GO which needs the path in which it was started. This is done by using readlink and virtual link /proc/self/exe (see source https://github.com/golang/go/blob/master/src/os/executable_procfs.go) But this link can't be found due to the fact, that /proc is not mounted.

Arg[0] is not possible because you can call the file via "./app".

Is there a nother option to get execution path? Thanks for any help!

recycler
  • 1,301
  • 9
  • 9
  • `./app` combined with `realpath` seems like a reasonable solution. The tricky part is `realpath` due to buffer sizes and `PATH_MAX` and `_POSIX_PATH_MAX`. Also see questions like [Where is PATH_MAX defined in Linux?](https://stackoverflow.com/q/9449241/608639), [How to determine system value for _POSIX_PATH_MAX](https://stackoverflow.com/q/30766163/608639), [Example of realpath function in C](https://stackoverflow.com/q/1563168/608639) and [What is the safe alternative to realpath()?](https://stackoverflow.com/q/4109638/608639) – jww Feb 07 '19 at 23:36

0 Answers0