Uh oh!
There was an error while loading. Please reload this page.
fix(service): default identity + cache dirs to the machine state dir for a service run - #128
Closed
MichaelTaylor3d wants to merge 1 commit into
Closed
fix(service): default identity + cache dirs to the machine state dir for a service run#128MichaelTaylor3d wants to merge 1 commit into
MichaelTaylor3d wants to merge 1 commit into
Conversation
…for a service run A packaged Linux .deb install never joins the P2P network. The systemd unit sets ProtectHome=true (correctly), which blanks $HOME, but the identity seed (digstore-remote's $HOME/.config/dig) and the .dig cache (dig-node-core's $HOME/DigNode/cache) both default under $HOME. load_or_create_seed() then fails EROFS, so the node loads no identity and peer bring-up refuses with "no identity seed; peer network needs a stable identity"; the cache falls back to a /tmp dir that does not survive a restart. Every official Linux install is therefore a node that serves locally but never gets a peer_id, a relay reservation, or a peer. Both readers already honor DIG_IDENTITY_DIR / DIG_NODE_CACHE, so a new state::apply_service_state_env() defaults them to the machine-wide state dir (/var/lib/dig-node, /Library/Application Support/DigNode, %PROGRAMDATA%\DigNode) when this process is the installed service (DIG_NODE_RUN_CONTEXT=service) and the operator has not pinned them. Wired once at the top of run(), so systemd, launchd, and the Windows SCM are all steered from one place rather than each packaging target re-deriving a path — and ProtectHome=true stays. A bare CLI run is unaffected (keeps the shared $HOME cache, byte-identical to the browser node, #96). Regression tests assert the service-context identity + cache paths land outside $HOME, that an explicit override is never clobbered, and that a CLI run is a no-op. Closes #1928 Co-Authored-By: Claude <noreply@anthropic.com>
MichaelTaylor3d
commented
Aug 2, 2026
ContributorAuthor
Closing as a duplicate — superseded by #127 ( Generated by Claude Code |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for freeto join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #1928.
Problem
A packaged Linux
.debinstall produces a node that serves content locally but never joins the P2P network — nopeer_id, no relay reservation, no peers, ever. Two individually-reasonable facts are jointly fatal:ProtectHome=true(correct hardening) → systemd runs the root service withHOME=/rootand/rootinaccessible.$HOME: the identity seed viadigstore-remote::identity_dir()($HOME/.config/dig) and the.digcache viadig-node-core::canonical_cache_dir()($HOME/DigNode/cache).So
load_or_create_seed()failsEROFS,Node::from_env()setsidentity_seed: None, and peer bring-up refuses with"no identity seed; peer network needs a stable identity". The cache also falls back to a/tmpdir that doesn't survive a restart. Every official Linux install is a dead node on the connect leg of install→connect→read.Fix (dig-node-only — no cross-repo release)
Both readers already honor
DIG_IDENTITY_DIR/DIG_NODE_CACHE. Newstate::apply_service_state_env()defaults them to the machine-wide state dir (/var/lib/dig-node,/Library/Application Support/DigNode,%PROGRAMDATA%\DigNode) when this process is the installed service (DIG_NODE_RUN_CONTEXT=service) and the operator hasn't pinned them. Wired once at the top ofrun(), so systemd and launchd and the Windows SCM are steered from one place — the ticket's preferred shape (no per-packaging path re-derivation).ProtectHome=truestays. A bare CLI run is a no-op (keeps the shared$HOMEcache, byte-identical to the browser's in-process node, #96).No packaging edit needed: the systemd unit and launchd plist already set
DIG_NODE_RUN_CONTEXT=service, and the Windows service registers with it too, so the code fix covers the whole class the ticket flagged across all three OSes.Blast radius (checked)
apply_service_state_envis a new symbol called from exactly one site (entrypoint::run). It only sets two env vars, only for a service run, only when unset. It reuses the existingstate_dir()/machine_state_dirs()(#501) resolution — no new path logic. Non-service (CLI) behavior is unchanged.Verification
service_state_env_defaults_land_under_the_machine_dir_not_home(pure placement) andapply_service_state_env_service_context_points_outside_home_and_respects_overrides(service-context lands outside$HOME, explicit override preserved, CLI no-op).cargo test -p dig-node-service --lib state::→ 34 passed, 0 failed.cargo fmtclean;cargo clippy -p dig-node-service --all-targetszero warnings.Version
0.71.1→0.71.2(patch —fix:, no public API change), re-locked in the same commit.🤖 Generated with Claude Code
Co-Authored-By: Claude noreply@anthropic.com
Generated by Claude Code