The cross-harness, self-improving memory layer for AI agents. Join our community: https://discord.com/invite/zdNChS2fBu
Go agent-ai-cliagent-harnessesagent-securitybrowser-extensionciclaude-codecloudcodexcursordetection-engineeringjevknowledge-basememorymobile-device-managementobservabilitysecuritysecurity-information-and-event-managementsecurity-toolstelemetrytraces
fix(endpoint): stop telling Windows users to rerun with sudo
Saurav Singhc1e4c053954b
diff --git a/cli/beacon/cmd/endpoint_connect.go b/cli/beacon/cmd/endpoint_connect.goindex befd0555..20c66d01 100644--- a/cli/beacon/cmd/endpoint_connect.go+++ b/cli/beacon/cmd/endpoint_connect.go@@ -84,7 +84,8 @@ func init() {func runEndpointConnect(cmd *cobra.Command, args []string) error {userMode := endpointUserMode()if !userMode && !lifecycle.HasSystemPrivileges() {- return fmt.Errorf("connecting a system endpoint needs root: rerun with sudo, or pass --user for a per-user install")+ return fmt.Errorf("connecting a system endpoint needs elevated privileges; %s, or pass --user for a per-user install",+ lifecycle.SystemPrivilegeHint())}return connectEndpoint(cmd, userMode, loadOrDefaultConfig().LogPath, false)}@@ -242,7 +243,8 @@ func hasAccountScope(scopes []string, target string) bool {func runEndpointDisconnect(cmd *cobra.Command, args []string) error {userMode := endpointUserMode()if !userMode && !lifecycle.HasSystemPrivileges() {- return fmt.Errorf("disconnecting a system endpoint needs root: rerun with sudo, or pass --user for a per-user install")+ return fmt.Errorf("disconnecting a system endpoint needs elevated privileges; %s, or pass --user for a per-user install",+ lifecycle.SystemPrivilegeHint())}enrollment, loadErr := asymptote.LoadEnrollment(userMode)cfg := loadOrDefaultConfig()diff --git a/cli/beacon/cmd/endpoint_connect_test.go b/cli/beacon/cmd/endpoint_connect_test.goindex 0d5677f5..ed75ef1e 100644--- a/cli/beacon/cmd/endpoint_connect_test.go+++ b/cli/beacon/cmd/endpoint_connect_test.go@@ -4,6 +4,7 @@ import ("bytes""context""errors"+ "runtime""strings""testing""time"@@ -12,6 +13,7 @@ import ("github.com/asymptote-labs/agent-beacon/cli/beacon/internal/account""github.com/asymptote-labs/agent-beacon/cli/beacon/internal/endpoint/asymptote"+ "github.com/asymptote-labs/agent-beacon/cli/beacon/internal/endpoint/lifecycle""github.com/asymptote-labs/agent-beacon/cli/beacon/internal/endpoint/service""github.com/asymptote-labs/agent-beacon/cli/beacon/internal/managedprivacy""github.com/asymptote-labs/agent-beacon/cli/beacon/internal/onboarding"@@ -84,6 +86,43 @@ func TestDashboardHomeURL(t *testing.T) {}}+// A system connect or disconnect from a shell without privileges used to say "rerun with sudo",+// which names a command Windows does not have. The hint has to come from the platform, as it+// already does for install, update and the job commands.+func TestSystemConnectAndDisconnectNameThePlatformElevationHint(t *testing.T) {+ if lifecycle.HasSystemPrivileges() {+ t.Skip("an elevated process can connect a system endpoint")+ }+ originalEndpointOpts := endpointOpts+ originalConnect := connectManagedEndpoint+ t.Cleanup(func() {+ endpointOpts = originalEndpointOpts+ connectManagedEndpoint = originalConnect+ })+ endpointOpts.userMode, endpointOpts.systemMode = false, true+ connectManagedEndpoint = func(context.Context, asymptote.ConnectOptions) (*asymptote.ConnectResult, error) {+ return nil, errors.New("must not run")+ }+ for name, run := range map[string]func(*cobra.Command, []string) error{+ "connect": runEndpointConnect,+ "disconnect": runEndpointDisconnect,+ } {+ err := run(&cobra.Command{}, nil)+ if err == nil {+ t.Fatalf("%s: a system %s without privileges returned nil", name, name)+ }+ if !strings.Contains(err.Error(), "elevated privileges") {+ t.Fatalf("%s: error = %v, want it to name the elevation requirement", name, err)+ }+ if !strings.Contains(err.Error(), lifecycle.SystemPrivilegeHint()) {+ t.Fatalf("%s: error = %v, want it to carry this platform's hint (%q)", name, err, lifecycle.SystemPrivilegeHint())+ }+ if strings.Contains(err.Error(), "sudo") && runtime.GOOS == "windows" {+ t.Fatalf("%s: error = %v names sudo on Windows", name, err)+ }+ }+}+func TestConnectRequiresSignedInAccountInUserMode(t *testing.T) {originalLoad, originalConnect := connectAccountLoad, connectManagedEndpointt.Cleanup(func() {diff --git a/cli/beacon/internal/endpoint/lifecycle/lifecycle.go b/cli/beacon/internal/endpoint/lifecycle/lifecycle.goindex 6e59497b..7b2f609d 100644--- a/cli/beacon/internal/endpoint/lifecycle/lifecycle.go+++ b/cli/beacon/internal/endpoint/lifecycle/lifecycle.go@@ -874,7 +874,8 @@ func Uninstall(opts UninstallOptions) error {// success. Install has always had this gate; uninstall never did, which is the asymmetry that// let an unprivileged removal look like it worked.if !cfg.UserMode && !HasSystemPrivileges() {- return fmt.Errorf("removing a system endpoint needs root: rerun with sudo, or pass --user to remove a user-mode install")+ return fmt.Errorf("removing a system endpoint needs elevated privileges; %s, or pass --user to remove a user-mode install",+ SystemPrivilegeHint())}var problems []stringdiff --git a/cli/beacon/internal/endpoint/lifecycle/uninstall_reporting_test.go b/cli/beacon/internal/endpoint/lifecycle/uninstall_reporting_test.goindex f8006b73..f3d6db37 100644--- a/cli/beacon/internal/endpoint/lifecycle/uninstall_reporting_test.go+++ b/cli/beacon/internal/endpoint/lifecycle/uninstall_reporting_test.go@@ -22,8 +22,12 @@ func TestUninstallRefusesAnUnprivilegedSystemRemoval(t *testing.T) {if err == nil {t.Fatal("an unprivileged system uninstall returned nil, which the CLI prints as success")}- if !strings.Contains(err.Error(), "root") {- t.Errorf("error %q should say privileges are the problem, so the operator knows to rerun with sudo", err)+ if !strings.Contains(err.Error(), "elevated privileges") {+ t.Errorf("error %q should say privileges are the problem", err)+ }+ // The advice has to be runnable on the platform that printed it: sudo does not exist on Windows.+ if !strings.Contains(err.Error(), SystemPrivilegeHint()) {+ t.Errorf("error %q should carry this platform's hint (%q)", err, SystemPrivilegeHint())}}diff --git a/docs/changelog/cli.mdx b/docs/changelog/cli.mdxindex 8794d34c..adac5d5f 100644--- a/docs/changelog/cli.mdx+++ b/docs/changelog/cli.mdx@@ -11,6 +11,7 @@ Stay up to date with the latest changes to the Agent Beacon CLI.## Unreleased+- **Windows gets the right advice for elevation** · `beacon endpoint connect`, `disconnect` and `uninstall --system` from a shell without privileges told Windows users to rerun with `sudo`, a command Windows does not have. They now say to run from an elevated shell, the same as `beacon endpoint install --system` already did.- **Scheduled session sync** · `beacon endpoint install|repair --session-sync` turns on a job that runs every 15 minutes and reads new records from the agent runtimes' local session stores into the runtime log. It runs the same bounded, confined sweep install already runs once, so session-store data keeps reaching the log, and any forwarder reading it, after install. Off by default; repair and upgrades keep the setting, and `--no-session-sync` removes the job. See [Scheduled session sync](/cli/endpoint-install#scheduled-session-sync).- **Turn session sync on or off without a repair** · `beacon endpoint sessions enable|disable` changes only the scheduled session sync setting and installs or removes its job. `beacon endpoint repair --session-sync` rebuilds the endpoint from its flags, so run without the ones an endpoint was set up with it reset harnesses and OTLP ports and dropped Splunk or Falcon HEC destinations. For package and MDM installs, `BEACON_SESSION_SYNC=1` in the environment of `/opt/beacon/scripts/install-endpoint.sh` (macOS and Linux) turns it on, and `0` turns it off; unset keeps the endpoint's own setting, so package upgrades never change it.- **Repair keeps the collector it came with** · Without `--collector`, `beacon endpoint repair` and `install` now use the `beacon-otelcol` beside the `beacon` CLI before one on `PATH`, and repair checks the collector before it takes the endpoint down. Under `sudo` on a Mac that also had Homebrew Beacon, repair found Homebrew's older collector first, refused it after removing the collector's service and config, and left the endpoint without its collector.