Bug 1567768

Summary: SELinux is preventing nginx from using the 'dac_override' capabilities.
Product: [Fedora] Fedora Reporter: Ed Marshall <esm>
Component: nginxAssignee: Nobody's working on this, feel free to take it <nobody>
Status: CLOSED EOL QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 28CC: 7d28c752, affix, anton4linux, athmanem, bperkins, chad.schroeder, dwalsh, esm, evan, jeremy, jkaluza, jonathan, jorti, jorton, luhliari, lvrabec, pahan, pavel.lisy, peter.borsa, plautrba, tadej.j, wtogami
Target Milestone: ---Keywords: Reopened
Target Release: ---   
Hardware: x86_64   
OS: Unspecified   
Whiteboard: abrt_hash:d30a0e35981359d0104bc2c3c75fda104a76320e1638bcb50d6dc875af6497f7;
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2019-05-29 00:01:21 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Ed Marshall 2018-04-16 07:53:56 UTC
Description of problem:
Tried to start nginx after an update to F28.
SELinux is preventing nginx from using the 'dac_override' capabilities.

*****  Plugin dac_override (91.4 confidence) suggests   **********************

If you want to help identify if domain needs this access or you have a file with the wrong permissions on your system
Then turn on full auditing to get path information about the offending file and generate the error again.
Do

Turn on full auditing
# auditctl -w /etc/shadow -p w
Try to recreate AVC. Then execute
# ausearch -m avc -ts recent
If you see PATH record check ownership/permissions on file, and fix it,
otherwise report as a bugzilla.

*****  Plugin catchall (9.59 confidence) suggests   **************************

If you believe that nginx should have the dac_override capability by default.
Then you should report this as a bug.
You can generate a local policy module to allow this access.
Do
allow this access for now by executing:
# ausearch -c 'nginx' --raw | audit2allow -M my-nginx
# semodule -X 300 -i my-nginx.pp

Additional Information:
Source Context                system_u:system_r:httpd_t:s0
Target Context                system_u:system_r:httpd_t:s0
Target Objects                Unknown [ capability ]
Source                        nginx
Source Path                   nginx
Port                          <Unknown>
Host                          (removed)
Source RPM Packages           
Target RPM Packages           
Policy RPM                    selinux-policy-3.14.1-19.fc28.noarch
Selinux Enabled               True
Policy Type                   targeted
Enforcing Mode                Enforcing
Host Name                     (removed)
Platform                      Linux (removed) 4.16.2-300.fc28.x86_64 #1 SMP Thu
                              Apr 12 14:58:07 UTC 2018 x86_64 x86_64
Alert Count                   4
First Seen                    2018-04-16 00:48:18 PDT
Last Seen                     2018-04-16 00:50:05 PDT
Local ID                      869563a6-51b3-44a9-8729-9b737d5ad0d4

Raw Audit Messages
type=AVC msg=audit(1523865005.825:433): avc:  denied  { dac_override } for  pid=16071 comm="nginx" capability=1  scontext=system_u:system_r:httpd_t:s0 tcontext=system_u:system_r:httpd_t:s0 tclass=capability permissive=0


Hash: nginx,httpd_t,httpd_t,capability,dac_override

Version-Release number of selected component:
selinux-policy-3.14.1-19.fc28.noarch

Additional info:
component:      selinux-policy
reporter:       libreport-2.9.4
hashmarkername: setroubleshoot
kernel:         4.16.2-300.fc28.x86_64
type:           libreport

Comment 1 Lukas Vrabec 2018-04-16 16:44:14 UTC
Hi, 

Could you reproduce, but full auditing? 

*****  Plugin dac_override (91.4 confidence) suggests   **********************

If you want to help identify if domain needs this access or you have a file with the wrong permissions on your system
Then turn on full auditing to get path information about the offending file and generate the error again.
Do

Turn on full auditing
# auditctl -w /etc/shadow -p w
Try to recreate AVC. Then execute
# ausearch -m avc -ts recent
If you see PATH record check ownership/permissions on file, and fix it,
otherwise report as a bugzilla.

Comment 2 Juan Orti 2018-04-17 16:11:16 UTC
Same here with selinux-policy-3.14.1-21.fc28.noarch

With full auditing:

time->Tue Apr 17 18:09:19 2018
type=AVC msg=audit(1523981359.846:520): avc:  denied  { dac_override } for  pid=3418 comm="nginx" capability=1  scontext=system_u:system_r:httpd_t:s0 tcontext=system_u:system_r:httpd_t:s0 tclass=capability permissive=0
----
time->Tue Apr 17 18:09:20 2018
type=AVC msg=audit(1523981360.512:521): avc:  denied  { dac_override } for  pid=3418 comm="nginx" capability=1  scontext=system_u:system_r:httpd_t:s0 tcontext=system_u:system_r:httpd_t:s0 tclass=capability permissive=0

Comment 3 Evan Klitzke 2018-04-23 15:30:05 UTC
I get this with a brand new unconfigured nginx install out of the box on Fedora 28, with nginx-1.12.1-5.fc28.x86_64 and selinux-policy-3.14.1-21.fc28.noarch

Comment 4 Ed Marshall 2018-04-27 01:55:10 UTC
Yep, same result as Juan for me. systemctl status says:

# systemctl start nginx
Job for nginx.service failed because the control process exited with error code.
See "systemctl status nginx.service" and "journalctl -xe" for details.
# systemctl status nginx
● nginx.service - The nginx HTTP and reverse proxy server
   Loaded: loaded (/usr/lib/systemd/system/nginx.service; enabled; vendor preset: disabled)
   Active: failed (Result: exit-code) since Fri 2018-04-27 01:47:53 UTC; 7s ago
  Process: 16038 ExecStartPre=/usr/sbin/nginx -t (code=exited, status=1/FAILURE)
  Process: 16037 ExecStartPre=/usr/bin/rm -f /run/nginx.pid (code=exited, status=0/SUCCESS)

Apr 27 01:47:52 zenbook.sfo1.in.logic.net systemd[1]: Starting The nginx HTTP and reverse proxy server...
Apr 27 01:47:52 zenbook.sfo1.in.logic.net nginx[16038]: nginx: [alert] could not open error log file: open() "/var/log/nginx/error.log" failed (13: Permission denied)
Apr 27 01:47:52 zenbook.sfo1.in.logic.net nginx[16038]: nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
Apr 27 01:47:52 zenbook.sfo1.in.logic.net nginx[16038]: 2018/04/27 01:47:52 [emerg] 16038#0: open() "/var/log/nginx/error.log" failed (13: Permission denied)
Apr 27 01:47:52 zenbook.sfo1.in.logic.net nginx[16038]: nginx: configuration file /etc/nginx/nginx.conf test failed
Apr 27 01:47:53 zenbook.sfo1.in.logic.net systemd[1]: nginx.service: Control process exited, code=exited status=1
Apr 27 01:47:53 zenbook.sfo1.in.logic.net systemd[1]: nginx.service: Failed with result 'exit-code'.
Apr 27 01:47:53 zenbook.sfo1.in.logic.net systemd[1]: Failed to start The nginx HTTP and reverse proxy server.

Looks like this came up in the context of AppArmor policies too?
https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=819751
https://serverfault.com/questions/776940/does-nginx-really-need-dac-override-in-its-apparmor-policy

Comment 5 Chad 2018-05-02 13:16:03 UTC
I'm having the same issue.  Upgraded from FC27 to FC28 and nginx no longer starts.

* nginx-1.12.1-5.fc28.x86_64

* selinux-policy-3.14.1-21.fc28.noarch

Comment 6 Luboš Uhliarik 2018-05-02 15:09:20 UTC

*** This bug has been marked as a duplicate of bug 1573942 ***

Comment 7 Jonathan Dieter 2018-05-06 07:27:27 UTC
I'm unable to see bug 1573942 because it's marked private, so I'm re-opening this bug.  Feel free to close again if needed.

After installing nginx-1.12.1-7.fc28.x86_64, I'm still seeing this.  I get:
SELinux is preventing nginx from using the dac_override capability.

*****  Plugin dac_override (91.4 confidence) suggests   **********************

If you want to help identify if domain needs this access or you have a file with the wrong permissions on your system
Then turn on full auditing to get path information about the offending file and generate the error again.
Do

Turn on full auditing
# auditctl -w /etc/shadow -p w
Try to recreate AVC. Then execute
# ausearch -m avc -ts recent
If you see PATH record check ownership/permissions on file, and fix it,
otherwise report as a bugzilla.


After turning on full auditing, I get the following:
----
time->Sun May  6 07:17:55 2018
type=AVC msg=audit(1525591075.044:178): avc:  denied  { dac_override } for  pid=998 comm="nginx" capability=1  scontext=system_u:system_r:httpd_t:s0 tcontext=system_u:system_r:httpd_t:s0 tclass=capability permissive=1
----
time->Sun May  6 07:18:14 2018
type=AVC msg=audit(1525591094.369:194): avc:  denied  { dac_override } for  pid=1036 comm="nginx" capability=1  scontext=system_u:system_r:httpd_t:s0 tcontext=system_u:system_r:httpd_t:s0 tclass=capability permissive=1

Comment 8 Luboš Uhliarik 2018-05-07 09:45:56 UTC
Hey Jonathan,

I made bug 1573942 public. I tried to reproduce the SELinux dac_override issue, but I was not successful. 

With new version of nginx, I'm able to start nginx server without any problems:

# rpm -qa nginx
nginx-1.12.1-7.fc28.x86_64
# systemctl start nginx

Comment 9 Jonathan Dieter 2018-05-07 11:24:09 UTC
Ok, I've figured it out.  I did an upgrade from Fedora 27 to Fedora 28, and apparently the owner of the files in /var/log/nginx has changed from nginx to root.  After changing the owner and group of /var/log/nginx/access.log and /var/log/nginx/error.log to root, the problem disappeared.

This should probably be documented somewhere, but I'll go ahead and change my karma since it seems to be an upgrade issue.

Comment 10 rugk 2018-05-10 07:58:28 UTC
Description of problem:
I just trie to start nginx after my Fedora 28 upgrade.

Version-Release number of selected component:
selinux-policy-3.14.1-24.fc28.noarch

Additional info:
reporter:       libreport-2.9.5
hashmarkername: setroubleshoot
kernel:         4.16.6-302.fc28.x86_64
type:           libreport

Comment 11 Evan Klitzke 2018-05-12 21:14:58 UTC
(In reply to Jonathan Dieter from comment #9)
> Ok, I've figured it out.  I did an upgrade from Fedora 27 to Fedora 28, and
> apparently the owner of the files in /var/log/nginx has changed from nginx
> to root.  After changing the owner and group of /var/log/nginx/access.log
> and /var/log/nginx/error.log to root, the problem disappeared.

Thanks for this tip Jonathan -- changing the owner of the files to root does indeed fix the problem for me. I'm not sure if this is the "right" solution or not, but at least it lets me re-enable SELinux.

Comment 12 Ed Marshall 2018-05-13 04:45:53 UTC
As an FYI, it looks like the logrotate configuration also needs to be updated to the new permissions/ownership, or the problem will show up again after nginx restarts following a log rotation.

Comment 13 Luboš Uhliarik 2018-05-14 10:11:51 UTC
Hi Ed, you are right logrotate configuration needs to be update. I will create new build today with patch, which should fix problems with owner/group permissions after USR1 signal is sent.

Comment 14 Ben Cotton 2019-05-02 19:35:06 UTC
This message is a reminder that Fedora 28 is nearing its end of life.
On 2019-May-28 Fedora will stop maintaining and issuing updates for
Fedora 28. It is Fedora's policy to close all bug reports from releases
that are no longer maintained. At that time this bug will be closed as
EOL if it remains open with a Fedora 'version' of '28'.

Package Maintainer: If you wish for this bug to remain open because you
plan to fix it in a currently maintained version, simply change the 'version' 
to a later Fedora version.

Thank you for reporting this issue and we are sorry that we were not 
able to fix it before Fedora 28 is end of life. If you would still like 
to see this bug fixed and are able to reproduce it against a later version 
of Fedora, you are encouraged  change the 'version' to a later Fedora 
version prior this bug is closed as described in the policy above.

Although we aim to fix as many bugs as possible during every release's 
lifetime, sometimes those efforts are overtaken by events. Often a 
more recent Fedora release includes newer upstream software that fixes 
bugs or makes them obsolete.

Comment 15 Ben Cotton 2019-05-29 00:01:21 UTC
Fedora 28 changed to end-of-life (EOL) status on 2019-05-28. Fedora 28 is
no longer maintained, which means that it will not receive any further
security or bug fix updates. As a result we are closing this bug.

If you can reproduce this bug against a currently maintained version of
Fedora please feel free to reopen this bug against that version. If you
are unable to reopen this bug, please file a new report against the
current release. If you experience problems, please add a comment to this
bug.

Thank you for reporting this bug and we are sorry it could not be fixed.