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
Address review: configure only people's logins, keep errors in the old fields
Claude93c3088c6244
diff --git a/cli/beacon/cmd/endpoint_console_user_test.go b/cli/beacon/cmd/endpoint_console_user_test.goindex 91b1fc5d..5e2e8b96 100644--- a/cli/beacon/cmd/endpoint_console_user_test.go+++ b/cli/beacon/cmd/endpoint_console_user_test.go@@ -174,8 +174,12 @@ func fakeLoginctl(t *testing.T, sessions []fakeSession) {seat = "-" // what loginctl really prints for an unseated session}fmt.Fprintf(&table, "%s 1000 %s %s tty1 %s no -\n", sess.id, sess.user, seat, sess.state)- fmt.Fprintf(&cases, " %s) printf 'Name=%s\\nSeat=%s\\nState=%s\\n' ;;\n",- sess.id, sess.user, sess.seat, sess.state)+ class := sess.class+ if class == "" {+ class = "user"+ }+ fmt.Fprintf(&cases, " %s) printf 'Name=%s\\nSeat=%s\\nState=%s\\nClass=%s\\n' ;;\n",+ sess.id, sess.user, sess.seat, sess.state, class)}dir := t.TempDir()script := "#!/bin/sh\ncase \"$1\" in\n" +@@ -189,7 +193,7 @@ func fakeLoginctl(t *testing.T, sessions []fakeSession) {}type fakeSession struct {- id, user, seat, state string+ id, user, seat, state, class string}func shellSingleQuote(s string) string {@@ -389,3 +393,37 @@ func TestActiveConsoleUsersSkipsTheUnresolvable(t *testing.T) {t.Fatalf("users, err = %+v, %v; want none and no error without logind", users, err)}}++// A display manager's greeter and a lingering account's service manager are live logind sessions+// but nobody's login: on a GNOME desktop gdm (home /var/lib/gdm3) sits on seat0 beside the person.+func TestActiveConsoleUsersSkipsGreeterAndManagerSessions(t *testing.T) {+ if runtime.GOOS != "linux" {+ t.Skip("linux-only resolution")+ }+ t.Setenv("SUDO_USER", "")+ stubLookup(t)+ fakeLoginctl(t, []fakeSession{+ {id: "c1", user: "gdm", seat: "seat0", state: "online", class: "greeter"},+ {id: "c2", user: "lightdm", seat: "seat0", state: "active", class: "lock-screen"},+ {id: "c3", user: "svc", seat: "", state: "active", class: "manager"},+ {id: "c4", user: "builder", seat: "", state: "active", class: "background"},+ {id: "5", user: "alice", seat: "seat0", state: "active"},+ {id: "6", user: "early", seat: "", state: "active", class: "user-early"},+ })+ users, err := defaultActiveConsoleUsers()+ if err != nil {+ t.Fatal(err)+ }+ var names []string+ for _, u := range users {+ names = append(names, u.Username)+ }+ if got, want := strings.Join(names, ","), "alice,early"; got != want {+ t.Fatalf("users = %s, want %s: only people's logins", got, want)+ }+ // The single pick is filtered the same way: with only a greeter, nobody is at the keyboard.+ fakeLoginctl(t, []fakeSession{{id: "c1", user: "gdm", seat: "seat0", state: "active", class: "greeter"}})+ if info, ok, _ := linuxActiveConsoleUser(); ok {+ t.Fatalf("linuxActiveConsoleUser() = %+v from a greeter session", info)+ }+}diff --git a/cli/beacon/cmd/endpoint_hooks_repair.go b/cli/beacon/cmd/endpoint_hooks_repair.goindex 773366da..84746061 100644--- a/cli/beacon/cmd/endpoint_hooks_repair.go+++ b/cli/beacon/cmd/endpoint_hooks_repair.go@@ -355,7 +355,7 @@ func (s logindSession) rank() int {// describeLogindSession reads one session's properties, skipping anything that is not a live login.func describeLogindSession(id string) (logindSession, bool) {- out, err := exec.Command("loginctl", "show-session", id, "-p", "Name", "-p", "State", "-p", "Seat").Output()+ out, err := exec.Command("loginctl", "show-session", id, "-p", "Name", "-p", "State", "-p", "Seat", "-p", "Class").Output()if err != nil {return logindSession{}, false}@@ -373,6 +373,17 @@ func describeLogindSession(id string) (logindSession, bool) {if props["Name"] == "" {return logindSession{}, false}+ // Only a person's login. A display manager keeps its greeter session (gdm, lightdm, sddm, each+ // with a real home under /var/lib) open beside the desktop it started, and systemd 256 lists+ // lingering accounts' service managers as sessions too; a session with no terminal or seat+ // (cron, a script's su) is "background". None of them is anyone whose agent runtime to+ // configure. "user-early" is a login made before the system finished booting. A logind too old+ // to report a class reports only people's sessions as live ones, so an empty class is kept.+ switch props["Class"] {+ case "", "user", "user-early":+ default:+ return logindSession{}, false+ }return logindSession{user: props["Name"],seated: strings.TrimSpace(props["Seat"]) != "",diff --git a/cli/beacon/cmd/endpoint_test.go b/cli/beacon/cmd/endpoint_test.goindex eb251ca7..48eedf15 100644--- a/cli/beacon/cmd/endpoint_test.go+++ b/cli/beacon/cmd/endpoint_test.go@@ -2105,6 +2105,20 @@ func TestRepairInstalledEndpointUserConfigConfiguresEveryLoggedInUser(t *testingif result.Users[2].User != "carol" || result.Users[2].Error != "" {t.Errorf("carol's entry = %+v, want configured after bob failed", result.Users[2])}+ // When the first person fails, the single-user fields carry the error too, so a reader of the+ // older shape never sees their user without it.+ bobFirst, err := func() (endpointUserConfigRepairResult, error) {+ stubConsoleUsers(t, bob, alice)+ return repairInstalledEndpointUserConfig()+ }()+ if err == nil || bobFirst.User != "bob" || bobFirst.Error == "" {+ t.Fatalf("bob first = %+v, %v; want bob with his error at the top level", bobFirst, err)+ }+ stubConsoleUsers(t, alice, bob, carol)+ if result.Error != "" {+ t.Errorf("top-level error = %q when the first person succeeded", result.Error)+ }+// The single-user fields still describe the first person, for readers of the older shape.if result.User != "alice" || result.HomeDir != alice.HomeDir || strings.Join(result.HookTargets, ",") != "claude,codex,cursor" {t.Errorf("top-level result = %+v, want alice's", result)diff --git a/cli/beacon/cmd/endpoint_user_config.go b/cli/beacon/cmd/endpoint_user_config.goindex 7d11cffd..626f2178 100644--- a/cli/beacon/cmd/endpoint_user_config.go+++ b/cli/beacon/cmd/endpoint_user_config.go@@ -140,6 +140,8 @@ func repairInstalledEndpointUserConfig() (endpointUserConfigRepairResult, error)first := result.Users[0]result.User, result.HomeDir, result.RuntimeLogPath = first.User, first.HomeDir, first.RuntimeLogPathresult.NativeConfigTargets, result.NativeConfigPaths, result.HookTargets = first.NativeConfigTargets, first.NativeConfigPaths, first.HookTargets+ // With its error, so a reader of the single-user shape never takes a failure for success.+ result.Error = first.Errorreturn result, errors.Join(errs...)}diff --git a/docs/platforms/linux.mdx b/docs/platforms/linux.mdxindex 3025455f..a7ca806e 100644--- a/docs/platforms/linux.mdx+++ b/docs/platforms/linux.mdx@@ -175,7 +175,7 @@ Vector comes with Beacon. The `.deb` and `.rpm` install it at `/opt/beacon/bin/v| Runtime log | `/var/log/beacon-agent/runtime.jsonl` || Agent runtime | Claude Code and Codex CLI settings and hooks for the installing user and everyone logged in, pointed at `127.0.0.1:4317` |-That last row is worth knowing about. A system-mode endpoint runs as root, so the install has to work out whose agent settings to configure, and the collector is useless if nothing exports to it. Beacon configures the user named by `SUDO_USER`, which is set when you install with `sudo`, and every account logind reports a live session for, which is what an install by a configuration manager running as root (Salt, Ansible, Puppet) has to go on. Each is configured as that user, in their own home, and the install prints one line per person:+That last row is worth knowing about. A system-mode endpoint runs as root, so the install has to work out whose agent settings to configure, and the collector is useless if nothing exports to it. Beacon configures the user named by `SUDO_USER`, which is set when you install with `sudo`, and every account logind reports a live login session for (a desktop, ssh or terminal login; not a display manager's greeter or a background session such as cron's), which is what an install by a configuration manager running as root (Salt, Ansible, Puppet) has to go on. Each is configured as that user, in their own home, and the install prints one line per person:```beacon: the hook lines above are root's own; configuring the agent runtimes of logged-in usersdiff --git a/packaging/linux/smoke-package.sh b/packaging/linux/smoke-package.shindex 61a4f0e9..ae9cc52d 100755--- a/packaging/linux/smoke-package.sh+++ b/packaging/linux/smoke-package.sh@@ -111,8 +111,14 @@ for u in "$SMOKE_USER" "$SMOKE_USER2"; dodocker exec "$CONTAINER" useradd -m -s /bin/bash "$u" >/dev/null 2>&1 || truedocker exec "$CONTAINER" test -d "/home/$u" || {echo "could not create the test user $u" >&2; exit 1; }- docker exec -d "$CONTAINER" su -l "$u" -c 'exec sleep infinity'+ # -t: a login on a terminal, which logind classes "user". Without one it is a "background"+ # session (what cron opens), which Beacon rightly does not take for a person.+ docker exec -dt "$CONTAINER" su -l "$u" -c 'exec sleep infinity'done+# And an account whose only session is not a person's login: no terminal, so logind classes it+# "background", as it does cron's. A display manager's greeter is the desktop case of the same thing.+docker exec "$CONTAINER" useradd -m -s /bin/bash beaconsvc >/dev/null 2>&1 || true+docker exec -d "$CONTAINER" su -l beaconsvc -c 'exec sleep infinity'i=0while [ "$i" -lt 20 ]; dosessions="$(docker exec "$CONTAINER" loginctl list-sessions --no-legend 2>/dev/null || true)"@@ -204,7 +210,10 @@ for u in "$SMOKE_USER" "$SMOKE_USER2"; doexit 1}done-echo "ok: every logged-in user was configured, and the install said so for each"+if docker exec "$CONTAINER" test -e /home/beaconsvc/.claude/settings.json; then+ echo "beaconsvc, whose only session is a background one, was configured as if it were a person" >&2; exit 1+fi+echo "ok: every logged-in user was configured, and the install said so for each (and not a background session's account)"# Reachable by name, not just by absolute path.#