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:
committed by
Tobias Brunner
parent
0d2e18a189
commit
b9fcc61991
@@ -477,6 +477,7 @@ int main (int argc, char **argv)
|
||||
}
|
||||
}
|
||||
|
||||
#ifndef STARTER_ALLOW_NON_ROOT
|
||||
/* verify that we can start */
|
||||
if (getuid() != 0)
|
||||
{
|
||||
@@ -484,6 +485,7 @@ int main (int argc, char **argv)
|
||||
cleanup();
|
||||
exit(LSB_RC_NOT_ALLOWED);
|
||||
}
|
||||
#endif
|
||||
|
||||
if (check_pid(pid_file))
|
||||
{
|
||||
@@ -520,6 +522,7 @@ int main (int argc, char **argv)
|
||||
exit(LSB_RC_INVALID_ARGUMENT);
|
||||
}
|
||||
|
||||
#ifndef SKIP_KERNEL_IPSEC_MODPROBES
|
||||
/* determine if we have a native netkey IPsec stack */
|
||||
if (!starter_netkey_init())
|
||||
{
|
||||
@@ -530,6 +533,7 @@ int main (int argc, char **argv)
|
||||
DBG1(DBG_APP, "no known IPsec stack detected, ignoring!");
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
last_reload = time_monotonic(NULL);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user