Guide to generating a new AppArmor profile.
Creating a Profile
- Use
which <application name>to get the path of the application - Run
sudo aa-genprof <path to application> to start the generation- Alternatively use
sudo aa-autodep <path to application>to create a profile for a constantly running application, like a webserver
- Alternatively use
- Start the application as you would and use it for some time
- After using the application for some time, run press the
skey in theaa-genprofterminal to scan the audit logs for files the application accessed - You will see the results in the terminal, switch between them with the arrow keys
- Depending on if you want to allow or deny access to that file, you can now press
ato allow accessdto deny access
- You can now continue to press the
skey to scan for new behavior - To finish profiling and create the profile, press the
fkey - Now run
sudo aa-statusto check if the new profile has been created
The profile has now been created. You can update all profiles using sudo aa-logprof, which scans for new, undocumented access to new files.
Running a Profile
To test the new profile, run sudo aa-complain <path to profile> to start it in complain mode. Or run sudo aa-enforce <path to profile> to use the profile in enforce mode.
Profiles are typically stored in /etc/apparmor.d.
Deleting a Profile
To delete a profile remove the corresponding file in the /etc/apparmor.d folder and restart AppArmor.