Repository navigation
fix: make curl|sh re-run upgrade instead of silently succeeding - #34
Merged
Merged
Conversation
Four problems when install.sh runs via curl|sh: 1. $0 is 'sh', so dirname gives cwd — if cwd has no cc_peer.py and the destination already has one, neither copy nor fetch runs. Fix: detect piped execution with [ -f "$0" ] and always fetch. 2. Existing files at the destination skip the fetch, so re-running never upgrades. Fix: always copy or fetch, never skip. 3. usage() reads $0 with sed, which fails on a pipe. Fix: replace with a heredoc. 4. --host values are not validated against injection (cc_peer.py has check_ssh_argument, install.sh did not). Fix: add validate_host(). 5. remote_run() also assumed $0 was a file — now fetches to a temp dir when running from a pipe. Also adds an install-smoke CI job that verifies fresh install, re-run upgrade, and uninstall. Closes #23
Put *permitlocalcommand* before *localcommand* — the longer pattern must come first or shellcheck SC2221/SC2222 flags the shorter one as both always-overriding and never-matching.
Merged
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.
Problem
Running
curl -fsSL .../install.sh | sha second time installs nothing and reports success:$0isshwhen piped, sodirnamegives cwd — no project files thereusage()reads$0withsed, which fails on a pipe--hostvalues are not validated (unlikecc_peer.py'scheck_ssh_argument)remote_run()also assumes$0is a fileFix
[ -f "$0" ]and setsrc_dir=""usage()sedwith a heredocvalidate_host()matchingcc_peer.py's injection checksremote_run()fetches to a temp dir when source files aren't availableCI
Added
install-smokejob: fresh install → verify → re-run upgrade → uninstall.Closes #23