aboutsummaryrefslogtreecommitdiffstats
path: root/src/libcharon/plugins/socket_default
diff options
context:
space:
mode:
authorTobias Brunner <tobias@strongswan.org>2013-06-25 08:23:35 +0200
committerTobias Brunner <tobias@strongswan.org>2013-06-25 17:16:32 +0200
commit1dd61bf13d688dfa71b25d3eb7872dc784f1e57c (patch)
treeb60338396ebac09f3e8740f4b23b6e4f7ebcb7b0 /src/libcharon/plugins/socket_default
parent41b8546ac0a8c95496d1812f35eefa696cf8212c (diff)
downloadstrongswan-1dd61bf13d688dfa71b25d3eb7872dc784f1e57c.tar.bz2
strongswan-1dd61bf13d688dfa71b25d3eb7872dc784f1e57c.tar.xz
socket-default: Require CAP_NET_BIND_SERVICE for ports < 1024
Since we don't know which ports are used with socket-dynamic we can't demand the capability there, but it might still be required.
Diffstat (limited to 'src/libcharon/plugins/socket_default')
-rw-r--r--src/libcharon/plugins/socket_default/socket_default_socket.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/libcharon/plugins/socket_default/socket_default_socket.c b/src/libcharon/plugins/socket_default/socket_default_socket.c
index aa3d795fc..494bf57b1 100644
--- a/src/libcharon/plugins/socket_default/socket_default_socket.c
+++ b/src/libcharon/plugins/socket_default/socket_default_socket.c
@@ -692,6 +692,18 @@ socket_default_socket_t *socket_default_socket_create()
this->natt = 0;
}
+ if ((this->port && this->port < 1024) || (this->natt && this->natt < 1024))
+ {
+ if (!lib->caps->keep(lib->caps, CAP_NET_BIND_SERVICE))
+ {
+ /* required to bind ports < 1024 */
+ DBG1(DBG_NET, "socket-default plugin requires CAP_NET_BIND_SERVICE "
+ "capability");
+ destroy(this);
+ return NULL;
+ }
+ }
+
/* we allocate IPv6 sockets first as that will reserve randomly allocated
* ports also for IPv4. On OS X, we have to do it the other way round
* for the same effect. */