Commit Graph

1852 Commits

Author SHA1 Message Date
Tobias Brunner 7b95688124 stroke: Make down-nb actually non-blocking
Fixes #1191.
2015-11-09 10:55:46 +01:00
Andreas Steffen a88d958933 Explicitly mention SHA2 algorithm in BLISS OIDs and signature schemes 2015-11-06 14:55:31 +01:00
Tobias Brunner 00c2c87b06 eap-radius: Fix creation of host_t objects based on Framed-IPv6-Address attributes
Fixes ec490e68ae ("eap-radius: Add support for some basic IPv6-specific RADIUS attributes").
References #1001.
2015-08-28 16:52:57 +02:00
Tobias Brunner fbb593092e eap-ttls: Limit maximum length of tunneled EAP packet to EAP-TTLS packet 2015-08-27 15:29:16 +02:00
Tobias Brunner e3e208fb9f ha: Close control FIFO if it is not valid 2015-08-27 14:31:42 +02:00
Tobias Brunner c605a96d7f Fix some Doxygen issues 2015-08-27 12:03:11 +02:00
Tobias Brunner 735f929ca7 ike: Only consider number of half-open SAs as responder when deciding whether COOKIEs are sent 2015-08-27 11:18:51 +02:00
Evan Broder 78ed330099 vici: Handle closed sockets in the Ruby gem
From recvfrom(2) (which UDPSocket#recv backs into):

  The return value will be 0 when the peer has performed an orderly
  shutdown.

(i.e. it will return an empty string)

Previously in this scenario, Vici::Transport#recv_all would spin
forever trying to pull more data off the socket. I'm not entirely
clear what happened that caused strongSwan to shutdown the socket, but
it probably should not cause vici Ruby apps to spin.

Closes strongswan/strongswan#13.
2015-08-24 11:24:05 +02:00
Tobias Brunner 256e666d22 vici: Optionally check limits when initiating connections
If the init-limits parameter is set (disabled by default) init limits
will be checked and might prevent new SAs from getting initiated.
2015-08-21 18:21:13 +02:00
Tobias Brunner b9d7319fb3 vici: Add get_bool() convenience getter for VICI messages 2015-08-21 18:21:13 +02:00
Tobias Brunner ff0abde9ed controller: Optionally adhere to init limits also when initiating IKE_SAs 2015-08-21 18:21:13 +02:00
Tobias Brunner ffa20bad63 stroke: Allow %any as local address
Actually, resolving addresses in `left` might be overkill as we'll assume
left=local anyway (the only difference is the log message).
2015-08-21 18:19:26 +02:00
Tobias Brunner 8212f3d9a4 stroke: Add an option to disable side-swapping of configuration options
In some scenarios it might be preferred to ensure left is always local
and no unintended swaps occur.
2015-08-21 18:19:26 +02:00
Tobias Brunner 517cc501ef stroke: Change how CA certificates are stored
Since 11c14bd2f5 CA certificates referenced in ca sections were
enumerated by two credential sets if they were also stored in
ipsec.d/cacerts.  This caused duplicate certificate requests to
get sent.  All CA certificates, whether loaded automatically or
via a ca section, are now stored in stroke_ca_t.

Certificates referenced in ca sections are now also reloaded
when `ipsec rereadcacerts` is used.
2015-08-20 19:33:41 +02:00
Tobias Brunner 01d3ecbaf0 stroke: Combine CA certificate load methods
Also use the right credential set for CA cert references loaded from
stroke_ca_t.
2015-08-20 19:19:38 +02:00
Tobias Brunner 99610f406d stroke: Atomically replace CA and AA certificates when reloading them
Previously it was possible that certificates were not found between the
time the credential sets were cleared and the certificates got readded.
2015-08-20 19:19:37 +02:00
Tobias Brunner 6927d6224e sql: Also do a reversed ID match
This is required for the case where IDr is not sent (i.e. is %any).
The backend manager does the same.

Fixes #1044.
2015-08-17 18:58:14 +02:00
Tobias Brunner fffee7c759 ha: Recreate the control FIFO if the file exists but is not a FIFO
This may happen if something like `echo ... > /path/to/fifo` is used
before the plugin was able to create the FIFO. In that case we'd end
up in a loop always reading the same values from the static file.
2015-08-17 17:51:20 +02:00
Tobias Brunner 9322e5b398 vici: Add option to disable policy installation for CHILD_SAs 2015-08-17 12:01:36 +02:00
Tobias Brunner 39afe6e9d0 eap-radius: Use Framed-IPv6-Address attributes to send IPv6 VIPs in accounting messages
This attribute is more appropriate for single IPv6 virtual IPs than the
Framed-IPv6-Prefix attribute.

Fixes #1001.
2015-08-17 11:23:41 +02:00
Tobias Brunner ec490e68ae eap-radius: Add support for some basic IPv6-specific RADIUS attributes
These are defined in RFC 6911.

Fixes #1001.
2015-08-17 11:23:33 +02:00
Tobias Brunner b3d91cc64e vici: Add listen methods to receive arbitrary events in Python library 2015-08-17 11:12:18 +02:00
Tobias Brunner cf4cefee42 vici: Move event (un-)registration to a helper method in Python library
Also make sure events are unregistered in case of exceptions in
streamed_request().
2015-08-17 11:12:17 +02:00
Tobias Brunner 65ac0851c0 vici: Add ike/child-rekey events 2015-08-17 11:12:17 +02:00
Tobias Brunner 7f21363ee5 vici: Document the ike/child-updown events 2015-08-17 11:12:17 +02:00
Tobias Brunner 22842cce0d vici: Don't include a child-sas section in ike-updown event
This makes it clearer that only the data concerning the IKE_SA is
transmitted (there could be CHILD_SAs e.g. during IKEv1
reauthentication).
2015-08-17 11:12:17 +02:00
Tobias Brunner 085b8f4fb0 vici: Explicitly notify listeners of the type of ike/child-updown event 2015-08-17 11:12:12 +02:00
Andreas Steffen a330f72ecf Fixed AR identities in mutual TNC measurements case 2015-08-15 22:46:21 +02:00
Tobias Brunner 98c09357d5 load-tester: Include string.h for strcmp() on some platforms 2015-08-13 15:12:42 +02:00
Tobias Brunner 6967948241 Initialize variables that some compilers seem to warn about 2015-08-13 15:12:38 +02:00
Tobias Brunner f809e485fb Fixed some typos 2015-08-13 15:12:34 +02:00
Tobias Brunner 6fe8fe0cfd whitelist: Use hash() method so DNs with different string types match
strongSwan uses PrintableString when encoding DNs from strings (if the
character set permits it, otherwise T61String is currently used) but
certificates might be encoded with UTF8String even for simple ASCII strings.
By ignoring this string type when hashing RDNs we make sure the same hash
results in this case as long as the actual string values are the same.

Fixes #991.
2015-08-06 17:24:04 +02:00
Tobias Brunner 1de31bcc2b updown: Pass virtual IPs assigned to a peer to the updown script
Previously only received virtual IPs were available.

References #1008.
2015-08-06 16:30:08 +02:00
Tobias Brunner d04b093374 eap-radius: Don't send RADIUS Accounting Start messages twice
If a client does Mode Config during reauthentication the assign_vips()
event might be triggered twice, we should not send another Start message
in that case.

Fixes #937.
2015-08-06 14:57:47 +02:00
Tobias Brunner 186d25cbe6 eap-radius: Change trigger for Accounting Start messages for IKEv1
Some clients won't do Mode Config or XAuth during reauthentication.
Because Start messages previously were triggered by TRANSACTION exchanges
none were sent for new SAs of such clients, while Stop messages were still
sent for the old SAs when they were destroyed.  This resulted in an
incorrect state on the RADIUS server.

Since 31be582399 the assign_vips() event is also triggered during
reauthentication if the client does not do a Mode Config exchange.
So instead of waiting for a TRANSACTION exchange we trigger the Start
message when a virtual IP is assigned to a client.

With this the charon.plugins.eap-radius.accounting_requires_vip option
would not have any effect for IKEv1 anymore.  However, it previously also
only worked if the client did an XAuth exchange, which is probably
rarely used without virtual IPs, so this might not be much of a
regression.

Fixes #937.
2015-08-06 14:57:26 +02:00
Tobias Brunner a7f381ef00 ha: Properly initialize algo variables when installing CHILD_SAs
If AEAD algorithms are used no integrity algorithm will be received from
the other HA node.  But since AUTH_UNDEFINED is 1024 and not 0 this value
was incorrectly added to the proposal, resulting in a failure during key
derivation.  The variables are now explicitly initialized to 0, as already
was the case for the IKE SAs.

Fixes #1051.
2015-08-04 11:23:27 +02:00
Thomas Egerer 3434709460 ha: Sync remote address in HA_IKE_ADD, too
When the IKE_SA is synced without the remote address, after a
reauthentication charon is not able to find it in its connected_peers
table since the destination host will be %any (it's missing in the
message, hence the default from the newly created ike_sa_t -- %any --
will be used).
By adding the value to the HA_IKE_ADD message, we should be able to
solve this problem.

Signed-off-by: Thomas Egerer <thomas.egerer@secunet.com>
2015-08-04 11:21:54 +02:00
Tobias Brunner 93caf23e1b ha: Use the same init values for jhash() as Linux 4.1 2015-07-31 12:34:44 +02:00
Tobias Brunner 36bc52b441 sql: Fix memory leak in SQL logger 2015-07-28 15:35:11 +02:00
Andreas Steffen 63d370387d vici: Certification Authority support added.
CDP and OCSP URIs for a one or multiple certification authorities
can be added via the VICI interface. swanctl allows to read
definitions from a new authorities section.
2015-07-21 13:02:30 +02:00
Andreas Steffen e194349148 vici: Compute rekey_bytes and rekey_packets if life_bytes and life_packets are defined 2015-07-20 21:34:09 +02:00
Martin Willi 856ea64129 vici: Asynchronize debug logging
The vici logger uses the listener_t.log() callback to raise vici events.

When doing so, it holds the bus lock as reader while acquiring the vici socket
mutex (1). If at the same time the vici socket enables a writer, that thread
tries to lock the watcher mutex (2). The watcher thread uses debugging while
holding the lock, i.e. acquires the bus read lock (3).

(1) bus.rlock -> vici.lock!
(2) vici.lock -> watcher.lock!
(3) watcher.lock -> bus.rlock!

This all actually would resolve just fine, as we have a shared read lock on the
bus. However, under Windows we seem to have a strict writer preference when
acquiring the rwlock (4). This results in blocking read locks until any pending
write lock can be fulfilled, and makes the constellation deadlock. The relevant
threads are:

Thread (1)
6  0x71313d25 in wait_ at threading/windows/mutex.c:137
7  0x7054c8a2 in find_entry at vici_socket.c:201
8  0x7054d690 in send_ at vici_socket.c:624
9  0x7054f6c1 in send_op at vici_dispatcher.c:119
10 0x705502c1 in raise_event at vici_dispatcher.c:469
12 0x704c3878 in log_cb at bus/bus.c:332
13 0x712c7c3a in invoke_function at collections/linked_list.c:414
14 0x704c3a63 in vlog at bus/bus.c:400
15 0x704c3b36 in log_ at bus/bus.c:430
18 0x70508f1f in process_response at sa/ikev2/task_manager_v2.c:664
20 0x704f5430 in process_message at sa/ike_sa.c:1369
21 0x704e3823 in execute at processing/jobs/process_message_job.c:74
22 0x712e629f in process_job at processing/processor.c:235

Thread (2)
4  0x71313b61 in lock at threading/windows/mutex.c:66
5  0x712e81fd in add at processing/watcher.c:441
6  0x712e1ab9 in add_watcher at networking/streams/stream.c:213
7  0x712e1b4d in on_write at networking/streams/stream.c:237
8  0x7054d606 in _cb_enable_writer at vici_socket.c:609
9  0x712e5e34 in execute at processing/jobs/callback_job.c:77
10 0x712e629f in process_job at processing/processor.c:235

Thread (3)
3  0x71313f38 in read_lock at threading/windows/rwlock.c:74
4  0x704c3971 in vlog at bus/bus.c:373
5  0x704cc156 in dbg_bus at daemon.c:126
6  0x712e7bf9 in watch at processing/watcher.c:316
7  0x712e5e34 in execute at processing/jobs/callback_job.c:77
8  0x712e629f in process_job at processing/processor.c:235

Thread (4)
3  0x71313f70 in write_lock at threading/windows/rwlock.c:82
4  0x704c378b in remove_logger at bus/bus.c:290
5  0x704cb284 in listener_unregister at control/controller.c:166
6  0x713136cd in thread_cleanup_pop at threading/windows/thread.c:558
8  0x704cb94e in initiate at control/controller.c:435
9  0x70553996 in _cb_initiate at vici_control.c:187
12 0x7054d200 in _cb_process_queue at vici_socket.c:508
13 0x712e5e34 in execute at processing/jobs/callback_job.c:77
14 0x712e629f in process_job at processing/processor.c:235

To avoid such a situation, we dissolve the (1) lock sequence. It's actually
never good practice to acquire shared locks during bus hooks, as it is
problematic if we raise bus events while holding the lock. We do so by
raising vici events for log message asynchronously, but of curse must keep
log order as is using a synchronized queue.
2015-07-12 13:57:48 +02:00
Martin Willi 61d6cdb926 osx-attr: Optionally replace existing DNS server instead of appending them 2015-06-18 10:36:04 +02:00
Tobias Brunner 711cb586fa ha: Document tunnel parameter 2015-05-27 12:59:39 +02:00
Tobias Brunner 06a5b0e2e8 ha: Skip SA for sync messages when resyncing HA segments 2015-05-26 15:43:46 +02:00
Tobias Brunner 0de116cadc ha: Move plugin initialization from constructor to plugin callback
This fixes support for the secret option, as otherwise the kernel interface
is not registered yet when the trap policy is installed.
2015-05-26 12:47:17 +02:00
Tobias Brunner e94aae83d3 vici: Explicitly disable --user-install when installing Ruby Gem
Only one of `--user-install` and `--install-dir` may be set and if
`--user-install` is the default on a system installation will fail
unless we disable it explicitly.

Fixes #914.
2015-05-21 17:22:11 +02:00
Tobias Brunner f16f792e17 vici: Make installation of Ruby Gem and Python Egg optional
Installing them might not work well when building distro packages (e.g.
with DESTDIR installs).  It might be easier to install them later with a
script in the distro package.

When building from source on the local system it could still be useful to
install the packages directly, which can be enabled with separate configure
options.

The main problem with DESTDIR installations of the Python Egg is that
easy_install creates or modifies a file called easy-install.pth in the
installation directory.  So it's not actually possible to simply copy
the results in DESTDIR over to the actual system as that file would have
to be merged with any existing one.

Fixes #914.
2015-05-21 17:22:01 +02:00
Tobias Brunner 5a817407bc vici: Support out-of-tree build of Python Egg
We also don't require setup.py to exist during cleanup, as e.g. with
make distcheck the source directory is not writable when the build directory
is cleaned, so setup.py can't be created (to just get removed again anyway
if VICI and the Python Eggs haven't been enabled previously).
2015-05-21 17:19:09 +02:00
Tobias Brunner 2b51124026 eap-radius: Keep track of stats for SAs migrated during IKEv1 reauthentication 2015-05-21 15:38:31 +02:00
Tobias Brunner 8dbef6dac8 eap-radius: Remove cache entries for expired SAs during ike/child_rekey 2015-05-21 15:38:31 +02:00
Tobias Brunner 7fbe79bce7 eap-radius: Add cache for usage stats of expired/rekeyed SAs
There are several situations that the previous code didn't handle that
well, for example, interim updates during rekeying (until the rekeyed SA
was deleted the numbers were too high, then suddenly dropped afterwards),
or rekeying for IKEv1 in general because rekeyed IPsec SAs stay installed
until they expire (so if they were still around when the IKE_SA was
terminated, the reported numbers in the Stop message were too high).

If intermediate updates are not used the cache entries for rekeyed
CHILD_SA will accumulate, we can't clean them up as we don't get
child_updown() events for them.
2015-05-21 15:38:25 +02:00
Timo Teräs 17d3435693 vici: Default to certificate subject for identity
If id is not specified and certificate authentication is used, use the
certificate subject name as identity. Simplifies configuration as in most cases
this is the right thing to do.

Signed-off-by: Timo Teräs <timo.teras@iki.fi>
2015-05-04 13:42:51 +02:00
Timo Teräs a7e4a2d6c2 vici: Add support for ike_sa and child_sa updown notifications
Useful for monitoring and management purposes.

Signed-off-by: Timo Teräs <timo.teras@iki.fi>
2015-05-04 13:38:39 +02:00
Timo Teräs 8d96f90a79 vici: Add function to test if an event should be generated
Useful to avoid generating vici messages if they are not needed and their
generation is heavy operation.

Signed-off-by: Timo Teräs <timo.teras@iki.fi>
2015-05-04 13:35:18 +02:00
Martin Willi f17861dca9 vici: Relicense libvici.h under MIT
libvici currently relies on libstrongswan, and therefore is bound to the GPLv2.
But to allow alternatively licensed reimplementations without copyleft based
on the same interface, we liberate the header.
2015-04-14 17:42:53 +02:00
Martin Willi 161a015782 utils: Use chunk_equals_const() for all cryptographic purposes 2015-04-14 12:02:51 +02:00
Martin Willi 71afe0a556 utils: Use memeq_const() for all cryptographic purposes 2015-04-14 11:53:31 +02:00
Martin Willi d20be3fa28 vici: Defer read/write error reporting after connection entry has been released
If a vici client registered for (control-)log events, but a vici read/write
operation fails, this may result in a deadlock. The attempt to write to the
bus results in a vici log message, which in turn tries to acquire the lock
for the entry currently held.

While a recursive lock could help as well for a single thread, there is still
a risk of inter-thread races if there is more than one thread listening for
events and/or having read/write errors.

We instead log to a local buffer, and write to the bus not before the connection
entry has been released. Additionally, we mark the connection entry as unusable
to avoid writing to the failed socket again, potentially triggering an error
loop.
2015-04-13 15:08:10 +02:00
Tobias Brunner c063b9cfe9 stroke: Properly parse bliss key strength in public key constraint 2015-03-25 13:27:15 +01:00
Tobias Brunner 328db935bb eap-tnc: Free eap-tnc object if IKE_SA not found to get IPs 2015-03-25 13:24:37 +01:00
Tobias Brunner a2ec3b0546 Fixed some typos, courtesy of codespell 2015-03-25 12:00:20 +01:00
Tobias Brunner 70728eb1b6 child-sa: Add a new state to track rekeyed IKEv1 CHILD_SAs
This is needed to handle DELETEs properly, which was previously done via
CHILD_REKEYING, which we don't use anymore since 5c6a62ceb6 as it prevents
reauthentication.
2015-03-25 12:00:20 +01:00
Martin Willi a777155ffe diffie-hellman: Add a bool return value to set_other_public_value() 2015-03-23 17:54:03 +01:00
Martin Willi 42431690e0 diffie-hellman: Add a bool return value to get_my_public_value() 2015-03-23 17:54:03 +01:00
Martin Willi bace1d6479 diffie-hellman: Use bool instead of status_t as get_shared_secret() return value
While such a change is not unproblematic, keeping status_t makes the API
inconsistent once we introduce return values for the public value operations.
2015-03-23 17:54:02 +01:00
Martin Willi 4909612c3b load-tester: Migrate NULL DH implementation to INIT/METHOD macros 2015-03-23 17:54:02 +01:00
Martin Willi fd6cc7f243 attr-sql: Rename sql_attribute_t to attr_sql_provider_t
As the plugin has its origins in the sql plugin, it still uses the naming
scheme for the attribute provider implementation. Rename the class to better
match the naming scheme we use in any other plugin
2015-03-19 11:24:31 +01:00
Björn Schuberg 2e74aa0a91 vici: Add support for python 3 2015-03-18 13:59:15 +01:00
Martin Willi c7e3c5943f vici: Execute python tests during "check" if py.test is available 2015-03-18 13:59:15 +01:00
Björn Schuberg c193b5947a vici: Add test of Packet layer in python library 2015-03-18 13:59:15 +01:00
Björn Schuberg 9b97029a5f vici: Add test of Message (de)serialization in python library 2015-03-18 13:59:15 +01:00
Martin Willi b5d17e55d7 vici: Evaluate Python streamed command results, and raise CommandException 2015-03-18 13:59:14 +01:00
Martin Willi 90c5b48c96 vici: Catch Python GeneratorExit to properly cancel streamed event iteration 2015-03-18 13:59:14 +01:00
Martin Willi 288b654173 vici: Fall back to heap buffer when vararg printing on stack fails
This avoids failures when building log event messages including larger hexdumps.
2015-03-18 13:59:14 +01:00
Martin Willi a47e431ba9 vici: Return a Python generator instead of a list for streamed responses
In addition that it may reduce memory usage and improve performance for large
responses, it returns immediate results. This is important for longer lasting
commands, such as initiate/terminate, where immediate log feedback is preferable
when interactively calling such commands.
2015-03-18 13:59:14 +01:00
Martin Willi 90e16837ba vici: Raise a Python CommandException instead of returning a CommandResult 2015-03-18 13:59:14 +01:00
Martin Willi 871cffa141 vici: Add initial Python egg documentation to README 2015-03-18 13:59:14 +01:00
Martin Willi 305023a27d vici: Use OrderedDict to handle vici responses in Python library
The default Python dictionaries are unordered, but order is important for some
vici trees (for example the order of authentication rounds).
2015-03-18 13:59:14 +01:00
Martin Willi 94bb26fae3 vici: Return authentication rounds with unique names
To simplify handling of authentication rounds in dictionaries/hashtables on the
client side, we assign unique names to each authentication round when listing
connection.
2015-03-18 13:59:14 +01:00
Martin Willi d1ad65f7b2 vici: Rebuild ruby gem on source file changes 2015-03-18 13:59:14 +01:00
Martin Willi fb8b119cfa vici: Use default Unix vici socket if none passed to ruby constructor
While we currently have a static path instead of one generated with Autotools,
this at least is congruent to what we have in the Python library.
2015-03-18 13:59:14 +01:00
Martin Willi 61fb10c8cf vici: Support non-Unix sockets for vici connections using Python 2015-03-18 13:59:14 +01:00
Martin Willi 358793389a vici: Add python egg setuptools building and installation using easy_install
An uninstall target is currently not supported, as there is no trivial way with
either plain setuptools or with easy_install. pip would probably be the best
choice, but we currently don't depend on it.
2015-03-18 13:59:14 +01:00
Martin Willi 1e2ec9f96a vici: Generate a version specific setup.py for setuptools installation 2015-03-18 13:59:14 +01:00
Martin Willi 2c8c52c4e2 vici: Include python package in distribution 2015-03-18 13:59:14 +01:00
Björn Schuberg 163e15a571 vici: Add python package MIT license 2015-03-18 13:59:13 +01:00
Björn Schuberg b269c1a89a vici: Expose Session as a top-level symbol in python package 2015-03-18 13:59:13 +01:00
Björn Schuberg 6a31a0f60c vici: Introduce main API Session class in python package 2015-03-18 13:59:13 +01:00
Björn Schuberg 8c089cddef vici: Add a python vici command execution handler 2015-03-18 13:59:13 +01:00
Björn Schuberg b26e142863 vici: Add vici python protocol handler 2015-03-18 13:59:13 +01:00
Tobias Brunner 6d41927b42 vici: Use %u to print stats returned by mallinfo(3)
Fixes #886.
2015-03-13 15:26:01 +01:00
Tobias Brunner 8286e2050b stroke: Use %u to print stats returned by mallinfo(3)
References #886.
2015-03-13 15:25:53 +01:00
Martin Willi c4b6332211 eap-radius: Increase Acct-Session-ID string buffer
As the startup timestamp needs 10 characters, we only have left 4 characters
for the IKE_SA unique identifier. This is insufficient when having 10000 IKE_SAs
or more established, resulting in non-unique session identifiers.

Fixes #889.
2015-03-13 09:42:03 +01:00
Martin Willi 438318c6c3 ha: Destroy synced IKE_SA if no configuration is found during update 2015-03-10 15:08:58 +01:00
Martin Willi 607eebcfcf libipsec: Pass separate inbound/update flags to the IPsec SA manager
Similar to other kernel interfaces, the libipsec backends uses the flag for
different purposes, and therefore should get separate flags.
2015-03-09 18:18:20 +01:00
Martin Willi 942797a5b5 kernel-interface: Add a separate "update" flag to add_sa()
The current "inbound" flag is used for two purposes: To define the actual
direction of the SA, but also to determine the operation used for SA
installation. If an SPI has been allocated, an update operation is required
instead of an add.

While the inbound flag normally defines the kind of operation required, this
is not necessarily true in all cases. On the HA passive node, we install inbound
SAs without prior SPI allocation.
2015-03-09 18:18:20 +01:00
Martin Willi 8be21ae7ef Revert "ha: Always install the CHILD_SAs with the inbound flag set to FALSE"
While this change results in the correct add/update flag during installation,
it exchanges all other values in the child_sa->install() call. We should pass
the correct flag, but determine the add/update flag by other means.

This reverts commit e722ee5d.
2015-03-09 18:18:20 +01:00
Andreas Steffen 00cd79b678 Make access requestor IP address available to TNC server 2015-03-08 17:17:11 +01:00
Tobias Brunner 31bccf4ba1 stroke: Enable BLISS-based public key constraints 2015-03-04 13:54:11 +01:00
Martin Willi f6b5952b32 stroke: Support public key constraints for EAP methods 2015-03-03 14:08:01 +01:00
Martin Willi 0864a31d13 eap-ttls: Support EAP auth information getter in EAP-TTLS 2015-03-03 14:08:01 +01:00
Martin Willi de2a62cfb6 eap-tls: Support EAP auth information getter in EAP-TLS 2015-03-03 14:08:01 +01:00
Martin Willi 11c14bd2f5 stroke: Serve ca section CA certificates directly, not over central CA set
This makes these CA certificates independent from the purge issued by reread
commands. Certificates loaded by CA sections can be removed through ipsec.conf
update/reread, while CA certificates loaded implicitly from ipsec.d/cacerts
can individually be reread using ipsec rereadcacerts.
2015-03-03 13:50:26 +01:00
Martin Willi aba46b104e stroke: Purge existing CA/AA certificates during reread 2015-03-03 13:50:26 +01:00
Martin Willi d69cf39bb4 stroke: Use separate credential sets for CA/AA certificates 2015-03-03 13:50:26 +01:00
Martin Willi 845d36969e stroke: Refactor load_certdir function 2015-03-03 13:50:26 +01:00
Martin Willi 1549a98493 vici: Don't use a default rand_time larger than half of rekey/reauth_time 2015-03-03 13:49:14 +01:00
Martin Willi f6511e36b5 vici: If a IKE reauth_time is configured, disable the default rekey_time 2015-03-03 13:49:14 +01:00
Martin Willi 1151c9922a vici: Support ruby gem out-of-tree builds
Referencing $(srcdir) in the gemspec is not really an option, as "gem build"
includes the full path in the gem, so we need to build in $(srcdir). As there
does not seem to be a way to control the output of "gem build", we manually
move the gem to $(builddir) in OOT builds.
2015-02-27 11:44:20 +01:00
Martin Willi e722ee5df8 ha: Always install the CHILD_SAs with the inbound flag set to FALSE
The inbound flag is used to determine if we have to install an update or a new
SA in the kernel. As we do not have allocated SPIs and therefore can't update
an existing SA in the HA plugin, always set the flag to FALSE.

Before 698ed656 we had extra logic for that case, but handling it directly in
the HA plugin is simpler.
2015-02-27 10:58:32 +01:00
Tobias Brunner 98632af672 forecast: Explicitly cast sockaddr to fix compiler warning
On Travis we compile with -Werror.
2015-02-23 12:35:50 +01:00
Tobias Brunner 89b60e9fd7 configure: Use pkg-config to detect libiptc used by connmark/forecast
This ensures the library is available.  On Debian/Ubuntu it is a dynamic
library provided by the iptables-dev package.
2015-02-23 12:35:28 +01:00
Martin Willi e5ad2e6614 forecast: Add the broadcast/multicast forwarding plugin called forecast 2015-02-20 16:34:55 +01:00
Martin Willi b8973b2661 connmark: Add CONNMARK rules to select correct output SA based on conntrack
Currently supports transport mode connections using IPv4 only, and requires
a unique mark configured on the connection.

To select the correct outbound SA when multiple connections match (i.e.
multiple peers connected from the same IP address / NAT router) marks must be
configured. This mark should usually be unique, which can be configured in
ipsec.conf using mark=0xffffffff.

The plugin inserts CONNMARK netfilter target rules: Any peer-initiated flow
is tagged with the assigned mark as connmark. On the return path, the mark
gets restored from the conntrack entry to select the correct outbound SA.
2015-02-20 16:34:53 +01:00
Martin Willi 8c2290dcf9 connmark: Add a plugin stub 2015-02-20 15:33:59 +01:00
Martin Willi 45ab5b0fca load-tester: Support initiating XAuth authentication
As with other configuration backends, XAuth is activated with a two round
client authentication using pubkey and xauth. In load-tester, this is configured
with initiator_auth=pubkey|xauth.

Fixes #835.
2015-02-20 14:04:23 +01:00
Martin Willi 22e6a06b8c mem-pool: Pass the remote IKE address, to re-acquire() an address during reauth
With make-before-break IKEv2 re-authentication, virtual IP addresses must be
assigned overlapping to the same peer. With the remote IKE address, the backend
can detect re-authentication attempts by comparing the remote host address and
port. This allows proper reassignment of the virtual IP if it is re-requested.

This change removes the mem-pool.reassign_online option, as it is obsolete now.
IPs get automatically reassigned if a peer re-requests the same address, and
additionally connects from the same address and port.
2015-02-20 13:34:57 +01:00
Martin Willi b9be25ea39 attribute-handler: Pass full IKE_SA to handler backends 2015-02-20 13:34:56 +01:00
Martin Willi bc9ded9dbf attribute-provider: Pass full IKE_SA to provider backends 2015-02-20 13:34:56 +01:00
Martin Willi 124490a8e0 unit-tester: Drop the old unit-tester libcharon plugin
While it has some tests that we don't directly cover with the new unit tests,
most of them require special infrastructure and therefore have not been used
for a long time.
2015-02-20 13:34:55 +01:00
Martin Willi 751363275f attributes: Move the configuration attributes framework to libcharon 2015-02-20 13:34:55 +01:00
Martin Willi 82e4b83378 attr-sql: Move plugin to libcharon 2015-02-20 13:34:55 +01:00
Martin Willi c6c7f97a1d attr: Move plugin to libcharon 2015-02-20 13:34:54 +01:00
Martin Willi 6bfd1fbb71 resolve: Move plugin back to libcharon
Since pluto is gone, all existing users build upon libcharon.
2015-02-20 13:34:54 +01:00
Martin Willi 246c969d8b ike: Consistently log CHILD_SAs with their unique_id instead of their reqid 2015-02-20 13:34:52 +01:00
Martin Willi fa42367ca1 unity: Reference IKE_SAs by the IKEv1 COOKIEs, improving lookup performance
When handling thousands of IKE_SAs, the unique ID based lookup is rather slow,
as we have no indexing.
2015-02-20 13:34:52 +01:00
Martin Willi db80d0d2da ike-sa-manager: Remove IKE_SA checkout by CHILD_SA reqid 2015-02-20 13:34:51 +01:00
Martin Willi f81a949748 kernel-interface: Raise expires with a proto/SPI/dst tuple instead of reqid 2015-02-20 13:34:50 +01:00
Martin Willi 971a91685d controller: Use the CHILD_SA unique_id to terminate CHILD_SAs 2015-02-20 13:34:50 +01:00
Martin Willi 53cf7fa60a stroke: List CHILD_SA unique ID as the primary identifier, but print reqid, too 2015-02-20 13:34:50 +01:00
Martin Willi adc1885bf7 vici: Include the CHILD_SA unique ID in list-sa event 2015-02-20 13:34:50 +01:00
Martin Willi 85b238887d child-sa: Replace reqid based marks by "unique" marks
As we now use the same reqid for multiple CHILD_SAs with the same selectors,
having marks based on the reqid makes not that much sense anymore. Instead we
use unique marks that use a custom identifier. This identifier is reused during
rekeying, keeping the marks constant for any rule relying on it (for example
installed by updown).

This also simplifies handling of reqid allocation, as we do not have to query
the marks that is not yet assigned for an unknown reqid.
2015-02-20 13:34:49 +01:00
Martin Willi d05d85fe65 kernel-interface: Pass full list of traffic selectors to add_sa()
While we can handle the first selector only in BEET mode in kernel-netlink,
passing the full list gives the backend more flexibility how to handle this
information.
2015-02-20 13:34:47 +01:00
Martin Willi fd9417607c libipsec: Remove unused src/dst_ts parameters from ipsec_sa_mgr_t.add_sa() 2015-02-20 13:34:47 +01:00
Martin Willi 2a1c9e20bd kernel-interface: Remove reqid parameter from get_spi/get_cpi() methods
The reqid is not strictly required, as we set the reqid with the update
call when installing the negotiated SA.

If we don't need a reqid at this stage, we can later allocate the reqid in
the kernel backend once the SA parameters have been fully negotaited. This
allows us to assign the same reqid for the same selectors to avoid conflicts
on backends this is necessary.
2015-02-20 13:34:32 +01:00
Martin Willi 3e779ff555 libipsec: Remove unused reqid parameter from ipsec_sa_mgr_t.get_spi() 2015-02-19 15:42:22 +01:00
Thomas Egerer 875f7be5fc ha: Perform child rekeying outside of CHILD_SA enumerator
When rekey_child_sa is called while enumerating the children of an IKE_SA, and
the child to be rekeyed is redundant a QUICK_DELETE task is queued instead of a
QUICK_MODE task. This alters the IKE_SA's list of children (ike_sa_t::child_sas)
invalidating the current element of the child_sa_enumerator. The enumerate
function of linked_list_t will then advance to an element with unpredictable
contents most likely resulting in an segmentation violation. A similar behavior
should be observed when delete_child_sa is called.

This patch creates a list of protocol/spi values while holding the
child_sa_enumerator and performs the rekeying (deletion of redundant) chlidren
after releasing the enumerator.

Signed-off-by: Thomas Egerer <thomas.egerer@secunet.com>
2015-02-19 10:58:40 +01:00
Martin Willi c8992ea6d2 vici: Fix ruby gem author email 2015-01-22 15:00:45 +01:00
Martin Willi 96df0a0ebd vici: Fix README example encoding element type values, off by one
While we fixed the wrong values in the description with d39e04b5, the example
values are still off by one.

Fixes #828.
2015-01-21 09:31:24 +01:00
Tobias Brunner 3000f6aada Fixed some typos, courtesy of codespell 2014-12-15 17:11:14 +01:00
Martin Willi 6855b8b36b vici: Use silent builder destroy function in vici_free_req() 2014-12-12 10:23:59 +01:00
Martin Willi c04ee43af7 vici: Add a destroy method to builder, allowing cancellation without error
When cancelling a builder, finalize throws an error which we might prefer
to avoid.
2014-12-12 10:23:59 +01:00
Martin Willi 971ef077ce eap-radius: Use the single-server legacy server options as fallback 2014-12-12 10:23:59 +01:00
Tobias Brunner 02df52fd2b unity: Only do narrowing of responder's TS if we received 0.0.0.0/0
iOS and Mac OS X clients establish individual IPsec SAs for the traffic
selectors received in Split-Include attributes (might have been different
in earlier releases).  If we return 0.0.0.0/0 as TSr that either results
in a bunch of Quick Mode exchanges (for each TS), or with the latest
client releases an error notify (ATTRIBUTES_NOT_SUPPORTED).
We also can't install the IPsec SA with all configured subnets as that
would cause conflicts if the client later negotiates SAs for other subnets,
which iOS 8 does based on traffic to such subnets.

For Shrew and the Cisco client, which propose 0.0.0.0/0, we still need to
override the narrowed TS with 0.0.0.0/0, as they otherwise won't accept
the Quick Mode response.  Likewise, we also have to narrow the TS before
installing the IPsec SAs and policies.

So we basically have to follow the client's proposal and only modify TSr
if we received 0.0.0.0/0.  Since we don't get the original TS in the
narrow hook we handle the inbound QM messages and make note of IKE_SAs on
which we received a TSr of 0.0.0.0/0.

Fixes #737.
2014-12-05 10:12:46 +01:00
Martin Willi e1a448314f kernel-wfp: Install outbound ALE connect rules for IPsec
Similar to the inbound rules, the ALE filter processes IP-in-IP packets for
outbound tunnel mode traffic. When using an outbound default-drop policy,
Windows does not allow connection initiation without these explicit rules.
2014-12-04 11:10:48 +01:00
Martin Willi a8142a17cf kernel-wfp: Install inbound ALE IP-in-IP filters
When processing inbound tunnel mode packets, Windows decrypts packets and
filters them as IP-in-IP packets. We therefore require an ALE filter that
calls the FWPM_CALLOUT_IPSEC_INBOUND_TUNNEL_ALE_ACCEPT callout to allow them
when using a default-drop policy.

Without these rules, any outbound packet created an ALE state that allows
inbound packets as well. Processing inbound packets without any outbound
traffic fails without these rules.
2014-12-04 11:10:48 +01:00
Martin Willi 070461b70d kernel-wfp: Add missing IPsec sublayer GUIDs 2014-12-04 11:10:48 +01:00
Martin Willi a21338a43e kernel-wfp: Define IPsec related ALE layers and callout GUIDs 2014-12-04 11:10:48 +01:00
Martin Willi 4d48dfd6a3 kernel-wfp: Fix logging of MM/QM/EM NetEvent failures 2014-12-04 11:10:48 +01:00
Martin Willi b164cc8e15 vici: Make sure to send/recv all requested bytes over socket
As the underlying C functions, send/recv on ruby sockets are not guaranteed
to send/recv all requested bytes. Use wrapper functions to make sure we get
all bytes needed.
2014-12-04 10:42:22 +01:00
Andreas Steffen b6bb32e658 Implemented full BLISS support for IKEv2 public key authentication and the pki tool 2014-11-29 14:51:18 +01:00
Martin Willi eeaa6f9b1a kernel-libipsec: Use poll(2) instead of select 2014-11-21 12:02:07 +01:00
Martin Willi ed247660e8 socket-default: Use round-robin selection of sockets to read from
If multiple sockets are ready, we previously preferred the IPv4 non-NAT socket
over others. To handle all with equal priority, use a round-robin selection.
2014-11-21 12:02:07 +01:00
Martin Willi ce13ba62cc socket-default: Use poll(2) instead of select
It is not only simpler, but also allows the use of arbitrary high fd numbers,
which silently fails with select().
2014-11-21 12:02:07 +01:00
Tobias Brunner 5e92534313 vici: Add support for address range definitions of pools 2014-10-30 12:32:45 +01:00
Tobias Brunner c355e2b2c7 stroke: Add support for address range definitions of in-memory pools 2014-10-30 12:32:45 +01:00
Martin Willi 4736ba0657 updown: Explicitly pass caller PATH to updown script
When invoking /bin/sh, its default PATH is used. On some systems, that does
not include the PATH where the ipsec script is installed, as charon is invoked
with a custom PATH. Explicitly setting the PATH of charon should fix this
case, properly invoking the (default) updown script.

Fixes #745.
2014-10-22 14:53:36 +02:00
Martin Willi bdfbecb3e6 vici: Return default value for get_int() if message value is empty string
This is the behavior of some strtol() implementations, and it makes sense,
so force it.
2014-10-14 16:33:10 +02:00
Tobias Brunner 283229bcb7 vici: Add vici.gemspec.in and vici.rb to distribution 2014-10-14 11:26:41 +02:00
Martin Willi d4d85135c5 vici: Cancel processor before calling library_deinit()
For non-direct libstrongswan users, the deinitialization segfaults because
of the missing worker thread cancellation.
2014-10-10 11:42:18 +02:00
Martin Willi 3db58e837c vici: Reduce debug level during thread spawning
We want to avoid libvici users to get a cluttered stderr for no real error.
2014-10-10 11:42:18 +02:00
Martin Willi 046b547a37 vici: Don't include-depend on libstrongswan for boolean types
As we want to avoid the libstrongswan include dependencies for libvici, avoid
the use of the bool type. Unfortunately this change may break the ABI for
vici_dump(). As this function is mostly for debugging purposes, we do it
nonetheless; my apologies if somebody already relies on the ABI stability of
that function.
2014-10-10 11:42:18 +02:00
Martin Willi 6f55149335 vici: Document the ruby gem and add some simple examples 2014-10-10 11:42:18 +02:00
Martin Willi dccb2c6eba vici: Add some simple libvici examples to the README 2014-10-10 11:42:18 +02:00
Martin Willi 56f17733c9 vici: Document the available vici command and event messages 2014-10-10 11:42:18 +02:00
Martin Willi f684be6583 vici: Use "gem"-assisted vici ruby gem building and installation 2014-10-10 11:42:17 +02:00
Martin Willi 1038d96537 vici: Add a ruby gem providing a native vici interface 2014-10-10 11:42:17 +02:00
Martin Willi 94d9398202 vici: Return a success result for the clear-creds command
Even if the command actually can't fail, this looks more aligned to similar
commands.
2014-10-10 11:42:17 +02:00
Martin Willi d39e04b557 vici: Fix message encoding type values in documentation 2014-10-10 11:42:17 +02:00
Tobias Brunner 3633b80147 eap-radius: Add option to set interval for interim accounting updates
Any interval returned by the RADIUS server in the Access-Accept message
overrides the configured interval.  But it might be useful if RADIUS is
only used for accounting.
2014-10-10 09:51:13 +02:00
Tobias Brunner f00a9c1715 packet: Define a global default maximum size for IKE packets 2014-10-10 09:32:42 +02:00
Martin Willi b2c1973ffb ext-auth: Add an ext-auth plugin invoking an external authorization script
Original patch courtesy of Vyronas Tsingaras.
2014-10-06 18:30:46 +02:00
Martin Willi 6890bdc7a0 updown: Use process abstraction to invoke updown script 2014-10-06 18:24:39 +02:00
Shea Levy 213e02b872 stroke: Allow specifying the ipsec.secrets location in strongswan.conf 2014-10-02 14:31:00 +02:00
Martin Willi 455e213cb0 vici: Add a command to reload strongswan.conf 2014-09-22 13:44:27 +02:00
Tobias Brunner de622eb1f9 eap-radius: Forward Cisco and Microsoft specific DNS/NBNS attributes
Fixes #677.
2014-09-09 10:56:16 +02:00
Martin Willi e1c7e1bc1f ha: Don't adopt IKEv1 children when building without IKEv1 support
The adopt_children_job_create() function is not available when IKEv1 support
is disabled. Fixes uncommon builds using --enable-ha --disable-ikev1.

Fixes #690.
2014-08-28 10:19:57 +02:00
Martin Willi cfdc620a3f unity: Do not bump TS to 0.0.0.0/0 as initiator when no Split-Include received
When having the unity plugin enabled and both peers send the Unity Vendor ID,
we proposed 0.0.0.0/0 as traffic selector, even if no Split-Include has been
received on the SA. This can break compatibility with some responders, as
they don't narrow the TS themselves, but expect the configured TS.
2014-08-25 10:02:44 +02:00
Tobias Brunner a45ba880c8 unity: Handle narrowing according to roles in the IKE_SA
Since the narrow hook types reflect the roles in the Quick Mode exchange
the plugin behaved incorrectly if the server initiated the CHILD_SA
rekeying.
2014-08-25 09:59:43 +02:00
Tobias Brunner 44870e5313 xauth-pam: Add workaround for null-terminated passwords
Fixes #631.
2014-07-07 11:14:02 +02:00
Tobias Brunner 28a79e4e0c stroke: Don't log unspecified options of conn and ca sections 2014-06-30 13:29:26 +02:00
Tobias Brunner 3b16c2b55d libvici: Add missing argument to Doxygen comment 2014-06-30 13:16:16 +02:00
Tobias Brunner ed01c1afff Fixed some typos 2014-06-30 13:16:16 +02:00
Tobias Brunner 4431e1e04d updown: Force subnet address to be numeric 2014-06-25 16:17:15 +02:00
Martin Willi fc8ca5f2f2 eap-radius: Increase buffer for accounting attributes to maximum attribute size
Fixes #624.
2014-06-25 13:11:34 +02:00
Tobias Brunner 8661c56d38 vici: Install libvici in ipseclibdir like we do with other libraries 2014-06-19 14:42:07 +02:00
Tobias Brunner c005073d0b kernel-interface: Add destination prefix to get_nexthop()
This allows to determine the next hop to reach a subnet, for instance, when
installing routes for shunt policies.
2014-06-19 14:33:40 +02:00
Martin Willi 9f950af17a load-tester: Add a crl option to include a CRL uri in generated certificates 2014-06-19 10:48:27 +02:00
Martin Willi 5885ec2a27 vici: Support memory stats without leak-detective on Windows 2014-06-17 17:55:45 +02:00
Martin Willi 65689ce76a vici: Add a stats command returning various daemon infos and statistics 2014-06-17 17:55:45 +02:00
Martin Willi d73a46171d vici: Support a replay_window CHILD_SA option 2014-06-17 16:41:31 +02:00
Martin Willi d5367d2262 starter: Add a replay_window connection option 2014-06-17 16:41:31 +02:00
Martin Willi 30c009c2fe kernel-interface: Add a replay_window parameter to add_sa() 2014-06-17 16:41:30 +02:00
Martin Willi 2d846c2035 socket-win: Use non-overlapped I/O and socket event selection
The use of overlapped I/O was incorrect, as we passed stack based buffers, but
did not cancel/wait for pending completion on all sockets. Our receive-from-all
socket interface is actually tricky to implement using overlapped I/O. Switch
to WSAEventSelect() event management, which can be canceled properly while
working in a select()-like way.
2014-06-17 15:19:25 +02:00
Andreas Steffen dacb75f5c0 Split swanctl --raw mode into single-line and --pretty mode 2014-06-14 15:40:22 +02:00
Martin Willi cab59c73fc windows: Use WINAPI call convention for Windows API callbacks
For x86_64 it does not actually matter, but for i686 builds the call convention
is different with WINAPI.
2014-06-06 16:28:28 +02:00
Martin Willi 4b9848a2cc kernel-wfp: Include Windows header patch for MinGW 4.8.1 2014-06-04 16:32:12 +02:00
Martin Willi 75afbeee21 kernel-wfp: Clone acquire traffic selectors only if they exist 2014-06-04 16:32:11 +02:00
Martin Willi 78bde29a7c kernel-wfp: Install routes for trap policies 2014-06-04 16:32:11 +02:00