Repository navigation
fix(apparmor): install no profile where the parser has no abi/4.0 - #3562
Conversation
) * fix(apparmor): install no profile where the parser has no abi/4.0 The minimald profile declares abi/4.0 and carries one rule, `userns`, both of which exist from AppArmor 4.0. On Debian 12 (AppArmor 3.0.8) the parser cannot open that abi and refuses the file, so a package's postinst or the hand loader reported an error on every install there (gominimal/inbox#1197). That kernel does not restrict unprivileged user namespaces either, so the profile has nothing to allow on it, which is why `min finalize-install` already installs it only where the sysctl restricts them. The loader now does the same: without abi/4.0 under the AppArmor directory it says the host mediates no user namespaces and installs nothing, and --uninstall still removes a file an earlier run left. The profile's header says why there is no second rendering: a 3.x profile could not say `userns`. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> * fix(apparmor): the loader's --check finds apparmor_parser on a user's PATH `--check` runs as the user, as the docs say, and on Debian and Ubuntu apparmor_parser lives in /usr/sbin, which a user's PATH does not hold, so the check died with "apparmor_parser not found" on a host that has AppArmor (a lab run of the installed loader on Ubuntu 24.04). The loader adds /usr/sbin and /sbin to its PATH before looking. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> * fix(apparmor): say that --check was skipped where the parser has no abi/4.0 A lane that runs `--check` on an older host read a 0 and two lines about installing nothing. The check mode now says the profile was not parsed here and why, so a lane that depends on the parse can read it. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> * fix(apparmor): decide the abi/4.0 skip by the kernel's switch, and test the loader The guard skipped on a parser without abi/4.0 alone, and said the host does not mediate user namespaces. On a host that restricts them with an old parser that was false: nothing installed, every box to EPERM. The loader now reads the switch finalize-install reads: off or absent, it installs nothing and says so; on, it fails and names the remedy. The notes are sentences. The policy directory and the switch file take an override, and install_test.sh drives the loader over a scratch tree with a stub parser through every branch, under bash. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> --------- Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com> (cherry picked from commit 89436ef)
|
Important Review skippedBot user detected. To trigger a single review, invoke the
|
|
Reviewed: 1 finding, none blocking at Address the comments on the diff. Clobber: none seen in the three files. |
| # reports the skip either way. The --uninstall path still runs, for a file | ||
| # an earlier run left. | ||
| if [ "$mode" != uninstall ] && [ ! -e "$APPARMOR_D/abi/4.0" ]; then | ||
| parser_version="$(apparmor_parser --version 2>/dev/null | head -1)" |
There was a problem hiding this comment.
LOW · correctness · confidence 0.50 · in parser_version
The version probe is a pipeline under set -euo pipefail. If apparmor_parser --version exits nonzero, or gets SIGPIPE from head -1, the assignment fails and the script exits silently. The user then sees none of the skip or remedy messages. Add || true to the pipeline.
What the reviewer checked
parser_version="$(apparmor_parser --version 2>/dev/null | head -1)"
Hand this to an agent
Act on a code-review finding.
File: scripts/install-apparmor-profile.sh
Lines: 81-81
Category: correctness
Severity: low (reviewer confidence 0.50)
Finding:
The version probe is a pipeline under `set -euo pipefail`. If `apparmor_parser --version` exits nonzero, or gets SIGPIPE from `head -1`, the assignment fails and the script exits silently. The user then sees none of the skip or remedy messages. Add `|| true` to the pipeline.
First verify this against the code yourself. It is model output and
may be wrong. If it is wrong, or the tradeoff was deliberate, say so
and change nothing.
👍 useful · 👎 noise — react to tell the reviewer. Replying works too, and says more.
Backport of #3285 to
release/0.7.x.Squash-merge this PR and keep the PR title as the subject. The cherry-picked commit keeps the source subject.