Repository navigation
Conversation
…20206) Signed-off-by: Sean Collins <[email protected]>
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 free
to 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.
Description of changes
Adds
services.crowdsec.hub.updateOnStart, a new boolean option(default
true, preserves existing behaviour) that controls whethercscli hub updateruns as part of thecrowdsec.serviceExecStartPre.Closes #520206.
Motivation
When
cscli hub updateruns unconditionally inside theExecStartPrescript (which usesset -euo pipefail), anynetwork-unavailable condition at service-start time aborts the
script and fails the service. The failure combines badly with the
DynamicUser+StateDirectorysemantics of thecrowdsec-firewall-bouncer-registerservice, which migrates/var/lib/crowdsec→/var/lib/private/crowdsecunder the dynamicuser. After that migration, subsequent script runs get EACCES on
/var/lib/crowdsecand the service is permanently stuck withoutmanual filesystem cleanup. See #520206 for the full cascade.
This blocks
pkgs.testers.nixosTest-based integration testing ofthe
services.crowdsecmodule (test VMs have no network bydefault) and affects air-gapped / DNS-strict / pre-network-online
deployments in production.
Approach
Minimal-diff fix that exposes operator choice rather than
heuristic auto-detection:
Add
services.crowdsec.hub.updateOnStart(defaulttrue).When
true, behaviour is identical to the pre-patch module.When
false, thecscli hub updateline is omitted from theExecStartPrescript entirely.The existing
services.crowdsec.autoUpdateServiceoption(periodic timer-based updates) is unaffected and continues to
work alongside this — operators can choose any combination:
updateOnStartautoUpdateServicetrue(default)truetruefalsefalsetruefalsefalsecscli hub updateonlyWhat I did NOT change
set -euo pipefailstays. A failed
cscli hub updatestill aborts service startwhen
updateOnStart = true. The fix is opt-out of the call, notsilently swallowing errors when it runs.
crowdsec-firewall-bouncer-registerDynamicUser+StateDirectorymigration — that's the secondary half of thecascade and deserves its own change. This PR addresses the
proximate trigger so testing can land first.
services.crowdsec.autoUpdateServicesemantics.Things done
PR. The change is module-config-shaped (new option, conditional
inclusion of an existing list element); a
nixos-rebuild dry-buildagainst a config that sets the new option tofalsewould be the expected pre-merge verification on the reviewer
side, plus an actual
pkgs.testers.nixosTestre-run withservices.crowdsec.hub.updateOnStart = falseto confirm thetest now passes where it previously failed.
pkgs.testers.nixosTestexistsfor
services.crowdsec, but it currently hits the bugdocumented in nixos/crowdsec: ExecStartPre hub update fails in hermetic VMs, cascades to permanent EACCES via bouncer-register StateDirectory #520206 and times out. Adding a passing test that
sets
updateOnStart = falsewould be the natural follow-upcommit if maintainers want it included in this PR.
conditional matches the existing
lib.optionalspattern usedelsewhere in the same
scriptArray(e.g. forcfg.hub.collections,cfg.hub.scenarios).truepreservespre-patch behaviour exactly.
Verification of the issue is current
The bug location at
nixos/modules/services/security/crowdsec.nixlines 553–557 (the
scriptArraydefinition) was verified againstthe current
mainHEAD ofNixOS/nixpkgsat PR-prep time.Issue-reference: closes #520206.