I am building an AppArmor policy for nginx in Ubuntu 14.04 and I cannot make it work without enabling the dac_override capability.

Does nginx really need this enabled or is there some way to work around it? Overriding all discretionary access control looks risky, but perhaps it's common within the AppArmor constraints.

nginx runs fine unconfined, so I don't think there is a permission issue, but I'm new to AppArmor so I may be wrong.

  • 1
    You should be looking at the specific calls which are failing. – Michael Hampton May 15 '16 at 21:41
  • nginx fails to boot because of log file permissions, but I fail to see why it works unconfined. – Federico B. May 16 '16 at 0:09
  • I personally think this is a bug, I opened a bug report explaining how to run nginx without dac_override. bugs.debian.org/cgi-bin/bugreport.cgi?bug=819751 – TiCPU Oct 22 '16 at 0:27

The default file permissions for nginx logs in Ubuntu are rw-r-----. These files are owned by www-admin:adm.

nginx starts under user root, which has CAP_DAC_OVERRIDE capability by default (remember that root can read and write to any file in the system) but once AppArmor confinement kicks in, the process loses that capability even though it runs as root, so the master nginx process cannot open the log files.

The solution is either changing the permissions so that root can also write to these files, or adding the dac_override capability to the AppArmor nginx profile.


Further to your own answer above, you could perhaps mitigate the issue of perceived excessively wide access by using a "restricted dac_override" policy:

capability dac_override {
    /var/log/nginx* rw,

According to the docs, it should also be noted that even an unrestricted dac_override policy doesn't provide an unrestricted access across the entire filesystem such that a regular, unconfined, root process would enjoy:

"... to be able to access file that is not owned by someone else the task must have the dac_overide capability and the profile must contain both a file access rule and capability dac_override."

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.