Skip to content

Commit

Permalink
cmd/buildlet: set a safe default for shell
Browse files Browse the repository at this point in the history
On non-Linux, non-Windows OSes, gomotes use the value of the SHELL
environment variable. If the variable is unset, starting gomote fails.

Instead, set /bin/sh as a safe default.

Fixes golang/go#70163.

Change-Id: I88bdb2d83fa6d81eeccaffd1562fc8512bc0c4c5
Reviewed-on: https://go-review.googlesource.com/c/build/+/624796
Reviewed-by: Dmitri Shuralyov <[email protected]>
Reviewed-by: Dmitri Shuralyov <[email protected]>
Reviewed-by: Carlos Amedee <[email protected]>
LUCI-TryBot-Result: Go LUCI <[email protected]>
  • Loading branch information
bsiegert committed Nov 4, 2024
1 parent 60c7972 commit 58cbe53
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions cmd/buildlet/buildlet.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,8 @@ var (
// 26: clean up path validation and normalization
// 27: export GOPLSCACHE=$workdir/goplscache
// 28: add support for gomote server
const buildletVersion = 28
// 29: fall back to /bin/sh when SHELL is unset
const buildletVersion = 29

func defaultListenAddr() string {
if runtime.GOOS == "darwin" {
Expand Down Expand Up @@ -2039,6 +2040,9 @@ func shell() string {
case "windows":
return `C:\Windows\System32\cmd.exe`
default:
return os.Getenv("SHELL")
if shell := os.Getenv("SHELL"); shell != "" {
return shell
}
return "/bin/sh"
}
}

0 comments on commit 58cbe53

Please sign in to comment.