dmesg shows audit type=1400 apparmor DENIED lines and a service fails
Your error
audit: type=1400 audit(1571868402.378:24425): apparmor="DENIED" operation="open" profile="/usr/sbin/cups-browsed" name="/var/lib/libvirt/dnsmasq/"2 more lines it can showFix it fast
Most common cause, 1 of 3A packaged profile does not allow a path your setup uses
Put the extra rule in the matching file under /etc/apparmor.d/local/, which package upgrades leave alone, then reload only that profile.
# /etc/apparmor.d/local/usr.sbin.myservice
/srv/myservice/ r,
/srv/myservice/** rwk,
sudo apparmor_parser -r /etc/apparmor.d/usr.sbin.myserviceShort answer
audit: type=1400 apparmor="DENIED" means an AppArmor profile blocked one action, and the line says which: profile= names the profile, operation= the action and name= the path. Add the path to the package's local override file and reload it, connect a snap interface for snap. profiles, or grant userns create for operation="userns_create" on Ubuntu 24.04.
Which cause do you have?
Print the latest denials and read three fields on each line. A profile that is a program path, such as /usr/sbin/mysqld, points to cause 1. A profile starting with snap. points to cause 2. operation="userns_create" with profile="unconfined" points to cause 3.
sudo dmesg | grep 'apparmor="DENIED"' | tail -n 20Then find the line you see in this list and open its fix:
- 1A packaged profile does not allow a path your setup uses
profile= is a program path and name= is a folder you moved or added, such as a new data, log or socket directory - 2A snap is blocked by its own sandbox
profile= starts with snap., for example snap.lxd.lxc - 3Ubuntu restricts unprivileged user namespaces for unconfined programs
operation="userns_create", profile="unconfined" and info="User namespace creation restricted"; the comm= field names the program, such as steamwebhelper in the AppArmor wiki's sample
What does the error look like?
audit: type=1400 audit(1571868402.378:24425): apparmor="DENIED" operation="open" profile="/usr/sbin/cups-browsed" name="/var/lib/libvirt/dnsmasq/"apparmor="DENIED" operation="sendmsg" profile="snap.lxd.lxc"apparmor="DENIED" operation="userns_create" class="namespace" info="User namespace creation restricted" profile="unconfined"
Cause 1 of 3
A packaged profile does not allow a path your setup uses
You seeprofile= is a program path and name= is a folder you moved or added, such as a new data, log or socket directory
Check
An apparmor DENIED line with operation="open" and a path-style profile means the program's own profile has no rule for the file in name=. This often follows a custom data directory, a socket in a new place or files kept under /srv. The profile itself is a file in /etc/apparmor.d/ that mentions the program path, and packages that need local tweaks include a matching file from /etc/apparmor.d/local/.
# use the program path from profile=
grep -rl "/usr/sbin/myservice" /etc/apparmor.d/ 2>/dev/null
grep -n "local/" /etc/apparmor.d/usr.sbin.myserviceFix
Put the extra rule in the matching file under /etc/apparmor.d/local/, which package upgrades leave alone, then reload only that profile. Grant the narrowest access the denied_mask asks for.
# /etc/apparmor.d/local/usr.sbin.myservice
/srv/myservice/ r,
/srv/myservice/** rwk,
sudo apparmor_parser -r /etc/apparmor.d/usr.sbin.myserviceVerify
Restart the service and repeat the action. No new DENIED line with that profile appears.
sudo dmesg | grep 'apparmor="DENIED"' | grep -c myserviceConfirmed by ubuntu.com
Cause 2 of 3
A snap is blocked by its own sandbox
You seeprofile= starts with snap., for example snap.lxd.lxc
Check
Ubuntu's AppArmor guide calls snap profiles special: they sit in /var/lib/snapd/apparmor/profiles, not in /etc/apparmor.d. What a snap may reach is decided by its interfaces instead, and some interfaces are not connected automatically at install time.
snap connections lxdFix
Find the interface that covers the denied access, for example removable-media for files under /media or /mnt, and connect it. If no interface covers the path, move the files somewhere the snap can read, or use a non-snap package.
snap connections <snap>
sudo snap connect <snap>:removable-mediaVerify
snap connections now shows a slot for that plug, and the action no longer logs a denial.
snap connections <snap> | grep removable-mediaConfirmed by snapcraft.io
Cause 3 of 3
Ubuntu restricts unprivileged user namespaces for unconfined programs
You seeoperation="userns_create", profile="unconfined" and info="User namespace creation restricted"; the comm= field names the program, such as steamwebhelper in the AppArmor wiki's sample
Check
When the restriction is on, the AppArmor project explains that an unprivileged program without CAP_SYS_ADMIN may only create user namespaces if a profile confines it and allows them. The sysctl below prints 1 when the restriction is active.
cat /proc/sys/kernel/apparmor_restrict_unprivileged_usernsFix
Give that one program a small profile with a userns rule instead of switching the restriction off for the whole machine, then load it.
# /etc/apparmor.d/opt.myapp
abi <abi/4.0>,
include <tunables/global>
profile myapp /opt/myapp/myapp flags=(unconfined) {
allow userns create,
}
sudo apparmor_parser -r /etc/apparmor.d/opt.myappVerify
The program starts, and no userns_create denial appears for its comm= name.
sudo dmesg | grep userns_create | tail -n 3Confirmed by gitlab.com
How do I stop it coming back?
- Keep site-specific rules only in /etc/apparmor.d/local/ files and track them in configuration management.
- Before moving a service's data or socket directory, check whether its AppArmor profile lists the old path.
- Test a suspect profile with sudo aa-complain for a short time to confirm AppArmor is the cause, then put it back with aa-enforce.
Sources
How was this page made?
I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.