A mirror of Man pages
Go to file
Stefan Puiu 375c65a9c2 connect.2: Can return EACCES because of SELinux
Recently I had to troubleshoot a problem where a connect() call
was returning EACCES:

17648 socket(AF_INET, SOCK_STREAM, IPPROTO_IP) = 37
17648 connect(37, {sa_family=AF_INET, sin_port=htons(8081),
sin_addr=inet_addr("10.12.1.201")}, 16) = -1 EACCES (Permission
denied)

I've traced this to SELinux policy denying the connection. This is
on a Fedora 23 VM:

$ cat /etc/redhat-release
Fedora release 23 (Twenty Three)
$ uname -a
Linux mako-fedora-01 4.8.13-100.fc23.x86_64 #1 SMP Fri Dec 9 14:51:40
UTC 2016 x86_64 x86_64 x86_64 GNU/Linux

The manpage says this can happen when connecting to a broadcast
address, or when a local firewall rule blocks the connection.
However, the address above is unicast, and using 'wget' from
another account to access the URL works fine.

The context is that we're building an OS image, and this involves
downloading RPMs through a proxy. The proxy (polipo) is labelled
by SELinux, and I guess there is some sort of policy that says
"proxy can only connect to HTTP ports". When trying to connect to
a server listening on a port that is not labeled as an HTTP server
port, I guess SELinux steps in. With 'setenforce 0', the build
works fine. In the kernel sources I see connect() calls
security_socket_connect() (see
https://elixir.bootlin.com/linux/latest/source/net/socket.c#L1855),
which calls whatever security hooks are registered. I see the
SELinux hook getting registered at
https://elixir.bootlin.com/linux/latest/source/security/selinux/hooks.c#L7047,
and setting a perf probe on the call proves that the
selinux_socket_connect function gets called (while
tcp_v4_connect() is not).

Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2020-06-09 10:09:55 +02:00
man1 Various pages: retitle EXAMPLE section heading to EXAMPLES 2020-05-31 10:45:27 +02:00
man2 connect.2: Can return EACCES because of SELinux 2020-06-09 10:09:55 +02:00
man3 random.3: wfix: no need to mention INT32_MAX 2020-06-08 23:09:36 +02:00
man4 Various pages: retitle EXAMPLE section heading to EXAMPLES 2020-05-31 10:45:27 +02:00
man5 core.5: Note that not dumping core of an unreadable binary is a security measure 2020-06-08 18:16:53 +02:00
man6 intro.6: wfix 2017-08-25 21:41:03 +02:00
man7 user_namespaces.7: Clarify "system time" 2020-06-09 10:03:04 +02:00
man8 ldconfig.8: Mention new default for --format in glibc 2.32 2020-05-21 15:20:27 +02:00
scripts scripts: mark them executable 2018-05-31 21:34:32 +02:00
CONTRIBUTING CONTRIBUTING: New file with some starting tips on how to contribute 2019-09-13 15:59:08 +02:00
Changes Start of man-pages-5.07: updating Changes and Changes.old 2020-04-12 08:32:06 +02:00
Changes.old Changes.old: Fixes to 5.06 change log 2020-04-12 09:34:30 +02:00
Makefile Makefile: Remove a redundant comment 2017-11-20 10:38:10 +01:00
README README: Remove "Man page overlap and duplication" section 2020-04-13 09:06:45 +02:00
man-pages-5.07.Announce Start of man-pages-5.07: updating .Announce and .lsm files 2020-04-12 08:32:06 +02:00
man-pages-5.07.lsm Start of man-pages-5.07: updating .Announce and .lsm files 2020-04-12 08:32:06 +02:00

README

This package contains Linux man pages for sections 1 through 8.  Some
more information is given in the 'man-pages-x.y.Announce' file.

Homepage
========
For information about the Linux man-pages project, see
http://www.kernel.org/doc/man-pages/index.html.

Bug reports and contributing
============================
If you have corrections and additions to suggest, see
http://www.kernel.org/doc/man-pages/contributing.html
(Although there is a mirror of this repository on GitHub,
please don't report issues via the GitHub issue tracker!)

For further information on contributing, see the CONTRIBUTING file.

Installing and uninstalling
===========================
"make install" will copy these man pages to /usr/share/man/man[1-8].

To install to a path different from /usr, use
"make install prefix=/install/path".

"make remove" or "make uninstall" will remove any man page in this
distribution from its destination.  Use with caution, and remember to
use "prefix" if desired, as with the "install" target.

"make" or "make all" will perform "make uninstall" followed by "make
install".

Copyrights
==========
See the 'man-pages-x.y.Announce' file.