diff --git a/cmd/clawgo/cmd_gateway.go b/cmd/clawgo/cmd_gateway.go index 3de3919..6b8e542 100644 --- a/cmd/clawgo/cmd_gateway.go +++ b/cmd/clawgo/cmd_gateway.go @@ -1,7 +1,6 @@ package main import ( - "bufio" "context" "encoding/json" "fmt" @@ -691,67 +690,6 @@ func runGatewayBootstrapInit(parent context.Context, cfg *config.Config, agentLo logger.InfoC("gateway", "Bootstrap init model call completed") } -func maybePromptAndEscalateRoot(command string) { - if os.Getenv(envRootPrompted) == "1" { - return - } - if !isInteractiveStdin() { - return - } - - fmt.Printf("Grant root permissions for `clawgo %s`? (yes/no): ", command) - reader := bufio.NewReader(os.Stdin) - line, _ := reader.ReadString('\n') - answer := strings.ToLower(strings.TrimSpace(line)) - if answer != "yes" && answer != "y" { - _ = os.Setenv(envRootPrompted, "1") - _ = os.Setenv(envRootGranted, "0") - return - } - - _ = os.Setenv(envRootPrompted, "1") - _ = os.Setenv(envRootGranted, "1") - - if os.Geteuid() == 0 { - return - } - - exePath, err := os.Executable() - if err != nil { - fmt.Printf("Error resolving executable for sudo re-run: %v\n", err) - os.Exit(1) - } - exePath, _ = filepath.Abs(exePath) - - cmdArgs := append([]string{"-E", exePath}, os.Args[1:]...) - cmd := exec.Command("sudo", cmdArgs...) - cmd.Stdin = os.Stdin - cmd.Stdout = os.Stdout - cmd.Stderr = os.Stderr - cmd.Env = append(os.Environ(), envRootPrompted+"=1", envRootGranted+"=1") - - if err := cmd.Run(); err != nil { - if exitErr, ok := err.(*exec.ExitError); ok { - os.Exit(exitErr.ExitCode()) - } - fmt.Printf("Failed to elevate privileges with sudo: %v\n", err) - os.Exit(1) - } - os.Exit(0) -} - -func shouldPromptGatewayRoot(args []string) bool { - return len(args) == 2 && args[1] == "gateway" -} - -func isInteractiveStdin() bool { - info, err := os.Stdin.Stat() - if err != nil { - return false - } - return (info.Mode() & os.ModeCharDevice) != 0 -} - func applyMaximumPermissionPolicy(cfg *config.Config) { cfg.Tools.Shell.Enabled = true cfg.Tools.Shell.Sandbox.Enabled = false diff --git a/cmd/clawgo/main.go b/cmd/clawgo/main.go index d430008..0546148 100644 --- a/cmd/clawgo/main.go +++ b/cmd/clawgo/main.go @@ -22,7 +22,6 @@ var embeddedFiles embed.FS const version = "0.1.0" const logo = "🦞" const gatewayServiceName = "clawgo-gateway.service" -const envRootPrompted = "CLAWGO_ROOT_PROMPTED" const envRootGranted = "CLAWGO_ROOT_GRANTED" var globalConfigPathOverride string