Commit Graph

1798 Commits

Author SHA1 Message Date
Tobias Brunner 040608a48d Simplify handling of terminating signals in all libcharon wrappers
Closes strongswan/strongswan#182.
2020-09-30 12:47:39 +02:00
Sheena Mira-ato fe3ae5be5d Add compile option to disable internal handling of fatal signals
By default, charon and its derivatives internally handle the SIGSEGV,
SIGILL, and SIGBUS signals raised by threads (segv_handler).  Add a compile
option so that the signal handling can optionally be done externally.

Closes strongswan/strongswan#132.
2019-05-28 10:44:48 +02:00
Micah Morton 4f1d2f2b09 Allow charon to change group on files before dropping caps
Allow charon to start as a non-root user without CAP_CHOWN and still be
able to change the group on files that need to be accessed by charon
after capabilities have been dropped. This requires the user charon starts
as to have access to socket/pidfile directory as well as belong to the
group that charon will run as after dropping capabilities.

Closes strongswan/strongswan#105.
2018-06-12 10:25:30 +02:00
Tobias Brunner 89bd016ef4 Fixed some typos, courtesy of codespell 2018-05-23 16:33:02 +02:00
Micah Morton b9fcc61991 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.
2018-05-14 15:50:01 +02:00
Martin Willi 9655a3ffbc charon: Ignore an existing PID file if it references ourself
If a daemon PID file references the process that does the check, it is safe
to ignore it; no running process can have the same PID. While this is rather
unlikely to get restarted with the same PID under normal conditions, it is
quite common when running inside PID namespaced containers: If a container
gets stopped and restarted with a PID file remaining, it is very likely that
the PID namespace assigns the same PID to our service, as they are assigned
sequentially starting from 1.
2018-03-21 10:25:49 +01:00
Tobias Brunner 42353849cb charon: Explicitly check return value of fileno()
This is mainly for Coverity because fchown() can't take a negative
value, which the -1 check implies is possible.
2017-11-15 14:37:43 +01:00
Tobias Brunner 1b4d97dbb7 charon: Unlink PID file after daemon deinit (i.e. after unloading plugins etc.)
Make sure, though, that we only remove the file if we actually
created it (e.g. not for --help or --version).  And do so before
deinitializing libstrongswan due to leak detective.

Fixes #2460.
2017-11-10 10:55:43 +01:00
Tobias Brunner 9665686bd8 daemon: Use separate method to set default loggers
This way it is not necessary to pass the same values to reload the
loggers.
2017-01-25 14:58:09 +01:00
Martin Willi 518a5b2ece configure: Check for and explicitly link against -latomic
Some C libraries, such as uClibc, require an explicit link for some atomic
functions. Check for any libatomic, and explcily link it.
2016-06-14 14:27:20 +02:00
Tobias Brunner 28649f6d91 libhydra: Remove empty unused library 2016-03-03 17:36:11 +01:00
Tobias Brunner 88b85e022a sigwaitinfo() may fail with EINTR if interrupted by an unblocked signal not in the set
Fixes #1213.
2015-11-23 11:37:19 +01:00
Tobias Brunner 858148092d Replace usages of sigwait(3) with sigwaitinfo(2)
This is basically the same call, but it has the advantage of being
supported by FreeBSD's valgrind, which sigwait() is not.

References #1106.
2015-10-29 15:38:37 +01:00
Martin Willi 68da3bad57 settings: Use strongswan.conf used during library initialization for reload
Since 4b670a20 we require an explicit strongswan.conf to re-load configurations.
However, the define was missing in the build, breaking SIGHUP based config
reloading.

Fixes #651.
2014-09-22 13:40:39 +02:00
Martin Willi 866514c70c charon: Set CLOEXEC flag on daemon PID file and /dev/(u)random source FDs
On Fedora, SELinux complains about these open file descriptors when the
updown script invokes iptables. While it seems difficult to set the flag
on all file descriptors, this at least fixes those covered by the SELinux
policy.

As these two cases are in code executed while the daemon is still single
threaded, we avoid the use of atomic but not fully portable fdopen("e") or
open(O_CLOEXEC) calls.

Fixes #519.
2014-06-24 15:26:38 +02:00
Tobias Brunner 4b670a20a9 settings: strongswan.conf must be loaded explicitly 2014-05-15 11:28:10 +02:00
Tobias Brunner 1c306c0ee9 libcharon: Remove unused charon->name 2014-02-12 14:34:33 +01:00
Tobias Brunner 10c4f4e1fd libhydra: Remove unused hydra->daemon 2014-02-12 14:34:32 +01:00
Tobias Brunner 34d3bfcf14 lib: Add global config namespace 2014-02-12 14:34:31 +01:00
Tobias Brunner 20c99edab9 android: Remove dependency on libvstr 2013-11-13 11:40:47 +01:00
Martin Willi 19cb07b890 automake: replace INCLUDES by AM_CPPFLAGS
INCLUDES are now deprecated and throw warnings when using automake 1.13.
We now also differentiate AM_CPPFLAGS and AM_CFLAGS, where includes and
defines are passed to AM_CPPFLAGS only.
2013-07-18 14:59:19 +02:00
Tobias Brunner 68b7448eab capabilities: Make the user and group charon(-nm) changes to configurable 2013-06-25 17:16:33 +02:00
Tobias Brunner a2eb581781 capabilities: Move global capabilities_t instance to libstrongswan 2013-06-25 17:16:32 +02:00
Tobias Brunner 607f8e9906 plugin-loader: Add method to print loaded plugins on a given log level 2013-06-21 15:17:53 +02:00
Martin Willi 1f69412b4d When receiving critical signals, additionally log backtraces to syslog/files 2013-03-04 15:46:34 +01:00
Adrian-Ken Rueegsegger a25047e412 Return SS_RC_INITIALIZATION_FAILED if pid file exists
Let charon return SS_RC_INITIALIZATION_FAILED if an existing pid file is found.
Starter only terminates itself if the result code of the daemon is a valid
SS_RC_* value.
2013-01-23 15:59:21 +01:00
Tobias Brunner 3555bacac7 Reload logger configuration on SIGHUP
Besides changing the configuration this allows to easily rotate log files.

Also moved logger initialization back to daemon_t.
2012-10-18 14:42:10 +02:00
Tobias Brunner d35d669180 Make syslog and file loggers configurable at runtime 2012-10-18 14:42:10 +02:00
Tobias Brunner 56d07af3be Added ESP log group for libipsec log messages. 2012-08-08 15:12:25 +02:00
Martin Willi bd28543512 Rebuild charon after running ./configure to reflect plugin changes 2012-08-03 13:11:45 +02:00
Martin Willi 0619ddfaa4 Refactored heavily #ifdefd capability code to its own libstrongswan class 2012-07-04 11:01:40 +02:00
Martin Willi b8e17eb36f Show some uname() info during charon startup 2012-06-28 11:56:15 +02:00
Andreas Steffen a71f0f3bdc charon is now an IKE daemon 2012-05-03 20:48:01 +02:00
Tobias Brunner 18758e3d2e Store the name of the binary using libcharon to enable specific settings. 2012-05-03 13:57:04 +02:00
Tobias Brunner 94b48e071a Provide plugin list from charon, not internally in libcharon. 2012-05-03 13:14:07 +02:00
Tobias Brunner ead92870b8 Loggers specify what log messages they want to receive during registration.
This also allows us to generate the log message only once for all
loggers that need it (avoids calls to custom printf specifier callbacks).

To update the log levels loggers can simply be registered again.
2012-05-02 14:45:38 +02:00
Tobias Brunner 0e474f9148 Use a separate interface for loggers.
The new interface does not allow loggers to unregister themselves from
the bus.  This allows us to use a rwlock_t for them.

The latter also means that loggers can now be called concurrently by
multiple threads.
2012-05-02 14:45:38 +02:00
Tobias Brunner 5895c2e948 Option added to set identifier for syslog(3) logging.
This identifier is added to each log message by syslog.
2012-04-20 09:26:12 +02:00
Tobias Brunner 2e0b478a01 Android 4 requires LOCAL_MODULE_TAGS to be set for all modules.
Because all packages are now marked as optional executables that are to
be installed on the final system have to be added to PRODUCT_PACKAGES in
build/target/product/core.mk.  Dependencies (such as libraries) are
installed automatically.
2012-01-12 19:18:35 +01:00
Tobias Brunner 54d096a712 Added ASN debug group to log low-level encoding/decoding (ASN.1, X.509).
This will allow us to remove quite some clutter from the LIB debug group
for higher debug levels.
2011-12-16 16:44:38 +01:00
Tobias Brunner 48e87e12ab Revert "fixed integrity tests of plugins using libtls or libtnccs"
This reverts commit b597ac4a4c (not
completely).
2011-11-08 18:35:11 +01:00
Tobias Brunner e034cc9ca9 Revert "fixed integrity tests of plugins using libsimaka"
This reverts commit 8c42f16dee.

Conflicts:

	src/charon/Makefile.am
2011-11-08 18:35:11 +01:00
Andreas Steffen f094dbc9bf use the correct USE_SIMAKA conditional 2011-11-04 11:27:19 +01:00
Andreas Steffen 8c42f16dee fixed integrity tests of plugins using libsimaka 2011-11-04 11:27:19 +01:00
Andreas Steffen 90bb98f4ac charon must load libtls if available 2011-11-02 09:28:09 +01:00
Andreas Steffen b597ac4a4c fixed integrity tests of plugins using libtls or libtnccs 2011-11-02 06:42:08 +01:00
Tobias Brunner bdbbab35b1 pluto: Switch to user 'vpn' on Android. 2011-10-18 11:36:52 +02:00
Tobias Brunner 6d36f8b60a Make sure the PID read from charon.pid is null-terminated. 2011-09-28 13:57:59 +02:00
Andreas Steffen b9d61f78d3 added PTS debug class 2011-09-11 00:11:04 +02:00
Andreas Steffen a6cb374136 added DBG_IMC and DBG_IMV debug options 2011-05-29 10:25:13 +02:00