From b52263d0bb4f4f5a981b3f6e623ba2a445603e80 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jaroslav=20Bene=C5=A1?= Date: Thu, 3 Dec 2026 08:07:20 +0000 Subject: [PATCH] Security (S11, S14, S16): the shell's own autocomplete is gone; least privilege in CI; set-up refuses root and another version's release S11. autocomplete = 'shell' had the shell integration send what was typed to the engine itself: it could not see a private pane or the AI switch, and had its own timeout and no chosen model. autocomplete.bash and autocomplete.zsh are removed, with what exported their switch; the shell integration keeps its zones and the status record. 'shell' turns nothing on and is said in the log. S14. The build job may only read the repository; a job of its own, for a tag only and after the build passed, downloads the build's artefact and publishes the release with write access. Every action is pinned by its commit, with the tag it was taken from beside it. S16. The set-up program refuses to run as root (everything goes into the person's own home). A signed SHA256SUMS whose first line names a product and version must name the release asked for: an older signed release served under the newest tag is refused. Sums that name nothing yet are still taken, and that is said. Tests for both, and for the root refusal. Co-Authored-By: Claude Opus 5.5 --- .github/workflows/llembas-term.yml | 35 +++++-- llembas/packaging/package.sh | 4 +- llembas/setup/llembas-term-setup | 35 +++++-- llembas/shell/autocomplete.bash | 43 -------- llembas/shell/autocomplete.zsh | 154 ----------------------------- llembas/shell/llembas-term.sh | 18 +--- llembas/tests/setup-test.sh | 28 +++++- 7 files changed, 86 insertions(+), 231 deletions(-) delete mode 100644 llembas/shell/autocomplete.bash delete mode 100644 llembas/shell/autocomplete.zsh diff --git a/.github/workflows/llembas-term.yml b/.github/workflows/llembas-term.yml index 7e5f0cf37..dafd61d90 100644 --- a/.github/workflows/llembas-term.yml +++ b/.github/workflows/llembas-term.yml @@ -8,6 +8,10 @@ # packages (kept as a build artefact), installed over the last package of the earlier name. # On a signed tag vX.Y.Z or vX.Y.Z-beta.N: the same, and then the GitHub Release with the # packages, SHA256SUMS and the tag message as its notes. +# +# Least privilege: the job that builds can read the repository and nothing else; only the job +# that publishes (tags only, after the build, from the build's own artefact) can write a +# release. Every action is pinned by its commit, the tag it was taken from beside it. name: llembas-term on: push: @@ -29,12 +33,12 @@ jobs: runs-on: ubuntu-22.04 timeout-minutes: 120 permissions: - contents: write + contents: read env: CARGO_INCREMENTAL: "0" CARGO_TERM_COLOR: always steps: - - uses: actions/checkout@v5 + - uses: actions/checkout@fbc6f3992d24b796d5a048ff273f7fcc4a7b6c09 # v5.1.0 with: # The whole history: the hygiene check reads what was added since the commit in # UPSTREAM, and the build derives WezTerm's version from the newest commit. @@ -60,15 +64,14 @@ jobs: - name: Shell scripts, the workflow, the desktop file run: | shellcheck scripts/*.sh llembas/packaging/*.sh llembas/tests/*.sh llembas/ci/*.sh \ - llembas/shell/llembas-term.sh llembas/shell/autocomplete.bash llembas/setup/llembas-term-setup - zsh -n llembas/shell/autocomplete.zsh + llembas/shell/llembas-term.sh llembas/setup/llembas-term-setup zsh -n llembas/shell/llembas-term.sh yamllint -d '{extends: default, rules: {line-length: disable, document-start: disable, truthy: disable}}' .github/workflows/llembas-term.yml desktop-file-validate llembas/packaging/eu.llembas.term.desktop appstreamcli validate --no-net llembas/packaging/eu.llembas.term.appdata.xml || true - name: System libraries run: env CI=yes ./get-deps - - uses: actions-rust-lang/setup-rust-toolchain@v1 + - uses: actions-rust-lang/setup-rust-toolchain@166cdcfd11aee3cb47222f9ddb555ce30ddb9659 # v1.17.0 with: # Upstream's code is not held to "no warnings" here; the action's default would be. rustflags: "" @@ -140,16 +143,34 @@ jobs: { echo "# llembas-term $version"; sha256sum -- *; } > ../SHA256SUMS mv ../SHA256SUMS . cat SHA256SUMS - - uses: actions/upload-artifact@v4 + - uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2 with: name: llembas-term-linux-x86_64 path: dist/* retention-days: 14 + + release: + # only for a tag, only after everything above passed, and only this job may write + if: startsWith(github.ref, 'refs/tags/v') + needs: linux + runs-on: ubuntu-22.04 + timeout-minutes: 15 + permissions: + contents: write + steps: + - uses: actions/checkout@fbc6f3992d24b796d5a048ff273f7fcc4a7b6c09 # v5.1.0 + with: + # the tag's message is the release's notes + fetch-depth: 0 + - uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0 + with: + name: llembas-term-linux-x86_64 + path: dist - name: Publish the GitHub Release - if: startsWith(github.ref, 'refs/tags/v') env: GH_TOKEN: ${{ github.token }} run: | + git fetch --force origin "refs/tags/$GITHUB_REF_NAME:refs/tags/$GITHUB_REF_NAME" version="$(tr -d '[:space:]' < VERSION)" git tag -l --format='%(contents)' "$GITHUB_REF_NAME" | sed '/-----BEGIN SSH SIGNATURE-----/,$d' > notes.md # A version is released once: a fix is a new version, never the old one re-released. diff --git a/llembas/packaging/package.sh b/llembas/packaging/package.sh index 4034f5960..6009d7464 100755 --- a/llembas/packaging/package.sh +++ b/llembas/packaging/package.sh @@ -10,7 +10,7 @@ # llembas-term-setup (installs the LLeMbas CLI and LLeMbas IDE # when they are missing; the package carries neither) # usr/bin/ links to those four -# usr/share/llembas-term/shell/ shell integration: llembas-term.sh, wezterm.sh, autocomplete.* +# usr/share/llembas-term/shell/ shell integration: llembas-term.sh, wezterm.sh # usr/share/llembas-term/lua/ the LLeMbas layer's source, to read (the binary has it built in) # usr/share/applications, metainfo, icons/hicolor # usr/share/doc/llembas-term/ licences: ours and WezTerm's (LICENSE.md, licenses/), README, @@ -47,7 +47,7 @@ done install -m755 llembas/setup/llembas-term-setup "$lib/llembas-term-setup" ln -s ../lib/llembas-term/llembas-term-setup "$root/usr/bin/llembas-term-setup" -install -m644 llembas/shell/llembas-term.sh llembas/shell/autocomplete.bash llembas/shell/autocomplete.zsh "$share/shell/" +install -m644 llembas/shell/llembas-term.sh "$share/shell/" install -m644 assets/shell-integration/wezterm.sh "$share/shell/wezterm.sh" install -m644 llembas/lua/default-config.lua "$share/lua/default-config.lua" install -m644 llembas/lua/llembas/init.lua llembas/lua/llembas/core.lua "$share/lua/llembas/" diff --git a/llembas/setup/llembas-term-setup b/llembas/setup/llembas-term-setup index 20e3ab8c9..73db841a5 100755 --- a/llembas/setup/llembas-term-setup +++ b/llembas/setup/llembas-term-setup @@ -8,7 +8,9 @@ # For each one that is not installed it says what it would do and asks. What it then runs is # that product's own installer, from that product's own release, and only after checking it: # the release's SHA256SUMS must be signed with the LLeMbas release key, and the installer must -# match SHA256SUMS. Nothing runs as root; nothing that is already installed is touched (each +# match SHA256SUMS; a SHA256SUMS that names its product and version (a first line +# `# `) must name the release that was asked for. It refuses to run as root +# (everything goes into your own home); nothing that is already installed is touched (each # product updates itself: `lembas update`, `llembas-ide update`). # # It changes no file of yours. When ~/.zshrc or ~/.bashrc still has the shell integration's line @@ -107,9 +109,10 @@ newest() { # slug, channel return 1 } -# A release's installer, checked: SHA256SUMS signed by the release key, the installer in it. -checked_installer() { # slug, tag, installer file name -> path of the checked file - local slug="$1" tag="$2" name="$3" dir base +# A release's installer, checked: SHA256SUMS signed by the release key, naming this release +# where it names one, and the installer in it. +checked_installer() { # slug, tag, installer file name, product -> path of the checked file + local slug="$1" tag="$2" name="$3" product="$4" dir base head dir="$TMP/$(printf '%s' "$slug-$tag" | tr '/' '-')" base="$FORGE/$slug/releases/download/$tag" mkdir -p "$dir" @@ -121,6 +124,17 @@ checked_installer() { # slug, tag, installer file name -> path of the checked fi printf '%s %s\n' "$NAMESPACE" "$PUBKEY" >"$dir/allowed" ssh-keygen -Y verify -f "$dir/allowed" -I "$NAMESPACE" -n "$NAMESPACE" -s "$dir/SHA256SUMS.sig" <"$dir/SHA256SUMS" >/dev/null 2>&1 || die "SHA256SUMS of $slug $tag is not signed by the LLeMbas release key — nothing installed" + # The signature says who made the sums, not which release they are of: a listing that + # answered with an older signed release under the newest tag would pass it. A first line + # that names the product and version binds them to the tag asked for. + head="$(head -n1 "$dir/SHA256SUMS")" + case "$head" in + '#'*) + [ "$head" = "# $product ${tag#v}" ] || + die "SHA256SUMS of $slug $tag is of another release (it says: ${head#\# }) — nothing installed" + ;; + *) warn "($slug $tag: its SHA256SUMS does not name its release; the signature is checked)" ;; + esac (cd "$dir" && grep -E "^[0-9a-f]{64} \*?$name\$" SHA256SUMS | sed 's/ \*/ /' | sha256sum -c --strict --quiet - >/dev/null 2>&1) || die "$name of $slug $tag does not match its SHA256SUMS — nothing installed" printf '%s' "$dir/$name" @@ -140,11 +154,11 @@ setup_cli() { return 0 fi ask "Install it now, for this user only?" || { - note "left out" + note "not installed" return 0 } tag="$(newest "$CLI_SLUG" "$chan")" || die "no $chan release of $CLI_SLUG was found (is this machine online?) — nothing installed" - installer="$(checked_installer "$CLI_SLUG" "$tag" get.sh)" + installer="$(checked_installer "$CLI_SLUG" "$tag" get.sh lembas)" note "LLeMbas CLI $tag: signature good, installing" LEMBAS_REF="$tag" LEMBAS_CHANNEL="$chan" bash "$installer" || die "the LLeMbas CLI's installer stopped — see above" } @@ -163,11 +177,11 @@ setup_ide() { return 0 fi ask "Install it now, for this user only?" || { - note "left out" + note "not installed" return 0 } tag="$(newest "$IDE_SLUG" "$chan")" || die "no $chan release of $IDE_SLUG was found (is this machine online?) — nothing installed" - installer="$(checked_installer "$IDE_SLUG" "$tag" install.sh)" + installer="$(checked_installer "$IDE_SLUG" "$tag" install.sh llembas-ide)" note "LLeMbas IDE $tag: signature good, installing" # --no-cli: the CLI is this program's own step above. bash "$installer" --version "${tag#v}" --channel "$chan" --no-cli --yes || die "LLeMbas IDE's installer stopped — see above" @@ -207,7 +221,7 @@ main() { shift ;; -h | --help) - sed -n '2,12p' "$0" | sed 's/^# \{0,1\}//' + sed -n '2,14p' "$0" | sed 's/^# \{0,1\}//' return 0 ;; *) die "unknown option $1 (see --help)" ;; @@ -215,6 +229,9 @@ main() { shift done case "$(channel)" in stable | beta) ;; *) die "--channel is stable or beta" ;; esac + # everything is installed into your own home, and installers are run: never as root + [ "$(id -u)" != 0 ] || die "run it as yourself, not as root: it installs for your own user only" + [ "$DRY" = 1 ] || TMP="$(mktemp -d)" say "LLeMbas TERM set-up ($(channel) releases)" diff --git a/llembas/shell/autocomplete.bash b/llembas/shell/autocomplete.bash deleted file mode 100644 index 3ebd28345..000000000 --- a/llembas/shell/autocomplete.bash +++ /dev/null @@ -1,43 +0,0 @@ -# shellcheck shell=bash -# LLeMbas TERM: prompt autocomplete for bash, on demand. -# -# bash cannot draw a suggestion after the cursor, so this is a key: press it -# and the rest of the line is asked from LLeMbas and put on the line. Nothing -# runs: you still press Enter yourself. -# -# key: Ctrl+X Ctrl+A (set LLEMBAS_TERM_AUTOCOMPLETE_KEY to a readline key -# sequence before this file is sourced to change it) -# -# Active only inside LLeMbas TERM. Loaded by llembas-term.sh when autocomplete is -# on, or source this file yourself. The line so far goes to -# `lembas complete --shell bash` on stdin; nothing is sent for an empty line, -# for a line that starts with a space, or when the cursor is not at the end. - -if [ -z "${LLEMBAS_TERM-}" ] || [ -z "${BASH_VERSION-}" ]; then - return 0 -fi -case "$-" in - *i*) ;; - *) return 0 ;; -esac - -__llembas_complete_line() { - local line="$READLINE_LINE" rest cli="${LLEMBAS_TERM_CLI:-lembas}" - [ -n "$line" ] || return 0 - case "$line" in - ' '* | *$'\n'*) return 0 ;; - esac - [ "$READLINE_POINT" -eq "${#line}" ] || return 0 - [ "${#line}" -le 2000 ] || return 0 - command -v "$cli" >/dev/null 2>&1 || return 0 - rest="$(printf '%s' "$line" | "$cli" complete --shell bash --cwd "$PWD" --timeout-ms 2500 2>/dev/null)" || return 0 - # What comes back is a model's text: one line, no control characters, not endless. - rest="${rest%%$'\n'*}" - rest="${rest//[[:cntrl:]]/}" - rest="${rest:0:500}" - [ -n "$rest" ] || return 0 - READLINE_LINE="$line$rest" - READLINE_POINT="${#READLINE_LINE}" -} - -bind -x "\"${LLEMBAS_TERM_AUTOCOMPLETE_KEY:-\\C-x\\C-a}\": __llembas_complete_line" diff --git a/llembas/shell/autocomplete.zsh b/llembas/shell/autocomplete.zsh deleted file mode 100644 index 1c2655d32..000000000 --- a/llembas/shell/autocomplete.zsh +++ /dev/null @@ -1,154 +0,0 @@ -# LLeMbas TERM: prompt autocomplete for zsh, as ghost text. -# -# While you type, the rest of the line is asked from LLeMbas -# (`lembas complete --shell zsh`, the line so far on stdin) and shown dimmed -# after the cursor. Right arrow or End takes it; any other key drops it. -# Nothing runs: you still press Enter yourself. -# -# Active only inside LLeMbas TERM. Loaded by llembas-term.sh when autocomplete is -# on (LLEMBAS_TERM_AUTOCOMPLETE=1), or source this file yourself. -# -# Nothing is sent: for an empty line, for a line that starts with a space, for -# a line of several lines, when the cursor is not at the end, or before you -# have paused typing (LLEMBAS_TERM_AUTOCOMPLETE_DELAY, hundredths of a second, -# default 35). A request still running when you type again is stopped. -# -# The request runs beside the line editor (a process substitution watched -# with `zle -F`), so typing never waits for it. - -[[ -n ${LLEMBAS_TERM-} && -n ${ZSH_VERSION-} && -o interactive ]] || return 0 -(( ${+__llembas_ac_loaded} )) && return 0 -typeset -g __llembas_ac_loaded=1 - -zmodload zsh/system 2>/dev/null || return 0 -zmodload zsh/zselect 2>/dev/null || return 0 -autoload -Uz add-zle-hook-widget add-zsh-hook 2>/dev/null || return 0 - -typeset -g __llembas_ac_fd= __llembas_ac_pid= __llembas_ac_for= __llembas_ac_seen= -typeset -g __llembas_ac_text= __llembas_ac_hl= __llembas_ac_off= - -__llembas_ac_stop() { - if [[ -n $__llembas_ac_fd ]]; then - zle -F $__llembas_ac_fd 2>/dev/null - exec {__llembas_ac_fd}<&- - __llembas_ac_fd= - fi - if [[ -n $__llembas_ac_pid ]]; then - kill -TERM $__llembas_ac_pid 2>/dev/null - __llembas_ac_pid= - fi -} - -__llembas_ac_clear() { - if [[ -n $__llembas_ac_text ]]; then - POSTDISPLAY= - __llembas_ac_text= - fi - if [[ -n $__llembas_ac_hl ]]; then - region_highlight=("${(@)region_highlight:#$__llembas_ac_hl}") - __llembas_ac_hl= - fi -} - -__llembas_ac_request() { - __llembas_ac_stop - [[ -z $__llembas_ac_off ]] || return 0 - local line=$BUFFER cli=${LLEMBAS_TERM_CLI:-lembas} - [[ -n $line && $line != ' '* && $line != *$'\n'* ]] || return 0 - (( CURSOR == ${#line} && ${#line} <= 2000 )) || return 0 - (( ${+commands[$cli]} )) || [[ -x $cli ]] || return 0 - - __llembas_ac_for=$line - local delay=${LLEMBAS_TERM_AUTOCOMPLETE_DELAY:-35} dir=$PWD - exec {__llembas_ac_fd}< <( - # our process id first, so that the request can be stopped - print -r -- $sysparams[pid] - # wait for a pause in the typing; a keystroke stops us here - zselect -t $delay - exec $cli complete --shell zsh --cwd $dir --timeout-ms 2500 2>/dev/null < <(print -rn -- $line) - ) - # (as zsh-autosuggestions found: without a fork here, Ctrl+C can stop working) - command true - IFS= read -r -u $__llembas_ac_fd __llembas_ac_pid - zle -F $__llembas_ac_fd __llembas_ac_ready -} - -__llembas_ac_ready() { - local fd=$1 rest= - if [[ -z ${2-} || ${2-} == hup ]]; then - IFS= read -r -u $fd rest - fi - zle -F $fd 2>/dev/null - exec {fd}<&- - __llembas_ac_fd= __llembas_ac_pid= - - # The line editor's variables can only be changed from a widget. - zle __llembas_ac_show -- "$rest" -} - -__llembas_ac_show() { - local rest=${1-} - # only for the line it was asked for, still unchanged - [[ $BUFFER == $__llembas_ac_for ]] && (( CURSOR == ${#BUFFER} )) || return 0 - # what came back is a model's text: one line, no control characters, not endless - rest=${rest//[[:cntrl:]]/} - rest=${rest[1,500]} - [[ -n $rest ]] || return 0 - - __llembas_ac_text=$rest - POSTDISPLAY=$rest - __llembas_ac_hl="${#BUFFER} $(( ${#BUFFER} + ${#POSTDISPLAY} )) ${LLEMBAS_TERM_AUTOCOMPLETE_STYLE:-fg=8}" - region_highlight+=("$__llembas_ac_hl") - zle -R -} - -# Before each redraw: when the line changed, the suggestion is for another -# line. Drop it and ask again. -__llembas_ac_redraw() { - [[ $BUFFER == $__llembas_ac_seen ]] && return 0 - __llembas_ac_seen=$BUFFER - __llembas_ac_clear - __llembas_ac_request -} - -__llembas_ac_finish() { - __llembas_ac_stop - __llembas_ac_clear - __llembas_ac_seen= -} - -__llembas_ac_take() { - if [[ -n $__llembas_ac_text ]] && (( CURSOR == ${#BUFFER} )); then - local text=$__llembas_ac_text - __llembas_ac_clear - BUFFER+=$text - CURSOR=${#BUFFER} - return 0 - fi - return 1 -} - -__llembas_ac_forward_char() { - __llembas_ac_take || zle .forward-char -} - -__llembas_ac_end_of_line() { - __llembas_ac_take || zle .end-of-line -} - -# zsh-autosuggestions draws in the same place. With it loaded, ours stays off -# unless asked for by name (LLEMBAS_TERM_AUTOCOMPLETE_FORCE=1). -__llembas_ac_check() { - add-zsh-hook -d precmd __llembas_ac_check - if (( ${+functions[_zsh_autosuggest_start]} )) && [[ ${LLEMBAS_TERM_AUTOCOMPLETE_FORCE-} != 1 ]]; then - __llembas_ac_off=1 - print -u2 -r -- "llembas-term: prompt autocomplete is off because zsh-autosuggestions is loaded (set LLEMBAS_TERM_AUTOCOMPLETE_FORCE=1 to use both)" - fi -} - -zle -N __llembas_ac_show -zle -N forward-char __llembas_ac_forward_char -zle -N end-of-line __llembas_ac_end_of_line -add-zle-hook-widget line-pre-redraw __llembas_ac_redraw -add-zle-hook-widget line-finish __llembas_ac_finish -add-zsh-hook precmd __llembas_ac_check diff --git a/llembas/shell/llembas-term.sh b/llembas/shell/llembas-term.sh index c91522c08..919d79677 100644 --- a/llembas/shell/llembas-term.sh +++ b/llembas/shell/llembas-term.sh @@ -6,15 +6,15 @@ # # [ -n "$LLEMBAS_TERM" ] && . /usr/share/llembas-term/shell/llembas-term.sh # -# It does three things, and only inside LLeMbas TERM, only in an interactive shell: +# It does two things, and only inside LLeMbas TERM, only in an interactive shell: # # 1. Semantic zones and the working directory (OSC 133, OSC 7), by WezTerm's # own integration script, shipped beside this file as wezterm.sh. That is # what lets the terminal tell one command and its output from the next. # The WEZTERM_SHELL_SKIP_* variables documented in that file apply. -# 2. Prompt autocomplete, when it was turned on (`autocomplete = true` in the -# LLeMbas layer's options exports LLEMBAS_TERM_AUTOCOMPLETE=1). Off by default. -# 3. The pane's status record: at every prompt, and when a command starts, a +# (Suggestions and the AI's autocomplete are drawn by the terminal itself +# on the line these mark; nothing of them runs in the shell.) +# 2. The pane's status record: at every prompt, and when a command starts, a # few lines that say where this shell stands - at its prompt or running a # command, how the last command ended, when, in which directory. It says # nothing of what the command was. It is how the terminal, and LLeMbas when @@ -71,16 +71,6 @@ if ! typeset -f __wezterm_semantic_precmd >/dev/null 2>&1; then fi fi -if [ "${LLEMBAS_TERM_AUTOCOMPLETE-}" = "1" ]; then - if [ -n "${ZSH_NAME-}" ] && [ -r "$__llembas_term_dir/autocomplete.zsh" ]; then - # shellcheck source=/dev/null - . "$__llembas_term_dir/autocomplete.zsh" - elif [ -n "${BASH_VERSION-}" ] && [ -r "$__llembas_term_dir/autocomplete.bash" ]; then - # shellcheck source=/dev/null - . "$__llembas_term_dir/autocomplete.bash" - fi -fi - if [ "${LLEMBAS_TERM_SKIP_STATUS-}" != "1" ] && [ -z "${__llembas_term_seq-}" ]; then __llembas_term_seq=0 __llembas_term_ran= diff --git a/llembas/tests/setup-test.sh b/llembas/tests/setup-test.sh index 277e5a1d9..edc69cf3f 100755 --- a/llembas/tests/setup-test.sh +++ b/llembas/tests/setup-test.sh @@ -46,9 +46,17 @@ expect "a beta terminal asks for the betas" "$out" "newest beta release of LLeMb refuse "--no-ide leaves the IDE out" "$out" "LLeMbas-IDE" out="$(run "$work/empty" bash "$SETUP")" -expect "nobody to answer: nothing is installed" "$out" "left out" +expect "nobody to answer: nothing is installed" "$out" "not installed$" if [ -z "$(find "$work/empty" -mindepth 1 | head -n1)" ]; then ok "and nothing is written"; else bad "written without an answer: $(find "$work/empty" -mindepth 1 | head)"; fi +# As root: refused, before anything is looked at (`id` stands in for root here). +mkdir -p "$work/root/bin" "$work/rootless" +printf '#!/bin/sh\necho 0\n' >"$work/root/bin/id" +chmod +x "$work/root/bin/id" +out="$(env -i PATH="$work/root/bin:/usr/bin:/bin" HOME="$work/rootless" LANG=C.UTF-8 bash "$SETUP" --yes &1)" +expect "it refuses to run as root" "$out" "not as root" +if [ -z "$(find "$work/rootless" -mindepth 1 | head -n1)" ]; then ok "and writes nothing"; else bad "as root it wrote: $(find "$work/rootless" -mindepth 1 | head)"; fi + # The shell integration's line of the terminal's old name in an rc file: the new line is said, # and the file is not touched. mkdir -p "$work/rc/.local/bin" @@ -92,11 +100,27 @@ out="$(run "$work/h3" "${local_forge[@]}" bash "$SETUP" --yes --no-ide)" expect "an installer that does not match the signed sums is refused" "$out" "does not match its SHA256SUMS" if [ ! -e "$work/h3/ran" ]; then ok "and does not run"; else bad "a changed installer ran"; fi -(cd "$rel" && sha256sum get.sh >SHA256SUMS) && rm -f "$rel/SHA256SUMS.sig" +# Signed sums of another release, served under this tag (a signed downgrade): refused when the +# sums name their release. +(cd "$rel" && { echo '# lembas 9.9.8'; sha256sum get.sh; } >SHA256SUMS) && rm -f "$rel/SHA256SUMS.sig" +ssh-keygen -Y sign -q -f "$work/key" -n lembas-release "$rel/SHA256SUMS" +mkdir -p "$work/h5" +out="$(run "$work/h5" "${local_forge[@]}" bash "$SETUP" --yes --no-ide)" +expect "signed sums of another release under this tag are refused" "$out" "is of another release \(it says: lembas 9\.9\.8\)" +if [ ! -e "$work/h5/ran" ]; then ok "and its installer does not run"; else bad "the installer of another release ran"; fi + +(cd "$rel" && { echo '# lembas 9.9.9'; sha256sum get.sh; } >SHA256SUMS) && rm -f "$rel/SHA256SUMS.sig" ssh-keygen -Y sign -q -f "$work/key" -n lembas-release "$rel/SHA256SUMS" out="$(run "$work/h4" "${local_forge[@]}" bash "$SETUP" --yes --no-ide)" expect "a signed, matching release is installed" "$out" "LLeMbas CLI v9\.9\.9: signature good, installing" +refuse "sums that name this release: nothing said of it" "$out" "does not name its release" expect "the stable channel takes the release, not the beta beside it" "$(cat "$work/h4/ran" 2>/dev/null)" "^ran with ref=v9\.9\.9$" +(cd "$rel" && sha256sum get.sh >SHA256SUMS) && rm -f "$rel/SHA256SUMS.sig" "$work/h4/ran" +ssh-keygen -Y sign -q -f "$work/key" -n lembas-release "$rel/SHA256SUMS" +out="$(run "$work/h4" "${local_forge[@]}" bash "$SETUP" --yes --no-ide)" +expect "sums that do not name a release yet: installed, and said" "$out" "does not name its release" +expect "and it ran" "$(cat "$work/h4/ran" 2>/dev/null)" "^ran with ref=v9\.9\.9$" + [ "$failed" -eq 0 ] && echo "setup: all passed" exit "$failed"