No. As a matter of fact AppArmor doesn't make a difference as dbus mediation is not enabled in Arch. Ubuntu uses a patched kernel and a patched dbus-daemon to achieve this. Hence, using dbus-daemon or dbus-broker doesn't make a difference on Arch if it comes to AppArmor.
It's not true that no MAC programs are officially supported in Arch.
AppArmor is supported by the Arch kernels and the apparmor package is in the official repos. It's not enabled by default and the apparmor package is not installed by default - but that's easy to do. In any case, AppArmor is officially supported.
SELinux is supported in the Arch kernels as well. But as mentioned in other posts here, many core utilities and systemd must be rebuilt in order to use it. They can be installed in various ways.
Tomoyo is also available for Arch. Depending on which version you use the userland programs are available in the AUR.
Jelle, I'm surprised that you say that AA is "more or less supported". IMO, Arch does support AA completely. It uses what upstream offers. Yes, if you install some applications (like Firefox or LibreOffice) in Ubuntu, it also automatically installs the proper AA profiles - which are not included in the official upstream package. So if they are not available in Arch this is not because AA is "more or less supported".
The problem was caused by a specific setting applied by myself which triggered an edge case in Firejail. It‘s being investigated by the Firejail developers. There is no general lesson/takeaway.
Could you be more specific? As a matter of fact I‘m using Firejail. In order to make sure it isn‘t the culprit I explicitly executed ˋ/usr/bin/makepkg -sˋ to bypass Firejail. But that didn’t change anything, and I didn’t see anything related in journalctl. Perhaps I missed something?
#!/bin/bash
UPDATE1(){
sudo reflector --verbose --country Germany --country France --country Czechia --country Denmark --country Sweden --country Netherlands --country Switzerland --protocol https --latest 20 --score 10 --sort age --ipv4 --save /etc/pacman.d/mirrorlist
sudo pacman -Syu
paru -Sua
echo
# https://wiki.archlinux.org/title/Pacman/Pacnew_and_Pacsave#Locating_.pac*_files :
sudo updatedb && locate --existing --regex "\.pac(new|save)$" > ~/pacnew.log
# https://wiki.archlinux.org/title/Pacman#Cleaning_the_package_cache :
sudo paccache -ruk0 && sudo paccache -rvk2
# https://wiki.archlinux.org/title/Pacman/Tips_and_tricks#Listing_packages :
pacman -Qqn > pkglist.txt
pacman -Qqm > pkglist-foreign.txt
echo
if [ -s ~/pacnew.log ]
then
echo
echo "ATTENTION! .pacnew and/or .pacsave files available:"
cat ~/pacnew.log
echo
# https://wiki.archlinux.org/title/Users_and_groups#Group_management
# Warning: Arch Linux defaults of the files are created as .pacnew files by new releases of the filesystem package.
# Unless Pacman outputs related messages for action, these .pacnew files can, and should, be disregarded/removed.
FILE1=/etc/group.pacnew
FILE2=/etc/shadow.pacnew
FILE3=/etc/gshadow.pacnew
FILE4=/etc/passwd.pacnew
if [ -f "$FILE1" ]; then
echo -e "\033[0;31m*** ATTENTION: The file \033[0;32m$FILE1 \033[0;31mexists. Do NOT merge!!!***\033[0m"
fi
if [ -f "$FILE2" ]; then
echo -e "\033[0;31m*** ATTENTION: The file \033[0;32m$FILE2 \033[0;31mexists. Do NOT merge!!!***\033[0m"
fi
if [ -f "$FILE3" ]; then
echo -e "\033[0;31m*** ATTENTION: The file \033[0;32m$FILE3 \033[0;31mexists. Do NOT merge!!!***\033[0m"
fi
if [ -f "$FILE4" ]; then
echo -e "\033[0;31m*** ATTENTION: The file \033[0;32m$FILE4 \033[0;31mexists. Do NOT merge!!!***\033[0m"
fi
fi
echo
# https://wiki.archlinux.org/title/System_maintenance#Restart_or_reboot_after_upgrades
sudo mycheckservices -u
echo
# Check for services to be restarted
sudo longoverdue list > /tmp/serviceupdates.txt
if [ -s /tmp/serviceupdates.txt ]; then
cat /tmp/serviceupdates.txt
echo
echo "*** Execute 'servrestart' *** "
fi
}
# check for news on https://archlinux.org/
FILE="/tmp/news.txt"
paru -Pw 2>&1 | tee "$FILE"
STRING="no new news"
if ! grep -q "$STRING" "$FILE"; then
read -n 1 -p "Continue? [Any key/N(o)]" ANSWER
if [ "$ANSWER" == "N" ]
then
echo
echo " *** Aborted ***"
else
echo
echo "Update continued"
UPDATE1
fi
else
UPDATE1
fi
Note that mycheckservicesis actually checkservicesfrom pacman-contrib (which also executes pacdiff if necessary) with line 99 modified to
systemctl --no-legend --full --type service --state running | tr -d '●' | awk '{print $1}' | sed 's/systemd-logind.service\|sddm.service\|plasma-kwin_wayland.service//g' | sed '/^$/d'
This makes sure that those services are not automatically restarted as this would log me out closing all open applications This is not what I want.
longoverdueis the respective AUR package which I've added as checkservices doesn't catch all services nor user units. Lines 11 -15 look like this:
# List of services not to restart automatically
NO_AUTORESTART = {"dbus.service": "reboot required",
"systemd-logind.service": "will log all users out",
"sddm.service": "will log all users out",
"plasma-kwin_wayland.service": "user unit - will log all users out"}
servrestartis simply the following alias:
alias servrestart="sudo longoverdue restart && longoverdue restart"
Also, found a reddit thread that suggested firejail might not be as safe.
That's not justified, IMO. Firejail had its vulnerabilities like many other packages but they were fixed very fast. And if it comes to Firejail being a SUID program, there are ways to mitigate this risk.
I was looking at firejail. It supports appamour. I am not sure which one is better.
See here. One advantage of Firejail is that it comes with profiles for many applications while there are only few ready-to-use profiles in AppArmor. However, it is relatively easy to write own profiles in AppArmor.
Actually everything is explained on the Arch wiki Firejail page.
whitelist directives for your /home doesn't make sense for evince as that means that everything is blocked what is not explicitly whitelisted.
The noblacklist directive must be added above the blacklist and/or .inc lines. The best way how to do this: Create evince.local in ~/.config/firejail and add the noblacklist directive therein. Please remember that editing the profiles in /etc/firejail directly is not recommended as they will be overwritten with every update.
Should there be a , between bpf and loglevel=3 quiet and one comma after quiet, to seperate the crypt?
loglevel=3 quiet was the standard value, should every kernel paramater be seperated by a comma?
No, they should be separated by a space.
Regarding your other questions: There is no need to bother. AppArmor is supported by all official Arch kernels. Just set it up as explained in the wiki. That's how I did it and it works as it should.
That's true. But let's face it: it makes a big difference with whom you get into as a user. You and your fellow forum moderators are doing a great job! But I remember a time when there was a (meanwhile retired) moderator (I won't mention his name) whose biggest hobby seemed to be to shoo away as many users as possible, quite often with a rude language at the edge of insulting. I think that behavior contributed a lot to the mixed reputation of the Arch community.
Fortunately, this has changed to the better since then. The discussion style has become more moderate and functional. Thanks a lot to you and your collegues and to helpful forum members like loqs and seth!
Thanks for your comprehensive reply! However, I still have some questions.
Learning mode can't do much more than list what it would have blocked within the context of the current policies.
...
The thousands of rules are the reason I mentioned that learning mode is the most effective with an already provided set of abstractions,
I don't understand that. What do you mean by "within the context of the current policies" and "provided set of abstractions"? I couldn't find any pre-defined abstractions so I'm not sure how the rules created by the learning mode could be limited somehow. What am I missing?
That being said, I wonder if it would make sense to install AppArmor or, even better yet, Firejail (which comes with profiles for many applications) first and Tomoyo thereafter. Since most applications would already be confined by those profiles, Tomoyo learning would not create rules for actions already blocked by Firejail. This would greatly reduce the number of rules in learning mode to be sifted through. Does this make sense to you?
Aside from using (and possibly finetune) the profiles in /usr/share/apparmor/extra-profilesthere are, e.g., many github repositories which offer self-made AppArmor profiles. The question is always how good they are, though.
But it's always possible and relatively easy to create your own profiles with aa-autodepand aa-logprof.
I've been testing Tomoyo in Arch running in a VM for some days and can confirm that it works together with AppArmor.
However, I still have problems to get along with it. Yes, there is a learning mode which is fine. However, when is it time to stop learning mode? After one day or after one week? In AppArmor a profile is created for a specific application which is easy to read (and to check with aa-logprof). In Tomoyo thousands of rules are created for the whole system. It's impossible to check all of them, hence, it's impossible to see if it includes rules which are possibly too permissive, IMO.
There are many extra profiles in /usr/share/apparmor/extra-profileswhich are (according to the README therein)
not turned on by default because they
are not as mature as the profiles in /etc/apparmor.d/.
Nevertheless you can use them - but further finetuning is probably necessary. E.g., there is a profile usr.lib.firefox.firefox. Copy that to /etc/apparmor.d and set it to complain mode:
sudo aa-complain *.firefox
Start Firefox and leave the profile in complain mode for some time while frequently executing sudo aa-logprofin order to add more needed rules. Once aa-logprof remains quiet you can set the profile to enforce mode with aa-enforce.
No. As a matter of fact AppArmor doesn't make a difference as dbus mediation is not enabled in Arch. Ubuntu uses a patched kernel and a patched dbus-daemon to achieve this. Hence, using dbus-daemon or dbus-broker doesn't make a difference on Arch if it comes to AppArmor.
There is an excellent project that offers more than 1,400 profiles. It's also available in the AUR.
It's not true that no MAC programs are officially supported in Arch.
AppArmor is supported by the Arch kernels and the apparmor package is in the official repos. It's not enabled by default and the apparmor package is not installed by default - but that's easy to do. In any case, AppArmor is officially supported.
SELinux is supported in the Arch kernels as well. But as mentioned in other posts here, many core utilities and systemd must be rebuilt in order to use it. They can be installed in various ways.
Tomoyo is also available for Arch. Depending on which version you use the userland programs are available in the AUR.
Jelle, I'm surprised that you say that AA is "more or less supported". IMO, Arch does support AA completely. It uses what upstream offers. Yes, if you install some applications (like Firefox or LibreOffice) in Ubuntu, it also automatically installs the proper AA profiles - which are not included in the official upstream package. So if they are not available in Arch this is not because AA is "more or less supported".
This is how I do it. I'm using the following script called updatecheck:
Then create the following user unit updatecheck.service:
and the corresponding updatecheck.timer:
and enable it with
The problem was caused by a specific setting applied by myself which triggered an edge case in Firejail. It‘s being investigated by the Firejail developers. There is no general lesson/takeaway.
/u/miffe was right. The problem is caused by Firejail.
I see. Found that file. Thanks!
Thanks, I might try that tomorrow.
Could you be more specific? As a matter of fact I‘m using Firejail. In order to make sure it isn‘t the culprit I explicitly executed ˋ/usr/bin/makepkg -sˋ to bypass Firejail. But that didn’t change anything, and I didn’t see anything related in journalctl. Perhaps I missed something?
Thanks! I tried that but didn't solve the problem.
I've created the following script in which I try to implement what is said on https://wiki.archlinux.org/title/System_maintenance
Note that
mycheckservicesis actuallycheckservicesfrom pacman-contrib (which also executes pacdiff if necessary) with line 99 modified toThis makes sure that those services are not automatically restarted as this would log me out closing all open applications This is not what I want.
longoverdueis the respective AUR package which I've added as checkservices doesn't catch all services nor user units. Lines 11 -15 look like this:servrestartis simply the following alias:That's not justified, IMO. Firejail had its vulnerabilities like many other packages but they were fixed very fast. And if it comes to Firejail being a SUID program, there are ways to mitigate this risk.
Regarding AppArmor: Read the article in the Arch Linux wiki and then the man pages, particularly https://man.archlinux.org/man/extra/apparmor/apparmor.d.5.en, https://man.archlinux.org/man/extra/apparmor/aa-logprof.8.en and https://man.archlinux.org/man/extra/apparmor/aa-autodep.8.en. A good source is also https://documentation.suse.com/sles/12-SP4/html/SLES-all/part-apparmor.html
FWIW, I'm using a very simple update notification script (without an online check):
See here. One advantage of Firejail is that it comes with profiles for many applications while there are only few ready-to-use profiles in AppArmor. However, it is relatively easy to write own profiles in AppArmor.
You should read https://wiki.archlinux.org/title/Firejail#Enable_AppArmor_support and https://wiki.archlinux.org/title/AppArmor
Ah - okay. So you should add ignore private-cache to evince.local.
Actually everything is explained on the Arch wiki Firejail page.
No, they should be separated by a space.
Regarding your other questions: There is no need to bother. AppArmor is supported by all official Arch kernels. Just set it up as explained in the wiki. That's how I did it and it works as it should.
That's true. But let's face it: it makes a big difference with whom you get into as a user. You and your fellow forum moderators are doing a great job! But I remember a time when there was a (meanwhile retired) moderator (I won't mention his name) whose biggest hobby seemed to be to shoo away as many users as possible, quite often with a rude language at the edge of insulting. I think that behavior contributed a lot to the mixed reputation of the Arch community.
Fortunately, this has changed to the better since then. The discussion style has become more moderate and functional. Thanks a lot to you and your collegues and to helpful forum members like loqs and seth!
It doesn't merge automatically, it rather compares the old file and the pacnew side by side. So it's very easy to make adjustments/merge changes.
Well, I always do it. And it's easy if you create a small update script which contains something like:
Then you can simply execute pacdiff:
Thanks for your comprehensive reply! However, I still have some questions.
I don't understand that. What do you mean by "within the context of the current policies" and "provided set of abstractions"? I couldn't find any pre-defined abstractions so I'm not sure how the rules created by the learning mode could be limited somehow. What am I missing?
That being said, I wonder if it would make sense to install AppArmor or, even better yet, Firejail (which comes with profiles for many applications) first and Tomoyo thereafter. Since most applications would already be confined by those profiles, Tomoyo learning would not create rules for actions already blocked by Firejail. This would greatly reduce the number of rules in learning mode to be sifted through. Does this make sense to you?
Aside from using (and possibly finetune) the profiles in
/usr/share/apparmor/extra-profilesthere are, e.g., many github repositories which offer self-made AppArmor profiles. The question is always how good they are, though.But it's always possible and relatively easy to create your own profiles with
aa-autodepandaa-logprof.I've been testing Tomoyo in Arch running in a VM for some days and can confirm that it works together with AppArmor.
However, I still have problems to get along with it. Yes, there is a learning mode which is fine. However, when is it time to stop learning mode? After one day or after one week? In AppArmor a profile is created for a specific application which is easy to read (and to check with aa-logprof). In Tomoyo thousands of rules are created for the whole system. It's impossible to check all of them, hence, it's impossible to see if it includes rules which are possibly too permissive, IMO.
Do you have any suggestions?
There are many extra profiles in
/usr/share/apparmor/extra-profileswhich are (according to the README therein)Nevertheless you can use them - but further finetuning is probably necessary. E.g., there is a profile
usr.lib.firefox.firefox. Copy that to /etc/apparmor.d and set it to complain mode:Start Firefox and leave the profile in complain mode for some time while frequently executing
sudo aa-logprofin order to add more needed rules. Once aa-logprof remains quiet you can set the profile to enforce mode with aa-enforce.