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
+9
-3
@@ -231,9 +231,15 @@ static bool check_pidfile()
|
||||
DBG1(DBG_LIB, "setting FD_CLOEXEC for '"PID_FILE"' failed: %s",
|
||||
strerror(errno));
|
||||
}
|
||||
ignore_result(fchown(fd,
|
||||
lib->caps->get_uid(lib->caps),
|
||||
lib->caps->get_gid(lib->caps)));
|
||||
/* Only fchown() the pidfile if we have CAP_CHOWN. Otherwise,
|
||||
* directory permissions should allow pidfile to be accessed
|
||||
* by the UID/GID under which the charon deamon will run. */
|
||||
if (lib->caps->check(lib->caps, CAP_CHOWN))
|
||||
{
|
||||
ignore_result(fchown(fd,
|
||||
lib->caps->get_uid(lib->caps),
|
||||
lib->caps->get_gid(lib->caps)));
|
||||
}
|
||||
fprintf(pidfile, "%d\n", getpid());
|
||||
fflush(pidfile);
|
||||
return FALSE;
|
||||
|
||||
Reference in New Issue
Block a user