Bug 981848 - SELinux is preventing /usr/sbin/nginx from 'write' accesses on the sock_file btcsrv.sn.g02.org.sock.
SELinux is preventing /usr/sbin/nginx from 'write' accesses on the sock_file ...
Status: CLOSED EOL
Product: Fedora
Classification: Fedora
Component: selinux-policy (Show other bugs)
19
x86_64 Unspecified
unspecified Severity unspecified
: ---
: ---
Assigned To: Miroslav Grepl
Fedora Extras Quality Assurance
abrt_hash:a8df0e27b767ebd5c895ccac614...
: Reopened
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2013-07-06 05:41 EDT by Renich Bon Ciric
Modified: 2015-02-18 08:58 EST (History)
3 users (show)

See Also:
Fixed In Version: selinux-policy-3.12.1-65.fc19
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2015-02-18 08:58:39 EST
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)

  None (edit)
Description Renich Bon Ciric 2013-07-06 05:41:37 EDT
Description of problem:
Same problem as in F18. Bugfix already applied but happened again.
SELinux is preventing /usr/sbin/nginx from 'write' accesses on the sock_file btcsrv.sn.g02.org.sock.

*****  Plugin catchall (100. confidence) suggests  ***************************

If you believe that nginx should be allowed write access on the btcsrv.sn.g02.org.sock sock_file 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:
# grep nginx /var/log/audit/audit.log | audit2allow -M mypol
# semodule -i mypol.pp

Additional Information:
Source Context                system_u:system_r:httpd_t:s0
Target Context                system_u:object_r:var_run_t:s0
Target Objects                btcsrv.sn.g02.org.sock [ sock_file ]
Source                        nginx
Source Path                   /usr/sbin/nginx
Port                          <Unknown>
Host                          (removed)
Source RPM Packages           nginx-1.4.1-1.fc19.x86_64
Target RPM Packages           
Policy RPM                    selinux-policy-3.12.1-57.fc19.noarch
Selinux Enabled               True
Policy Type                   targeted
Enforcing Mode                Enforcing
Host Name                     (removed)
Platform                      Linux (removed) 3.9.8-300.fc19.x86_64 #1 SMP Thu
                              Jun 27 19:24:23 UTC 2013 x86_64 x86_64
Alert Count                   6
First Seen                    2013-07-06 04:40:30 CDT
Last Seen                     2013-07-06 04:40:33 CDT
Local ID                      ee79fb45-6556-45e5-8009-e4d8b2d63213

Raw Audit Messages
type=AVC msg=audit(1373103633.491:1719): avc:  denied  { write } for  pid=26894 comm="nginx" name="btcsrv.sn.g02.org.sock" dev="tmpfs" ino=10957578 scontext=system_u:system_r:httpd_t:s0 tcontext=system_u:object_r:var_run_t:s0 tclass=sock_file


type=SYSCALL msg=audit(1373103633.491:1719): arch=x86_64 syscall=connect success=no exit=EACCES a0=c a1=7fbc4e1a8e30 a2=6e a3=7fffc18f1210 items=0 ppid=26893 pid=26894 auid=4294967295 uid=996 gid=996 euid=996 suid=996 fsuid=996 egid=996 sgid=996 fsgid=996 ses=4294967295 tty=(none) comm=nginx exe=/usr/sbin/nginx subj=system_u:system_r:httpd_t:s0 key=(null)

Hash: nginx,httpd_t,var_run_t,sock_file,write

Additional info:
reporter:       libreport-2.1.5
hashmarkername: setroubleshoot
kernel:         3.9.8-300.fc19.x86_64
type:           libreport

Potential duplicate: bug 967764
Comment 1 Daniel Walsh 2013-07-10 19:12:53 EDT
fce11d3fa690af8e040f9de82430d272cdc880f3 has additional fixes for this in git.

The problem you have is the /var/run/thin directory is not labeled correctly
Comment 2 Fedora Update System 2013-07-17 07:53:23 EDT
selinux-policy-3.12.1-65.fc19 has been submitted as an update for Fedora 19.
https://admin.fedoraproject.org/updates/selinux-policy-3.12.1-65.fc19
Comment 3 Fedora Update System 2013-07-18 02:01:46 EDT
Package selinux-policy-3.12.1-65.fc19:
* should fix your issue,
* was pushed to the Fedora 19 testing repository,
* should be available at your local mirror within two days.
Update it with:
# su -c 'yum update --enablerepo=updates-testing selinux-policy-3.12.1-65.fc19'
as soon as you are able to.
Please go to the following url:
https://admin.fedoraproject.org/updates/FEDORA-2013-13172/selinux-policy-3.12.1-65.fc19
then log in and leave karma (feedback).
Comment 4 Renich Bon Ciric 2013-07-18 09:09:51 EDT
(In reply to Fedora Update System from comment #3)
> Package selinux-policy-3.12.1-65.fc19:
> * should fix your issue,
> * was pushed to the Fedora 19 testing repository,
> * should be available at your local mirror within two days.
> Update it with:
> # su -c 'yum update --enablerepo=updates-testing
> selinux-policy-3.12.1-65.fc19'
> as soon as you are able to.
> Please go to the following url:
> https://admin.fedoraproject.org/updates/FEDORA-2013-13172/selinux-policy-3.
> 12.1-65.fc19
> then log in and leave karma (feedback).

Still have the problem:

Still have the problem.

type=AVC msg=audit(1374152922.172:1360): avc:  denied  { connectto } for  pid=18413 comm="nginx" path="/run/thin/www.evalinux.com.sock" scontext=system_u:system_r:httpd_t:s0 tcontext=system_u:system_r:initrc_t:s0 tclass=unix_stream_socket
type=SYSCALL msg=audit(1374152922.172:1360): arch=c000003e syscall=42 success=no exit=-13 a0=d a1=7fe0768b5a10 a2=6e a3=7fff5f8bb940 items=0 ppid=18412 pid=18413 auid=4294967295 uid=996 gid=996 euid=996 suid=996 fsuid=996 egid=996 sgid=996 fsgid=996 ses=4294967295 tty=(none) comm="nginx" exe="/usr/sbin/nginx" subj=system_u:system_r:httpd_t:s0 key=(null)
Comment 5 Fedora Update System 2013-07-20 05:33:33 EDT
selinux-policy-3.12.1-65.fc19 has been pushed to the Fedora 19 stable repository.  If problems still persist, please make note of it in this bug report.
Comment 6 Miroslav Grepl 2013-07-29 06:43:51 EDT
What does

# ps -efZ |grep initrc
Comment 7 Renich Bon Ciric 2013-08-01 02:31:10 EDT
(In reply to Miroslav Grepl from comment #6)
> What does
> 
> # ps -efZ |grep initrc

# ps -efZ |grep initrc
system_u:system_r:initrc_t:s0   redis      503     1  0 Jul31 ?        00:01:08 /usr/sbin/redis-server /etc/redis.conf
system_u:system_r:initrc_t:s0   root     12699     1  0 00:33 ?        00:00:02 /usr/bin/ruby-mri /usr/local/bin/thin -C /srv/www/sinatra/btcsrv.com/default/config/thin.yml start
unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023 root 17961 17922  0 01:30 pts/0 00:00:00 grep --color=auto initrc
Comment 8 Miroslav Grepl 2013-08-02 09:08:33 EDT
We need a policy for /usr/sbin/redis-server.
Comment 9 Miroslav Grepl 2013-08-02 09:14:07 EDT
Also

system_u:system_r:initrc_t:s0   root     12699     1  0 00:33 ?        00:00:02 /usr/bin/ruby-mri /usr/local/bin/thin -C /srv/www/sinatra/btcsrv.com/default/config/thin.yml start

is it your own thin instance?
Comment 10 Renich Bon Ciric 2013-08-02 12:45:30 EDT
(In reply to Miroslav Grepl from comment #9)
> Also
> 
> system_u:system_r:initrc_t:s0   root     12699     1  0 00:33 ?       
> 00:00:02 /usr/bin/ruby-mri /usr/local/bin/thin -C
> /srv/www/sinatra/btcsrv.com/default/config/thin.yml start
> 
> is it your own thin instance?

Yep, it is.

Any thin instance will generate a socket file. Maybe keeping it with a .sock extension would be convenient for SELinux so it could label those as something?

Also, redis uses sockets.

I think we solved it with: 

[root@web1 selinux]# cat mynginxsockwrite.te

module mynginxsockwrite 1.0;

require {
	type var_run_t;
	type httpd_t;
	class sock_file write;
}

#============= httpd_t ==============
allow httpd_t var_run_t:sock_file write;
[root@web1 selinux]# cat mythin.te 
policy_module(mythin, 1.0.0)
gen_require(` type thin_t, thin_var_run_t; ')
manage_sock_files_pattern(thin_t, thin_var_run_t, thin_var_run_t)
apache_read_sys_content(thin_t)
gen_require(` type httpd_t; ')
stream_connect_pattern(httpd_t, thin_var_run_t, thin_var_run_t, thin_t)
Comment 11 Miroslav Grepl 2013-08-05 01:35:52 EDT
We have these rules. 

$ rpm -q selinux-policy


Basically we would need to get a script which starts this thin instance. See

http://mgrepl.wordpress.com/2012/11/30/how-would-tools-like-paster-work-with-selinux-thin-story/

Then we could have a policy with

thin_btcsrv_t

domain type.
Comment 12 Fedora End Of Life 2015-01-09 17:11:04 EST
This message is a notice that Fedora 19 is now at end of life. Fedora 
has stopped maintaining and issuing updates for Fedora 19. It is 
Fedora's policy to close all bug reports from releases that are no 
longer maintained. Approximately 4 (four) weeks from now this bug will
be closed as EOL if it remains open with a Fedora 'version' of '19'.

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 19 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 13 Fedora End Of Life 2015-02-18 08:58:39 EST
Fedora 19 changed to end-of-life (EOL) status on 2015-01-06. Fedora 19 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.

Note You need to log in before you can comment on or make changes to this bug.