Allow strongSwan to be spawned as non-root user

This patch allows for giving strongSwan only the runtime capabilities it
needs, rather than full root privileges.

Adds preprocessor directives which allow strongSwan to be configured to
 1) start up as a non-root user
 2) avoid modprobe()'ing IPsec kernel modules into the kernel, which
    would normally require root or CAP_SYS_MODULE

Additionally, some small mods to charon/libstrongswan ensure that charon
fully supports starting as a non-root user.

Tested with strongSwan 5.5.3.
This commit is contained in:
Micah Morton
2018-05-14 15:50:01 +02:00
committed by Tobias Brunner
parent 0d2e18a189
commit b9fcc61991
5 changed files with 26 additions and 7 deletions
+4 -1
View File
@@ -422,7 +422,10 @@ METHOD(capabilities_t, drop, bool,
{
#ifndef WIN32
#ifdef HAVE_PRCTL
prctl(PR_SET_KEEPCAPS, 1, 0, 0, 0);
if (has_capability(this, CAP_SETPCAP, NULL))
{
prctl(PR_SET_KEEPCAPS, 1, 0, 0, 0);
}
#endif
if (this->uid && !init_supplementary_groups(this))
+3
View File
@@ -47,6 +47,9 @@ typedef struct capabilities_t capabilities_t;
#ifndef CAP_DAC_OVERRIDE
# define CAP_DAC_OVERRIDE 1
#endif
#ifndef CAP_SETPCAP
# define CAP_SETPCAP 8
#endif
/**
* POSIX capability dropping abstraction layer.