MCPcopy
hub / github.com/FiloSottile/mkcert / commandWithSudo

Function commandWithSudo

main.go:382–393  ·  view source on GitHub ↗
(cmd ...string)

Source from the content-addressed store, hash-verified

380var sudoWarningOnce sync.Once
381
382func commandWithSudo(cmd ...string) *exec.Cmd {
383 if u, err := user.Current(); err == nil && u.Uid == "0" {
384 return exec.Command(cmd[0], cmd[1:]...)
385 }
386 if !binaryExists("sudo") {
387 sudoWarningOnce.Do(func() {
388 log.Println(`Warning: "sudo" is not available, and mkcert is not running as root. The (un)install operation might fail. ⚠️`)
389 })
390 return exec.Command(cmd[0], cmd[1:]...)
391 }
392 return exec.Command("sudo", append([]string{"--prompt=Sudo password:", "--"}, cmd...)...)
393}

Callers 6

execKeytoolFunction · 0.85
installPlatformMethod · 0.85
uninstallPlatformMethod · 0.85
execCertutilFunction · 0.85
installPlatformMethod · 0.85
uninstallPlatformMethod · 0.85

Calls 1

binaryExistsFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…