diff options
| author | Tobias Brunner <tobias@strongswan.org> | 2013-06-25 17:17:40 +0200 |
|---|---|---|
| committer | Tobias Brunner <tobias@strongswan.org> | 2013-06-25 17:17:40 +0200 |
| commit | 9da5a2ed1e72d1b68feefd5811a089d0881dd87d (patch) | |
| tree | 2eeb8375e6ffb24321e1d7e3a4ba06183bf9eaec /src/libcharon/plugins/socket_default | |
| parent | a65024264379bacc2733282f2b59b8c14e3897c0 (diff) | |
| parent | ac2ffde4ae8ceaddeab8b6f740804536033153e6 (diff) | |
| download | strongswan-9da5a2ed1e72d1b68feefd5811a089d0881dd87d.tar.bz2 strongswan-9da5a2ed1e72d1b68feefd5811a089d0881dd87d.tar.xz | |
Merge branch 'check-caps'
Plugins may now ensure the process has all the required capabilities.
Some minor changes to UID/GID handling are also included.
Diffstat (limited to 'src/libcharon/plugins/socket_default')
| -rw-r--r-- | src/libcharon/plugins/socket_default/socket_default_socket.c | 12 |
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. */ |
