Commit Graph

644 Commits

Author SHA1 Message Date
Tobias Brunner 1b67166921 Unify format of HSR copyright statements 2018-05-23 16:32:53 +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
Tobias Brunner 2db6d5b8b3 Fixed some typos, courtesy of codespell 2018-02-13 12:19:54 +01:00
Tobias Brunner 024b979522 certificate: Return signature scheme and parameters from issued_by() method
This also required some include restructuring (avoid including library.h
in headers) to avoid unresolvable circular dependencies.
2017-11-08 16:48:10 +01:00
Tobias Brunner b93ebb4ea9 utils: Add helper function to parse time spans from strings 2017-11-02 10:04:03 +01:00
Tobias Brunner c782d367c6 asn1: Add additional OIDs seen in certificate DNs 2017-11-02 10:02:26 +01:00
Tobias Brunner d4593353c9 utils: Include stdint.h
Recent releases of glibc don't include the full stdint.h header in some
network headers included by utils.h.  So uintptr_t might not be defined.
Since we use fixed width integers, including the latter, all over the place
we make sure the complete file is included.

Fixes #2425.
2017-09-19 13:24:39 +02:00
Tobias Brunner 7004a59a4c utils: Make second argument to memxor() const 2017-07-05 10:02:05 +02:00
Andreas Steffen 29e1c58643 leak-detective: Whitelisted memory leaks in FHH IMCs and IMVs 2017-05-29 10:59:04 +02:00
Tobias Brunner 95a63bf281 Migrate all enumerators to venumerate() interface change 2017-05-26 13:56:44 +02:00
Tobias Brunner 5297c65398 utils: Add helper macros to read variadic arguments into local variables 2017-05-26 13:56:44 +02:00
Tobias Brunner aed77b0961 chunk: Correctly parse Base64 text where four = follow in a row
That's not correct Base64 but invalid data could trigger this. Since
outlen would get reduced four times, but is only ever increased three
times per iteration, this could result in an integer underflow and then
a potential buffer overflow.
2017-05-23 18:29:12 +02:00
Andreas Steffen cfdccc93f5 utils: chunk_from_hex() skips optional 0x prefix 2017-03-06 18:54:09 +01:00
Tobias Brunner 1da567734f libipsec: Fix Windows build via MinGW
Fixes #2118.
2017-01-25 17:12:30 +01:00
Tobias Brunner 95f9fa82d5 leak-detective: Whitelist thread ID getter
In case an external thread calls into our code and logs messages, a thread
object is allocated that will never be released.  Even if we try to clean
up the object via thread value destructor there is no guarantee that the
thread actually terminates before we check for leaks, which seems to be the
case for the Ada Tasking threads.
2016-09-20 16:26:05 +02:00
Tobias Brunner fd2ade9935 leak-detective: Whitelist functions of the Ada runtime related to Tasking 2016-09-20 16:26:05 +02:00
Tobias Brunner 0b5d490e33 leak-detective: Whitelist some glib/libsoup functions
Some of these are pretty broad, so maybe an alternative option is to
not use the soup plugin in the openssl-ikev2/rw-suite-b* scenarios.  But
the plugin is not tested anywhere else so lets go with this for now.
2016-09-20 16:22:08 +02:00
Tobias Brunner f44e0efb11 leak-detective: Whitelist leak in libldap 2016-09-20 15:36:14 +02:00
Tobias Brunner 603a1d3c8f utils: Fix definition of BYTE_ORDER with MinGW 2016-08-24 10:40:57 +02:00
Andreas Steffen 8993cb556e utils: Defined uletoh16() and htole16() 2016-08-06 12:09:05 +02:00
Tobias Brunner 505c318701 leak-detective: Try to properly free allocations after deinitialization
If a function we whitelist allocates memory while leak detective is enabled
but only frees it after LD has already been disabled, free() will get called
with invalid pointers (not pointing to the actually allocated memory by LD),
which will cause checks in the C library to fail and the program to crash.
This tries to detect such cases and calling free with the correct pointer.
2016-06-29 11:09:38 +02:00
Tobias Brunner c1410cb045 openssl: Whitelist OPENSSL_init_crypto() and others in leak detective
Lots of static data is allocated in this function, which isn't freed until
the library is unloaded (we can't call OPENSSL_cleanup() as initialization
would fail when calling it again later).  When enabling the leak
detective the test runner eventually crashes as all the data allocated during
initialization has an invalid size when freed after leak detective has been
unloaded.
2016-06-29 11:09:38 +02:00
Tobias Brunner e0c59faa68 leak-detective: Make sure to actually call malloc() from calloc() hook
Newer versions of GCC are too "smart" and replace a call to malloc(X)
followed by a call to memset(0,X) with a call co calloc(), which obviously
results in an infinite loop when it does that in our own calloc()
implementation.  Using `volatile` for the variable storing the total size
prevents the optimization and we actually call malloc().
2016-06-15 16:21:47 +02:00
Tobias Brunner 8f1806605d leak-detective: Whitelist __fprintf_chk as seen on newer systems 2016-06-15 11:21:39 +02:00
Tobias Brunner a366fa365e identification: Compare identity types when comparing ID_FQDN/ID_RFC822_ADDR identities
References #1380.
2016-06-06 13:49:41 +02:00
Yannick Cann 49fa6ebf1c identification: Add support for dmdName RDN (2.5.4.54)
It's listed in RFC 2256 but was later removed with RFC 4519, but there
are still some certs that use it.

Closes strongswan/strongswan#43.
2016-04-25 17:06:04 +02:00
Andreas Steffen c87f428836 leak-detective: added _IO_file_doallocate to whitelist 2016-04-24 23:34:44 +02:00
Tobias Brunner b82b5f6398 chunk: Skip all leading zero bytes in chunk_skip_zero() not just the first 2016-04-04 15:39:42 +02:00
Tobias Brunner 85597f2983 string: Gracefully handle NULL in str*eq() macros 2016-04-04 10:43:46 +02:00
Tobias Brunner 90c8cf6819 byteorder: Explicitly check for htoXeXX macros
Some platforms have XetohXX macros instead of XeXXtoh macros, in which
case we'd redefine the htoXeXX macros.
2016-03-31 19:47:31 +02:00
Tobias Brunner c545688788 utils: Remove nonsensical typedefs for standard uint types 2016-03-31 09:25:11 +02:00
Andreas Steffen b12c53ce77 Use standard unsigned integer types 2016-03-24 18:52:48 +01:00
Tobias Brunner 17e36cd48c android: Enable build against API level 21
While building against this level in general would break our app on
older systems, the NDK will automatically use this level for 64-bit
ABI builds (which are not supported in older levels).  So to build
against 64-bit ABIs we have to support this API level.
2016-03-23 14:18:37 +01:00
Tobias Brunner 755d076fec Fix some Doxygen issues 2016-03-11 12:25:14 +01:00
Tobias Brunner 0fc8b1d03e identification: Make `written` signed to fix error checking when printing ranges 2016-03-11 10:09:02 +01:00
Andreas Steffen 1d86d1d65a Implemented IPv4/IPv6 subnet and range identities
The IKEv1 IPV4_ADDR_SUBNET, IPV6_ADDR_SUBNET, IPV4_ADDR_RANGE and
IPV6_ADDR_RANGE identities have been fully implemented and can be
used as owners of shared secrets (PSKs).
2016-03-10 13:59:37 +01:00
Tobias Brunner fac9fd7368 byteorder: Simplify htoun64/untoh64 functions 2016-03-04 18:43:26 +01:00
Tobias Brunner 14de79604a byteorder: Always define be64toh/htobe64 macros 2016-03-04 18:43:26 +01:00
Tobias Brunner 28649f6d91 libhydra: Remove empty unused library 2016-03-03 17:36:11 +01:00
Tobias Brunner 10c5981d3b utils: Add enum name for pseudo log group 'any' 2016-02-05 15:41:39 +01:00
Andreas Steffen 7c81942357 Support pseudonym RDN 2016-01-27 11:38:18 +01:00
Martin Willi 057e6cc524 byteorder: Provide a fallback for le32toh/htole32()
Some older toolchains don't provide these macros, so implement them using
the gcc builtins. We also provide 64-bit variants as used by chapoly.
2015-12-04 10:29:09 +01:00
Martin Willi 8fa0c7bc77 byteorder: Add 32-bit unaligned little-endian conversion functions 2015-12-04 10:29:09 +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 5461efe7b9 utils: Use the more low-level __NR_ prefix to refer to the syscall number
The __NR_ constants are also defined in the Android headers.
2015-11-17 17:21:36 +01:00
Tobias Brunner ef4279f2e5 utils: Provide a fallback for sigwaitinfo() if needed
Apparently, not available on Mac OS X 10.10 Yosemite. We don't provide
this on Windows.
2015-11-13 18:24:45 +01:00
Tobias Brunner 073761ec41 android: Provide a fallback for sigwaitinfo() 2015-11-12 14:11:21 +01:00
Tobias Brunner 9be6b2e0b5 android: Replace AndroidConfigLocal.h with a header in utils/compat 2015-11-12 14:10:33 +01:00
Tobias Brunner 7bea8e0f4a windows: Define RTLD_NOW, even if it is not used 2015-11-09 14:37:07 +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