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
Restrict the system log on first package installs on macOS and Windows too
Claude7e7ae3449d90
diff --git a/CLAUDE.md b/CLAUDE.mdindex ab88bb44..7ffc9a4a 100644--- a/CLAUDE.md+++ b/CLAUDE.md@@ -28,7 +28,7 @@ Do not recreate or depend on removed `asymptote` mirror trees. Keep new work foc- Beacon is visibility-first endpoint telemetry for local AI agent runtimes, not a hosted policy service or general endpoint protection product.- Preserve the local-only default. The public Beacon build must not require a hosted account, remote policy fetch, hosted dashboard, or external network dependency during normal hook execution, and hooks themselves never touch the network.- `beacon login` is the account-identity channel for interactive users and is required by the interactive `beacon endpoint install` wizard. It uses browser PKCE against beacon.sh and stores the scoped CLI token only in `~/.beacon/auth/session.json` (0600 under a 0700 directory). Signing in alone never starts forwarding. User-mode `beacon endpoint connect` may send that token once to `POST /api/cli/enroll/account` to authorize minting a separate device ingest key, and `beacon mcp token create` may send it to `POST /api/cli/mcp/tokens` (scope `mcp:token:create`, listed on the sign-in page) to mint a personal MCP token that is printed once to stdout and never written to a file, and `beacon share` may send it (scope `traces:write`, also on the sign-in page) to `PUT /v1/traces/{external_id}`, `POST /v1/traces/{external_id}/events/batch` and `GET /v1/traces/{external_id}` on the Beacon API host (`https://api.beacon.sh` for a beacon.sh sign-in, other hosts unchanged, `BEACON_API_URL` overrides) to upload a shared trace the person chose to publish, as a `beacon.trace.v1` summary and its events (`cli/beacon/internal/account/share.go`; a `bcn_api_` API key from `--key` or `BEACON_API_KEY` may stand in for it, precedence `--key`, then a current sign-in carrying the scope, then the environment). These are explicit, user-initiated requests with redirects refused. Hooks, plugins and background jobs never make them, with one exception: the git pre-push hook, only when the person opted in with `beacon git setup --share-sessions` (public needs confirmation), may make the three share requests during a push the person started, within the hook's budget and never failing the push. Never copy the account token into endpoint config, Vector, hook environments, logs, or command output. System/root/package/MDM/CI/piped-stdin/dry-run installs stay noninteractive and account-free.-- System log access (`beacon endpoint install|repair --system --log-access shared|restricted`; docs in `docs/cli/endpoint-install.mdx#restricted-log-access`). Shared, the CLI default, is the system log as it always was: hooks append to `/var/log/beacon-agent/runtime.jsonl` directly, so it is `0666`. Restricted is opt-in for the CLI and the macOS/Windows packages, and the default for a first Linux `.deb`/`.rpm` install (`packaging/linux/install-endpoint.sh` passes `--log-access restricted` only when neither the system `config.json` nor the runtime log exists, `/proc/1/comm` is systemd and `BEACON_SERVICE` is unset, `auto` or `systemd`; otherwise it passes nothing and the endpoint keeps its mode; `packaging/linux/beacon-settings.sh`, sourced by that script and by the postinstall (which takes only `BEACON_ENDPOINT_HARNESSES`, through `beacon_settings_harnesses` in a subshell, because its user-config step re-runs the CLI as each logged-in user with its environment and must not hand them a Splunk HEC token from the file), reads the `BEACON_*` install settings, never sourcing the file, from a root-owned, not group/other-writable `/etc/default/beacon` or `/etc/sysconfig/beacon` in shell syntax with trailing comments, skipping a malformed value with a warning naming only the key, the last assignment of a key winning within the file, the environment and `install-endpoint.sh`'s positional arguments winning over it; the postinstall prints the `usermod -aG beacon-log` hint for a restricted log; `packaging/linux/test-endpoint-scripts.sh` checks all of it). Restricted makes the root collector the only writer: its `beacon_ingest` extension (`collector-builder/exporter/beaconjsonexporter/beaconingestextension`, appending through the exporter's own `internal/runtimelog`) serves `/var/run/beacon-agent/ingest.sock`, and the hook adapter and the CLI writer, as any account but root writing the system log, hand finished lines to it through `pkg/asymptoteobserve/localingest` (`Deliverer`). The protocol is one batch per connection (`BEACON-INGEST/1`, a header naming the log, one event per line, one JSON reply saying how far it got); the server refuses a batch for any log but its own, identifies the sender only by kernel peer credentials (`SO_PEERCRED`, `LOCAL_PEERCRED`), overwrites the event's `user` with that uid and its resolved name and always derives `event.id` itself (`StampLine` re-encodes, so a sender cannot split or forge lines or reuse another event's id), and bounds connections overall and per uid, batch size, each account's bytes per second, and its own time per connection (shorter than the client's, so it reports how far it got instead of being resent). The client sends only to a socket that root owns in a directory nobody else can write (group-writable ancestors only for gid 0/1, which macOS's `/private/var/run` needs). `Deliverer.Write` sends through the socket when it answers and otherwise appends directly as before; only a direct append refused for permission (a restricted log whose collector is down) spools the line, to the account's private spool for that log (`~/.beacon/endpoint/spool/<log digest>`, 0600 under 0700), and the next line that gets through either way drains it. Root writers and per-user logs always write directly. The mode is `config.json` `log_access`, carried through repair and package upgrades (`BEACON_LOG_ACCESS` in the install scripts); install creates the `beacon-log` group (`internal/endpoint/loggroup`, getent/groupadd, dscl/dseditgroup) and `writer.RestrictSystemLog` makes the directory `root:beacon-log 02750`, the log and archives `0640` and the lock root-only `0600`, after writing the root-owned `.beacon-log-access` marker beside the log; a shared log is not narrowed in place but copied to fresh root-created files and renamed over, under its lock (bounded wait), because a descriptor opened while it was 0666 survives any chmod. A failed install restores the previous mode in its rollback, and a shared install removes a dead socket. The marker is what tells every root writer (`asymptoteobserve.RuntimeLogModes`) to keep the restricted modes. The OTLP receivers on loopback are not covered by the socket: any local process can still send OTLP. On Linux those events are attributed to the account that owns the sending socket (peer attribution, below), which names the sender but does not stop an account sending what it likes under its own name; elsewhere they are unattributed, so never claim more than that. Doctor's `runtime_log_access` covers the marker, the socket and pending spool. Unix sockets are local IPC, not a network channel, so the hooks-never-touch-the-network rule holds. On Windows the same mode runs over the named pipe `\\.\pipe\beacon-agent-ingest` (`localingest` `transport_windows.go`, go-winio): the collector creates it as the first instance, and when the name is taken (any account may create one) it reports a recoverable error and retries every few seconds rather than failing, so the rest of the collector stays up; it rejects remote clients and its DACL denies NETWORK and withholds `FILE_CREATE_PIPE_INSTANCE` from ordinary accounts, so it is not a network channel either; a client connects at identification level and sends only to a pipe owned by SYSTEM or Administrators; the server counts a connection against its account from the client process's token before reading and stamps the SID it reads by `ImpersonateNamedPipeClient` after the preamble (they must agree), with `Peer.UID` a string (decimal uid on Unix, SID on Windows) and the name from `LookupAccountSid`, bounded. Privileged writers there are SYSTEM and tokens with Administrators enabled (`CheckTokenMembership`; elevation for another group is not enough). The directory gets `sysacl.RestrictedLogDirDACL` (protected: SYSTEM and Administrators full, `beacon-log` local group read, nothing else; the lock SYSTEM and Administrators only) and everything below it is reset, because every account may bypass traverse checking; `writer.RestrictSystemLog` replaces every file directly in the directory (the log family under the lock; files outside it with another hard link are skipped) with a copy created with its final owner and DACL (`sysacl.CreateRestrictedFile`) and a POSIX-semantics rename, fails naming any file held open without sharing delete and then puts a log that was shared back to shared, and writes the marker last (on Windows it decides nothing for root writers, so a failed or killed run is not mistaken for a finished one). The marker counts there when SYSTEM or Administrators own it and no other account can write it. `loggroup` creates the local group with `net.exe` and looks it up qualified with the computer name. Doctor reads the restricted ACL (`writer.CheckRestrictedSystemLogACL`). `packaging/windows/smoke-restricted-log.ps1` runs in `windows-package-smoke` against the installed MSI with a real ordinary account. Hook and writer tests point `logging.EndpointIngest`/`writer.Ingest` at sockets of their own.+- System log access (`beacon endpoint install|repair --system --log-access shared|restricted`; docs in `docs/cli/endpoint-install.mdx#restricted-log-access`). Shared, the CLI default, is the system log as it always was: hooks append to `/var/log/beacon-agent/runtime.jsonl` directly, so it is `0666`. Restricted is opt-in for the CLI and the default for a first package install on every platform (see below; on Linux `packaging/linux/install-endpoint.sh` passes `--log-access restricted` only when neither the system `config.json` nor the runtime log exists, `/proc/1/comm` is systemd and `BEACON_SERVICE` is unset, `auto` or `systemd`; otherwise it passes nothing and the endpoint keeps its mode; `packaging/linux/beacon-settings.sh`, sourced by that script and by the postinstall (which takes only `BEACON_ENDPOINT_HARNESSES`, through `beacon_settings_harnesses` in a subshell, because its user-config step re-runs the CLI as each logged-in user with its environment and must not hand them a Splunk HEC token from the file), reads the `BEACON_*` install settings, never sourcing the file, from a root-owned, not group/other-writable `/etc/default/beacon` or `/etc/sysconfig/beacon` in shell syntax with trailing comments, skipping a malformed value with a warning naming only the key, the last assignment of a key winning within the file, the environment and `install-endpoint.sh`'s positional arguments winning over it; the postinstall prints the `usermod -aG beacon-log` hint for a restricted log; `packaging/linux/test-endpoint-scripts.sh` checks all of it). Restricted makes the root collector the only writer: its `beacon_ingest` extension (`collector-builder/exporter/beaconjsonexporter/beaconingestextension`, appending through the exporter's own `internal/runtimelog`) serves `/var/run/beacon-agent/ingest.sock`, and the hook adapter and the CLI writer, as any account but root writing the system log, hand finished lines to it through `pkg/asymptoteobserve/localingest` (`Deliverer`). The protocol is one batch per connection (`BEACON-INGEST/1`, a header naming the log, one event per line, one JSON reply saying how far it got); the server refuses a batch for any log but its own, identifies the sender only by kernel peer credentials (`SO_PEERCRED`, `LOCAL_PEERCRED`), overwrites the event's `user` with that uid and its resolved name and always derives `event.id` itself (`StampLine` re-encodes, so a sender cannot split or forge lines or reuse another event's id), and bounds connections overall and per uid, batch size, each account's bytes per second, and its own time per connection (shorter than the client's, so it reports how far it got instead of being resent). The client sends only to a socket that root owns in a directory nobody else can write (group-writable ancestors only for gid 0/1, which macOS's `/private/var/run` needs). `Deliverer.Write` sends through the socket when it answers and otherwise appends directly as before; only a direct append refused for permission (a restricted log whose collector is down) spools the line, to the account's private spool for that log (`~/.beacon/endpoint/spool/<log digest>`, 0600 under 0700), and the next line that gets through either way drains it. Root writers and per-user logs always write directly. The mode is `config.json` `log_access`, carried through repair and package upgrades (`BEACON_LOG_ACCESS` in the install scripts). A first install from any package (`.deb`/`.rpm` on systemd hosts, the macOS `.pkg`, the MSI; no system config and no kept log) defaults to restricted in its install script, and adds to `beacon-log` (`--log-readers`, `loggroup.AddMember`: gpasswd/addgroup, dseditgroup, net.exe; add-only, failures reported not fatal) exactly `BEACON_LOG_READERS` when set, even empty, else only a person who installed interactively (Linux `SUDO_USER`; macOS Installer.app without `COMMAND_LINE_INSTALL`; Windows MSI `UILevel` >= 4 via the custom action's `-UiLevel`), never an unattended fleet install. Fleet tooling sets the `BEACON_*` install settings where it writes settings: `/etc/default/beacon`/`/etc/sysconfig/beacon` (`packaging/linux/beacon-settings.sh`), managed or local preferences for `com.beacon.endpoint` (`packaging/macos/beacon-settings.sh`), `HKLM\SOFTWARE\Policies\Beacon\Endpoint` (`install-endpoint.ps1`); each read only when root/admin-controlled, environment wins; docs in `docs/security/restricted-log-access.mdx#package-installs`. Install creates the `beacon-log` group (`internal/endpoint/loggroup`, getent/groupadd, dscl/dseditgroup) and `writer.RestrictSystemLog` makes the directory `root:beacon-log 02750`, the log and archives `0640` and the lock root-only `0600`, after writing the root-owned `.beacon-log-access` marker beside the log; a shared log is not narrowed in place but copied to fresh root-created files and renamed over, under its lock (bounded wait), because a descriptor opened while it was 0666 survives any chmod. A failed install restores the previous mode in its rollback, and a shared install removes a dead socket. The marker is what tells every root writer (`asymptoteobserve.RuntimeLogModes`) to keep the restricted modes. The OTLP receivers on loopback are not covered by the socket: any local process can still send OTLP. On Linux those events are attributed to the account that owns the sending socket (peer attribution, below), which names the sender but does not stop an account sending what it likes under its own name; elsewhere they are unattributed, so never claim more than that. Doctor's `runtime_log_access` covers the marker, the socket and pending spool. Unix sockets are local IPC, not a network channel, so the hooks-never-touch-the-network rule holds. On Windows the same mode runs over the named pipe `\\.\pipe\beacon-agent-ingest` (`localingest` `transport_windows.go`, go-winio): the collector creates it as the first instance, and when the name is taken (any account may create one) it reports a recoverable error and retries every few seconds rather than failing, so the rest of the collector stays up; it rejects remote clients and its DACL denies NETWORK and withholds `FILE_CREATE_PIPE_INSTANCE` from ordinary accounts, so it is not a network channel either; a client connects at identification level and sends only to a pipe owned by SYSTEM or Administrators; the server counts a connection against its account from the client process's token before reading and stamps the SID it reads by `ImpersonateNamedPipeClient` after the preamble (they must agree), with `Peer.UID` a string (decimal uid on Unix, SID on Windows) and the name from `LookupAccountSid`, bounded. Privileged writers there are SYSTEM and tokens with Administrators enabled (`CheckTokenMembership`; elevation for another group is not enough). The directory gets `sysacl.RestrictedLogDirDACL` (protected: SYSTEM and Administrators full, `beacon-log` local group read, nothing else; the lock SYSTEM and Administrators only) and everything below it is reset, because every account may bypass traverse checking; `writer.RestrictSystemLog` replaces every file directly in the directory (the log family under the lock; files outside it with another hard link are skipped) with a copy created with its final owner and DACL (`sysacl.CreateRestrictedFile`) and a POSIX-semantics rename, fails naming any file held open without sharing delete and then puts a log that was shared back to shared, and writes the marker last (on Windows it decides nothing for root writers, so a failed or killed run is not mistaken for a finished one). The marker counts there when SYSTEM or Administrators own it and no other account can write it. `loggroup` creates the local group with `net.exe` and looks it up qualified with the computer name. Doctor reads the restricted ACL (`writer.CheckRestrictedSystemLogACL`). `packaging/windows/smoke-restricted-log.ps1` runs in `windows-package-smoke` against the installed MSI with a real ordinary account. Hook and writer tests point `logging.EndpointIngest`/`writer.Ingest` at sockets of their own.- Beacon Cloud forwarding (`cli/beacon/internal/endpoint/asymptote`, `beacon endpoint connect`, `beacon endpoint asymptote`) is Vector-shaped: Beacon writes local JSONL, Vector ships runtime lines only from the connection point forward and reads inventory from the beginning to establish the endpoint's current baseline, plus the one bounded exception of the session backfill (below), and the `bcn_device_*` key stays only in `<BaseDir>/asymptote/vector-secrets.json` via Vector's secret backend. The onboarding wizard preselects Beacon Cloud, and confirming it connects this endpoint in the same command once the local install has succeeded; an endpoint that is already enrolled is never re-enrolled, because enrollment rotates the device key. Standard mode ships locally sanitized retained content; metadata-only uses local Vector transforms to remove prompts, responses, reasoning, tool arguments/results, tool descriptions/definitions, retrieval queries/documents, evaluation explanations, agent descriptions, stop sequences, approval/policy reasons, command output, raw fields, diffs, inventory content, and MCP definitions before buffering/upload. Every text-shaped event field must be classified in `metadata_fields_test.go` (`metadataOnlyRemoved`, each with its own `del()` in `pack/metadata-transforms.toml`, or `metadataOnlyKept`); a new field fails that test until it is, and `BEACON_TEST_VECTOR_BIN` runs the transform on an event with every field set. `vector.toml` is not rendered only at connect: `asymptote.ReconcileForwarder` re-renders it in place for a connected endpoint from the current pack with the enrollment's ingest URL and recorded privacy mode, validates it with the forwarder's own Vector exactly as connect does, atomically replaces it, and, when run from install, repair, the package upgrade or the hidden reconcile the macOS postinstall runs (`ReconcileOptions.Restart`), restarts a running forwarder even when nothing changed (after `vector validate` of the current config with the forwarder's own Vector, and never after a warning, so a refused config or a missing Vector leaves the running forwarder alone), as the Sentinel reconcile does: switching to restricted log access replaces the runtime log with a copy, and Vector, which recognizes a file by its first line, keeps tailing the replaced one until it restarts; an upgrade may also have installed a new Vector. A stopped one is never started and reads the new config when it next starts. The `beacon_runtime` source reads `runtime.jsonl.1` too, as the Sentinel pack does, so lines written to a replaced log before a restart are found again at the next rotation instead of lost. It never enrolls, reads or rewrites the secrets file, makes a network request, or touches `vector-data/` (checkpoints stay, so pack changes must keep source ids and fingerprinting stable), and a rejected config is a warning that keeps the old one; it is a no-op when not connected, after an incomplete connect, without an installed unit, or where `ForwarderManager` is unsupported (supervised mode). `lifecycle.Install` runs it last when services are started (so install, repair and the Linux package upgrade), repair's teardown keeps the forwarder (`UninstallOptions.KeepManagedIngest`) instead of disconnecting it, and the macOS postinstall, which installs with `--no-start`, runs the hidden `beacon endpoint asymptote reconcile --system`. Keep the ingest URL `https://`, the wire contract aligned with `beacon-ingest` (`/v1/ingest/{runtime,inventory}` and `/v1/ingest/health`), and do not add another endpoint network channel. The cloud-sandbox shuttle is the bounded exception: only with `BEACON_ORIGIN=cloud`, it can upload new runtime lines to GCS, S3, or the same Beacon ingest contract because no Vector/service manager/browser/persistent disk exists there.- Session backfill (`cli/beacon/cmd/endpoint_backfill.go`; docs in `docs/cli/endpoint-install.mdx#session-backfill` and `docs/cli/endpoint-connect.mdx#session-backfill`): after every successful install (user or system mode), every session-store collector runs once with `CollectOptions.Since` (30 days; `sessionwindow.Recent` keeps those sessions, newest first, and never touches the cursors of the rest) and a shared `writer.Budget` (24 MiB, at most 12 MiB per runtime through `Budget.Sub`; a refused append returns `writer.ErrBudgetSpent`, the collector stops with cursors past only what was written, and a manual sync reads the rest). A new session-store collector takes both fields, reads its store only through `internal/sessionfs` (a test parses every collector package to enforce it), and joins `endpointBackfillRunners` and that test's list. Every connect, first or re-connect, user or system, runs the same sweep before enrollment (skipped when install just ran it) and, before the forwarder starts, `asymptote.StageBackfill` copies the window's `harness.collection_method=poll` lines into `cloud-backfill.jsonl` beside the runtime log, which the `beacon_backfill` Vector source (fingerprinted `device_and_inode`, so each atomically restaged copy is a new file) reads from the beginning into the runtime sink through the same privacy transform. Live hook/OTLP/plugin history before the connection point stays local. Re-connects restage, so a resend of already-shipped lines is expected and rests on the deterministic `event.id`; a privacy-mode change clears the checkpoints and the restage renames the new-mode copy over the old one (kept until then so the copy is always a new inode; deleted instead when nothing restages), and `disconnect` removes it. System mode runs the collectors under `withUserHome` for the active console user (`activeConsoleUser`), with cursors under the system base directory, and reports a skip when nobody is logged in; root is reading a home the console user controls, so the sweep runs under `sessionfs.Confine` (an `os.Root` on that home, files owned by the home's owner only, non-blocking opens that refuse FIFOs/devices, SQLite read from a private snapshot under `<SystemBaseDir>/state/backfill-snapshots`, retried until the database size/change counter and WAL header are unchanged across the copy, and refused past `sessionfs.MaxSnapshotBytes` (512 MiB with its WAL) with the runtime's sync command named in the report), and refused paths read as absent and are listed in the report. User-mode sync and backfill stay unconfined. The wizard's confirm screen names the upload (`WizardOptions.BackfillDays`). Dry-run, `--no-backfill` and `BEACON_BACKFILL=0` skip all of it; the cmd tests run with `BEACON_BACKFILL=0` set in `TestMain`.- `beacon endpoint install` has a full-screen onboarding wizard on interactive user TTYs. It signs in, preselects Beacon Cloud, requires an explicit choice to opt out to Local, and asks Managed users to choose Standard or Metadata-only privacy. Signing in alone still moves no telemetry. Confirming Beacon Cloud does: the confirm screen states that it installs Beacon and starts forwarding, and names what the selected privacy mode sends, so that screen is the consent point. The managed destination is recorded only after enrollment succeeds, so a failed enrollment leaves a working local install, prints `beacon endpoint connect` as the retry, and re-offers the question on the next install. The onboarding record is written only after `lifecycle.Install` returns, because a profile written first left a failed install looking onboarded and silently skipped the wizard on the retry. Explicit `install --connect` is unchanged. The wizard is skipped for system/root/CI/piped-stdin/dry-run or `BEACON_ONBOARDING=0`; those unattended paths must never gain an account or browser dependency. Legacy `BEACON_ONBOARDING_EMAIL`/`USAGE` submissions remain only for fleet compatibility. After the destination, the wizard shows an agent tools screen; every row is preselected (opt-out, space toggles). Beacon Cloud MCP is offered only with Beacon Cloud and runs the `beacon mcp connect` flow (`connectCloudMCP` with `yes`, OAuth, detected harnesses) only after the endpoint is connected (or already was), via `finishCloudSetup`; a failed enrollment skips it and names the retry. The Beacon Agent Skills are offered for either destination and installed user-wide into `~/.agents/skills` and, when Claude Code is set up, `~/.claude/skills` (`cli/beacon/internal/agentskills`, `beacon skills install|uninstall`; a `.beacon-managed` marker decides what Beacon may replace or remove; install and repair refresh only copies Beacon already wrote). Both run after `lifecycle.Install` returns and warn rather than fail. The answers are recorded as `onboarding.cloud_mcp`/`agent_skills`. Implementation lives in `cli/beacon/internal/onboarding`, `cli/beacon/cmd/endpoint_onboarding.go`, `cli/beacon/cmd/endpoint_install.go` and `cli/beacon/cmd/agent_tools.go`; keep `docs/cli/endpoint-onboarding.mdx` and `docs/cli/skills.mdx` in sync.diff --git a/cli/beacon/cmd/endpoint.go b/cli/beacon/cmd/endpoint.goindex fa8f33ec..67e18ee3 100644--- a/cli/beacon/cmd/endpoint.go+++ b/cli/beacon/cmd/endpoint.go@@ -62,6 +62,7 @@ var endpointOpts struct {elasticPackDir stringhookLevel stringlogAccess string+ logReaders []stringcontentRetention stringsplunkHECEndpoint stringsplunkHECToken string@@ -458,6 +459,7 @@ func init() {_ = endpointInstallCmd.Flags().MarkHidden("content-retention")_ = endpointInstallCmd.Flags().MarkDeprecated("content-retention", "Beacon now always captures full content; this flag is ignored")endpointInstallCmd.Flags().StringVar(&endpointOpts.logAccess, "log-access", "", logAccessUsage)+ endpointInstallCmd.Flags().StringSliceVar(&endpointOpts.logReaders, "log-readers", nil, logReadersUsage)registerSplunkFlags(endpointInstallCmd)registerFalconFlags(endpointInstallCmd)registerOTLPForwardFlags(endpointInstallCmd)@@ -477,6 +479,7 @@ func init() {_ = endpointRepairCmd.Flags().MarkHidden("content-retention")_ = endpointRepairCmd.Flags().MarkDeprecated("content-retention", "Beacon now always captures full content; this flag is ignored")endpointRepairCmd.Flags().StringVar(&endpointOpts.logAccess, "log-access", "", logAccessUsage)+ endpointRepairCmd.Flags().StringSliceVar(&endpointOpts.logReaders, "log-readers", nil, logReadersUsage)registerSplunkFlags(endpointRepairCmd)registerFalconFlags(endpointRepairCmd)registerOTLPForwardFlags(endpointRepairCmd)diff --git a/cli/beacon/cmd/endpoint_install.go b/cli/beacon/cmd/endpoint_install.goindex 2094d045..428e2004 100644--- a/cli/beacon/cmd/endpoint_install.go+++ b/cli/beacon/cmd/endpoint_install.go@@ -140,6 +140,7 @@ func endpointInstallOptions(selection endpointTargetSelection, serviceKind serviSessionSync: sessionSync,ServiceKind: serviceKind,LogAccess: strings.ToLower(strings.TrimSpace(endpointOpts.logAccess)),+ LogReaders: endpointOpts.logReaders,}}diff --git a/cli/beacon/cmd/endpoint_logaccess.go b/cli/beacon/cmd/endpoint_logaccess.goindex 9d5b4271..798b3fd5 100644--- a/cli/beacon/cmd/endpoint_logaccess.go+++ b/cli/beacon/cmd/endpoint_logaccess.go@@ -5,6 +5,7 @@ import ("io""os""runtime"+ "strings""github.com/asymptote-labs/agent-beacon/cli/beacon/internal/endpoint/lifecycle""github.com/asymptote-labs/agent-beacon/cli/beacon/internal/endpoint/loggroup"@@ -17,6 +18,10 @@ const logAccessUsage = "System log access: shared (hooks append to a log every a"root -- SYSTEM and Administrators on Windows -- and the " + asymptoteobserve.RuntimeLogReadersGroup +" group can read it). Empty keeps the current mode. System installs only"+const logReadersUsage = "Accounts to add to the " + asymptoteobserve.RuntimeLogReadersGroup + " group of a restricted system log, " ++ "comma-separated (DOMAIN\\name on Windows). Members are only added, never removed; an account that cannot be added is " ++ "reported without failing the install. System installs with --log-access restricted only"+// reportLogAccess says what the system log's access mode means for the people who read it. A// restricted log is unreadable to an existing log shipper that does not run as root until its// account joins the readers group, which nothing else on the screen would tell them.@@ -28,7 +33,10 @@ func reportLogAccess(w io.Writer, result lifecycle.InstallResult) {} else {fmt.Fprintf(w, "Runtime log access: restricted (0640 root:%s; hooks send events to %s)\n", loggroup.Name, localingest.DefaultSocketPath)}- if result.LogReadersGroupCreated {+ if len(result.LogReadersAdded) > 0 {+ fmt.Fprintf(w, "Added to the %s group: %s (each takes effect at that account's next login)\n", loggroup.Name, strings.Join(result.LogReadersAdded, ", "))+ }+ if result.LogReadersGroupCreated && len(result.LogReadersAdded) == 0 {fmt.Fprintf(w, "Created the %s group. Add each account that should read the log, such as a log shipper's: %s\n", loggroup.Name, addToGroupHint("<account>"))} else {fmt.Fprintf(w, "Accounts that read the log need to be in the %s group: %s\n", loggroup.Name, addToGroupHint("<account>"))@@ -36,6 +44,9 @@ func reportLogAccess(w io.Writer, result lifecycle.InstallResult) {case asymptoteobserve.LogAccessShared:fmt.Fprintln(w, "Runtime log access: shared (any local account can append to and read the log; --log-access restricted narrows it)")}+ for _, problem := range result.LogReaderErrors {+ fmt.Fprintf(w, "Warning: %s\n", problem)+ }}func addToGroupHint(account string) string {diff --git a/cli/beacon/cmd/endpoint_logaccess_test.go b/cli/beacon/cmd/endpoint_logaccess_test.goindex baba76df..e7f26150 100644--- a/cli/beacon/cmd/endpoint_logaccess_test.go+++ b/cli/beacon/cmd/endpoint_logaccess_test.go@@ -54,3 +54,40 @@ func TestReportLogAccess(t *testing.T) {t.Errorf("a user-mode install reported a log access mode: %q", out.String())}}++func TestLogReadersFlag(t *testing.T) {+ for _, cmd := range []string{"install", "repair"} {+ c := endpointInstallCmd+ if cmd == "repair" {+ c = endpointRepairCmd+ }+ if c.Flags().Lookup("log-readers") == nil {+ t.Fatalf("endpoint %s has no --log-readers", cmd)+ }+ }+ old := endpointOpts+ t.Cleanup(func() { endpointOpts = old })+ endpointOpts.logReaders = []string{"alice", "svc_splunk"}+ if got := endpointInstallOptions(endpointTargetSelection{}, service.KindAuto).LogReaders; strings.Join(got, ",") != "alice,svc_splunk" {+ t.Fatalf("--log-readers gave LogReaders %v", got)+ }+}++func TestReportLogAccessNamesTheReadersAdded(t *testing.T) {+ var out bytes.Buffer+ reportLogAccess(&out, lifecycle.InstallResult{+ LogAccess: "restricted",+ LogReadersGroupCreated: true,+ LogReadersAdded: []string{"alice"},+ LogReaderErrors: []string{"could not add nosuchuser to the beacon-log group: user does not exist"},+ })+ text := out.String()+ for _, want := range []string{"Added to the beacon-log group: alice", "next login", "Warning: could not add nosuchuser"} {+ if !strings.Contains(text, want) {+ t.Errorf("report lacks %q:\n%s", want, text)+ }+ }+ if strings.Contains(text, "Created the beacon-log group. Add each account") {+ t.Errorf("report still says the new group has no members after adding alice:\n%s", text)+ }+}diff --git a/cli/beacon/internal/endpoint/lifecycle/lifecycle.go b/cli/beacon/internal/endpoint/lifecycle/lifecycle.goindex ea8b9c3c..439f4591 100644--- a/cli/beacon/internal/endpoint/lifecycle/lifecycle.go+++ b/cli/beacon/internal/endpoint/lifecycle/lifecycle.go@@ -340,6 +340,10 @@ type InstallOptions struct {// LogAccess sets the system log's access mode, "shared" or "restricted". Empty keeps what the// existing config records, so repair and a package upgrade never change it.LogAccess string+ // LogReaders are accounts to add to the readers group of a restricted system log after the+ // install. Members are only ever added, never removed, and an account that cannot be added is+ // reported rather than failing the install. Ignored, and reported, for a shared log.+ LogReaders []string// SessionSync turns the scheduled session-store sync on or off; nil keeps what the existing// config records (off for a new install), so repair and package upgrades never change it.SessionSync *bool@@ -382,8 +386,12 @@ type InstallResult struct {LogAccess string `json:"log_access,omitempty"`// LogReadersGroupCreated is true when this install created the readers group a restricted log// is readable by, which then has no members yet.- LogReadersGroupCreated bool `json:"log_readers_group_created,omitempty"`- InventoryJobDetail string `json:"inventory_job_detail,omitempty"`+ LogReadersGroupCreated bool `json:"log_readers_group_created,omitempty"`+ // LogReadersAdded are the LogReaders accounts now in the readers group; LogReaderErrors say why+ // any others are not, or that they were ignored because the log is shared.+ LogReadersAdded []string `json:"log_readers_added,omitempty"`+ LogReaderErrors []string `json:"log_reader_errors,omitempty"`+ InventoryJobDetail string `json:"inventory_job_detail,omitempty"`// SessionSyncJobPath is the scheduled session sync unit when `session_sync.enabled` is on;// SessionSyncJobDetail says why it is not installed on a host without a scheduler.SessionSyncJobPath string `json:"session_sync_job_path,omitempty"`@@ -678,6 +686,7 @@ func Install(opts InstallOptions) (InstallResult, error) {logReadersGroupCreated = createdrestoreLogAccess = restore}+ logReadersAdded, logReaderErrors := addLogReaders(cfg, opts.LogReaders)tx := newInstallRollback(manager)tx.RestoreLogAccess = restoreLogAccess@@ -884,6 +893,8 @@ func Install(opts InstallOptions) (InstallResult, error) {SessionSyncJobDetail: sessionSyncResult.Skipped,LogAccess: logAccessOf(cfg),LogReadersGroupCreated: logReadersGroupCreated,+ LogReadersAdded: logReadersAdded,+ LogReaderErrors: logReaderErrors,}, nil}diff --git a/cli/beacon/internal/endpoint/lifecycle/logaccess.go b/cli/beacon/internal/endpoint/lifecycle/logaccess.goindex 434ce3ec..b028d723 100644--- a/cli/beacon/internal/endpoint/lifecycle/logaccess.go+++ b/cli/beacon/internal/endpoint/lifecycle/logaccess.go@@ -2,6 +2,7 @@ package lifecycleimport ("fmt"+ "strings"endpointconfig "github.com/asymptote-labs/agent-beacon/cli/beacon/internal/endpoint/config""github.com/asymptote-labs/agent-beacon/cli/beacon/internal/endpoint/loggroup"@@ -13,6 +14,7 @@ import (// Seams for tests, which cannot be root or change the account database.var (ensureLogReadersGroup = loggroup.Ensure+ addLogReaderMember = loggroup.AddMemberlogIsRestricted = asymptoteobserve.RuntimeLogAccessRestrictedremoveStaleIngestSocket = localingest.RemoveStalerestrictSystemLog = writer.RestrictSystemLog@@ -88,3 +90,30 @@ func logAccessRestorer(cfg endpointconfig.Config) func() {_ = shareSystemLog(cfg.LogPath)}}++// addLogReaders puts each named account in the readers group of a restricted system log. It never+// removes anyone, and an account that cannot be added (unknown, or a tool that failed) is reported+// rather than failing an install that has otherwise succeeded: a fleet install must not stop over+// one misspelled name. A shared log has no readers group, so the names are reported as ignored.+func addLogReaders(cfg endpointconfig.Config, readers []string) (added, problems []string) {+ if cfg.UserMode || len(readers) == 0 {+ return nil, nil+ }+ if !cfg.RestrictedLogAccess() {+ return nil, []string{fmt.Sprintf("ignored log readers %s: the system log is shared, so every account can already read it", strings.Join(readers, ", "))}+ }+ seen := map[string]bool{}+ for _, account := range readers {+ account = strings.TrimSpace(account)+ if account == "" || seen[account] {+ continue+ }+ seen[account] = true+ if err := addLogReaderMember(loggroup.Name, account); err != nil {+ problems = append(problems, fmt.Sprintf("could not add %s to the %s group: %v", account, loggroup.Name, err))+ continue+ }+ added = append(added, account)+ }+ return added, problems+}diff --git a/cli/beacon/internal/endpoint/lifecycle/logaccess_test.go b/cli/beacon/internal/endpoint/lifecycle/logaccess_test.goindex baa0a020..c4a56c00 100644--- a/cli/beacon/internal/endpoint/lifecycle/logaccess_test.go+++ b/cli/beacon/internal/endpoint/lifecycle/logaccess_test.go@@ -193,3 +193,40 @@ func TestRollbackRestoresTheLogAccessMode(t *testing.T) {t.Fatal("Rollback did not restore the log access mode")}}++func TestAddLogReaders(t *testing.T) {+ var added []string+ prev := addLogReaderMember+ t.Cleanup(func() { addLogReaderMember = prev })+ addLogReaderMember = func(group, account string) error {+ if group != loggroup.Name {+ t.Fatalf("added to group %q, want %q", group, loggroup.Name)+ }+ if account == "nosuchuser" {+ return errors.New("user does not exist")+ }+ added = append(added, account)+ return nil+ }+ restricted := endpointconfig.Config{LogAccess: "restricted"}++ got, problems := addLogReaders(restricted, []string{"alice", " alice ", "", "nosuchuser", "svc_splunk"})+ if strings.Join(got, ",") != "alice,svc_splunk" || strings.Join(added, ",") != "alice,svc_splunk" {+ t.Fatalf("added = %v (calls %v), want alice and svc_splunk once each", got, added)+ }+ if len(problems) != 1 || !strings.Contains(problems[0], "nosuchuser") {+ t.Fatalf("problems = %v, want one naming nosuchuser", problems)+ }++ added = nil+ got, problems = addLogReaders(endpointconfig.Config{LogAccess: "shared"}, []string{"alice"})+ if len(got) != 0 || len(added) != 0 || len(problems) != 1 || !strings.Contains(problems[0], "shared") {+ t.Fatalf("shared log: added %v, calls %v, problems %v; want nothing added and one note", got, added, problems)+ }+ if got, problems := addLogReaders(endpointconfig.Config{UserMode: true, LogAccess: "restricted"}, []string{"alice"}); got != nil || problems != nil {+ t.Fatalf("user mode: %v, %v; want nothing", got, problems)+ }+ if got, problems := addLogReaders(restricted, nil); got != nil || problems != nil {+ t.Fatalf("no readers: %v, %v; want nothing", got, problems)+ }+}diff --git a/cli/beacon/internal/endpoint/loggroup/loggroup.go b/cli/beacon/internal/endpoint/loggroup/loggroup.goindex 9c38a2f5..b5314031 100644--- a/cli/beacon/internal/endpoint/loggroup/loggroup.go+++ b/cli/beacon/internal/endpoint/loggroup/loggroup.go@@ -91,6 +91,43 @@ func Lookup(name string) (gid int, found bool, err error) {return lookup(name)}+// AddMember adds account to the group, which must exist. Adding an account that is already a member+// succeeds. The account may come from a directory service, so it is resolved by the system's own+// tools, never by os/user.+func AddMember(group, account string) error {+ if err := validName(group); err != nil {+ return err+ }+ if err := validAccount(account); err != nil {+ return err+ }+ return addMember(group, account)+}++// validAccount accepts the account names local and directory accounts use -- letters, digits and+// . _ - $ @, plus one DOMAIN\name separator on Windows -- so a name is never read as an option, a+// path or a second argument by the tools it is passed to.+func validAccount(account string) error {+ if account == "" || len(account) > 256 || strings.HasPrefix(account, "-") {+ return fmt.Errorf("invalid account name %q", account)+ }+ backslashes := 0+ for _, r := range account {+ switch {+ case r >= 'a' && r <= 'z', r >= 'A' && r <= 'Z', r >= '0' && r <= '9':+ case r == '.' || r == '_' || r == '-' || r == '$' || r == '@':+ case r == '\\' && accountDomainSeparator:+ backslashes+++ default:+ return fmt.Errorf("invalid account name %q", account)+ }+ }+ if backslashes > 1 || strings.HasPrefix(account, "\\") || strings.HasSuffix(account, "\\") {+ return fmt.Errorf("invalid account name %q", account)+ }+ return nil+}+// validName accepts only what both platforms accept as a group name, so a name is never read as an// option or a path by the tools it is passed to.func validName(name string) error {diff --git a/cli/beacon/internal/endpoint/loggroup/loggroup_account_test.go b/cli/beacon/internal/endpoint/loggroup/loggroup_account_test.gonew file mode 100644index 00000000..a6439af0--- /dev/null+++ b/cli/beacon/internal/endpoint/loggroup/loggroup_account_test.go@@ -0,0 +1,28 @@+package loggroup++import (+ "strings"+ "testing"+)++func TestValidAccount(t *testing.T) {+ for _, account := range []string{"alice", "alice.smith", "svc_splunk", "build-01", "MACHINE$", "[email protected]"} {+ if err := validAccount(account); err != nil {+ t.Errorf("validAccount(%q) = %v, want accepted", account, err)+ }+ }+ for _, account := range []string{"", "-alice", "a b", "a/b", "a;b", "a,b", "a\nb", "naïve", "$(id)", "`id`", strings.Repeat("x", 257)} {+ if err := validAccount(account); err == nil {+ t.Errorf("validAccount(%q) accepted", account)+ }+ }+ // A DOMAIN\name account exists only on Windows, with exactly one separator between two names.+ if got := validAccount(`CORP\alice`) == nil; got != accountDomainSeparator {+ t.Errorf("validAccount(CORP\\alice) accepted = %v, want %v", got, accountDomainSeparator)+ }+ for _, account := range []string{`\\alice`, `CORP\`, `A\B\c`} {+ if err := validAccount(account); err == nil {+ t.Errorf("validAccount(%q) accepted", account)+ }+ }+}diff --git a/cli/beacon/internal/endpoint/loggroup/loggroup_darwin.go b/cli/beacon/internal/endpoint/loggroup/loggroup_darwin.goindex f8018d5c..5ae57fed 100644--- a/cli/beacon/internal/endpoint/loggroup/loggroup_darwin.go+++ b/cli/beacon/internal/endpoint/loggroup/loggroup_darwin.go@@ -41,3 +41,12 @@ func create(name string) error {}return nil}++// accountDomainSeparator is false: macOS short names never contain a backslash.+const accountDomainSeparator = false++// addMember adds the user to the local group record; dseditgroup succeeds for an existing member.+func addMember(group, account string) error {+ _, err := run(dseditgroup, "-o", "edit", "-a", account, "-t", "user", group)+ return err+}diff --git a/cli/beacon/internal/endpoint/loggroup/loggroup_darwin_test.go b/cli/beacon/internal/endpoint/loggroup/loggroup_darwin_test.goindex 56725248..7f9cba88 100644--- a/cli/beacon/internal/endpoint/loggroup/loggroup_darwin_test.go+++ b/cli/beacon/internal/endpoint/loggroup/loggroup_darwin_test.go@@ -77,3 +77,14 @@ func TestDarwinLookupOnThisSystem(t *testing.T) {t.Fatalf("Lookup(missing) = %v, %v", found, err)}}++func TestAddMemberEditsTheLocalGroup(t *testing.T) {+ calls := fakeDirectory(t, map[string]int{Name: 401})+ if err := AddMember(Name, "alice"); err != nil {+ t.Fatal(err)+ }+ want := dseditgroup + " -o edit -a alice -t user " + Name+ if len(*calls) != 1 || (*calls)[0] != want {+ t.Fatalf("calls = %q, want [%q]", *calls, want)+ }+}diff --git a/cli/beacon/internal/endpoint/loggroup/loggroup_linux.go b/cli/beacon/internal/endpoint/loggroup/loggroup_linux.goindex 3fc2dee9..970cabb6 100644--- a/cli/beacon/internal/endpoint/loggroup/loggroup_linux.go+++ b/cli/beacon/internal/endpoint/loggroup/loggroup_linux.go@@ -47,3 +47,21 @@ func create(name string) error {}return errors.New("neither groupadd nor addgroup is available")}++// accountDomainSeparator is false: Linux account names never contain a backslash.+const accountDomainSeparator = false++// addMember uses gpasswd, which resolves the account through NSS and so accepts a directory (SSSD,+// LDAP) account that usermod, which reads only /etc/passwd, refuses; busybox addgroup where that is+// all there is. Both are no-ops for an existing member.+func addMember(group, account string) error {+ if gpasswd, ok := lookPath("gpasswd", "/usr/bin/gpasswd", "/usr/sbin/gpasswd", "/bin/gpasswd"); ok {+ _, err := run(gpasswd, "-a", account, group)+ return err+ }+ if addgroup, ok := lookPath("addgroup", "/usr/sbin/addgroup", "/sbin/addgroup"); ok {+ _, err := run(addgroup, account, group)+ return err+ }+ return errors.New("neither gpasswd nor addgroup is available")+}diff --git a/cli/beacon/internal/endpoint/loggroup/loggroup_linux_test.go b/cli/beacon/internal/endpoint/loggroup/loggroup_linux_test.goindex 1a4951be..697be1d5 100644--- a/cli/beacon/internal/endpoint/loggroup/loggroup_linux_test.go+++ b/cli/beacon/internal/endpoint/loggroup/loggroup_linux_test.go@@ -48,6 +48,10 @@ func install(t *testing.T, sys *fakeSystem) {return line + "\n", nil}return "", exitCode(t, 2)+ case strings.HasSuffix(path, "gpasswd"):+ return "Adding user " + args[1] + " to group " + args[2] + "\n", nil+ case strings.HasSuffix(path, "addgroup") && len(args) == 2 && args[0] != "-S":+ return "", nilcase strings.HasSuffix(path, "groupadd"), strings.HasSuffix(path, "addgroup"):if sys.failAdd != nil {return "", sys.failAdd@@ -165,3 +169,42 @@ func contains(calls []string, want string) bool {}return false}++func TestAddMemberUsesGpasswd(t *testing.T) {+ sys := &fakeSystem{groups: map[string]string{}, tools: map[string]bool{"gpasswd": true, "addgroup": true}}+ install(t, sys)+ if err := AddMember("beacon-log", "[email protected]"); err != nil {+ t.Fatal(err)+ }+ if !contains(sys.calls, "/usr/sbin/gpasswd -a [email protected] beacon-log") {+ t.Fatalf("calls = %v", sys.calls)+ }+}++func TestAddMemberFallsBackToBusyboxAddgroup(t *testing.T) {+ sys := &fakeSystem{groups: map[string]string{}, tools: map[string]bool{"addgroup": true}}+ install(t, sys)+ if err := AddMember("beacon-log", "alice"); err != nil {+ t.Fatal(err)+ }+ if !contains(sys.calls, "/usr/sbin/addgroup alice beacon-log") {+ t.Fatalf("calls = %v", sys.calls)+ }+ install(t, &fakeSystem{groups: map[string]string{}, tools: map[string]bool{}})+ if err := AddMember("beacon-log", "alice"); err == nil {+ t.Fatal("AddMember succeeded with no tool to add a member")+ }+}++func TestInvalidAccountsNeverReachATool(t *testing.T) {+ sys := &fakeSystem{groups: map[string]string{}, tools: map[string]bool{"gpasswd": true}}+ install(t, sys)+ for _, account := range []string{"", "-a", "a b", "a/b", "a;b", "a,b", `CORP\alice`, "$(id)", strings.Repeat("x", 257)} {+ if err := AddMember("beacon-log", account); err == nil {+ t.Errorf("AddMember(%q) accepted", account)+ }+ }+ if len(sys.calls) != 0 {+ t.Fatalf("ran a tool for an invalid account: %v", sys.calls)+ }+}diff --git a/cli/beacon/internal/endpoint/loggroup/loggroup_other.go b/cli/beacon/internal/endpoint/loggroup/loggroup_other.goindex 087583dc..1779d403 100644--- a/cli/beacon/internal/endpoint/loggroup/loggroup_other.go+++ b/cli/beacon/internal/endpoint/loggroup/loggroup_other.go@@ -5,3 +5,7 @@ package loggroupfunc lookup(string) (int, bool, error) { return 0, false, ErrUnsupported }func create(string) error { return ErrUnsupported }++const accountDomainSeparator = false++func addMember(string, string) error { return ErrUnsupported }diff --git a/cli/beacon/internal/endpoint/loggroup/loggroup_windows.go b/cli/beacon/internal/endpoint/loggroup/loggroup_windows.goindex 40486acc..fa50fbb1 100644--- a/cli/beacon/internal/endpoint/loggroup/loggroup_windows.go+++ b/cli/beacon/internal/endpoint/loggroup/loggroup_windows.go@@ -6,6 +6,7 @@ import ("errors""fmt""path/filepath"+ "strings""golang.org/x/sys/windows")@@ -57,3 +58,22 @@ func create(name string) error {"/comment:Accounts that may read the Beacon system runtime log")return err}++// accountDomainSeparator is true: a Windows account may be named DOMAIN\name.+const accountDomainSeparator = true++// addMember adds the account to the local group with net.exe from the system directory. net.exe+// reports an existing member as error 1378, which counts as success.+func addMember(group, account string) error {+ system, err := windows.GetSystemDirectory()+ if err != nil {+ return fmt.Errorf("find the system directory: %w", err)+ }+ if _, err := run(filepath.Join(system, "net.exe"), "localgroup", group, account, "/add"); err != nil {+ if strings.Contains(err.Error(), "1378") {+ return nil+ }+ return err+ }+ return nil+}diff --git a/cli/beacon/internal/endpoint/loggroup/loggroup_windows_test.go b/cli/beacon/internal/endpoint/loggroup/loggroup_windows_test.goindex 3c3f9900..112d19ab 100644--- a/cli/beacon/internal/endpoint/loggroup/loggroup_windows_test.go+++ b/cli/beacon/internal/endpoint/loggroup/loggroup_windows_test.go@@ -87,3 +87,23 @@ func TestEnsureAgainstThisMachine(t *testing.T) {t.Fatalf("second Ensure = created %v, %v", created, err)}}++func TestAddMemberAddsToTheLocalGroup(t *testing.T) {+ calls := fakeAccounts(t, map[string]string{Name: "S-1-5-21-1-2-3-1500"})+ if err := AddMember(Name, `CORP\alice`); err != nil {+ t.Fatal(err)+ }+ if len(*calls) != 1 || (*calls)[0] != "net.exe localgroup "+Name+` CORP\alice /add` {+ t.Fatalf("calls = %q", *calls)+ }+}++func TestAddMemberTreatsAnExistingMemberAsSuccess(t *testing.T) {+ fakeAccounts(t, map[string]string{Name: "S-1-5-21-1-2-3-1500"})+ run = func(string, ...string) (string, error) {+ return "", fmt.Errorf("net.exe: exit status 2: System error 1378 has occurred. The specified account name is already a member of the group.")+ }+ if err := AddMember(Name, "alice"); err != nil {+ t.Fatalf("AddMember = %v, want success for an existing member", err)+ }+}diff --git a/docs/changelog/cli.mdx b/docs/changelog/cli.mdxindex 658345ea..f112e830 100644--- a/docs/changelog/cli.mdx+++ b/docs/changelog/cli.mdx@@ -11,8 +11,8 @@ Stay up to date with the latest changes to the Agent Beacon CLI.## Unreleased-- **Linux package installs are restricted from the start** · A first install of the `.deb` or `.rpm` now sets up [restricted log access](/security/restricted-log-access) on its own: the `beacon-log` group, a `0640 root:beacon-log` log that only the collector writes, and hooks that send their events over the local socket, recorded under the account that sent them. Before, a fleet install by root (Salt, Ansible, an MDM script) left the log world-writable until someone ran `sudo beacon endpoint repair --system --log-access restricted`. Only where systemd runs the collector: without it, or with `BEACON_SERVICE=none`, the default stays shared. Upgrades, and reinstalls over a log kept by `uninstall --keep-logs`, keep the mode an endpoint already has, so existing endpoints do not change; `BEACON_LOG_ACCESS=shared` installs a new endpoint shared. Log shippers that do not run as root, and people who read the log with the dashboard, `beacon share` or `beacon traces`, need to join `beacon-log` (`sudo usermod -aG beacon-log <user>`); the install says so.-- **Package install settings from `/etc/default/beacon`** · Configuration managers run `apt` or `dnf` without letting you set the package's environment, so the `BEACON_*` install settings could not reach a Salt or Ansible install. The Linux package now also reads them from `/etc/default/beacon` or `/etc/sysconfig/beacon`, for both the system install and the people it configures (read as shell syntax, trailing comments included, but never run; root-owned and not writable by other accounts, or it is ignored with a warning; a malformed value is skipped with a warning naming its key). The environment, and the install script's positional arguments, still win, and a key set twice takes its last value. See [Settings for configuration-manager installs](/platforms/linux#settings-for-configuration-manager-installs).+- **Package installs are restricted from the start, on Linux, macOS and Windows** · A first install of the `.deb` or `.rpm`, the macOS `.pkg` or the Windows MSI now sets up [restricted log access](/security/restricted-log-access) on its own: the `beacon-log` group, a log that only the collector writes, and hooks that send their events over the local socket or named pipe, recorded under the account that sent them. Before, a fleet install (Salt, Ansible, Jamf, Intune) left the log writable by every account until someone ran `beacon endpoint repair --system --log-access restricted`. On Linux, only where systemd runs the collector. Upgrades, and reinstalls over a kept config or log, keep the mode an endpoint already has; `BEACON_LOG_ACCESS=shared` installs a new endpoint shared. A person who installs the package interactively (`sudo apt install`, Installer.app, the MSI's full interface) is added to `beacon-log`, so the dashboard, `beacon traces` and `beacon share` work for them; an unattended fleet install adds nobody. `BEACON_LOG_READERS`, or the new `--log-readers`, names exactly who is added. See [Package installs](/security/restricted-log-access#package-installs).+- **Package install settings for fleet tooling** · MDMs and configuration managers install packages without letting you set the install script's environment, so the `BEACON_*` install settings could not reach a fleet install. Each package now also reads them where that platform's tooling writes settings: `/etc/default/beacon` or `/etc/sysconfig/beacon` on Linux (read as shell syntax, never run), managed preferences for `com.beacon.endpoint` on macOS, and `HKLM\SOFTWARE\Policies\Beacon\Endpoint` on Windows. Each is ignored unless root (SYSTEM or Administrators) controls it, and the environment still wins. See [Package installs](/security/restricted-log-access#package-installs).- **OpenTelemetry events name the person who sent them on Linux** · On a system install every account exports to the same local collector, so prompts and token usage from Claude Code, Codex and the browser extension were recorded, and forwarded to SIEMs such as Microsoft Sentinel, under the collector's account, `root`, whoever typed them. The Linux collector now records each OpenTelemetry export under the account that owns the connection it arrived on, as the kernel reports it, over gRPC and HTTP alike, and ignores any account a sender names for itself, on the resource or on a record, span or datapoint. Claude Cowork events on Linux carry no `user`: they reach the collector through a relay such as `beacon endpoint cowork --ngrok`, so the kernel names the relay's account rather than the person, and the cloud account Cowork reports is the sender's own claim. Both stay in the event's raw attributes. An export whose sender cannot be identified (it disconnected before the collector looked) carries no `user` at all, rather than the collector's `root`, so a recorded `root` always means root sent it. A Falcon LogScale HEC destination records the same account as `runtime.jsonl`. Beacon's OTLP forward to another backend is unchanged. macOS and Windows are unchanged. Run `beacon endpoint repair --system` (package upgrades do this) to render the new collector config; the collector from the same release is required.- **Root and fleet installs configure everyone logged in, and say who** · A system install by root with no `sudo` user, such as Salt's `pkg.installed` or an Ansible `apt` task, configured the agent runtime of only the first logged-in session it found, and printed nothing about it; the only hook lines in the output were root's own. `beacon endpoint user-config repair-installed --system`, which the Linux package runs after installing, now configures the `sudo` user and every account with a live logind session, each as themselves, carries on when one of them fails, and prints `Configured <user> (<home>): …` for each, or that nobody was logged in and what to run. `--json` adds a `users` array; the existing fields still describe the first person.- **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.diff --git a/docs/cli/endpoint-install.mdx b/docs/cli/endpoint-install.mdxindex d599fe2c..2cba18ec 100644--- a/docs/cli/endpoint-install.mdx+++ b/docs/cli/endpoint-install.mdx@@ -62,7 +62,8 @@ The `claude` harness writes both Claude Code's OpenTelemetry settings and its us| `--no-otlp-forward` | Remove a configured OTLP forward || `--session-sync` | Turn on the [scheduled session sync](#scheduled-session-sync): every 15 minutes, read new records from the agent runtimes' local session stores into the runtime log. Kept by repair and package upgrades || `--no-session-sync` | Turn the scheduled session sync off and remove its job |-| `--log-access <mode>` | System log access: `shared` (the default) or `restricted`. See [Restricted log access](#restricted-log-access). Omitted, an install keeps the mode the endpoint already has. System installs on macOS and Linux only |+| `--log-access <mode>` | System log access: `shared` (the default) or `restricted`. See [Restricted log access](#restricted-log-access). Omitted, an install keeps the mode the endpoint already has. A first install from a package is restricted ([Package installs](/security/restricted-log-access#package-installs)). System installs only |+| `--log-readers <accounts>` | Accounts to add to the `beacon-log` group of a restricted log, comma-separated (`DOMAIN\name` on Windows). Accounts are only added, never removed; one that cannot be added is reported without failing the install. Package installs set it from `BEACON_LOG_READERS`. System installs only || `--no-backfill` | Skip the [session backfill](#session-backfill). `BEACON_BACKFILL=0` does the same || `--connect` | After a successful install, attempt to connect this endpoint to Beacon Cloud ingest. User mode uses the signed-in CLI account; system mode opens browser approval. A connection failure does not roll back or fail the completed local install; verify with `beacon endpoint status --json` and retry with [`beacon endpoint connect`](/cli/endpoint-connect) |@@ -310,7 +311,7 @@ sudo dseditgroup -o edit -a <account> -t user beacon-logThe log format and every event field stay the same, so a SIEM or forwarder that parses the log needs no change. Shippers that run as root, and the Beacon Cloud forwarder, keep working without one.-The mode is recorded in `config.json` as `log_access`, and in a root-owned `.beacon-log-access` marker beside the log. `beacon endpoint repair`, package upgrades, the Jamf `repair-hooks.sh` policy, and a reinstall after `uninstall --keep-logs` keep it. To go back, run `sudo beacon endpoint repair --system --log-access shared`; the log is writable by every account again at once. For package installs, set `BEACON_LOG_ACCESS=restricted` in the environment of the package's install script. A first install from the Linux `.deb` or `.rpm` is restricted without it (`BEACON_LOG_ACCESS=shared` opts out), and the Linux install script also reads its settings from `/etc/default/beacon` or `/etc/sysconfig/beacon` for configuration managers that cannot set its environment.+The mode is recorded in `config.json` as `log_access`, and in a root-owned `.beacon-log-access` marker beside the log. `beacon endpoint repair`, package upgrades, the Jamf `repair-hooks.sh` policy, and a reinstall after `uninstall --keep-logs` keep it. To go back, run `sudo beacon endpoint repair --system --log-access shared`; the log is writable by every account again at once. A first install from a package (the `.deb` or `.rpm`, the macOS `.pkg`, the Windows MSI) is restricted without any setting, and adds to `beacon-log` only the person who ran it interactively, or the accounts in `BEACON_LOG_READERS`; `BEACON_LOG_ACCESS=shared` opts out. Fleet tooling that cannot set the install script's environment sets these in `/etc/default/beacon` on Linux, managed preferences on macOS, or registry policy on Windows; see [Package installs](/security/restricted-log-access#package-installs).What this does and does not change:diff --git a/docs/platforms/linux.mdx b/docs/platforms/linux.mdxindex edffc4fc..fe75963b 100644--- a/docs/platforms/linux.mdx+++ b/docs/platforms/linux.mdx@@ -212,7 +212,7 @@ The `Claude Code hooks installed: /root/...` lines printed before it are root'ssudo beacon endpoint user-config repair-installed --system```-Other users on the same machine run the same command for themselves. They all export to the same collector and the same log. A first package install on a host where systemd runs the collector sets the log to [restricted access](/cli/endpoint-install#restricted-log-access): the collector is the only writer, hooks hand their events to it over a local socket and are recorded under the account the kernel says sent them, and only root and the `beacon-log` group can read the log. That includes the people using the machine: the dashboard, `beacon share` and `beacon traces` cannot read the system log for an account outside `beacon-log`, so on a single person's workstation add them with `sudo usermod -aG beacon-log <user>` (and log in again); the install prints this. Without systemd as PID 1 (a container, WSL without systemd) or with `BEACON_SERVICE=none`, the collector is a process nothing restarts, so those installs stay shared unless you ask for restricted. A package upgrade, or a reinstall over a log kept by `uninstall --keep-logs`, keeps whatever mode the endpoint already has, so an endpoint installed from an earlier package stays shared until you switch it with `sudo beacon endpoint repair --system --log-access restricted`. To install with the older shared log instead, where every account appends to the file directly, set `BEACON_LOG_ACCESS=shared` (see below).+Other users on the same machine run the same command for themselves. They all export to the same collector and the same log. A first package install on a host where systemd runs the collector sets the log to [restricted access](/cli/endpoint-install#restricted-log-access): the collector is the only writer, hooks hand their events to it over a local socket and are recorded under the account the kernel says sent them, and only root and the `beacon-log` group can read the log. That includes the people using the machine: the dashboard, `beacon share` and `beacon traces` cannot read the system log for an account outside `beacon-log`. When you install the package yourself with `sudo`, you are added to `beacon-log` (log in again for it to take effect); a configuration manager's install adds nobody. Add anyone else with `sudo usermod -aG beacon-log <user>`, or name them in `BEACON_LOG_READERS` (see [Package installs](/security/restricted-log-access#package-installs)). Without systemd as PID 1 (a container, WSL without systemd) or with `BEACON_SERVICE=none`, the collector is a process nothing restarts, so those installs stay shared unless you ask for restricted. A package upgrade, or a reinstall over a log kept by `uninstall --keep-logs`, keeps whatever mode the endpoint already has, so an endpoint installed from an earlier package stays shared until you switch it with `sudo beacon endpoint repair --system --log-access restricted`. To install with the older shared log instead, where every account appends to the file directly, set `BEACON_LOG_ACCESS=shared` (see below).### Settings for configuration-manager installs@@ -220,6 +220,7 @@ Salt's `pkg.installed`, Ansible's `apt` and `dnf` modules, Puppet and Chef run t```bash title="/etc/default/beacon"BEACON_LOG_ACCESS=restricted+BEACON_LOG_READERS= # nobody is added to beacon-log implicitlyBEACON_ENDPOINT_HARNESSES=claude,codex,cursorBEACON_SESSION_SYNC=1```@@ -232,6 +233,7 @@ BEACON_SESSION_SYNC=1- mode: "0600"- contents: |BEACON_LOG_ACCESS=restricted+ BEACON_LOG_READERS=beacon:pkg.installed:@@ -241,7 +243,7 @@ beacon:- file: /etc/default/beacon```-The file is read, not run: each line is a `KEY=VALUE` written as a shell would read it (an `export` in front, quotes around the value, and `# comments` on their own line or after the value are allowed; a value with an unquoted space or an unclosed quote is skipped with a warning naming the key), and only the install settings the script documents are taken (`BEACON_LOG_ACCESS`, `BEACON_ENDPOINT_HARNESSES`, `BEACON_OTLP_GRPC_PORT`, `BEACON_OTLP_HTTP_PORT`, `BEACON_SESSION_SYNC`, `BEACON_SERVICE`, `BEACON_NO_START`, `BEACON_COLLECTOR` and the `BEACON_SPLUNK_*` settings). Because the install script runs as root, the file is ignored, with a warning, unless root owns it and no other account can write it. A variable set in the install script's environment, or passed as one of its positional arguments when you run `/opt/beacon/scripts/install-endpoint.sh` yourself, wins over the file. A key the file sets twice takes the last value, as a shell would, so appending a line overrides an earlier one. The package reads it for both of its steps, so `BEACON_ENDPOINT_HARNESSES` reaches the system install and the agent runtimes of the people it configures. The file is read on every install and upgrade, so keep it in step with what you want the endpoint to be; an unset `BEACON_LOG_ACCESS` on an upgrade keeps the mode the endpoint has.+The file is read, not run: each line is a `KEY=VALUE` written as a shell would read it (an `export` in front, quotes around the value, and `# comments` on their own line or after the value are allowed; a value with an unquoted space or an unclosed quote is skipped with a warning naming the key), and only the install settings the script documents are taken (`BEACON_LOG_ACCESS`, `BEACON_LOG_READERS`, `BEACON_ENDPOINT_HARNESSES`, `BEACON_OTLP_GRPC_PORT`, `BEACON_OTLP_HTTP_PORT`, `BEACON_SESSION_SYNC`, `BEACON_SERVICE`, `BEACON_NO_START`, `BEACON_COLLECTOR` and the `BEACON_SPLUNK_*` settings). Because the install script runs as root, the file is ignored, with a warning, unless root owns it and no other account can write it. A variable set in the install script's environment, or passed as one of its positional arguments when you run `/opt/beacon/scripts/install-endpoint.sh` yourself, wins over the file. A key the file sets twice takes the last value, as a shell would, so appending a line overrides an earlier one. The package reads it for both of its steps, so `BEACON_ENDPOINT_HARNESSES` reaches the system install and the agent runtimes of the people it configures. The file is read on every install and upgrade, so keep it in step with what you want the endpoint to be; an unset `BEACON_LOG_ACCESS` on an upgrade keeps the mode the endpoint has.## Managing the servicediff --git a/docs/platforms/macos.mdx b/docs/platforms/macos.mdxindex f29669d6..e79612f7 100644--- a/docs/platforms/macos.mdx+++ b/docs/platforms/macos.mdx@@ -34,6 +34,34 @@ For deployment across machines, use the signed, notarized, and stapled `.pkg` atThe package also configures the console user's agent runtime, because a system endpoint runs as root and the collector is useless if nothing is exporting to it.+A first install from the package sets up [restricted log access](/security/restricted-log-access): only the collector writes the log, and only root and the `beacon-log` group can read it. An upgrade keeps the mode the endpoint already has. A person who installs the package in Installer.app is added to `beacon-log`, so the dashboard, `beacon traces` and `beacon share` work for them after they log in again; an MDM install adds nobody. See [Package installs](/security/restricted-log-access#package-installs).++### Settings for MDM installs++An MDM installs the package without letting you set the environment of its install script. Push the settings as a configuration profile for the preference domain `com.beacon.endpoint` instead, with keys named exactly like the variables, and the install script reads them from the managed preferences:++```xml title="Configuration profile payload (com.beacon.endpoint)"+<dict>+ <key>PayloadType</key>+ <string>com.beacon.endpoint</string>+ <key>BEACON_LOG_ACCESS</key>+ <string>restricted</string>+ <key>BEACON_LOG_READERS</key>+ <string></string>+ <key>BEACON_ENDPOINT_HARNESSES</key>+ <string>claude,codex,cursor</string>+</dict>+```++An empty `BEACON_LOG_READERS` means nobody is added to `beacon-log` implicitly. Without an MDM, write the same keys to the local preferences as an administrator, before installing:++```bash title="Local install settings"+sudo defaults write /Library/Preferences/com.beacon.endpoint BEACON_LOG_ACCESS restricted+sudo defaults write /Library/Preferences/com.beacon.endpoint BEACON_LOG_READERS ""+```++Managed preferences win over local ones, and a variable set in the install script's environment wins over both. Only the documented `BEACON_*` install settings are read, one key at a time, so nothing in the files runs, and a file is ignored with a warning unless root owns it and no other account can write it. The settings are read on every install and upgrade.+<Columns cols={2}><Card title="Jamf Pro" icon="screwdriver-wrench" href="/mdm/jamf">Package deployment, policy scripts, validation, and Extension Attributes.diff --git a/docs/platforms/windows.mdx b/docs/platforms/windows.mdxindex a728a6bb..32987342 100644--- a/docs/platforms/windows.mdx+++ b/docs/platforms/windows.mdx@@ -23,6 +23,20 @@ msiexec /i BeaconEndpointAgent-<version>-x64.msi /qn /l*v install.logThe install needs administrator rights, because it writes under `%ProgramData%` and registers a service. Elevation is requested for you when you double-click the package. A silent install must already be running elevated, which is the normal case for Intune, SCCM, or a management agent.+A first install sets up [restricted log access](/security/restricted-log-access#on-windows): only the SYSTEM collector writes the log, and only SYSTEM, Administrators and the `beacon-log` local group can read it. An upgrade keeps the mode the endpoint already has. Installing interactively adds the account signed in at the console to `beacon-log`, so the dashboard, `beacon traces` and `beacon share` work for it after signing in again; a silent install (`/qn`) adds nobody. See [Package installs](/security/restricted-log-access#package-installs).++### Settings for fleet installs++The MSI cannot take environment variables from Intune or SCCM, so its install step also reads the install settings as string values under `HKLM\SOFTWARE\Policies\Beacon\Endpoint`, named exactly like the variables. Set them before installing, with an Intune or Group Policy registry setting, or:++```powershell title="Install settings as policy values (elevated)"+New-Item -Path 'HKLM:\SOFTWARE\Policies\Beacon\Endpoint' -Force | Out-Null+Set-ItemProperty -Path 'HKLM:\SOFTWARE\Policies\Beacon\Endpoint' -Name BEACON_LOG_ACCESS -Value restricted+Set-ItemProperty -Path 'HKLM:\SOFTWARE\Policies\Beacon\Endpoint' -Name BEACON_LOG_READERS -Value ''+```++An empty `BEACON_LOG_READERS` value means nobody is added to `beacon-log` implicitly. A variable set in the install step's environment wins over the policy value. The values are read on every install and upgrade.+The `/l*v` log records what Windows Installer did, but not what Beacon's own install and uninstall steps printed. Those go to a separate log for each run, in the temporary directory of the account that ran the package (`C:\Windows\Temp` when a management agent installs as SYSTEM):```powershell title="Find the logs of Beacon's install and uninstall steps"diff --git a/docs/security/restricted-log-access.mdx b/docs/security/restricted-log-access.mdxindex 9edbc221..d0ec230f 100644--- a/docs/security/restricted-log-access.mdx+++ b/docs/security/restricted-log-access.mdx@@ -59,12 +59,38 @@ On an endpoint that is already installed, including one installed from the signesudo beacon endpoint repair --system --log-access restricted```-For package installs you can instead set `BEACON_LOG_ACCESS=restricted` in the environment of the package's install script. On Linux a first install from the `.deb` or `.rpm` is restricted already, with no setting; an upgrade keeps the mode the endpoint has, and `BEACON_LOG_ACCESS=shared` installs a new endpoint shared instead. A configuration manager that cannot set the install script's environment (Salt, Ansible, Puppet, Chef) can put the setting in `/etc/default/beacon` or `/etc/sysconfig/beacon`; see [Settings for configuration-manager installs](/platforms/linux#settings-for-configuration-manager-installs).+A first install from a package is restricted already, with no setting, on Linux, macOS and Windows; see [Package installs](#package-installs).Switching replaces the log and its archives with fresh copies, so a file handle another account opened while the log was shared stops reaching it. Existing events are kept.The mode is recorded in `config.json` as `log_access` and in a root-owned `.beacon-log-access` marker beside the log. `beacon endpoint repair`, package upgrades, the Jamf `repair-hooks.sh` policy, and a reinstall after `uninstall --keep-logs` all keep it, so you set it once per endpoint.+## Package installs++The `.deb` and `.rpm`, the macOS `.pkg` and the Windows MSI follow the same rules.++**A first install is restricted.** A package is installed by an administrator for the whole machine, often by fleet tooling, so it sets up restricted access without a second step. An upgrade, a reinstall over a kept config, or a reinstall over a log kept by `uninstall --keep-logs` keeps whatever mode the endpoint already has, so existing endpoints never change. On Linux, a host without systemd as PID 1 (a container, WSL without systemd), or with `BEACON_SERVICE=none`, stays shared, because nothing there restarts the collector. `BEACON_LOG_ACCESS=shared` installs a new endpoint shared.++**Who is added to `beacon-log` depends on how the package was installed:**++| Installed by | How the install recognizes it | Added to `beacon-log` |+|---|---|---|+| Fleet tooling, unattended (Salt, Ansible, Jamf, Kandji, Intune, SCCM) | Linux: root with no `SUDO_USER`. macOS: `installer` (sets `COMMAND_LINE_INSTALL`). Windows: a silent MSI (`msiexec /qn`) | Nobody |+| A person, as an administrator | Linux: `sudo apt install` or `sudo dpkg -i`. macOS: Installer.app. Windows: the installer's full interface | That person, so the dashboard, `beacon traces` and `beacon share` work for them after they log in again |+| Anyone, with `BEACON_LOG_READERS` set | The setting, even an empty one | Exactly the accounts it lists, comma-separated (`DOMAIN\name` on Windows) |++Set `BEACON_LOG_READERS` to an empty value in a fleet's settings so that nobody is ever added implicitly, whatever runs the install. Accounts are only ever added, never removed, and one that cannot be added is reported without failing the install. `--log-readers` does the same on `beacon endpoint install|repair --system`.++**Fleet tooling sets these settings where it already writes settings,** because an MDM or a configuration manager cannot set the environment of a package's install script. The names are the same everywhere: `BEACON_LOG_ACCESS`, `BEACON_LOG_READERS`, `BEACON_ENDPOINT_HARNESSES` and the other documented `BEACON_*` install settings.++| Platform | Where | Written by |+|---|---|---|+| Linux | `/etc/default/beacon` (Debian, Ubuntu) or `/etc/sysconfig/beacon` (Fedora, RHEL), as `KEY=VALUE` lines; see [Settings for configuration-manager installs](/platforms/linux#settings-for-configuration-manager-installs) | Salt, Ansible, Puppet, Chef |+| macOS | Managed preferences for the domain `com.beacon.endpoint` (a configuration profile), or `/Library/Preferences/com.beacon.endpoint`; see [Settings for MDM installs](/platforms/macos#settings-for-mdm-installs) | Jamf, Kandji, Intune, or `sudo defaults write` |+| Windows | String values under `HKLM\SOFTWARE\Policies\Beacon\Endpoint`; see [Settings for fleet installs](/platforms/windows#settings-for-fleet-installs) | Intune, Group Policy, SCCM |++Each is read only when root (SYSTEM or Administrators on Windows) controls it, and a value set in the install script's environment wins over it.+## On WindowsRestricted mode works the same way on a Windows system install, with Windows mechanisms in place of the Unix ones.@@ -86,7 +112,7 @@ Run the commands from an elevated shell:beacon endpoint repair --system --log-access restricted```-For the MSI and `install-endpoint.ps1`, set `BEACON_LOG_ACCESS=restricted` in the machine environment before installing. An upgrade with the variable unset keeps whatever mode the endpoint has. The MSI's install step runs inside the Windows Installer service, which sees a machine variable set after the service started only once it restarts, so after installing check that `beacon endpoint status --system --json` reports `"log_access": "restricted"`, and if it does not, switch with `beacon endpoint repair --system --log-access restricted`.+A first MSI install is restricted already. An upgrade keeps whatever mode the endpoint has. Fleet tooling sets `BEACON_LOG_ACCESS` and the other install settings as policy values; see [Package installs](#package-installs).Switching replaces every file in the log directory with a fresh copy and resets the security of everything in it, so a handle another account opened while the log was shared stops reaching it. Windows cannot replace a file that another process holds open without allowing deletes. If one does, the switch waits a few seconds, then fails and names the file. The log is put back to shared, so hooks keep writing. Close that process (or sign the account out) and run the command again.@@ -113,7 +139,7 @@ It lists `NT AUTHORITY\SYSTEM`, `BUILTIN\Administrators` and `beacon-log` and no## Let your log shipper read the log-Install creates the `beacon-log` group if it is missing and adds nobody to it. A shipper that runs as root keeps working with no change, and so does the Beacon Cloud forwarder. A shipper that runs as its own account needs to join the group, and then be restarted so it picks up the new membership:+Install creates the `beacon-log` group if it is missing and adds only the accounts named by `BEACON_LOG_READERS` or `--log-readers`, or the person who ran a first package install interactively (see [Package installs](#package-installs)). A shipper that runs as root keeps working with no change, and so does the Beacon Cloud forwarder. A shipper that runs as its own account needs to join the group, and then be restarted so it picks up the new membership:```bash title="Add a shipper's account to beacon-log"# Linuxdiff --git a/packaging/linux/beacon-settings.sh b/packaging/linux/beacon-settings.shindex 694c1f50..0c1be889 100644--- a/packaging/linux/beacon-settings.sh+++ b/packaging/linux/beacon-settings.sh@@ -21,7 +21,8 @@# The documented install settings, the only keys taken from the file.BEACON_SETTINGS_KEYS='BEACON_ENDPOINT_HARNESSES BEACON_OTLP_GRPC_PORT BEACON_OTLP_HTTP_PORT-BEACON_COLLECTOR BEACON_NO_START BEACON_SERVICE BEACON_LOG_ACCESS BEACON_SESSION_SYNC+BEACON_COLLECTOR BEACON_NO_START BEACON_SERVICE BEACON_LOG_ACCESS BEACON_LOG_READERS+BEACON_DASHBOARD BEACON_SESSION_SYNCBEACON_SPLUNK_HEC_ENDPOINT BEACON_SPLUNK_HEC_TOKEN BEACON_SPLUNK_INDEX BEACON_SPLUNK_SOURCEBEACON_SPLUNK_SOURCETYPE BEACON_SPLUNK_INSECURE_SKIP_VERIFY BEACON_SPLUNK_CA_FILE'diff --git a/packaging/linux/install-endpoint.sh b/packaging/linux/install-endpoint.shindex ede2fbfd..7cb291b6 100755--- a/packaging/linux/install-endpoint.sh+++ b/packaging/linux/install-endpoint.sh@@ -64,7 +64,11 @@ BEACON_LOG_ACCESS="${BEACON_LOG_ACCESS:-}"BEACON_SYSTEM_CONFIG="${BEACON_SYSTEM_CONFIG:-/etc/beacon/endpoint/config.json}"BEACON_SYSTEM_LOG="${BEACON_SYSTEM_LOG:-/var/log/beacon-agent/runtime.jsonl}"BEACON_INIT_COMM="${BEACON_INIT_COMM:-/proc/1/comm}"-if [ -z "$BEACON_LOG_ACCESS" ] && [ ! -e "$BEACON_SYSTEM_CONFIG" ] && [ ! -e "$BEACON_SYSTEM_LOG" ]; then+first_install=0+if [ ! -e "$BEACON_SYSTEM_CONFIG" ] && [ ! -e "$BEACON_SYSTEM_LOG" ]; then+ first_install=1+fi+if [ -z "$BEACON_LOG_ACCESS" ] && [ "$first_install" = 1 ]; theninit="$(cat "$BEACON_INIT_COMM" 2>/dev/null || true)"case "$BEACON_SERVICE" in''|auto|systemd)@@ -74,6 +78,21 @@ if [ -z "$BEACON_LOG_ACCESS" ] && [ ! -e "$BEACON_SYSTEM_CONFIG" ] && [ ! -e "$B;;esacfi+# Accounts to add to the beacon-log group of a restricted log, comma-separated. Set, even to+# nothing, it is exactly the list: an unattended fleet install sets BEACON_LOG_READERS= so that nobody+# is ever added implicitly. Unset, a first install that a person ran with sudo (`sudo apt install`,+# `sudo dpkg -i`) adds that person, so whoever installed Beacon on their own machine can use the+# dashboard, `beacon traces` and `beacon share` without a second step. A configuration manager runs+# as root with no SUDO_USER, so its installs add nobody. Members are only ever added, never removed.+if [ -z "${BEACON_LOG_READERS+set}" ]; then+ BEACON_LOG_READERS=+ if [ "$first_install" = 1 ] && [ "$BEACON_LOG_ACCESS" = restricted ]; then+ case "${SUDO_USER:-}" in+ ''|root) ;;+ *) BEACON_LOG_READERS="$SUDO_USER" ;;+ esac+ fi+fi# 1 turns the scheduled session sync on and 0 turns it off; empty keeps what the endpoint already# has, so a package upgrade never changes it.BEACON_SESSION_SYNC="${BEACON_SESSION_SYNC:-}"@@ -94,6 +113,7 @@ set -- endpoint install --system \[ -n "$BEACON_SERVICE" ] && set -- "$@" --service "$BEACON_SERVICE"[ "$BEACON_NO_START" = "1" ] && set -- "$@" --no-start[ -n "$BEACON_LOG_ACCESS" ] && set -- "$@" --log-access "$BEACON_LOG_ACCESS"+[ -n "$BEACON_LOG_READERS" ] && set -- "$@" --log-readers "$BEACON_LOG_READERS"case "$BEACON_SESSION_SYNC" in1|true|TRUE|yes|YES)set -- "$@" --session-syncdiff --git a/packaging/linux/nfpm/postinstall.sh b/packaging/linux/nfpm/postinstall.shindex 3224fe40..8b561d62 100755--- a/packaging/linux/nfpm/postinstall.sh+++ b/packaging/linux/nfpm/postinstall.sh@@ -58,10 +58,11 @@ if [ -x /opt/beacon/bin/beacon ]; thenecho "beacon: scheduled session sync job not configured (endpoint is installed and running)" >&2fi-# A restricted log is readable only by root and the beacon-log group, and install adds nobody to it,-# so the people on the machine can no longer read the system log with the local tools that read it-# (the dashboard, `beacon share`, `beacon traces`). That is the point of the mode on a shared machine;-# on someone's own workstation an administrator grants it per person.+# A restricted log is readable only by root and the beacon-log group. Install adds only the accounts+# in BEACON_LOG_READERS, or, on a first install a person ran with sudo, that person; anyone else on+# the machine can no longer read the system log with the local tools that read it (the dashboard,+# `beacon share`, `beacon traces`). That is the point of the mode on a shared machine; an+# administrator grants it per person.if grep -q '"log_access": *"restricted"' /etc/beacon/endpoint/config.json 2>/dev/null; thenecho "beacon: the system log is restricted to root and the beacon-log group. To let someone read it with" \"the local tools (dashboard, beacon share, beacon traces): sudo usermod -aG beacon-log <user>, then log in again"diff --git a/packaging/linux/test-endpoint-scripts.sh b/packaging/linux/test-endpoint-scripts.shindex 6882d239..bb8823de 100644--- a/packaging/linux/test-endpoint-scripts.sh+++ b/packaging/linux/test-endpoint-scripts.sh@@ -249,6 +249,41 @@ expect_log_access shared "defaults file mode 644"run_install BEACON_DEFAULTS_FILE="$DEFAULTS" BEACON_DEFAULTS_OWNER=12345expect_log_access restricted "defaults file owned by someone else"+# Log readers. A first install a person ran with sudo adds that person; a configuration manager's+# (no SUDO_USER) adds nobody; an upgrade adds nobody implicitly; BEACON_LOG_READERS, set even to+# nothing, is exactly the list.+expect_readers() {+ got="$(flag_value --log-readers)"+ [ "$got" = "$1" ] || fail "$2: --log-readers is '$got', want '$1'"+}+rm -f "$DEFAULTS"+run_install+has_flag --log-readers && fail "configuration-manager install (no SUDO_USER) passed --log-readers $(flag_value --log-readers)"+run_install SUDO_USER=alice+expect_readers alice "first install by sudo"+run_install SUDO_USER=root+has_flag --log-readers && fail "SUDO_USER=root added root as a reader"+run_install SUDO_USER=alice BEACON_LOG_ACCESS=shared+has_flag --log-readers && fail "shared first install by sudo passed --log-readers"+run_install SUDO_USER=alice BEACON_LOG_READERS=+has_flag --log-readers && fail "BEACON_LOG_READERS= (nobody) still added the sudo user"+run_install SUDO_USER=alice BEACON_LOG_READERS=svc_splunk,bob+expect_readers svc_splunk,bob "BEACON_LOG_READERS over the sudo user"+printf 'BEACON_LOG_READERS= # fleet: nobody implicitly\n' >"$DEFAULTS"+run_install BEACON_DEFAULTS_FILE="$DEFAULTS" SUDO_USER=alice+has_flag --log-readers && fail "defaults file BEACON_LOG_READERS= still added the sudo user"+printf 'BEACON_LOG_READERS=svc_splunk\n' >"$DEFAULTS"+run_install BEACON_DEFAULTS_FILE="$DEFAULTS"+expect_readers svc_splunk "defaults file BEACON_LOG_READERS"+rm -f "$DEFAULTS"+mkdir -p "$TMP_DIR/etc"+echo '{}' >"$TMP_DIR/etc/config.json"+run_install SUDO_USER=alice+has_flag --log-readers && fail "upgrade by sudo added the sudo user implicitly"+run_install SUDO_USER=alice BEACON_LOG_READERS=svc_splunk+expect_readers svc_splunk "upgrade with explicit BEACON_LOG_READERS"+rm -f "$TMP_DIR/etc/config.json"+if [ "$failures" -ne 0 ]; thenecho "$failures check(s) failed" >&2exit 1diff --git a/packaging/macos/beacon-settings.sh b/packaging/macos/beacon-settings.shnew file mode 100644index 00000000..e7b7f921--- /dev/null+++ b/packaging/macos/beacon-settings.sh@@ -0,0 +1,111 @@+# Beacon package install settings on macOS, shared by install-endpoint.sh and the package postinstall.+#+# Sourced, not run: it defines functions and nothing else. The macOS counterpart of+# packaging/linux/beacon-settings.sh (the settings file in /etc/default or /etc/sysconfig) and of the+# Windows registry policy read by packaging/windows/install-endpoint.ps1: the same BEACON_* names,+# kept where each platform's fleet tooling already writes settings.+#+# An MDM (Jamf, Kandji, Intune, Workspace ONE) installs the package with `installer` or its own agent+# and cannot set the environment of the package's scripts, so the BEACON_* variables could not reach+# a centrally deployed install any other way. It can push a configuration profile, which macOS+# writes as managed preferences: payload type com.beacon.endpoint, keys named exactly like the+# variables (BEACON_LOG_ACCESS = restricted, BEACON_LOG_READERS = "", ...). Without an MDM, an+# administrator can write the same keys to the local preferences:+#+# sudo defaults write /Library/Preferences/com.beacon.endpoint BEACON_LOG_ACCESS restricted+#+# Managed preferences win over local ones, and a variable already set in the environment wins over+# both. Only the documented install settings are read, one key at a time with `defaults read`, so+# nothing in the files runs. A file is ignored unless root owns it and no one else can write it,+# because the package scripts run as root. A value that is not a single line (an array or a+# dictionary) is skipped with a warning naming only its key.++# The documented install settings, the only keys read.+BEACON_SETTINGS_KEYS='BEACON_ENDPOINT_HARNESSES BEACON_OTLP_GRPC_PORT BEACON_OTLP_HTTP_PORT+BEACON_COLLECTOR BEACON_NO_START BEACON_LOG_ACCESS BEACON_LOG_READERS BEACON_DASHBOARD+BEACON_SESSION_SYNC BEACON_SPLUNK_HEC_ENDPOINT BEACON_SPLUNK_HEC_TOKEN BEACON_SPLUNK_INDEX+BEACON_SPLUNK_SOURCE BEACON_SPLUNK_SOURCETYPE BEACON_SPLUNK_INSECURE_SKIP_VERIFY BEACON_SPLUNK_CA_FILE+BEACON_FALCON_HEC_ENDPOINT BEACON_FALCON_HEC_TOKEN BEACON_FALCON_INDEX BEACON_FALCON_SOURCE+BEACON_FALCON_SOURCETYPE BEACON_FALCON_INSECURE_SKIP_VERIFY BEACON_FALCON_CA_FILE'++# beacon_prefs_trusted FILE succeeds when FILE is owned by root and not group- or world-writable.+beacon_prefs_trusted() {+ # GNU stat first, where the packaging tests run on Linux (its -f means file system status, so it+ # cannot be tried second); BSD stat on macOS rejects -c and answers -f.+ _beacon_meta="$(stat -c '%u %a' "$1" 2>/dev/null || stat -f '%u %Lp' "$1" 2>/dev/null)" || return 1+ # BEACON_SETTINGS_OWNER lets the packaging tests run as an ordinary account.+ [ "${_beacon_meta%% *}" = "${BEACON_SETTINGS_OWNER:-0}" ] || return 1+ case "${_beacon_meta##* }" in+ *[2367]?|*[2367]) return 1 ;;+ esac+ return 0+}++# beacon_load_settings exports the documented settings from managed, then local, preferences that+# are not already set in the environment.+beacon_load_settings() {+ _beacon_defaults="${BEACON_DEFAULTS_BIN:-/usr/bin/defaults}"+ [ -x "$_beacon_defaults" ] || return 0+ # Which settings are already set is decided once, before any file is read.+ _beacon_preset=' '+ for _beacon_key in $BEACON_SETTINGS_KEYS; do+ # $_beacon_key is one of the fixed names above, so the indirection cannot evaluate anything else.+ eval "_beacon_set=\${$_beacon_key+set}"+ [ -n "$_beacon_set" ] && _beacon_preset="$_beacon_preset$_beacon_key "+ done+ for _beacon_prefs in "${BEACON_MANAGED_PREFS:-/Library/Managed Preferences/com.beacon.endpoint}" \+ "${BEACON_LOCAL_PREFS:-/Library/Preferences/com.beacon.endpoint}"; do+ [ -f "$_beacon_prefs.plist" ] || continue+ if ! beacon_prefs_trusted "$_beacon_prefs.plist"; then+ echo "beacon: ignoring $_beacon_prefs.plist: it must be owned by root and writable by no one else" >&2+ continue+ fi+ for _beacon_key in $BEACON_SETTINGS_KEYS; do+ case "$_beacon_preset" in+ *" $_beacon_key "*) continue ;;+ esac+ # Taken from the first file that has it: managed preferences shadow local ones.+ eval "_beacon_set=\${$_beacon_key+set}"+ [ -n "$_beacon_set" ] && continue+ _beacon_value="$("$_beacon_defaults" read "$_beacon_prefs" "$_beacon_key" 2>/dev/null)" || continue+ case "$_beacon_value" in+ *"+"*|'('*|'{'*)+ # The key only, never the value: it may be a token.+ echo "beacon: ignoring $_beacon_key in $_beacon_prefs.plist: not a single value" >&2+ continue+ ;;+ esac+ export "$_beacon_key=$_beacon_value"+ done+ done+}++# beacon_settings_harnesses prints BEACON_ENDPOINT_HARNESSES as the environment or the preferences+# set it, or nothing, without exporting anything into the caller: the postinstall needs only this one+# value, and loading every setting into it would hand a forwarder token to the processes it starts.+beacon_settings_harnesses() {+ (+ beacon_load_settings+ printf '%s' "${BEACON_ENDPOINT_HARNESSES:-}"+ )+}++# beacon_installing_person prints the account of the person who ran this install in Installer.app,+# or nothing for an unattended install. `installer` (which MDM agents and scripts run) sets+# COMMAND_LINE_INSTALL; a person double-clicking the package does it in Installer.app, the console+# user's own session. Both must hold, so an MDM install that happens while someone is logged in adds+# nobody.+beacon_installing_person() {+ [ -z "${COMMAND_LINE_INSTALL:-}" ] || return 0+ _beacon_gui="${BEACON_INSTALLER_GUI:-}"+ if [ -z "$_beacon_gui" ]; then+ if /usr/bin/pgrep -x Installer >/dev/null 2>&1; then _beacon_gui=1; else _beacon_gui=0; fi+ fi+ [ "$_beacon_gui" = 1 ] || return 0+ _beacon_console="${BEACON_CONSOLE_USER:-$(stat -f '%Su' /dev/console 2>/dev/null || true)}"+ case "$_beacon_console" in+ ''|root|loginwindow|_mbsetupuser) return 0 ;;+ esac+ printf '%s' "$_beacon_console"+}diff --git a/packaging/macos/build-pkg.sh b/packaging/macos/build-pkg.shindex 0e1e36f9..c956fba1 100755--- a/packaging/macos/build-pkg.sh+++ b/packaging/macos/build-pkg.sh@@ -63,6 +63,7 @@ mkdir -p "$OUT_DIR" "$PKG_ROOT/opt/beacon/bin" "$PKG_ROOT/opt/beacon/scripts" \copy_file "$BEACON_BIN" "$PKG_ROOT/opt/beacon/bin/beacon"copy_file "$COLLECTOR_BIN" "$PKG_ROOT/opt/beacon/bin/beacon-otelcol"copy_file "$ROOT_DIR/packaging/macos/install-endpoint.sh" "$PKG_ROOT/opt/beacon/scripts/install-endpoint.sh"+copy_file "$ROOT_DIR/packaging/macos/beacon-settings.sh" "$PKG_ROOT/opt/beacon/scripts/beacon-settings.sh"copy_file "$ROOT_DIR/packaging/macos/uninstall-endpoint.sh" "$PKG_ROOT/opt/beacon/scripts/uninstall-endpoint.sh"copy_file "$ROOT_DIR/packaging/macos/scripts/postinstall" "$PKG_SCRIPTS/postinstall"copy_file "$ROOT_DIR/packaging/macos/scripts/preinstall" "$PKG_SCRIPTS/preinstall"diff --git a/packaging/macos/install-endpoint.sh b/packaging/macos/install-endpoint.shindex 5fb80ed7..214f6613 100755--- a/packaging/macos/install-endpoint.sh+++ b/packaging/macos/install-endpoint.sh@@ -1,6 +1,27 @@#!/bin/shset -eu+# The install settings an MDM pushes as managed preferences (com.beacon.endpoint); see+# beacon-settings.sh beside this script (/opt/beacon/scripts in the package).+BEACON_SCRIPTS_DIR="${BEACON_SCRIPTS_DIR:-$(CDPATH='' cd -- "$(dirname -- "$0")" && pwd)}"+# Positional arguments (Jamf passes them from $4) are named on the command line, so like the+# environment they win over the preferences: each is resolved into its variable before those are read.+[ -n "${4:-}" ] && BEACON_ENDPOINT_HARNESSES="${BEACON_ENDPOINT_HARNESSES:-$4}"+[ -n "${5:-}" ] && BEACON_OTLP_GRPC_PORT="${BEACON_OTLP_GRPC_PORT:-$5}"+[ -n "${6:-}" ] && BEACON_OTLP_HTTP_PORT="${BEACON_OTLP_HTTP_PORT:-$6}"+[ -n "${7:-}" ] && BEACON_COLLECTOR="${BEACON_COLLECTOR:-$7}"+[ -n "${8:-}" ] && BEACON_NO_START="${BEACON_NO_START:-$8}"+[ -n "${9:-}" ] && BEACON_SPLUNK_HEC_ENDPOINT="${BEACON_SPLUNK_HEC_ENDPOINT:-$9}"+[ -n "${10:-}" ] && BEACON_SPLUNK_HEC_TOKEN="${BEACON_SPLUNK_HEC_TOKEN:-${10}}"+[ -n "${11:-}" ] && BEACON_SPLUNK_INDEX="${BEACON_SPLUNK_INDEX:-${11}}"+[ -n "${12:-}" ] && BEACON_SPLUNK_SOURCE="${BEACON_SPLUNK_SOURCE:-${12}}"+[ -n "${13:-}" ] && BEACON_SPLUNK_SOURCETYPE="${BEACON_SPLUNK_SOURCETYPE:-${13}}"+[ -n "${14:-}" ] && BEACON_SPLUNK_INSECURE_SKIP_VERIFY="${BEACON_SPLUNK_INSECURE_SKIP_VERIFY:-${14}}"+[ -n "${15:-}" ] && BEACON_SPLUNK_CA_FILE="${BEACON_SPLUNK_CA_FILE:-${15}}"+# shellcheck source=beacon-settings.sh+. "$BEACON_SCRIPTS_DIR/beacon-settings.sh"+beacon_load_settings+if [ -z "${BEACON_BIN:-}" ]; thenif [ -x "/opt/beacon/bin/beacon" ]; thenBEACON_BIN="/opt/beacon/bin/beacon"@@ -31,6 +52,32 @@ BEACON_FALCON_CA_FILE="${BEACON_FALCON_CA_FILE:-}"# shared or restricted; empty keeps the mode the endpoint already has, so a package upgrade never# changes it.BEACON_LOG_ACCESS="${BEACON_LOG_ACCESS:-}"+# A first install from the package defaults to restricted, as on Linux and Windows: a package is+# installed by an administrator for the whole machine, often by an MDM across a fleet, and that is+# the install that should make the collector the only writer of the system log without a second+# step. Only a genuinely first install: an existing system config (an upgrade, or a reinstall over a+# kept config) or a runtime log left by `uninstall --keep-logs` passes no mode, so this never narrows+# or widens an existing endpoint. BEACON_LOG_ACCESS=shared opts a new install out.+BEACON_SYSTEM_CONFIG="${BEACON_SYSTEM_CONFIG:-/Library/Application Support/Beacon/Endpoint/config.json}"+BEACON_SYSTEM_LOG="${BEACON_SYSTEM_LOG:-/var/log/beacon-agent/runtime.jsonl}"+first_install=0+if [ ! -e "$BEACON_SYSTEM_CONFIG" ] && [ ! -e "$BEACON_SYSTEM_LOG" ]; then+ first_install=1+fi+if [ -z "$BEACON_LOG_ACCESS" ] && [ "$first_install" = 1 ]; then+ BEACON_LOG_ACCESS=restricted+fi+# Accounts to add to the beacon-log group of a restricted log, comma-separated. Set, even to nothing,+# it is exactly the list: an MDM sets BEACON_LOG_READERS to an empty string so that nobody is ever+# added implicitly. Unset, a first install that a person ran in Installer.app adds that person, so+# whoever installed Beacon on their own Mac can use the dashboard, `beacon traces` and `beacon share`+# without a second step. Members are only ever added, never removed.+if [ -z "${BEACON_LOG_READERS+set}" ]; then+ BEACON_LOG_READERS=+ if [ "$first_install" = 1 ] && [ "$BEACON_LOG_ACCESS" = restricted ]; then+ BEACON_LOG_READERS="$(beacon_installing_person)"+ fi+fi# 1 turns the scheduled session sync on and 0 turns it off; empty keeps what the endpoint already# has, so a package upgrade never changes it.BEACON_SESSION_SYNC="${BEACON_SESSION_SYNC:-}"@@ -53,6 +100,10 @@ if [ -n "$BEACON_LOG_ACCESS" ]; thenset -- "$@" --log-access "$BEACON_LOG_ACCESS"fi+if [ -n "$BEACON_LOG_READERS" ]; then+ set -- "$@" --log-readers "$BEACON_LOG_READERS"+fi+case "$BEACON_SESSION_SYNC" in1|true|TRUE|yes|YES)set -- "$@" --session-syncdiff --git a/packaging/macos/scripts/postinstall b/packaging/macos/scripts/postinstallindex 5a2cce5a..5f6a5a3c 100755--- a/packaging/macos/scripts/postinstall+++ b/packaging/macos/scripts/postinstall@@ -1,21 +1,19 @@#!/bin/shset -eu+# The step that configures the logged-in user needs the harness list the MDM's managed preferences+# (or the environment) give; install-endpoint.sh reads every other setting itself. Only that one+# value is taken here, so a forwarder token in the preferences never reaches the processes this+# script starts.+# shellcheck source=../beacon-settings.sh+. /opt/beacon/scripts/beacon-settings.sh+BEACON_ENDPOINT_HARNESSES="${BEACON_ENDPOINT_HARNESSES:-$(beacon_settings_harnesses)}"++# Only what this step decides is passed. install-endpoint.sh applies its own defaults for the rest,+# after reading the managed preferences, so a variable set here (even to an empty default) would+# shadow the MDM's value for it.BEACON_BIN="${BEACON_BIN:-/opt/beacon/bin/beacon}" \BEACON_COLLECTOR="${BEACON_COLLECTOR:-/opt/beacon/bin/beacon-otelcol}" \-BEACON_ENDPOINT_HARNESSES="${BEACON_ENDPOINT_HARNESSES:-claude,codex}" \-BEACON_CONTENT_RETENTION="${BEACON_CONTENT_RETENTION:-full}" \-BEACON_OTLP_GRPC_PORT="${BEACON_OTLP_GRPC_PORT:-4317}" \-BEACON_OTLP_HTTP_PORT="${BEACON_OTLP_HTTP_PORT:-4318}" \-BEACON_SPLUNK_HEC_ENDPOINT="${BEACON_SPLUNK_HEC_ENDPOINT:-}" \-BEACON_SPLUNK_HEC_TOKEN="${BEACON_SPLUNK_HEC_TOKEN:-}" \-BEACON_SPLUNK_INDEX="${BEACON_SPLUNK_INDEX:-}" \-BEACON_SPLUNK_SOURCE="${BEACON_SPLUNK_SOURCE:-}" \-BEACON_SPLUNK_SOURCETYPE="${BEACON_SPLUNK_SOURCETYPE:-}" \-BEACON_SPLUNK_INSECURE_SKIP_VERIFY="${BEACON_SPLUNK_INSECURE_SKIP_VERIFY:-0}" \-BEACON_SPLUNK_CA_FILE="${BEACON_SPLUNK_CA_FILE:-}" \-BEACON_LOG_ACCESS="${BEACON_LOG_ACCESS:-}" \-BEACON_SESSION_SYNC="${BEACON_SESSION_SYNC:-}" \BEACON_NO_START=1 \/opt/beacon/scripts/install-endpoint.shdiff --git a/packaging/macos/test-endpoint-scripts.sh b/packaging/macos/test-endpoint-scripts.shindex 26fa7dd9..0919b83c 100644--- a/packaging/macos/test-endpoint-scripts.sh+++ b/packaging/macos/test-endpoint-scripts.sh@@ -15,6 +15,16 @@ trap 'rm -rf "$TMP_DIR"' EXIT INT TERM# invocation in this file inside the temp dir instead.BEACON_FORWARDER_LOG_DIR="$TMP_DIR/forwarder-logs"export BEACON_FORWARDER_LOG_DIR+# Keep every install in this file away from the machine's own Beacon state and settings: the system+# config exists (so installs read as upgrades and keep their mode unless a test says otherwise), no+# preferences are read, and no Installer.app session is detected.+mkdir -p "$TMP_DIR/system-endpoint"+echo '{}' >"$TMP_DIR/system-endpoint/config.json"+BEACON_SYSTEM_CONFIG="$TMP_DIR/system-endpoint/config.json"+BEACON_SYSTEM_LOG="$TMP_DIR/system-endpoint/runtime.jsonl"+BEACON_DEFAULTS_BIN="$TMP_DIR/no-defaults-binary"+BEACON_INSTALLER_GUI=0+export BEACON_SYSTEM_CONFIG BEACON_SYSTEM_LOG BEACON_DEFAULTS_BIN BEACON_INSTALLER_GUIsh -n "$INSTALL_SCRIPT"sh -n "$UNINSTALL_SCRIPT"@@ -1323,6 +1333,7 @@ POSTINSTALL_LAUNCHCTL_LOG="$POSTINSTALL_ROOT/launchctl.log"POSTINSTALL_BEACON_LOG="$POSTINSTALL_ROOT/beacon.log"mkdir -p "$POSTINSTALL_BIN" "$POSTINSTALL_DAEMONS"sed -e "s#/opt/beacon/scripts/install-endpoint.sh#$POSTINSTALL_BIN/install-endpoint.sh#g" \+ -e "s#/opt/beacon/scripts/beacon-settings.sh#$ROOT_DIR/packaging/macos/beacon-settings.sh#g" \-e "s#/Library/LaunchDaemons/#$POSTINSTALL_DAEMONS/#g" \"$ROOT_DIR/packaging/macos/scripts/postinstall" >"$POSTINSTALL_ROOT/postinstall"if grep -q -e '/opt/beacon/scripts/' -e '/Library/LaunchDaemons/' "$POSTINSTALL_ROOT/postinstall"; then@@ -1443,3 +1454,6 @@ sh "$ROOT_DIR/packaging/macos/safari/test-safari-packaging.sh"# Fleet osquery files (packaging/macos/fleet) and the Fleet admin helper (examples/fleet).sh "$ROOT_DIR/examples/fleet/test/test-fleet-sql.sh"sh "$ROOT_DIR/examples/fleet/test/test-configure-beacon-macos-s3.sh"++# Install settings (managed preferences) and the first-install rules. Runs on Linux too.+sh "$ROOT_DIR/packaging/macos/test-install-settings.sh"diff --git a/packaging/macos/test-install-settings.sh b/packaging/macos/test-install-settings.shnew file mode 100644index 00000000..5c6f15d0--- /dev/null+++ b/packaging/macos/test-install-settings.sh@@ -0,0 +1,153 @@+#!/bin/sh+# Checks the macOS install script's settings and first-install rules without installing anything: a+# stub stands in for the beacon binary, and another for `defaults`, reading KEY=VALUE text files in+# place of the preferences plists. Runs on Linux too.+#+# sh packaging/macos/test-install-settings.sh+set -eu++ROOT_DIR="$(CDPATH='' cd -- "$(dirname -- "$0")/../.." && pwd)"+INSTALL_SCRIPT="$ROOT_DIR/packaging/macos/install-endpoint.sh"+TMP_DIR="$(mktemp -d)"+trap 'rm -rf "$TMP_DIR"' EXIT INT TERM++sh -n "$ROOT_DIR/packaging/macos/beacon-settings.sh"++STUB="$TMP_DIR/beacon"+ARGS="$TMP_DIR/args"+cat >"$STUB" <<'STUB'+#!/bin/sh+printf '%s\n' "$@" >"$BEACON_TEST_ARGS"+STUB+DEFAULTS_STUB="$TMP_DIR/defaults"+cat >"$DEFAULTS_STUB" <<'STUB'+#!/bin/sh+# defaults read PATH KEY+[ "$1" = read ] || exit 1+line="$(grep "^$3=" "$2.plist" 2>/dev/null | tail -n 1)" || exit 1+[ -n "$line" ] || exit 1+printf '%s\n' "${line#*=}"+STUB+chmod 755 "$STUB" "$DEFAULTS_STUB"+MANAGED="$TMP_DIR/managed/com.beacon.endpoint"+LOCAL="$TMP_DIR/local/com.beacon.endpoint"+mkdir -p "$TMP_DIR/managed" "$TMP_DIR/local" "$TMP_DIR/system"++failures=0+fail() {+ echo "FAIL: $*" >&2+ failures=$((failures + 1))+}++# run_install [VAR=value ...] runs the install script in a clean environment pointed at the stubs:+# a first install (no system config or log) unless the caller makes one, no preferences unless the+# caller writes them, and no Installer.app session unless the caller says so.+run_install() {+ rm -f "$ARGS"+ env -i PATH="$PATH" HOME="$TMP_DIR" BEACON_BIN="$STUB" BEACON_TEST_ARGS="$ARGS" \+ BEACON_COLLECTOR="$TMP_DIR/collector" \+ BEACON_SYSTEM_CONFIG="$TMP_DIR/system/config.json" \+ BEACON_SYSTEM_LOG="$TMP_DIR/system/runtime.jsonl" \+ BEACON_DEFAULTS_BIN="$DEFAULTS_STUB" \+ BEACON_MANAGED_PREFS="$MANAGED" \+ BEACON_LOCAL_PREFS="$LOCAL" \+ BEACON_SETTINGS_OWNER="$(id -u)" \+ BEACON_INSTALLER_GUI=0 \+ "$@" sh "$INSTALL_SCRIPT" >"$TMP_DIR/out" 2>&1 || { cat "$TMP_DIR/out" >&2; return 1; }+}++flag_value() {+ awk -v flag="$1" 'found { print; exit } $0 == flag { found = 1 }' "$ARGS"+}++has_flag() {+ grep -qx -- "$1" "$ARGS"+}++expect() {+ got="$(flag_value "$1")"+ [ "$got" = "$2" ] || fail "$3: $1 is '$got', want '$2'"+}++# First install: restricted. Upgrade (a system config) or a kept log: no mode, the endpoint keeps its+# own. BEACON_LOG_ACCESS=shared opts a first install out.+run_install+expect --log-access restricted "first install"+echo '{}' >"$TMP_DIR/system/config.json"+run_install+has_flag --log-access && fail "upgrade passed --log-access $(flag_value --log-access)"+rm -f "$TMP_DIR/system/config.json"+: >"$TMP_DIR/system/runtime.jsonl"+run_install+has_flag --log-access && fail "reinstall over a kept log passed --log-access $(flag_value --log-access)"+rm -f "$TMP_DIR/system/runtime.jsonl"+run_install BEACON_LOG_ACCESS=shared+expect --log-access shared "first install with BEACON_LOG_ACCESS=shared"++# Managed preferences are read, win over local ones, and lose to the environment and to arguments.+printf 'BEACON_LOG_ACCESS=shared\nBEACON_ENDPOINT_HARNESSES=claude,cursor\nBEACON_SESSION_SYNC=1\n' >"$MANAGED.plist"+printf 'BEACON_LOG_ACCESS=restricted\nBEACON_OTLP_GRPC_PORT=6317\n' >"$LOCAL.plist"+chmod 644 "$MANAGED.plist" "$LOCAL.plist"+run_install+expect --log-access shared "managed preferences"+expect --harness claude,cursor "managed preferences harnesses"+expect --otlp-grpc-port 6317 "local preferences fill what managed ones lack"+has_flag --session-sync || fail "managed BEACON_SESSION_SYNC=1 did not pass --session-sync"+run_install BEACON_LOG_ACCESS=restricted+expect --log-access restricted "environment over managed preferences"+rm -f "$ARGS"+env -i PATH="$PATH" HOME="$TMP_DIR" BEACON_BIN="$STUB" BEACON_TEST_ARGS="$ARGS" BEACON_COLLECTOR="$TMP_DIR/collector" \+ BEACON_SYSTEM_CONFIG="$TMP_DIR/system/config.json" BEACON_SYSTEM_LOG="$TMP_DIR/system/runtime.jsonl" \+ BEACON_DEFAULTS_BIN="$DEFAULTS_STUB" BEACON_MANAGED_PREFS="$MANAGED" BEACON_LOCAL_PREFS="$LOCAL" \+ BEACON_SETTINGS_OWNER="$(id -u)" BEACON_INSTALLER_GUI=0 \+ sh "$INSTALL_SCRIPT" _ _ _ codex >"$TMP_DIR/out" 2>&1 || fail "install with a positional harness failed"+expect --harness codex "Jamf positional argument over managed preferences"++# A preferences file another account can write, or owned by one, is ignored with a warning.+chmod 664 "$MANAGED.plist"+run_install+expect --log-access restricted "group-writable managed preferences ignored (local ones apply)"+grep -q "ignoring $MANAGED.plist" "$TMP_DIR/out" || fail "group-writable managed preferences: no warning"+chmod 644 "$MANAGED.plist"+run_install BEACON_SETTINGS_OWNER=12345+expect --log-access restricted "preferences owned by someone else ignored"+has_flag --session-sync && fail "preferences owned by someone else still set BEACON_SESSION_SYNC"+# A value that is not one line is skipped, naming only the key.+printf 'BEACON_SPLUNK_HEC_TOKEN=(\n' >"$MANAGED.plist"+run_install+has_flag --splunk-hec-token && fail "an array value passed --splunk-hec-token"+grep -q "ignoring BEACON_SPLUNK_HEC_TOKEN" "$TMP_DIR/out" || fail "array value: no warning naming the key"+rm -f "$MANAGED.plist" "$LOCAL.plist"++# Log readers: a first install a person ran in Installer.app adds them; `installer` (MDM, scripts)+# adds nobody, even with someone logged in; BEACON_LOG_READERS, set even to nothing, is the list.+run_install BEACON_CONSOLE_USER=alice+has_flag --log-readers && fail "unattended install added $(flag_value --log-readers)"+run_install BEACON_INSTALLER_GUI=1 BEACON_CONSOLE_USER=alice+expect --log-readers alice "Installer.app first install"+run_install BEACON_INSTALLER_GUI=1 BEACON_CONSOLE_USER=alice COMMAND_LINE_INSTALL=1+has_flag --log-readers && fail "COMMAND_LINE_INSTALL install added $(flag_value --log-readers)"+run_install BEACON_INSTALLER_GUI=1 BEACON_CONSOLE_USER=loginwindow+has_flag --log-readers && fail "loginwindow added as a reader"+run_install BEACON_INSTALLER_GUI=1 BEACON_CONSOLE_USER=alice BEACON_LOG_ACCESS=shared+has_flag --log-readers && fail "shared install added a reader"+run_install BEACON_INSTALLER_GUI=1 BEACON_CONSOLE_USER=alice BEACON_LOG_READERS=+has_flag --log-readers && fail "BEACON_LOG_READERS= still added the installing person"+printf 'BEACON_LOG_READERS=\n' >"$MANAGED.plist"+chmod 644 "$MANAGED.plist"+run_install BEACON_INSTALLER_GUI=1 BEACON_CONSOLE_USER=alice+has_flag --log-readers && fail "managed BEACON_LOG_READERS (empty) still added the installing person"+printf 'BEACON_LOG_READERS=svc_splunk,bob\n' >"$MANAGED.plist"+run_install+expect --log-readers svc_splunk,bob "managed BEACON_LOG_READERS"+rm -f "$MANAGED.plist"+echo '{}' >"$TMP_DIR/system/config.json"+run_install BEACON_INSTALLER_GUI=1 BEACON_CONSOLE_USER=alice+has_flag --log-readers && fail "upgrade in Installer.app added the person implicitly"+rm -f "$TMP_DIR/system/config.json"++if [ "$failures" -ne 0 ]; then+ echo "$failures check(s) failed" >&2+ exit 1+fi+echo "macos install settings checks passed"diff --git a/packaging/windows/beacon.wxs b/packaging/windows/beacon.wxsindex 74b7103f..f2805dce 100644--- a/packaging/windows/beacon.wxs+++ b/packaging/windows/beacon.wxs@@ -103,10 +103,14 @@-NonInteractive and -NoProfile because there is no console here and a machine's PowerShellprofile must not be able to change what an installer does.++ -UiLevel passes the UILevel property, formatted when the action is scheduled, so the script+ can tell a person running the installer's full interface (5) from a silent deployment (2,+ msiexec /qn, as Intune and SCCM run it). Only the former adds the console user to beacon-log.--><CustomAction Id="BeaconInstallEndpoint"Directory="ScriptsFolder"- ExeCommand=""[System64Folder]WindowsPowerShell\v1.0\powershell.exe" -NoProfile -NonInteractive -ExecutionPolicy Bypass -File "install-endpoint.ps1""+ ExeCommand=""[System64Folder]WindowsPowerShell\v1.0\powershell.exe" -NoProfile -NonInteractive -ExecutionPolicy Bypass -File "install-endpoint.ps1" -UiLevel "[UILevel]""Execute="deferred"Impersonate="no"Return="check" />diff --git a/packaging/windows/install-endpoint.ps1 b/packaging/windows/install-endpoint.ps1index 47d1b2ab..16d02795 100644--- a/packaging/windows/install-endpoint.ps1+++ b/packaging/windows/install-endpoint.ps1@@ -9,7 +9,12 @@# scripts call install-endpoint.sh -- two lists of flags that must agree is a thing that stops# agreeing.[CmdletBinding()]-param()+param(+ # The MSI's UILevel property (2 none, 3 basic, 4 reduced, 5 full), passed by its custom action so+ # this script can tell a person running the installer from a silent fleet deployment. Empty when+ # fleet tooling runs the script directly, which counts as unattended.+ [string]$UiLevel = ''+)$ErrorActionPreference = 'Stop'@@ -30,6 +35,35 @@ function Get-EnvOrDefault {return $value}+# The install settings fleet tooling (Intune, Group Policy, SCCM) sets as registry policy: values+# named exactly like the BEACON_* variables the Linux and macOS install scripts read, under this key.+# The Windows counterpart of /etc/default/beacon on Linux and the com.beacon.endpoint managed+# preferences on macOS, because an MSI deployment cannot set the environment of its custom action.+# HKLM\SOFTWARE\Policies is writable only by administrators. BEACON_POLICY_KEY lets the packaging+# tests point elsewhere.+$policyKey = Get-EnvOrDefault 'BEACON_POLICY_KEY' 'HKLM:\SOFTWARE\Policies\Beacon\Endpoint'++# Test-BeaconPolicy reports whether the policy key sets a value, even an empty one.+function Test-BeaconPolicy {+ param([string]$Name)+ if (-not (Test-Path -LiteralPath $policyKey)) { return $false }+ $item = Get-ItemProperty -LiteralPath $policyKey -Name $Name -ErrorAction SilentlyContinue+ return $null -ne $item+}++# Get-BeaconSetting reads a documented install setting: the environment wins, then the policy key,+# then the default.+function Get-BeaconSetting {+ param([string]$Name, [string]$Default)+ $value = [Environment]::GetEnvironmentVariable($Name)+ if (-not [string]::IsNullOrWhiteSpace($value)) { return $value }+ if (Test-BeaconPolicy $Name) {+ $policy = [string](Get-ItemProperty -LiteralPath $policyKey -Name $Name).$Name+ if (-not [string]::IsNullOrWhiteSpace($policy)) { return $policy.Trim() }+ }+ return $Default+}+# The installed layout, which mirrors /opt/beacon: bin next to scripts, so the collector sits beside# the CLI where DiscoverBinary looks for it first.$installRoot = Get-EnvOrDefault 'BEACON_INSTALL_ROOT' (Join-Path $env:ProgramFiles 'Beacon')@@ -40,17 +74,54 @@ if (-not (Test-Path -LiteralPath $beaconBin)) {throw "beacon.exe was not found at $beaconBin"}-$harnesses = Get-EnvOrDefault 'BEACON_ENDPOINT_HARNESSES' 'claude,codex'-$grpcPort = Get-EnvOrDefault 'BEACON_OTLP_GRPC_PORT' '4317'-$httpPort = Get-EnvOrDefault 'BEACON_OTLP_HTTP_PORT' '4318'-$collector = Get-EnvOrDefault 'BEACON_COLLECTOR' ''-$service = Get-EnvOrDefault 'BEACON_SERVICE' ''-$noStart = Get-EnvOrDefault 'BEACON_NO_START' '0'+$harnesses = Get-BeaconSetting 'BEACON_ENDPOINT_HARNESSES' 'claude,codex'+$grpcPort = Get-BeaconSetting 'BEACON_OTLP_GRPC_PORT' '4317'+$httpPort = Get-BeaconSetting 'BEACON_OTLP_HTTP_PORT' '4318'+$collector = Get-BeaconSetting 'BEACON_COLLECTOR' ''+$service = Get-BeaconSetting 'BEACON_SERVICE' ''+$noStart = Get-BeaconSetting 'BEACON_NO_START' '0'# shared or restricted; empty keeps whatever the endpoint already has, so an upgrade never changes# the mode. Restricted makes the SYSTEM collector the only writer of the runtime log: hooks send their# events to it over a local named pipe, and only SYSTEM, Administrators and the beacon-log group can# read the log. The same variable the Linux and macOS install scripts read.-$logAccess = Get-EnvOrDefault 'BEACON_LOG_ACCESS' ''+$logAccess = Get-BeaconSetting 'BEACON_LOG_ACCESS' ''++# A first install defaults to restricted, as on Linux and macOS: an MSI is installed by an+# administrator for the whole machine, often by Intune or SCCM across a fleet, and that is the install+# that should make the collector the only writer of the runtime log without a second step. Only a+# genuinely first install: an existing system config (an upgrade, or a reinstall over a kept config)+# or a runtime log left by `uninstall --keep-logs` passes no mode, so this never narrows or widens an+# existing endpoint. BEACON_LOG_ACCESS=shared opts a new install out.+$systemBase = Join-Path $env:ProgramData 'Beacon\Endpoint'+$systemConfig = Get-EnvOrDefault 'BEACON_SYSTEM_CONFIG' (Join-Path $systemBase 'config.json')+$systemLog = Get-EnvOrDefault 'BEACON_SYSTEM_LOG' (Join-Path $systemBase 'logs\runtime.jsonl')+$firstInstall = -not (Test-Path -LiteralPath $systemConfig) -and -not (Test-Path -LiteralPath $systemLog)+if ([string]::IsNullOrWhiteSpace($logAccess) -and $firstInstall) { $logAccess = 'restricted' }++# Accounts to add to the beacon-log local group of a restricted log, comma-separated (DOMAIN\name).+# Set -- in the environment, or as a policy value, even an empty one -- it is exactly the list: a+# fleet sets an empty BEACON_LOG_READERS policy value so that nobody is ever added implicitly. Unset,+# a first install that a person ran from the installer's full interface adds the person signed in at+# the console, so whoever installed Beacon on their own machine can use the dashboard, beacon traces+# and beacon share without a second step. A silent install (msiexec /qn, which Intune and SCCM run)+# adds nobody. Members are only ever added, never removed.+$logReaders = [Environment]::GetEnvironmentVariable('BEACON_LOG_READERS')+if ([string]::IsNullOrWhiteSpace($logReaders)) {+ if (Test-BeaconPolicy 'BEACON_LOG_READERS') {+ $logReaders = [string](Get-ItemProperty -LiteralPath $policyKey -Name 'BEACON_LOG_READERS').BEACON_LOG_READERS+ } else {+ $logReaders = ''+ $interactive = 0+ [void][int]::TryParse($UiLevel, [ref]$interactive)+ if ($firstInstall -and $logAccess -eq 'restricted' -and $interactive -ge 4) {+ $console = Get-EnvOrDefault 'BEACON_CONSOLE_USER' ''+ if ([string]::IsNullOrWhiteSpace($console)) {+ try { $console = [string](Get-CimInstance -ClassName Win32_ComputerSystem).UserName } catch { $console = '' }+ }+ if (-not [string]::IsNullOrWhiteSpace($console)) { $logReaders = $console.Trim() }+ }+ }+}# Auto-detected rather than required, so a manual invocation without BEACON_COLLECTOR still works.# DiscoverBinary would find this on its own -- it is passed explicitly so that a failure says which@@ -72,6 +143,7 @@ if (-not [string]::IsNullOrWhiteSpace($collector)) { $installArgs += @('--collecif (-not [string]::IsNullOrWhiteSpace($service)) { $installArgs += @('--service', $service) }if ($noStart -eq '1') { $installArgs += '--no-start' }if (-not [string]::IsNullOrWhiteSpace($logAccess)) { $installArgs += @('--log-access', $logAccess) }+if (-not [string]::IsNullOrWhiteSpace($logReaders)) { $installArgs += @('--log-readers', $logReaders.Trim()) }# The access control on %ProgramData%\Beacon is applied by the install itself, not here, so a fleet# that runs `beacon endpoint install --system` directly gets the same result as the MSI. It resets thediff --git a/packaging/windows/test-endpoint-scripts.ps1 b/packaging/windows/test-endpoint-scripts.ps1index 7c017fe7..f45f6c06 100644--- a/packaging/windows/test-endpoint-scripts.ps1+++ b/packaging/windows/test-endpoint-scripts.ps1@@ -51,6 +51,21 @@ foreach ($needle in @('endpoint', 'install', '--system', 'user-config', 'repair-if ($install -notmatch "BEACON_LOG_ACCESS" -or $install -notmatch [regex]::Escape("'--log-access'")) {Fail "install-endpoint.ps1 no longer passes BEACON_LOG_ACCESS on as --log-access"}+# BEACON_LOG_READERS is the readers list on all three platforms, and the policy key is where Windows+# fleet tooling sets every install setting, as /etc/default/beacon and the com.beacon.endpoint managed+# preferences are on Linux and macOS.+if ($install -notmatch "BEACON_LOG_READERS" -or $install -notmatch [regex]::Escape("'--log-readers'")) {+ Fail "install-endpoint.ps1 no longer passes BEACON_LOG_READERS on as --log-readers"+}+if ($install -notmatch [regex]::Escape('HKLM:\SOFTWARE\Policies\Beacon\Endpoint')) {+ Fail "install-endpoint.ps1 no longer reads install settings from the HKLM:\SOFTWARE\Policies\Beacon\Endpoint policy key"+}+# Only a person at the installer's full interface may be added implicitly, which the script can tell+# only from the UILevel the MSI passes it.+$wxs = Get-Content -Raw -LiteralPath (Join-Path $scriptDir 'beacon.wxs')+if ($wxs -notmatch [regex]::Escape('-UiLevel "[UILevel]"')) {+ Fail "beacon.wxs no longer passes [UILevel] to install-endpoint.ps1"+}# The step whose absence made the Linux package produce a healthy collector that captured nothing.if ($install -notmatch 'repair-installed') {Fail "install-endpoint.ps1 must configure the interactive user's runtime, or the endpoint captures nothing"