Skip to content

The cross-harness, self-improving memory layer for AI agents. Join our community: https://discord.com/invite/zdNChS2fBu

Address review: settings reach both steps, safer restricted default

Claudec711ff67aae4
diff --git a/CLAUDE.md b/CLAUDE.md
index 5dd0f617..100483ce 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` when no system `config.json` exists yet; an upgrade passes nothing and keeps the mode; that script also reads the `BEACON_*` install settings, never sourcing them, from a root-owned, not group/other-writable `/etc/default/beacon` or `/etc/sysconfig/beacon` for configuration managers that cannot set its environment, environment winning; `packaging/linux/test-endpoint-scripts.sh` checks both). 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: any local process can still send OTLP, unattributed, so never claim more than the hook channel guarantees. 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 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 so both its steps see the same values, 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, environment winning; 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: any local process can still send OTLP, unattributed, so never claim more than the hook channel guarantees. 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 restarts the forwarder only when the content changed and the forwarder is running (a stopped one reads the new config when it next starts). 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/.goreleaser.yaml b/cli/beacon/.goreleaser.yaml
index 6e6336fa..55e1102e 100644
--- a/cli/beacon/.goreleaser.yaml
+++ b/cli/beacon/.goreleaser.yaml
@@ -164,6 +164,11 @@ nfpms:
dst: /opt/beacon/scripts/uninstall-endpoint.sh
file_info:
mode: 0755
+ # Sourced by install-endpoint.sh and the postinstall: the /etc/default/beacon settings parser.
+ - src: ../../packaging/linux/beacon-settings.sh
+ dst: /opt/beacon/scripts/beacon-settings.sh
+ file_info:
+ mode: 0644
# Without these the payload is unreachable by name and every documented command fails with
# "beacon: command not found" -- including the one this package's own postinstall prints.
# 103 documentation pages call the binary bare, so the package is the right place to make
diff --git a/docs/changelog/cli.mdx b/docs/changelog/cli.mdx
index b29a239b..9f08185c 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`. Upgrades 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 need to join `beacon-log`.
-- **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 install script now also reads them from `/etc/default/beacon` or `/etc/sysconfig/beacon` (read, never run; root-owned and not writable by other accounts, or it is ignored with a warning). The environment still wins. See [Settings for configuration-manager installs](/platforms/linux#settings-for-configuration-manager-installs).
+- **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 still wins. See [Settings for configuration-manager installs](/platforms/linux#settings-for-configuration-manager-installs).
- **Microsoft Sentinel forwarding with one command, on macOS, Linux and Windows** · `beacon endpoint sentinel forwarder install --system` runs the Vector bundled with Beacon as a system service that sends the runtime log to Microsoft Sentinel through the Logs Ingestion API, with a Microsoft Entra app registration (certificate or client secret). The credential is stored where only root can read it, or SYSTEM and Administrators on Windows, and is never a command-line argument. Vector checks the config before anything changes. Repair and package upgrades keep the forwarder and restart it on the new Vector; uninstall removes the service. Throttling, server errors and `401`/`403` answers are retried without a limit, and a line counts as sent only once Azure has accepted it. `status` and `remove` complete the commands. The pack's Logs Ingestion DCR template no longer needs a Data Collection Endpoint. See [Vector and the Logs Ingestion API](/log-forwarding/microsoft-sentinel#vector-and-the-logs-ingestion-api).
- **The Windows MSI carries Vector** · The MSI now installs Vector 0.56.0 as `vector.exe` beside `beacon.exe` in `%ProgramFiles%\Beacon\bin`, as the macOS and Linux packages already carry it, checked against the same pinned checksums. Beacon finds it there. The package only installs it; nothing runs it until a forwarder is set up. Allow it alongside the other three programs if you run AppLocker or WDAC.
- **Scheduled session sync** · `beacon endpoint install|repair --session-sync` turns on a job that runs every 15 minutes and reads new records from the agent runtimes' local session stores into the runtime log. It runs the same bounded, confined sweep install already runs once, so session-store data keeps reaching the log, and any forwarder reading it, after install. Off by default; repair and upgrades keep the setting, and `--no-session-sync` removes the job. See [Scheduled session sync](/cli/endpoint-install#scheduled-session-sync).
diff --git a/docs/platforms/linux.mdx b/docs/platforms/linux.mdx
index 1ffdf59f..6cf5ee39 100644
--- a/docs/platforms/linux.mdx
+++ b/docs/platforms/linux.mdx
@@ -181,7 +181,7 @@ That last row is worth knowing about. A system-mode endpoint runs as root, so th
sudo 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 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. A package upgrade 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`, 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).
### Settings for configuration-manager installs
@@ -210,7 +210,7 @@ beacon:
- file: /etc/default/beacon
```
-The file is read, not run: each line is a `KEY=VALUE` (an `export` in front and quotes around the value are allowed), 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 wins over the file. 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_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 wins over the file. 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 service
diff --git a/packaging/linux/beacon-settings.sh b/packaging/linux/beacon-settings.sh
new file mode 100644
index 00000000..051c1610
--- /dev/null
+++ b/packaging/linux/beacon-settings.sh
@@ -0,0 +1,131 @@
+# Beacon package install settings, shared by install-endpoint.sh and the package postinstall.
+#
+# Sourced, not run: it defines beacon_load_settings and nothing else. Both scripts need the same
+# answer, because the postinstall runs two separate steps (the system install and configuring each
+# logged-in user) and a setting that reached only the first was silently ignored by the second.
+#
+# Settings a configuration manager drops before installing the package. Salt's pkg.installed,
+# Ansible's apt/dnf modules, Puppet and Chef all run the package manager without letting the caller
+# set the environment of the maintainer scripts, so the BEACON_* variables could not reach a
+# centrally deployed install any other way. /etc/default is the Debian convention and
+# /etc/sysconfig the RHEL one; the first that exists is read (BEACON_DEFAULTS_FILE names another).
+#
+# The file is read, never sourced: only the documented install settings are taken, as KEY=VALUE
+# lines in the shell syntax such files are written in (an optional `export`, one pair of matching
+# single or double quotes, whole-line and trailing `# comments`), so nothing in it runs. A value with
+# anything else left over (an unquoted space, an unterminated quote) is skipped with a warning rather
+# than passed on. The file is ignored unless root owns it and no one else can write it, because the
+# package scripts run as root. A variable already set in the environment wins over the file.
+
+# beacon_defaults_trusted FILE succeeds when FILE is owned by root and not group- or world-writable.
+beacon_defaults_trusted() {
+ # Owner uid and permission bits, from GNU stat (every Linux userland Beacon packages for) or
+ # BusyBox, which accepts the same format.
+ _beacon_meta="$(stat -c '%u %a' "$1" 2>/dev/null)" || return 1
+ # BEACON_DEFAULTS_OWNER lets the packaging tests run as an ordinary account.
+ [ "${_beacon_meta%% *}" = "${BEACON_DEFAULTS_OWNER:-0}" ] || return 1
+ # The last two octal digits are group and other: neither may include write (2, 3, 6, 7).
+ case "${_beacon_meta##* }" in
+ *[2367]?|*[2367]) return 1 ;;
+ esac
+ return 0
+}
+
+# beacon_settings_value RAW prints the value of an assignment's right-hand side, or fails when the
+# text is not one plain value.
+beacon_settings_value() {
+ _beacon_raw="$1"
+ # Leading and trailing whitespace.
+ _beacon_raw="${_beacon_raw#"${_beacon_raw%%[![:space:]]*}"}"
+ _beacon_raw="${_beacon_raw%"${_beacon_raw##*[![:space:]]}"}"
+ case "$_beacon_raw" in
+ \"*|\'*)
+ _beacon_q="$(printf '%s' "$_beacon_raw" | cut -c1)"
+ _beacon_inner="${_beacon_raw#?}"
+ case "$_beacon_inner" in
+ *"$_beacon_q"*) ;;
+ *) return 1 ;; # unterminated
+ esac
+ _beacon_rest="${_beacon_inner#*"$_beacon_q"}"
+ _beacon_inner="${_beacon_inner%%"$_beacon_q"*}"
+ # After the closing quote only whitespace, then optionally a comment, may follow. A `#` right
+ # after the quote is not a comment to a shell but more of the word, so it is refused too.
+ case "$_beacon_rest" in
+ '') printf '%s' "$_beacon_inner"; return 0 ;;
+ [[:space:]]*) ;;
+ *) return 1 ;;
+ esac
+ _beacon_rest="${_beacon_rest#"${_beacon_rest%%[![:space:]]*}"}"
+ case "$_beacon_rest" in
+ ''|'#'*) printf '%s' "$_beacon_inner"; return 0 ;;
+ esac
+ return 1
+ ;;
+ esac
+ # Unquoted: a `#` starts a comment only at the start or after whitespace, as in the shell.
+ case "$_beacon_raw" in
+ '#'*) _beacon_raw='' ;;
+ esac
+ case "$_beacon_raw" in
+ *[[:space:]]'#'*)
+ _beacon_raw="$(printf '%s' "$_beacon_raw" | sed 's/[[:space:]]#.*$//')"
+ ;;
+ esac
+ _beacon_raw="${_beacon_raw%"${_beacon_raw##*[![:space:]]}"}"
+ # Whitespace left inside an unquoted value would be a second word to a shell.
+ case "$_beacon_raw" in
+ *[[:space:]]*) return 1 ;;
+ esac
+ printf '%s' "$_beacon_raw"
+}
+
+# beacon_load_settings exports the documented settings from the defaults file that are not already
+# set in the environment.
+beacon_load_settings() {
+ _beacon_file="${BEACON_DEFAULTS_FILE:-}"
+ if [ -z "$_beacon_file" ]; then
+ for _beacon_candidate in /etc/default/beacon /etc/sysconfig/beacon; do
+ if [ -f "$_beacon_candidate" ]; then
+ _beacon_file="$_beacon_candidate"
+ break
+ fi
+ done
+ fi
+ [ -n "$_beacon_file" ] && [ -f "$_beacon_file" ] || return 0
+ if ! beacon_defaults_trusted "$_beacon_file"; then
+ echo "beacon: ignoring $_beacon_file: it must be owned by root and writable by no one else" >&2
+ return 0
+ fi
+ while IFS= read -r _beacon_line || [ -n "$_beacon_line" ]; do
+ _beacon_line="${_beacon_line#"${_beacon_line%%[![:space:]]*}"}"
+ case "$_beacon_line" in
+ ''|'#'*) continue ;;
+ export[[:space:]]*)
+ _beacon_line="${_beacon_line#export}"
+ _beacon_line="${_beacon_line#"${_beacon_line%%[![:space:]]*}"}"
+ ;;
+ esac
+ case "$_beacon_line" in
+ *=*) ;;
+ *) continue ;;
+ esac
+ _beacon_key="${_beacon_line%%=*}"
+ case "$_beacon_key" in
+ 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_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) ;;
+ *) continue ;;
+ esac
+ if ! _beacon_value="$(beacon_settings_value "${_beacon_line#*=}")"; then
+ # The key only, never the value: it may be a token.
+ echo "beacon: ignoring $_beacon_key in $_beacon_file: not a single value (quote a value with spaces)" >&2
+ continue
+ fi
+ # $_beacon_key is one of the names above, so the indirection cannot evaluate anything else.
+ eval "_beacon_set=\${$_beacon_key+set}"
+ if [ -z "$_beacon_set" ]; then
+ export "$_beacon_key=$_beacon_value"
+ fi
+ done <"$_beacon_file"
+}
diff --git a/packaging/linux/install-endpoint.sh b/packaging/linux/install-endpoint.sh
index 2d8eba53..2f374c90 100755
--- a/packaging/linux/install-endpoint.sh
+++ b/packaging/linux/install-endpoint.sh
@@ -6,78 +6,13 @@
# mixed fleet has one contract rather than two.
set -eu
-# Settings a configuration manager drops before installing the package. Salt's pkg.installed,
-# Ansible's apt/dnf modules, Puppet and Chef all run the package manager without letting the caller
-# set the environment of the maintainer scripts, so the BEACON_* variables below could not reach a
-# centrally deployed install any other way. /etc/default is the Debian convention and
-# /etc/sysconfig the RHEL one; the first that exists is read.
-#
-# The file is read, never sourced: only the variables this script documents are taken, as plain
-# KEY=VALUE lines (an optional `export`, matching single or double quotes, comments), so nothing in
-# it runs. It is skipped unless root owns it and no one else can write it, because this script runs
-# as root from the package manager. A variable already set in the environment wins over the file.
-BEACON_DEFAULTS_FILE="${BEACON_DEFAULTS_FILE:-}"
-if [ -z "$BEACON_DEFAULTS_FILE" ]; then
- for candidate in /etc/default/beacon /etc/sysconfig/beacon; do
- if [ -f "$candidate" ]; then
- BEACON_DEFAULTS_FILE="$candidate"
- break
- fi
- done
-fi
-
-beacon_defaults_trusted() {
- # Owner uid and permission bits, from GNU stat (every Linux userland Beacon packages for) or
- # BusyBox, which accepts the same format.
- meta="$(stat -c '%u %a' "$1" 2>/dev/null)" || return 1
- owner="${meta%% *}"
- mode="${meta##* }"
- # BEACON_DEFAULTS_OWNER lets the packaging tests run as an ordinary account.
- [ "$owner" = "${BEACON_DEFAULTS_OWNER:-0}" ] || return 1
- # The last two octal digits are group and other: neither may include write (2, 3, 6, 7).
- case "$mode" in
- *[2367]?|*[2367]) return 1 ;;
- esac
- return 0
-}
-
-if [ -n "$BEACON_DEFAULTS_FILE" ] && [ -f "$BEACON_DEFAULTS_FILE" ]; then
- if beacon_defaults_trusted "$BEACON_DEFAULTS_FILE"; then
- while IFS= read -r line || [ -n "$line" ]; do
- line="${line#"${line%%[![:space:]]*}"}"
- case "$line" in
- ''|'#'*) continue ;;
- export\ *) line="${line#export }"; line="${line#"${line%%[![:space:]]*}"}" ;;
- esac
- case "$line" in
- *=*) ;;
- *) continue ;;
- esac
- key="${line%%=*}"
- value="${line#*=}"
- case "$key" in
- 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_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) ;;
- *) continue ;;
- esac
- # Trailing whitespace, then one pair of matching quotes.
- value="${value%"${value##*[![:space:]]}"}"
- case "$value" in
- \"*\") value="${value#\"}"; value="${value%\"}" ;;
- \'*\') value="${value#\'}"; value="${value%\'}" ;;
- esac
- # $key is one of the names above, so the indirection below cannot evaluate anything else.
- eval "already=\${$key+set}"
- if [ -z "$already" ]; then
- export "$key=$value"
- fi
- done <"$BEACON_DEFAULTS_FILE"
- else
- echo "beacon: ignoring $BEACON_DEFAULTS_FILE: it must be owned by root and writable by no one else" >&2
- fi
-fi
+# The install settings a configuration manager can drop in /etc/default/beacon or
+# /etc/sysconfig/beacon; see beacon-settings.sh. It sits beside this script in the package
+# (/opt/beacon/scripts) and in the repository.
+BEACON_SCRIPTS_DIR="${BEACON_SCRIPTS_DIR:-$(CDPATH='' cd -- "$(dirname -- "$0")" && pwd)}"
+# shellcheck source=beacon-settings.sh
+. "$BEACON_SCRIPTS_DIR/beacon-settings.sh"
+beacon_load_settings
if [ -z "${BEACON_BIN:-}" ]; then
if [ -x "/opt/beacon/bin/beacon" ]; then
@@ -105,13 +40,30 @@ BEACON_SPLUNK_CA_FILE="${BEACON_SPLUNK_CA_FILE:-}"
BEACON_LOG_ACCESS="${BEACON_LOG_ACCESS:-}"
# A first install from the package defaults to restricted: a package is installed by root for the
# whole machine, often by a configuration manager across a fleet, and that is the install that
-# should make the collector the only writer of the system log without a second step. "First" means
-# there is no system config yet; an upgrade, or a reinstall over a kept config, keeps whatever mode
-# the endpoint has, so this never narrows (or widens) a running endpoint behind its operator's back.
+# should make the collector the only writer of the system log without a second step.
+#
+# Only a genuinely first install, and only where the collector will be a systemd service:
+# - a system config means an upgrade or a reinstall over a kept config, and a runtime log left
+# behind by `uninstall --keep-logs` means a reinstall whose old mode (recorded beside that log
+# when it was restricted) the install keeps on its own. Either way no mode is passed, so this
+# never narrows or widens an existing endpoint behind its operator's back.
+# - without systemd as PID 1 (a container, WSL without systemd) or with BEACON_SERVICE=none, the
+# collector is a supervised process nothing restarts. A restricted log there would leave every
+# hook event spooled in its user's home whenever that process is down, where a shared log keeps
+# taking them directly, so those installs stay shared unless asked.
# BEACON_LOG_ACCESS=shared opts a new install out.
BEACON_SYSTEM_CONFIG="${BEACON_SYSTEM_CONFIG:-/etc/beacon/endpoint/config.json}"
-if [ -z "$BEACON_LOG_ACCESS" ] && [ ! -e "$BEACON_SYSTEM_CONFIG" ]; then
- BEACON_LOG_ACCESS=restricted
+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
+ init="$(cat "$BEACON_INIT_COMM" 2>/dev/null || true)"
+ case "$BEACON_SERVICE" in
+ ''|auto|systemd)
+ if [ "$init" = systemd ]; then
+ BEACON_LOG_ACCESS=restricted
+ fi
+ ;;
+ esac
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.
diff --git a/packaging/linux/nfpm/postinstall.sh b/packaging/linux/nfpm/postinstall.sh
index 7f85d6f9..07e8852b 100755
--- a/packaging/linux/nfpm/postinstall.sh
+++ b/packaging/linux/nfpm/postinstall.sh
@@ -9,6 +9,15 @@ set -eu
# Both package managers invoke this for upgrades as well as first installs. `endpoint install` is
# idempotent and rewrites its own config, so no branch on the argument is needed -- but an upgrade
# must not lose an operator's explicit auto-update choice, which reconcile below preserves.
+# The settings a configuration manager wrote to /etc/default/beacon or /etc/sysconfig/beacon, loaded
+# here as well as inside install-endpoint.sh: the user-config step below is a separate command, and
+# a harness list that reached only the system install left each person's own runtime unconfigured.
+if [ -r /opt/beacon/scripts/beacon-settings.sh ]; then
+ # shellcheck source=../beacon-settings.sh
+ . /opt/beacon/scripts/beacon-settings.sh
+ beacon_load_settings
+fi
+
if ! /opt/beacon/scripts/install-endpoint.sh; then
echo "beacon: endpoint install failed" >&2
exit 1
@@ -42,4 +51,13 @@ if [ -x /opt/beacon/bin/beacon ]; then
echo "beacon: scheduled session sync job not configured (endpoint is installed and running)" >&2
fi
+# 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.
+if grep -q '"log_access": *"restricted"' /etc/beacon/endpoint/config.json 2>/dev/null; then
+ echo "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"
+fi
+
echo "beacon: endpoint installed. Check it with: beacon endpoint status --system"
diff --git a/packaging/linux/smoke-package.sh b/packaging/linux/smoke-package.sh
index be811c23..7586db68 100755
--- a/packaging/linux/smoke-package.sh
+++ b/packaging/linux/smoke-package.sh
@@ -106,6 +106,11 @@ docker exec "$CONTAINER" useradd -m -s /bin/bash "$SMOKE_USER" >/dev/null 2>&1 |
docker exec "$CONTAINER" test -d "/home/$SMOKE_USER" || {
echo "could not create the test user $SMOKE_USER" >&2; exit 1; }
+# A settings file, as a configuration manager would drop one before installing: its harness list has
+# to reach both the system install and the step that configures the user, and a trailing comment
+# must not fail the install.
+docker exec "$CONTAINER" sh -c 'printf "%s\n" "# managed by config management" "BEACON_ENDPOINT_HARNESSES=claude,codex,cursor # all three" >/etc/default/beacon && chmod 600 /etc/default/beacon'
+
if ! docker exec -e SUDO_USER="$SMOKE_USER" "$CONTAINER" sh -c "$PKGMGR_INSTALL" >/tmp/beacon-pkg-install.log 2>&1; then
echo "package install failed:" >&2
tail -30 /tmp/beacon-pkg-install.log >&2
@@ -167,6 +172,15 @@ adapter_owner="$(docker exec "$CONTAINER" stat -c %U "$ADAPTER" 2>/dev/null || t
echo "$ADAPTER is owned by $adapter_owner, not $SMOKE_USER" >&2; exit 1; }
echo "ok: hooks installed for the user and runnable by them"
+docker exec "$CONTAINER" test -f "/home/$SMOKE_USER/.cursor/hooks.json" || {
+ echo "Cursor from /etc/default/beacon was not configured for $SMOKE_USER" >&2
+ grep -i "hook\|ignoring" /tmp/beacon-pkg-install.log >&2 || true
+ exit 1
+}
+grep -q "sudo usermod -aG beacon-log" /tmp/beacon-pkg-install.log || {
+ echo "the install did not say how to let someone read the restricted log" >&2; exit 1; }
+echo "ok: the settings file reached the user step (Cursor configured), and the beacon-log hint was printed"
+
# Reachable by name, not just by absolute path.
#
# Every check in this file used /opt/beacon/bin/beacon, so the package could ship with nothing on
diff --git a/packaging/linux/test-endpoint-scripts.sh b/packaging/linux/test-endpoint-scripts.sh
index e189a98e..e0760a00 100644
--- a/packaging/linux/test-endpoint-scripts.sh
+++ b/packaging/linux/test-endpoint-scripts.sh
@@ -40,6 +40,8 @@ run_install() {
BEACON_SYSTEM_CONFIG="$TMP_DIR/etc/config.json" \
BEACON_DEFAULTS_FILE="$TMP_DIR/none" \
BEACON_DEFAULTS_OWNER="$(id -u)" \
+ BEACON_SYSTEM_LOG="$TMP_DIR/log/runtime.jsonl" \
+ BEACON_INIT_COMM="$TMP_DIR/init-comm" \
"$@" sh "$INSTALL_SCRIPT" >"$TMP_DIR/out" 2>&1 || { cat "$TMP_DIR/out" >&2; return 1; }
}
@@ -57,6 +59,9 @@ expect_log_access() {
[ "$got" = "$1" ] || fail "$2: --log-access is '$got', want '$1'"
}
+# systemd is PID 1 unless a test says otherwise.
+printf 'systemd\n' >"$TMP_DIR/init-comm"
+
# A first install, with no system config, defaults to restricted.
run_install
expect_log_access restricted "first install"
@@ -77,6 +82,27 @@ run_install BEACON_LOG_ACCESS=restricted
expect_log_access restricted "upgrade with BEACON_LOG_ACCESS=restricted"
rm -f "$TMP_DIR/etc/config.json"
+# Only where the collector will be a systemd service: a supervised collector nothing restarts would
+# leave a restricted log spooling every hook event whenever it is down.
+printf 'init\n' >"$TMP_DIR/init-comm"
+run_install
+has_flag --log-access && fail "no systemd: passed --log-access $(flag_value --log-access), want the shared default"
+printf 'systemd\n' >"$TMP_DIR/init-comm"
+run_install BEACON_SERVICE=none
+has_flag --log-access && fail "BEACON_SERVICE=none: passed --log-access $(flag_value --log-access), want the shared default"
+run_install BEACON_SERVICE=systemd
+expect_log_access restricted "BEACON_SERVICE=systemd"
+run_install BEACON_SERVICE=none BEACON_LOG_ACCESS=restricted
+expect_log_access restricted "BEACON_SERVICE=none asking for restricted"
+
+# A runtime log left by `uninstall --keep-logs` is a reinstall: the install keeps the mode recorded
+# beside it, so no mode is passed.
+mkdir -p "$TMP_DIR/log"
+: >"$TMP_DIR/log/runtime.jsonl"
+run_install
+has_flag --log-access && fail "reinstall over a kept log: passed --log-access $(flag_value --log-access); the kept mode must be kept"
+rm -rf "$TMP_DIR/log"
+
# A defaults file supplies settings a configuration manager cannot pass through the environment.
DEFAULTS="$TMP_DIR/default-beacon"
cat >"$DEFAULTS" <<'CONF'
@@ -88,7 +114,7 @@ BEACON_OTLP_HTTP_PORT=4319
NOT_A_BEACON_SETTING=1
BEACON_BIN=/tmp/evil
PATH=/tmp/evil
-BEACON_SERVICE=$(touch /tmp/beacon-defaults-ran)
+BEACON_SERVICE=$(touch${IFS}/tmp/beacon-defaults-ran)
not even an assignment
CONF
chmod 600 "$DEFAULTS"
@@ -100,9 +126,41 @@ has_flag --session-sync || fail "defaults file: BEACON_SESSION_SYNC='1' did not
# Only documented install settings are taken: the binary still came from the environment, and the
# command substitution was passed as an inert string rather than run.
[ -s "$ARGS" ] || fail "defaults file: BEACON_BIN in the file replaced the binary"
-[ "$(flag_value --service)" = '$(touch /tmp/beacon-defaults-ran)' ] || fail "defaults file: --service is '$(flag_value --service)'"
+[ "$(flag_value --service)" = '$(touch${IFS}/tmp/beacon-defaults-ran)' ] || fail "defaults file: --service is '$(flag_value --service)'"
[ -e /tmp/beacon-defaults-ran ] && fail "defaults file: a value was executed"
+# Trailing comments, as a shell reads them, and values that are not one value are skipped with a
+# warning instead of failing the package install.
+cat >"$DEFAULTS" <<'CONF'
+BEACON_LOG_ACCESS=shared # fleet default
+BEACON_OTLP_HTTP_PORT="4320" # alt port
+BEACON_ENDPOINT_HARNESSES='claude,cursor'#no space so part of nothing: quoted then comment-less junk
+BEACON_OTLP_GRPC_PORT=4317 4318
+BEACON_SERVICE="systemd
+BEACON_SPLUNK_INDEX=main#notacomment
+CONF
+chmod 600 "$DEFAULTS"
+run_install BEACON_DEFAULTS_FILE="$DEFAULTS"
+expect_log_access shared "trailing comment"
+[ "$(flag_value --otlp-http-port)" = "4320" ] || fail "quoted value with a comment: --otlp-http-port is '$(flag_value --otlp-http-port)'"
+[ "$(flag_value --harness)" = "claude,codex" ] || fail "junk after a closing quote was taken: --harness is '$(flag_value --harness)'"
+[ "$(flag_value --otlp-grpc-port)" = "4317" ] || fail "two words were taken as one value: --otlp-grpc-port is '$(flag_value --otlp-grpc-port)'"
+has_flag --service && fail "an unterminated quote was taken: --service $(flag_value --service)"
+[ "$(flag_value --splunk-index)" = "main#notacomment" ] || fail "a # inside a word is not a comment: --splunk-index is '$(flag_value --splunk-index)'"
+for key in BEACON_ENDPOINT_HARNESSES BEACON_OTLP_GRPC_PORT BEACON_SERVICE; do
+ grep -q "ignoring $key in $DEFAULTS" "$TMP_DIR/out" || fail "no warning for the malformed $key"
+done
+grep -q "4318" "$TMP_DIR/out" && fail "a warning printed a value; it must name the key only"
+
+# The package postinstall loads the same settings itself, for the step that configures each
+# logged-in user, which runs as a separate command.
+printf 'BEACON_ENDPOINT_HARNESSES=claude,codex,cursor # all three\n' >"$DEFAULTS"
+got="$(env -i PATH="$PATH" BEACON_DEFAULTS_FILE="$DEFAULTS" BEACON_DEFAULTS_OWNER="$(id -u)" \
+ sh -c '. "$1"; beacon_load_settings; printf %s "${BEACON_ENDPOINT_HARNESSES:-}"' sh "$ROOT_DIR/packaging/linux/beacon-settings.sh")"
+[ "$got" = "claude,codex,cursor" ] || fail "beacon_load_settings exported BEACON_ENDPOINT_HARNESSES='$got'"
+grep -q 'beacon_load_settings' "$ROOT_DIR/packaging/linux/nfpm/postinstall.sh" || fail "postinstall does not load the settings file"
+grep -q 'beacon-settings.sh' "$ROOT_DIR/cli/beacon/.goreleaser.yaml" || fail "the packages do not ship beacon-settings.sh"
+
# The environment wins over the file.
run_install BEACON_DEFAULTS_FILE="$DEFAULTS" BEACON_LOG_ACCESS=restricted
expect_log_access restricted "environment over defaults file"