MCPcopy Index your code
hub / github.com/docker/docker-agent / WindowsCmdExe

Function WindowsCmdExe

pkg/shellpath/shellpath.go:22–30  ·  view source on GitHub ↗

WindowsCmdExe returns the absolute path to cmd.exe on Windows using the SystemRoot environment variable (e.g. C:\Windows\System32\cmd.exe). This avoids resolving cmd.exe through PATH, which would be vulnerable to untrusted search path attacks (CWE-426). If the ComSpec environment variable is set, i

()

Source from the content-addressed store, hash-verified

20// As a last resort, if neither ComSpec nor SystemRoot is set, it falls back
21// to the bare "cmd.exe" name (should never happen on a normal Windows system).
22func WindowsCmdExe() string {
23 if comspec := os.Getenv("ComSpec"); comspec != "" {
24 return comspec
25 }
26 if systemRoot := os.Getenv("SystemRoot"); systemRoot != "" {
27 return filepath.Join(systemRoot, "System32", "cmd.exe")
28 }
29 return "cmd.exe"
30}
31
32// DetectShell returns the appropriate shell binary and its argument prefix
33// for the current platform.

Calls

no outgoing calls