fix(remote): abort the bootstrap when the installer cannot be fetched - #189
Open
tas50 wants to merge 1 commit into
Open
fix(remote): abort the bootstrap when the installer cannot be fetched#189tas50 wants to merge 1 commit into
tas50 wants to merge 1 commit into
Conversation
tas50
force-pushed
the
fix/bootstrap-detects-install-failure
branch
3 times, most recently
from
September 8, 2026 17:38
ad92bcf to
8a21cdc
Compare
The script opened with `set -e` and then ran curl -L <url> | sudo bash -s -- A pipeline reports only the exit status of its last command, so `set -e` saw bash's status, not curl's. A 404, a DNS failure or a TLS error was silently swallowed and the script marched on to run a cinc-client that had never been installed. The operator then had to diagnose a confusing downstream failure instead of the real one, a bad download. Download to a temp file and run that, so a failed fetch is a failed command that `set -e` acts on. curl gains -f, without which an HTTP error page is saved and executed as the "installer", and -sS to keep the progress meter out of the SSH output while preserving real error messages. A trap removes the file even when a later step fails. `set -o pipefail` would also work but is not POSIX, and the script runs under whatever login shell the target has. The trust assumption is unchanged: the target still executes whatever the bootstrap URL serves. Signed-off-by: Tim Smith <tim@mondoo.com>
tas50
force-pushed
the
fix/bootstrap-detects-install-failure
branch
from
September 8, 2026 17:42
8a21cdc to
4fb5aba
Compare
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.
The defect
The generated script opens with
set -eand then runs:A pipeline reports only the exit status of its last command, so
set -esees bash's status, not curl's. A 404, a DNS failure, or a TLS error is silently swallowed — bash cheerfully executes an empty or error-page input and exits 0 — and the script marches on to:which is not installed. The operator gets a confusing downstream failure instead of the real one, and
cinc node bootstrapreports it against a host that is now half-configured.The fix
Download to a temp file and run that, so a failed fetch is a failed command that
set -eacts on:-fso an HTTP error is a failure rather than an error page saved and executed as the "installer".-sSto keep the progress meter out of the SSH output while preserving real error messages.trapso the file is removed even when a later step fails.set -o pipefailwould also fix it, but it is not POSIX and the script runs under whatever login shell the target happens to have — dash, notably, does not support it.bash -s --becomesbash "$CINC_INSTALLER":-smeans "read the script from stdin", which no longer applies, and the--would otherwise be passed to the installer as$1.The trust assumption is unchanged. The target still executes whatever the bootstrap URL serves; this only makes a failure to fetch it visible.
Tests
TestBootstrapCommandStopsWhenTheInstallerCannotBeFetched— no pipe into a shell, curl uses-f,set -eretained.TestBootstrapCommandCleansUpTheInstaller— the temp file is trapped for removal.TestBootstrapCommandBuildsCincClientScriptandTestNodeBootstrapDryRunCommandboth pinned the old curl line and are updated.go test ./...,go vet ./..., andgofmt -l .are clean.