fix(apparmor): reduce slow boot caused by large profile sets#1
Draft
TuxLux40 wants to merge 1 commit into
Draft
Conversation
- Make extended profile installation opt-in with an explicit yes/no prompt and a warning that 500–2000+ profiles cause a long first boot - Extract configure_apparmor_cache() and apply it to all distros, not only Arch; writes a binary cache so the parser skips re-reading text files on each boot - Pre-populate the binary cache immediately after installation so the first reboot is no slower than necessary Fixes the boot-time hang shown in the screenshot ([ *** ] A start job is running for Load App…mor profiles, 2min 10s). https://claude.ai/code/session_016enaEcHMPpE4a97o6Zv1f8
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.
$(cat <<'EOF'
Problem
On boot, AppArmor can hang for 1–3 minutes (or more) at:
This happens because:
apparmor-profiles-extra,apparmor.d-git) unconditionallywrite-cache/cache-loc) was only applied for Arch Linux, not for Debian/Ubuntu or other distrosChanges
[y/N]prompt with a clear warning about the boot-time trade-off appears before installing the large profile packages. Users who just want AppArmor enabled (without the full extended set) can answerNand get a fast boot immediately.configure_apparmor_cache()now runs for all distros: writeswrite-cacheandcache-loc /etc/apparmor/earlypolicy/into/etc/apparmor/parser.confso the parser stores a compiled binary cache and reads it on subsequent boots instead of reparsing text files.apparmor_parser --write-cacheruns immediately after profile installation, so the very first reboot is also fast.Test plan
apparmor-setup.shon Ubuntu — answerNto extended profiles, verify boot is fastapparmor-setup.shon Ubuntu — answerYto extended profiles, verify/etc/apparmor/earlypolicy/is populated and boot is noticeably faster than before this fixapparmor-setup.shon Arch — same two scenariosaa-statusshows loaded profiles after reboot in both casescat /sys/kernel/security/lsmincludesapparmorhttps://claude.ai/code/session_016enaEcHMPpE4a97o6Zv1f8
EOF
)
Generated by Claude Code