0
0
mirror of https://github.com/OpenVPN/openvpn3.git synced 2024-09-20 12:12:15 +02:00
Commit Graph

3255 Commits

Author SHA1 Message Date
Heiko Hund
84c8b4aca6 convert CryptoAlgs::algs array to std::array
Remove constexpr in preparation for making it possible to modify the
data channel ciphers. Use std::array so the SIZE can be specified.

Remove the unused CryptoAlgs:get_index_ptr() function.

Signed-off-by: Heiko Hund <heiko@openvpn.net>
2021-06-17 20:32:21 +02:00
Heiko Hund
d28b241380 combine the two CryptoAlgs::name functions
Signed-off-by: Heiko Hund <heiko@openvpn.net>
2021-06-17 20:16:51 +02:00
David Sommerseth
6530f876c8 OpenVPN 3 Core library version 3.6.3
Jira: VULREP-15
 URL: https://openvpn.atlassian.net/browse/VULREP-15
 -----BEGIN PGP SIGNATURE-----
 
 iQJHBAABCAAxFiEEgDq5E1p1aZrNLFFkhs+UTJZx/fIFAmDHst8THGRhdmlkc0Bv
 cGVudnBuLm5ldAAKCRCGz5RMlnH98pEaD/9VaUW4M9q7hpwzoCDqktrdaUzpRgvx
 hCYLSzAuIkAgPO1UXQTL6DWazTAI+vUAfuV+a4dgPmSs52qQ3K1UNUtuuQLurBiQ
 AopeNYY2VVZeVhAzDQDQTPsqCLn0Bigy4m4quJZBVOir+hGoSNnK7XTllNDCc8Li
 6PBIzM408B+6ARISxmxIdqlpsYwthYhRSPRPGTFuYqrbaRC85seHeRUTHTTQ/LVi
 uoAikYHm/IuY/CCNQoYX26M9FAtLA6zKWpPtJ4RzB+Muw8kToT5tpsKVZvjgwvN7
 YvcipYeALqQTf/WX7q8BKF24XzOYaZ1DHEuS8H3KLx66ESXHWZlfsb0uoj0Nv0AV
 HDloyhK5W7l+IfNmW4ZrPm2YZnvemLWYJwPQMZqfVkUiqqBmJIvidoAdiyWJUu5r
 YPkwidx3pjfoAqgWUZWYgEuW9hBkTgcj67HpyrCUvdDMby7yf9y+KKEu1hvVnYFw
 Mwq+UbEGagNBkQns5xAMCjhyIDaJhcXFmvIj7p3t4uTmotX2iybV3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

OpenVPN 3 Core library version 3.6.3

Signed-off-by: David Sommerseth <davids@openvpn.net>
2021-06-14 21:58:27 +02:00
David Sommerseth
d06e216e8c
Finalizing OpenVPN 3 Core library release v3.6.3
This is release fixes an issue with the building of the OpenSSL
dependency on Windows, where the OpenSSL library could load an
OpenSSL configuration file, resulting in loading external third-party
libraries.

Signed-off-by: David Sommerseth <davids@openvpn.net>
2021-06-14 20:07:08 +02:00
Lev Stipakov
f746588d45
vcpkg: add openssl port with no-autoload-conf
In default configuration OpenSSL loads config from
certain location on disk, which may pose a security risk.

There is "no-autoload-config" config option for OpenSSL
which disables this functionality:

   https://github.com/openssl/openssl/pull/5959

however it is not "exported" to vcpkg.

This adds openssl port overlay which sets "no-autoload-config"
config option. Here is the diff:

diff --git a/ports/openssl/windows/portfile.cmake
b/ports/openssl/windows/portfile.cmake
index 7a3bf08ed..c873eb756 100644
--- a/ports/openssl/windows/portfile.cmake
+++ b/ports/openssl/windows/portfile.cmake
@@ -21,6 +21,7 @@ set(CONFIGURE_OPTIONS
     enable-capieng
     no-ssl2
     no-tests
+    no-autoload-config
     -utf-8
     ${OPENSSL_SHARED}
)

There is also corresponsing PR to vcpkg:

  https://github.com/microsoft/vcpkg/pull/18389

When above PR is merged, this port overlay can be removed.

Signed-off-by: Lev Stipakov <lev@openvpn.net>
2021-06-11 13:01:09 +03:00
Lev Stipakov
7d33caef16
agent mac: Update license header
Signed-off-by: Lev Stipakov <lev@openvpn.net>
2021-06-10 23:27:27 +02:00
Lev Stipakov
d31620d0c6
agent mac: move from common
Windows agent has been moved from common to core,
so for consistency move mac agent too.

Since agent and agent-enabled client depend on jsoncpp,
also move jsoncpp build scripts.

Signed-off-by: Lev Stipakov <lev@openvpn.net>
2021-06-10 23:06:24 +02:00
Lev Stipakov
0ad1bfecc0
mac agent: customize agent name
We want PT agent and Connect agent co-exist,
so make agent name customizable at build time.

Signed-off-by: Lev Stipakov <lev@openvpn.net>
2021-06-10 23:06:23 +02:00
Lev Stipakov
f9bf96101d
mac agent: implement /add-bypass-route method
This method is called to enable connectivity to a different remote
when force-tunneling is used and current VPN connection is broken.

Signed-off-by: Lev Stipakov <lev@openvpn.net>
2021-06-10 23:06:22 +02:00
Lev Stipakov
c6d1f9465f
agent mac: fail-safe tun close
This adds a watchdog thread, which wakes up when client
process exits and closes tun. Watchdog is removed
when agent process exits.

To monitor process exit, we use kqueue's NOTE_EXIT event,
to interrupt waiting on graceful exit we use self-pipe trick.

Signed-off-by: Lev Stipakov <lev@openvpn.net>
2021-06-10 23:06:21 +02:00
Lev Stipakov
76d6a966cd
Fix core build with agent support for macOS
Signed-off-by: Lev Stipakov <lev@openvpn.net>
2021-06-10 23:06:20 +02:00
James Yonan
adb0cfe792
copyright: updated to 2017
Signed-off-by: James Yonan <james@openvpn.net>
2021-06-10 23:06:19 +02:00
James Yonan
45ec790c25
license : this branch (common) is proprietary, so remove all GPL headers.
Signed-off-by: James Yonan <james@openvpn.net>
2021-06-10 23:06:19 +02:00
James Yonan
d141ed63bf
httpcliset : minor refactor of new_request_synchronous() which removes SyncPersistState as a parameter (replacing with sps boolean) and moves it to private area of TransactionSet. 2021-06-10 23:06:18 +02:00
James Yonan
969bb36241
copyright : updated to 2016 2021-06-10 23:06:17 +02:00
James Yonan
99026b1df8
Mac agent : fixed a regression caused by this commit:
httpcliset : when preserve_http_state is false, close out
  the HTTPStateContainer before calling completion callback,
  so as to improve reentrancy-safety if completion callback
  tries to queue a new request.

The problem with the above commit is that it breaks
the interprocess socket-passing technique in
UnixCommandAgent::establish(), requiring that we deploy a
WS::ClientSet::SyncPersistState object to extend the
lifetime of the HTTP connection state.
2021-06-10 23:06:16 +02:00
James Yonan
aef8cf368c
For jsoncpp usage, rename deprecated misspelled method name:
getFormatedErrorMessages -> getFormattedErrorMessages
2021-06-10 23:06:15 +02:00
James Yonan
128adb83ec
Added Mac OpenVPN Agent client and service for processing tun setup using split-privilege model.
Added build script in mac/buildcli to build both client and
agent.
2021-06-10 23:06:14 +02:00
Arne Schwabe
af93c1879b
Fix multiple instances of comparison of signed with unsigned 2021-06-10 23:06:13 +02:00
James Yonan
5f9c70c704
Use openvpn::strerror_str() instead of std::strerror().
std::strerror() doesn't claim to be thread-safe, so
add openvpn::strerror_str() which is thread-safe by
virtue of the fact that it backs to strerror_r().

Signed-off-by: James Yonan <james@openvpn.net>
2021-06-10 23:06:12 +02:00
James Yonan
eaa24e939e
copyright: updated to 2017
Signed-off-by: James Yonan <james@openvpn.net>
2021-06-10 23:06:11 +02:00
James Yonan
afb7c39dca
license : this branch (common) is proprietary, so remove all GPL headers.
Signed-off-by: James Yonan <james@openvpn.net>
2021-06-10 23:06:11 +02:00
James Yonan
6e157dd76e
copyright : updated to 2016 2021-06-10 23:06:10 +02:00
James Yonan
ba54b90b39
Added class XmitFD for transmitting/receiving file descriptors over a unix domain socket (because Asio doesn't directly support this).
Also added a client/server test in test/xmitfd.
2021-06-10 23:06:09 +02:00
Lev Stipakov
8cae2a770b
asio: support for version 1.18
ASIO 1.18 enabled UNIX domain sockets on Windows,
which breaks our code, since we use Linux-specific
API to work with sockets.

Fix by disabling UNIX domain (local in ASIO terminology)
sockets on Windows.

Bump ASIO version to 1.18.

Signed-off-by: Lev Stipakov <lev@openvpn.net>
2021-06-10 22:43:26 +02:00
Heiko Hund
dee1b625c3
fix occ proto strings
There are two things addressed here.

 1) regression introduced by commit f1bdbe5088:
    Since TCP is not an alias for TCPv4 anymore the occ string
    contained TCP_CLIENT as proto, which is not understood by peers.
    Since only the "v4" version of the proto strings are understood
    the code was simplified.
 2) wrong occ proto string for TCP servers:
    Servers were also sending out the proto with client suffix. Fixed
    by passing in a boolean and returning the server version if true.

Also renamed the method to reflect better what it is used for.

Signed-off-by: Heiko Hund <heiko@openvpn.net>
2021-06-10 22:40:18 +02:00
Antonio Quartulli
cbbe9d1768
ovpndcocli.hpp: implement SessionStats::DCOTransportSource
The DCO component now implements the SessionStats::DCOTransportSource interface.
This interface is already used by ovpncli.cpp to retrieve the peer stats
from DCO.

With this patch, also the OvpnDcoCli object can be used to retrieve the
peer stats from kernel space.

Signed-off-by: Antonio Quartulli <antonio@openvpn.net>
2021-06-09 17:23:03 +02:00
Antonio Quartulli
73664bb85a
ovpndcocli.hpp: properly parse and store peer statistics
After invoking the get_peer() API, let the DCOClient component
extract the statistics and store them locally.

Signed-off-by: Antonio Quartulli <antonio@openvpn.net>
2021-06-09 17:23:03 +02:00
Antonio Quartulli
07b85394c8
genl.hpp: implement get_peer() API to retrieve peer data from DCO
The get_peer API allows userspace to retrieve the data about a specific
peer. Implement the userspace counterpart so that OpenVPN can retrieve
the peer data when it needs to updte the client statistics.

Signed-off-by: Antonio Quartulli <antonio@openvpn.net>
2021-06-09 17:23:03 +02:00
Antonio Quartulli
3bd5b40d6d
TunBuilder: add tun_builder_dco_get_peer() method
Allow external implementations to be informed when to
retrieve the peer data via DCO.

Signed-off-by: Antonio Quartulli <antonio@openvpn.net>
2021-06-08 01:42:37 +02:00
Antonio Quartulli
4fa0d6763e
ovpncli.cpp: update stats with DCO data before querying them
Signed-off-by: Antonio Quartulli <antonio@openvpn.net>
2021-06-08 01:42:37 +02:00
Antonio Quartulli
0f264b71e4
genl.hpp: avoid cast for return value of lambda expression
Explicitly specify the return type of lambda expressions
so that we can avoid casting the return value.

Signed-off-by: Antonio Quartulli <antonio@openvpn.net>
2021-06-08 01:42:37 +02:00
David Sommerseth
b4663454b2
openssl: Fix include file issues with OpenSSL compat.hpp
The compat.hpp header had issues when building on Debian 9, where it
complained about SSL_CTX_set1_curves() not being defined.  This was
due to openssl/ssl.h not being included inside the #if block where the
compat wrapper was defined.

Signed-off-by: David Sommerseth <davids@openvpn.net>
2021-06-03 19:09:17 +02:00
James Yonan
0670c1606b proto test: retry up to 5 times to prevent errors from blowing up the test
By default, the proto test uses a relatively small
handshake_window to intentionally trigger
KEV_NEGOTIATE_ERROR, so that we can test mid-session error
recovery.  However if KEV_NEGOTIATE_ERROR is hit on the
first primary key (i.e. first KeyContext with key_id == 0),
it is fatal to the session and will trigger a disconnect.

This change introduces a retry to prevent this
low-probability, false-positive corner case from
blowing up the test.

Signed-off-by: James Yonan <james@openvpn.net>
2021-05-31 23:21:30 -06:00
James Yonan
e9fef02f52 unit tests: modified JY_ASSERT macros to use "do { ... } while (0)" syntax for better statement semantics
Signed-off-by: James Yonan <james@openvpn.net>
2021-05-31 13:34:44 -06:00
James Yonan
95b277ca58 TCPTransport::LinkCommon: updated initialization of halt to use C++11 member initializer
Signed-off-by: James Yonan <james@openvpn.net>
2021-05-31 13:34:44 -06:00
James Yonan
38ed30d4ad TCPTransport::LinkCommon: updated comment to reflect the fact that non-raw mode can be used for DNS as well as OpenVPN protocol over TCP
Signed-off-by: James Yonan <james@openvpn.net>
2021-05-31 13:34:44 -06:00
James Yonan
af4776f4a7 string: minor change of assumption about std::string::reserve() method
When copying strings, it appears sufficient to reserve()
space in the destination string equal to the length() of
the source string.

Signed-off-by: James Yonan <james@openvpn.net>
2021-05-31 13:34:44 -06:00
Heiko Hund
c88a5a1874 make class Signal d'tor noexcept(false)
If sigaction() fails the d'tor will throw a signal_error. However,
looking at the reasons sigaction() can fail (i.e. the sorce of the
exception), it is safe to assume things are wrong enough to terminate().

So, marking the d'tor potentially-throwing is the right thing to do here.

Signed-off-by: Heiko Hund <heiko@openvpn.net>
2021-05-27 17:27:51 +02:00
Heiko Hund
51bd6d4201 use DCO opportunistically
If DCO support is compiled in, detect if it is available (i.e. Windows driver
or Linux kernel module is loaded) and then use it, if it is.

This changes the default configuration for DCO from off to on, so users of
the library need to set ClientAPI::Config::dco to false in case they do not
want to use dco for a connection.

The change is also reflected in the reference client "ovpncli". If DCO is
enabled in a build, it will detect and use it. The previously available
"ovpncliovpndco" and "ovpncliovpndcowin" clients have thus been removed.

Signed-off-by: Heiko Hund <heiko@openvpn.net>
2021-05-27 17:20:24 +02:00
Lev Stipakov
0b02023a53
agent win: remove __DATE__ and __TIME__
This is required for deterministic builds.

Signed-off-by: Lev Stipakov <lev@openvpn.net>
2021-05-27 12:14:24 +03:00
Antonio Quartulli
99f9049d1f
sitnl: move large memory block from stack to heap
It is not recommended to allocate big blocks on the stack, however
the sitnl sending routine is stacking a 16KB large buffer.

Allocate it using heap memory and avoid using the stack.

Addresses-Coverity: ("Large stack use")
Signed-off-by: Antonio Quartulli <antonio@openvpn.net>
2021-05-24 21:19:57 +02:00
Antonio Quartulli
8d49172321
sitnl: properly assign prefix len of resulting route
When cycling through matching routes, the most specific (i.e. having the
longest prefix) should be selected. To achieve that, we must store the
prefix len of any selected route, so that it can be compared with the
next (if more than one is found).

As result, we return the prefix len of the matching route in the
route_res_t object.

Addresses-Coverity: ("Self assignment")
Signed-off-by: Antonio Quartulli <antonio@openvpn.net>
2021-05-24 18:34:48 +02:00
Arne Schwabe
fce979ec99 Add missing OpenSSL includes in openssl/compat.hpp
Add missing includes that allow the file to be included without having to
include them before including compat.hpp

Signed-off-by: Arne Schwabe <arne@openvpn.net>
2021-05-23 01:52:10 +02:00
Heiko Hund
4a0daf7827 fix signedness of variable
AltRoutingShimFactory::connect_timeout() returns an int, not an unsigned.
With that the if condition below makes sense again.

Signed-off-by: Heiko Hund <heiko@openvpn.net>
2021-05-19 03:30:25 +02:00
Heiko Hund
f3133090a6 remove unnecessary const from return type qualifier
Adding const here serves no purpose, since the return type is
a rvalue and cannot be modified anyways.

Signed-off-by: Heiko Hund <heiko@openvpn.net>
2021-05-18 06:13:31 +02:00
Heiko Hund
5787dc8835 remove unnecessary addition
match_ptr is not used after this statement. It is then overridden by a new
value in both surrounding loops in case there's more iterations. Thus the
incremented value is not inspected in any case.

Signed-off-by: Heiko Hund <heiko@openvpn.net>
2021-05-18 06:13:31 +02:00
Heiko Hund
5f3f4e82ae fix potential division by zero in compression test
Signed-off-by: Heiko Hund <heiko@openvpn.net>
2021-05-18 06:13:31 +02:00
Heiko Hund
5a85715946 fix potential nullptr deref with redirect-gateway
Signed-off-by: Heiko Hund <heiko@openvpn.net>
2021-05-18 06:13:31 +02:00
Heiko Hund
f228921d71 init several netlink related class members
Signed-off-by: Heiko Hund <heiko@openvpn.net>
2021-05-18 06:13:31 +02:00