MCPcopy Create free account
hub / github.com/tailscale/tailscale / canSudo

Method canSudo

drive/driveimpl/remote_impl.go:421–428  ·  view source on GitHub ↗

canSudo checks whether we can sudo -u the configured executable as the configured user by attempting to call the executable with the '-h' flag to print help.

()

Source from the content-addressed store, hash-verified

419// configured user by attempting to call the executable with the '-h' flag to
420// print help.
421func (s *userServer) canSudo() bool {
422 ctx, cancel := context.WithTimeout(context.Background(), 3*time.Second)
423 defer cancel()
424 if err := exec.CommandContext(ctx, "sudo", "-n", "-u", s.username, s.executable, "-h").Run(); err != nil {
425 return false
426 }
427 return true
428}
429
430// canSU checks whether the current process can run su with the right username.
431// If su can be run, this returns the path to the su command.

Callers 1

runMethod · 0.95

Calls 1

RunMethod · 0.65

Tested by

no test coverage detected