mirror of
https://github.com/coder/coder.git
synced 2025-07-12 00:14:10 +00:00
With the switch to Go 1.24.1, our dogfood workspaces started setting `GOTRACEBACK=none` in the environment, resulting in missing stacktraces for users. This is due to the capability changes we do when `USE_CAP_NET_ADMIN=true`.564b387262/provisionersdk/scripts/bootstrap_linux.sh (L60-L76)
This most likely triggers a change in securitybits which sets `_AT_SECURE` for the process.a1ddbdd3ef/src/runtime/os_linux.go (L297-L327)
Which in turn triggers secure mode:a1ddbdd3ef/src/runtime/security_unix.go
This should not affect workspaces as template authors can still set the environment on the agent resource. See https://pkg.go.dev/runtime#hdr-Security
56 lines
1.2 KiB
Go
56 lines
1.2 KiB
Go
package usershell_test
|
|
|
|
import (
|
|
"os/user"
|
|
"runtime"
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/require"
|
|
|
|
"github.com/coder/coder/v2/agent/usershell"
|
|
)
|
|
|
|
//nolint:paralleltest,tparallel // This test sets an environment variable.
|
|
func TestGet(t *testing.T) {
|
|
if runtime.GOOS == "windows" {
|
|
t.SkipNow()
|
|
}
|
|
|
|
t.Run("Fallback", func(t *testing.T) {
|
|
t.Setenv("SHELL", "/bin/sh")
|
|
|
|
t.Run("NonExistentUser", func(t *testing.T) {
|
|
shell, err := usershell.Get("notauser")
|
|
require.NoError(t, err)
|
|
require.Equal(t, "/bin/sh", shell)
|
|
})
|
|
})
|
|
|
|
t.Run("NoFallback", func(t *testing.T) {
|
|
// Disable env fallback for these tests.
|
|
t.Setenv("SHELL", "")
|
|
|
|
t.Run("NotFound", func(t *testing.T) {
|
|
_, err := usershell.Get("notauser")
|
|
require.Error(t, err)
|
|
})
|
|
|
|
t.Run("User", func(t *testing.T) {
|
|
u, err := user.Current()
|
|
require.NoError(t, err)
|
|
shell, err := usershell.Get(u.Username)
|
|
require.NoError(t, err)
|
|
require.NotEmpty(t, shell)
|
|
})
|
|
})
|
|
|
|
t.Run("Remove GOTRACEBACK=none", func(t *testing.T) {
|
|
t.Setenv("GOTRACEBACK", "none")
|
|
ei := usershell.SystemEnvInfo{}
|
|
env := ei.Environ()
|
|
for _, e := range env {
|
|
require.NotEqual(t, "GOTRACEBACK=none", e)
|
|
}
|
|
})
|
|
}
|