os/exec: Command does not pass absolute path to argv[0] #17536
Labels
Documentation
Issues describing a change to documentation.
FrozenDueToAge
NeedsFix
The path to resolution is known, but the work has not been done.
Milestone
Please answer these questions before submitting your issue. Thanks!
What version of Go are you using (
go version
)?go version go1.7.1 darwin/amd64
What operating system and processor architecture are you using (
go env
)?darwin amd64
What did you do?
Run
sshd
inexec.Command()
fails due to an incorrect absolute path.https://play.golang.org/p/z1UMtdSY2N
What did you expect to see?
Successful execution of the command
What did you see instead?
A message indicating that the command was not executed as it should be.
Discussion
exec.Command
does in fact expand the absolute path of a command and save it tocmd.Path
; however, it does not update the value ofcmd.Args[0]
, which remains the original stringname
.Even though the executed program is run correctly from its full system path, programs like
sshd
may make application-level checks againstargv[0]
. In these cases, we see the failure case as above.Note that this may be intentional, but the docs for
Command
state that the path is resolved to a complete name, which makes the behavior above a little unexpected.The text was updated successfully, but these errors were encountered: