Commit Graph

2956 Commits

Author SHA1 Message Date
Tobias Brunner f00a9c1715 packet: Define a global default maximum size for IKE packets 2014-10-10 09:32:42 +02:00
Martin Willi 7dd06d274d process: Add a wrapper to invoke a command under the system default shell 2014-10-06 18:24:39 +02:00
Martin Willi 02e4dedce5 process: Port child process spawning to the Windows platform 2014-10-06 18:24:39 +02:00
Martin Willi 1fea589c1f process: Provide an abstraction to spawn child processes with redirected I/O 2014-10-06 18:24:39 +02:00
Shea Levy 5fea45506e library: Allow specifying the path to strongswan.conf in the STRONGSWAN_CONF env var 2014-10-02 14:28:01 +02:00
Martin Willi a336aefa89 curl: For SSL features, depend on thread-safety provided by our crypto plugins
To use SSL in curl, we need to initialize the SSL library in a thread-safe
manner and provide the appropriate callbacks. As we already do that in our
crypto plugins using these libraries, we depend on these features.

This implies that we need the same plugin enabled (openssl, gcrypt) as the
curl backend is configured to use to fetch from HTTPS URIs.
2014-09-24 17:35:16 +02:00
Martin Willi d717b42b51 curl: Dynamically query supported protocols and register appropriate features 2014-09-24 11:35:59 +02:00
Martin Willi 6eaec1e349 leak-detective: Whitelist libssl SSL_COMP_get_compression_methods()
This function is called by libcurl initialization with SSL, and uses
a static allocation of compression algorithms not freed.
2014-09-24 11:35:59 +02:00
Martin Willi 85c95db17a curl: Try to initialize with SSL support to handle https:// URIs
If initialization fails, we fall back to the old behavior.
2014-09-24 11:35:59 +02:00
Martin Willi 5ea627bdfa watcher: Add a method to query the watcher state
This allows a user to check if the watcher is actually running, and potentially
perform read operations directly instead of relying on watcher.
2014-09-24 11:19:59 +02:00
Martin Willi 5421092b75 plugin-loader: Support a reload() callback for static features 2014-09-22 13:55:12 +02:00
Martin Willi d8ad0fc351 settings: Make loading a NULL or empty pattern a (nop-)success 2014-09-22 13:40:39 +02: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 9e783f6e89 library: Store the used root strongswan.conf configuration 2014-09-22 13:40:39 +02:00
Tobias Brunner c6e8b5dc2c chunk: Fix Doxygen comments for chunk_internet_checksum[_inc] 2014-09-11 17:56:12 +02:00
Tobias Brunner 8ca9a67fac auth-cfg: Fix crash after several reauthentications with multiple authentication rounds
Due to the issue described in c641974, purge() inadvertently destroyed
CA certificates that should have been kept (while the pointer to these
objects remained in the array).  This lead to incorrect reference counts
and after a few reauthentications with multiple authentication rounds,
which cause calls to purge(TRUE), to crashes.
2014-09-11 17:52:37 +02:00
Tobias Brunner ea50394bf1 array: Adjust negative index before calling remove_head|tail()
For ARRAY_TAIL we most often want to call remove_tail() not remove_head().
2014-09-11 17:52:37 +02:00
Tobias Brunner c641974de0 array: Warn about caveat with array_remove_at() and value based arrays
Because enumerate() for value based arrays returns a pointer directly to
the internal array elements and because array_remove_at() or rather the
called array_remove() may move elements over the element at the currently
enumerated position, the pointer passed to enumerate() will point to a
different array element after the array_remove_at() call.  The caller
will thus operate on the wrong element if that pointer is accessed again
before calling enumerate().

For performance reasons we currently don't change the implementation to copy
each array element during enumeration to a private member of the enumerator and
return a pointer to that.  Similarly, due to the danger of subtle bugs we don't
remember the pointer passed to enumerate() to later redirect it to a copy
created during the array_remove_at() call.
2014-09-11 17:52:00 +02:00
Tobias Brunner 92b76384a0 asn1: Try to fill the available binary OID buffer if possible 2014-09-09 12:31:00 +02:00
Tobias Brunner c6f886ce10 unit-tests: Give worker threads time to clean up when testing thread_t.detach() 2014-09-09 10:58:59 +02:00
Tobias Brunner cee338eccd stream-service: Prevent race conditions due to blocking call to destroy()
In the previous implementation queued jobs could prevent a service from
getting destroyed.  This could have lead to a deadlock when the
processor is cancelled.  Now destroy() still blocks, but waits only for
actually running tasks.  The service instance is reference counted so that
queued jobs can safely be destroyed.
2014-09-09 10:58:59 +02:00
Tobias Brunner 10859adfd4 stream-service: Do not accept or re-register when service is terminated 2014-09-09 10:58:59 +02:00
Tobias Brunner 22e90cad00 stream-service: Restart accepting without blocking
Calling on_accept() sometimes lead to deadlocks when service->destroy()
was called concurrently.  That is, two threads waiting in on_accept() but
the last worker would only wake one due to the call to signal().  Calling
broadcast() wouldn't help either as that could lead to crashes if the thread
that called destroy() is woken first.

This is also more efficient as a constant pool of concurrent workers can
be maintained, otherwise peaks at the limit were followed by only a single
worker being active.
2014-09-09 10:58:58 +02:00
Tobias Brunner 4df9250f26 asn1: Make sure not to exceed buffer for binary OID 2014-09-09 10:56:15 +02:00
Tobias Brunner dbd7f4be31 mutex: Use atomics to set current thread in recursive mutex
Because this->thread is also read by threads that don't hold the
mutex the previous implementation was problematic (especially since
pthread_t is an opaque type of unknown length).

Fixes #654.
2014-09-09 10:56:15 +02:00
Tobias Brunner 7e433456fc curl: Log error code too
It seems libcurl does not always return an error message.
2014-09-09 10:56:14 +02:00
Tobias Brunner 4f71ee2cf6 unit-tests: Add option to exclude specific test suites
Listing test suites in TESTS_SUITES_EXCLUDE allows excluding specific
test suites from running.
2014-09-09 10:56:14 +02:00
Tobias Brunner 5818467639 openssl: Report correct key length for EC keys when not using NIST curves
Fixes #688.
2014-09-02 08:15:17 +02:00
Thomas Egerer 8d80528a60 credmgr: Fix copy and paste error in add_validator
This won't hurt as long as sets and validators are of the same class.
But as soon as one of the object's class is changed this will cause
either a compile error (best option), or result (most likely) in a
crash.

Signed-off-by: Thomas Egerer <thomas.egerer@secunet.com>
2014-08-29 13:22:23 +02:00
Martin Willi 11bf11c1f5 utils: Check if the parameter passed to countof() is actually an array type
This should avoid errors such as the one fixed with 118b2879.
2014-08-25 09:48:53 +02:00
Martin Willi bb6be26197 utils: Add some initial build time assertion macros
These are useful to assert constants during build time. We evaluate the
expression to 0 when valid, so we can safely use the evaluated value.
2014-08-25 09:48:53 +02:00
Martin Willi 46184b07c1 diffie-hellman: Explicitly initialize DH exponent sizes during initialization
To avoid any race conditions when multiple threads call and initialize
diffie_hellman_get_params(), explicitly examine the optimum DH exponent size
during library initialization.

Fixes #655.
2014-08-25 09:43:29 +02:00
Tobias Brunner b557f4a7cd chunk: Add function to calculate Internet Checksums according to RFC 1071 2014-07-22 11:10:35 +02:00
Martin Willi a51c48eeaa settings: Allow spaces in time settings before the optional unit 2014-07-07 16:58:05 +02:00
Martin Willi 0058e26cb0 settings: Be more strict in converting settings to specific data types
As the behavior was inconsistent for empty strings or strings with characters
appended to a number, testing the code failed on some platforms. The new rules
are more strict, returning the default if additional characters or an empty
string was found for a setting.
2014-07-07 16:57:38 +02:00
Martin Willi 920d466f05 utils: Undefine mem{cpy,move,set} if set before defining them
Some platforms, such as OS X, use macros for these functions. Undefine them
to avoid compiler warnings.
2014-07-07 16:14:26 +02:00
Martin Willi c1490c649a enumerator: Enumerate glob(3) matches using gl_pathc
While glob should return a NULL terminated gl_pathv when having no matches,
at least on OS X this is not true when using GLOB_DOOFFS. Rely on the
number of matches returned in gl_pathc, which seems to be more reliable in
error cases.
2014-07-07 16:14:17 +02:00
Tobias Brunner 118b2879aa winhttp: Do not use countof() on pointer argument 2014-07-02 12:38:45 +02:00
Tobias Brunner 831045ef45 optionsfrom: Properly handle errors when determining file size 2014-07-02 12:38:45 +02:00
Tobias Brunner e44223dbcc windows: Fix off-by-one error in strerror_s_extended() 2014-07-02 12:38:45 +02:00
Tobias Brunner 0026600bfe windows: accept() socket handle could theoretically be 0 2014-07-02 12:38:45 +02:00
Tobias Brunner babe9e4f45 windows: Close correct socket when opening second socket fails in socketpair() 2014-07-02 12:38:44 +02:00
Tobias Brunner 0a26f39a71 windows: Make sure the string returned from ReadConsole() is null terminated 2014-07-02 12:38:44 +02:00
Tobias Brunner 32a262e7a1 windows: Remove useless assignment in put_thread() 2014-07-02 12:12:05 +02:00
Tobias Brunner 0e48f67562 backtrace: Remove name checks after SymFromAddr() calls
The Name member is an array whose address is always defined.
2014-07-02 12:11:59 +02:00
Tobias Brunner 1be2b84124 parser-helper: Ensure file_next() does not remove the sentinel item 2014-07-01 17:58:36 +02:00
Martin Willi 6fb1283242 gcrypt: Use predefined pthread locking functions instead of custom hooks
Starting with libgcrypt 1.6, it seems that custom locking functions are not
supported anymore. Instead, the user has to select from one of the pre-defined
set of locking functions.

Given that we have a proper threading abstraction API with optional profiling
on all platforms, this is somewhat annoying. However, there does not seem to be
a way to use custom functions, and we have no other choice than using the
provided macro magic to support all libgcrypt versions.

Fixes #630.
2014-07-01 12:23:19 +02:00
Tobias Brunner e79dbda390 utils: Helper macros to define overloaded macros based on number of arguments 2014-06-30 13:29:26 +02:00
Tobias Brunner e351169900 windows: Fix parameter name in Doxygen comment 2014-06-30 13:16:17 +02:00
Tobias Brunner aad072d517 enum: Replace þ with p in Doxygen comments 2014-06-30 13:16:17 +02:00