diff --git a/README.md b/README.md index 0e76b36..c9b1c57 100644 --- a/README.md +++ b/README.md @@ -13,9 +13,12 @@ change. It is plain POSIX shell, and it adds no packages and leaves nothing runn Run the command as root on a host that has auditd. ```sh -curl -fsSL https://github.com/spydisec/auditd-kit/releases/latest/download/get.sh | sudo sh +sudo sh -c "$(curl -fsSL https://github.com/spydisec/auditd-kit/releases/latest/download/get.sh)" ``` +Use this form, and don't pipe `curl` into `sudo sh`. The newer sudo on Ubuntu 25.10 and later +(sudo-rs) keeps the keyboard from a script that is piped in, so the questions can't be answered. + `get.sh` downloads the latest release into `/opt/auditd-kit`, checks it against `SHA256SUMS`, asks which profile you want, and shows each change before it makes any. RHEL 10 also needs the `tar` and `initscripts-service` packages. diff --git a/docs/guide.md b/docs/guide.md index 1b57c90..2dfad00 100644 --- a/docs/guide.md +++ b/docs/guide.md @@ -53,7 +53,9 @@ a copy of a loaded rule, prints as `result=warn` and doesn't change the exit cod auditd-kit has no fleet tool of its own. Your own tool, e.g. Ansible or an SSH loop, runs the same command on each host and copies your own rule files to `/etc/audit/rules.d/`. -- With no terminal, `get.sh` only prints the plan, and `--yes` makes it install. +- From a script, pipe `get.sh` into the shell and pass `--yes` with your settings, e.g. + `curl -fsSL /get.sh | sudo sh -s -- --yes --profile medium`. With no terminal and no + `--yes`, `get.sh` only prints the plan. - The last line of `get.sh` is one result line for the host, e.g. `result=installed version=0.4.0 host=web1`. A refusal adds `codes=`, and locked rules add `reboot=required`. diff --git a/scripts/get.sh b/scripts/get.sh index 9964a2a..8930ef5 100755 --- a/scripts/get.sh +++ b/scripts/get.sh @@ -1,8 +1,12 @@ #!/bin/sh # Download an auditd-kit release, check it, and run its install.sh. # -# Usage: curl -fsSL https://github.com/spydisec/auditd-kit/releases/latest/download/get.sh | sudo sh -# ... | sudo sh -s -- [--yes] [install.sh arguments] +# Usage: sudo sh -c "$(curl -fsSL https://github.com/spydisec/auditd-kit/releases/latest/download/get.sh)" +# curl -fsSL | sudo sh -s -- [--yes] [install.sh arguments] +# +# The first form is for a person at a terminal. Use it for the guided questions, because some +# sudo versions, e.g. sudo-rs on Ubuntu 25.10, keep the keyboard from a script that is piped in. +# The second form is for scripts and takes arguments. # # On a terminal, install runs in guided mode and asks before it changes anything. With no # terminal, as from ssh or a config tool, it only prints the host check and the plan. --yes runs @@ -128,6 +132,12 @@ case "$get_rc" in esac get_codes=$(sed -n 's/^refuse=\([^ ]*\).*/\1/p' "$get_tmp/out" | paste -sd, -) get_reboot= +case ",$get_codes," in + *,terminal_read,*) + # shellcheck disable=SC2016 + printf 'auditd-kit get: for the guided questions, run: sudo sh -c "$(curl -fsSL %s/get.sh)"\n' "$get_base" >&2 + ;; +esac ! grep -qx reboot=required "$get_tmp/out" || get_reboot=' reboot=required' printf 'result=%s version=%s host=%s%s%s\n' "$get_result" "$get_version" "$(uname -n)" \ "${get_codes:+ codes=$get_codes}" "$get_reboot" diff --git a/scripts/install.sh b/scripts/install.sh index bdabe2e..124aa0f 100755 --- a/scripts/install.sh +++ b/scripts/install.sh @@ -117,10 +117,16 @@ install_write_settings() { } # install_ask : ask on the terminal, and set install_ans to the answer or -# to the default when the answer is empty. +# to the default when the answer is empty. A read that fails is not an answer. It happens when +# the script is piped into a sudo that keeps the keyboard from it, e.g. sudo-rs on Ubuntu 25.10, +# and taking it as "no" would cancel the install before the user could type. install_ask() { printf '%s ' "$1" >/dev/tty - IFS= read -r install_ans /dev/tty + echo "refuse=terminal_read detail=can't read your answer from the terminal, so nothing changed. Don't pipe the script into sudo. Run it from a file, or pass the settings as flags without --guided" + exit "$AKIT_EXIT_REFUSED" + fi [ -n "$install_ans" ] || install_ans=$2 }