apparmor.d/docs/configuration.md

109 lines
3.8 KiB
Markdown
Raw Normal View History

2023-01-29 22:18:22 +01:00
---
title: Configuration
---
## AppArmor
2024-01-27 20:54:13 +01:00
As there are a lot of rules, it is recommended to enable caching AppArmor profiles. In `/etc/apparmor/parser.conf`, add `write-cache` and `Optimize=compress-fast`.
2023-01-29 22:18:22 +01:00
```sh
2023-02-18 19:16:16 +01:00
echo 'write-cache' | sudo tee -a /etc/apparmor/parser.conf
echo 'Optimize=compress-fast' | sudo tee -a /etc/apparmor/parser.conf
2023-01-29 22:18:22 +01:00
```
!!! info
See [Speed up AppArmor Start] on the Arch Wiki for more information:
[Speed up AppArmor Start]: https://wiki.archlinux.org/title/AppArmor#Speed-up_AppArmor_start_by_caching_profiles
## Personal directories
2024-01-27 20:54:13 +01:00
!!! danger
2023-01-29 22:18:22 +01:00
2024-01-27 20:54:13 +01:00
You need to ensure that all personal directories you are using are well-defined XDG directory. You may need to edit these variables to your own settings.
This project is designed in such a way that it is easy to personalize the directories your programs have access by defining a few variables.
The profiles heavily use the (largely extended) XDG directory variables defined in the **[Variables Reference](variables.md)** page.
2023-01-29 22:18:22 +01:00
??? note "XDG variables overview"
2023-10-27 16:27:23 +02:00
See **[Variables Reference](variables.md)** page for more.
2023-01-29 22:18:22 +01:00
| Description | Name | Value |
|-------------|:----:|---------|
| Desktop | `@{XDG_DESKTOP_DIR}` | `Desktop` |
| Download | `@{XDG_DOWNLOAD_DIR}` | `Downloads` |
| Templates | `@{XDG_TEMPLATES_DIR}` | `Templates` |
| Public | `@{XDG_PUBLICSHARE_DIR}` | `Public` |
| Documents | `@{XDG_DOCUMENTS_DIR}` | `Documents` |
| Music | `@{XDG_MUSIC_DIR}` | `Music` |
| Pictures | `@{XDG_PICTURES_DIR}` | `Pictures` |
| Videos | `@{XDG_VIDEOS_DIR}` | `Videos` |
| Books | `@{XDG_BOOKS_DIR}` | `Books` |
| Projects | `@{XDG_PROJECTS_DIR}` | `Projects` |
| Screenshots | `@{XDG_SCREENSHOTS_DIR}` | `@{XDG_PICTURES_DIR}/Screenshots` |
| Sync | `@{XDG_SYNC_DIR}` | `Sync` |
| Torrents | `@{XDG_TORRENTS_DIR}` | `Torrents` |
| Vm | `@{XDG_VM_DIR}` | `.vm`
| Wallpapers | `@{XDG_WALLPAPERS_DIR}` | `@{XDG_PICTURES_DIR}/Wallpapers` |
2024-06-03 20:06:02 +02:00
You can personalize these values.
First create the directory `/etc/apparmor.d/tunables/xdg-user-dirs.d/apparmor.d.d`:
```
sudo mkdir /etc/apparmor.d/tunables/xdg-user-dirs.d/apparmor.d.d
```
Then create a `local` addition file in it where you define your own personal
directories. Example:
2023-01-29 22:18:22 +01:00
```sh
@{XDG_VIDEOS_DIR}+="Films"
@{XDG_MUSIC_DIR}+="Musique"
@{XDG_PICTURES_DIR}+="Images"
@{XDG_BOOKS_DIR}+="BD" "Comics"
@{XDG_PROJECTS_DIR}+="Git" "Papers"
```
2024-06-07 21:22:38 +02:00
Then restart the AppArmor service to reload the profiles in the kernel:
2023-01-29 22:18:22 +01:00
```sh
sudo systemctl restart apparmor.service
```
**Examples**
- For git support, you may want to add your `GO_PATH` in the `XDG_PROJECTS_DIR`:
```sh
@{XDG_PROJECTS_DIR}+="go"
```
- If you use Keepass, personalize `XDG_PASSWORD_STORE_DIR` with your password directory. Eg:
```sh
@{XDG_PASSWORD_STORE_DIR}+="@{HOME}/.keepass/"
```
- Add pacman integration with your AUR helper. Eg for `yay`:
```sh
@{user_pkg_dirs}+=@{user_cache_dirs}/yay/
```
## Local profile extensions
2024-01-27 20:54:13 +01:00
You can extend any profile with your own rules by creating a file in the `/etc/apparmor.d/local/` directory with the name of your profile. For example, to extend the `foo` profile, create a file `/etc/apparmor.d/local/foo` and add your rules in it.
2023-01-29 22:18:22 +01:00
**Example**
2024-01-27 20:54:13 +01:00
- `child-open`, a profile that allows other program to open resources (URL, picture, books...) with some predefined GUI application. To allow it to open URLs with Firefox, create the file `/etc/apparmor.d/local/child-open` with:
2023-01-29 22:18:22 +01:00
```sh
@{bin}/firefox rPx,
2023-01-29 22:18:22 +01:00
```
!!! note
This is an example, no need to add Firefox into `child-open`, it is already there.
!!! info
2024-01-27 20:54:13 +01:00
`rPx` allows transition to the Firefox profile. Use `rPUx` to allow transition to an unconfined state if you do not have the profile for a given program.
2023-01-29 22:18:22 +01:00
2024-06-07 21:22:38 +02:00
Then, reload the AppArmor rules with `sudo systemctl restart AppArmor`.