mirror of
https://github.com/coder/coder.git
synced 2026-09-24 15:04:27 +08:00
fix: filter agent-exec env vars (#15764)
- Filters env vars specific to agent-exec from the exec'd process. This is to prevent any issues when developing Coder in Coder, particularly agent tests in the cli pkg.
This commit is contained in:
@@ -9,6 +9,7 @@ import (
|
||||
"os"
|
||||
"os/exec"
|
||||
"runtime"
|
||||
"slices"
|
||||
"strconv"
|
||||
"strings"
|
||||
"syscall"
|
||||
@@ -111,7 +112,16 @@ func CLI() error {
|
||||
return xerrors.Errorf("look path: %w", err)
|
||||
}
|
||||
|
||||
return syscall.Exec(path, args, os.Environ())
|
||||
// Remove environment variables specific to the agentexec command. This is
|
||||
// especially important for environments that are attempting to develop Coder in Coder.
|
||||
env := os.Environ()
|
||||
env = slices.DeleteFunc(env, func(e string) bool {
|
||||
return strings.HasPrefix(e, EnvProcPrioMgmt) ||
|
||||
strings.HasPrefix(e, EnvProcOOMScore) ||
|
||||
strings.HasPrefix(e, EnvProcNiceScore)
|
||||
})
|
||||
|
||||
return syscall.Exec(path, args, env)
|
||||
}
|
||||
|
||||
func defaultNiceScore() (int, error) {
|
||||
|
||||
Reference in New Issue
Block a user