Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitdf92df4

Browse files
authored
fix(agent): filter outGOTRACEBACK=none (#16924)
With the switch to Go 1.24.1, our dogfood workspaces started setting`GOTRACEBACK=none` in the environment, resulting in missing stacktracesfor users.This is due to the capability changes we do when`USE_CAP_NET_ADMIN=true`.https://github.com/coder/coder/blob/564b387262e5b768c503e5317242d9ab576395d6/provisionersdk/scripts/bootstrap_linux.sh#L60-L76This most likely triggers a change in securitybits which sets`_AT_SECURE` for the process.https://github.com/golang/go/blob/a1ddbdd3ef8b739aab53f20d6ed0a61c3474cf12/src/runtime/os_linux.go#L297-L327Which in turn triggers secure mode:https://github.com/golang/go/blob/a1ddbdd3ef8b739aab53f20d6ed0a61c3474cf12/src/runtime/security_unix.goThis should not affect workspaces as template authors can still set theenvironment on the agent resource.Seehttps://pkg.go.dev/runtime#hdr-Security
1 parentf01ee96 commitdf92df4

File tree

3 files changed

+24
-2
lines changed

3 files changed

+24
-2
lines changed

‎agent/agentexec/cli_linux.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ import (
1717
"golang.org/x/sys/unix"
1818
"golang.org/x/xerrors"
1919
"kernel.org/pub/linux/libs/security/libcap/cap"
20+
21+
"github.com/coder/coder/v2/agent/usershell"
2022
)
2123

2224
// CLI runs the agent-exec command. It should only be called by the cli package.
@@ -114,7 +116,8 @@ func CLI() error {
114116

115117
// Remove environment variables specific to the agentexec command. This is
116118
// especially important for environments that are attempting to develop Coder in Coder.
117-
env:=os.Environ()
119+
ei:= usershell.SystemEnvInfo{}
120+
env:=ei.Environ()
118121
env=slices.DeleteFunc(env,func(estring)bool {
119122
returnstrings.HasPrefix(e,EnvProcPrioMgmt)||
120123
strings.HasPrefix(e,EnvProcOOMScore)||

‎agent/usershell/usershell.go

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,17 @@ func (SystemEnvInfo) User() (*user.User, error) {
5050
}
5151

5252
func (SystemEnvInfo)Environ() []string {
53-
returnos.Environ()
53+
varenv []string
54+
for_,e:=rangeos.Environ() {
55+
// Ignore GOTRACEBACK=none, as it disables stack traces, it can
56+
// be set on the agent due to changes in capabilities.
57+
// https://pkg.go.dev/runtime#hdr-Security.
58+
ife=="GOTRACEBACK=none" {
59+
continue
60+
}
61+
env=append(env,e)
62+
}
63+
returnenv
5464
}
5565

5666
func (SystemEnvInfo)HomeDir() (string,error) {

‎agent/usershell/usershell_test.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,4 +43,13 @@ func TestGet(t *testing.T) {
4343
require.NotEmpty(t,shell)
4444
})
4545
})
46+
47+
t.Run("Remove GOTRACEBACK=none",func(t*testing.T) {
48+
t.Setenv("GOTRACEBACK","none")
49+
ei:= usershell.SystemEnvInfo{}
50+
env:=ei.Environ()
51+
for_,e:=rangeenv {
52+
require.NotEqual(t,"GOTRACEBACK=none",e)
53+
}
54+
})
4655
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp