Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
4 changes: 3 additions & 1 deletion docs/guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 <url>/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`.
Expand Down
14 changes: 12 additions & 2 deletions scripts/get.sh
Original file line number Diff line number Diff line change
@@ -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 <the same URL> | 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
Expand Down Expand Up @@ -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"
Expand Down
10 changes: 8 additions & 2 deletions scripts/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -117,10 +117,16 @@ install_write_settings() {
}

# install_ask <question> <default>: 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 || install_ans=
if ! IFS= read -r install_ans </dev/tty; then
echo >/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
}

Expand Down
Loading