Bug 1287313

Summary: SELinux is preventing /usr/bin/python2.7 (policyd-spf) from name_bind access on the tcp_socket port
Product: [Fedora] Fedora Reporter: Anthony Messina <amessina>
Component: postfixAssignee: Jaroslav Škarvada <jskarvad>
Status: CLOSED CANTFIX QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: medium Docs Contact:
Priority: medium    
Version: 23CC: amessina, bojan, dwalsh, jskarvad
Target Milestone: ---   
Target Release: ---   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2016-12-02 13:25:34 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Anthony Messina 2015-12-01 23:13:50 UTC
When using pypolicyd-spf with Postfix, pypolicyd-spf needs to open ports to function.  I often get SELinux denials like the following, with the port numbers changing if pypolicyd-spf happens to hit a port that is labeled by some other policy.  While the suggestion is enabling the 'nis_enabled' boolean, I am hoping that the SELinux team can come up with a better solution like a boolean that's perhaps narrowed to pypolicyd-spf.  Thanks.



SELinux is preventing /usr/bin/python2.7 from name_bind access on the tcp_socket port 22874.

*****  Plugin bind_ports (92.2 confidence) suggests   ************************

If you want to allow /usr/bin/python2.7 to bind to network port 22874
Then you need to modify the port type.
Do
# semanage port -a -t PORT_TYPE -p tcp 22874
    where PORT_TYPE is one of the following: amavisd_send_port_t, smtp_port_t, spamd_port_t.

*****  Plugin catchall_boolean (7.83 confidence) suggests   ******************

If you want to allow system to run with NIS
Then you must tell SELinux about this by enabling the 'nis_enabled' boolean.

Do
setsebool -P nis_enabled 1

*****  Plugin catchall (1.41 confidence) suggests   **************************

If you believe that python2.7 should be allowed name_bind access on the port 22874 tcp_socket 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 policyd-spf /var/log/audit/audit.log | audit2allow -M mypol
# semodule -i mypol.pp

Additional Information:
Source Context                system_u:system_r:postfix_master_t:s0
Target Context                system_u:object_r:unreserved_port_t:s0
Target Objects                port 22874 [ tcp_socket ]
Source                        policyd-spf
Source Path                   /usr/bin/python2.7
Port                          22874
Host                          example.com
Source RPM Packages           python-2.7.10-8.fc22.x86_64
Target RPM Packages           
Policy RPM                    selinux-policy-3.13.1-128.21.fc22.noarch
Selinux Enabled               True
Policy Type                   targeted
Enforcing Mode                Enforcing
Host Name                     example.com
Platform                      Linux example.com 4.2.6-201.fc22.x86_64
                              #1 SMP Tue Nov 24 18:42:39 UTC 2015 x86_64 x86_64
Alert Count                   2
First Seen                    2015-12-01 17:02:59 CST
Last Seen                     2015-12-01 17:02:59 CST
Local ID                      95335df4-f17f-4adf-88fb-7dd8f8c12001

Raw Audit Messages
type=AVC msg=audit(1449010979.552:1878): avc:  denied  { name_bind } for  pid=5976 comm="policyd-spf" src=22874 scontext=system_u:system_r:postfix_master_t:s0 tcontext=system_u:object_r:unreserved_port_t:s0 tclass=tcp_socket permissive=0


type=SYSCALL msg=audit(1449010979.552:1878): arch=x86_64 syscall=bind success=no exit=EACCES a0=4 a1=7ffeaf74fcf0 a2=10 a3=1999999999999999 items=0 ppid=5975 pid=5976 auid=4294967295 uid=99 gid=99 euid=99 suid=99 fsuid=99 egid=99 sgid=99 fsgid=99 tty=(none) ses=4294967295 comm=policyd-spf exe=/usr/bin/python2.7 subj=system_u:system_r:postfix_master_t:s0 key=(null)

Hash: policyd-spf,postfix_master_t,unreserved_port_t,tcp_socket,name_bind

Comment 1 Miroslav Grepl 2016-01-21 15:26:07 UTC
What port is a default port?

Comment 2 Anthony Messina 2016-01-22 00:05:29 UTC
(In reply to Miroslav Grepl from comment #1)
> What port is a default port?

It seems to use a wide range of TCP ports.  Unfortunately due to the issues between python-ipaddr and python-ipaddress (Bug #1232595), I can't test right now.

Comment 3 Fedora End Of Life 2016-11-24 13:53:43 UTC
This message is a reminder that Fedora 23 is nearing its end of life.
Approximately 4 (four) weeks from now Fedora will stop maintaining
and issuing updates for Fedora 23. 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 '23'.

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 23 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 4 Anthony Messina 2016-12-02 13:25:34 UTC
pypolicyd-spf with IPv6 addresses is still broken so I cannot test.  I'll reopen if it's an issue when the Python IPv6 parsing improves.