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

4093 Commits

Author SHA1 Message Date
Frank Lichtenheld
14136ee923 CMake: disable -Wmaybe-uninitialized for GCC builds
This is very noisy with lots of false positives, especially
in newer version of GCC. So for now disable this.

Signed-off-by: Frank Lichtenheld <frank@lichtenheld.com>
(cherry picked from commit d7e8375fc5)
2024-03-07 00:29:36 +02:00
Frank Lichtenheld
ce054c562c CMake: make doxygen generation work better
- Use CURRENT source and binary dir to make this work even
  if used as a sub-directory in another project.
- Make USE_MDFILE_AS_MAINPAGE actually work. It is only
  used when part of the INPUT and does not automatically
  add it to INPUT.
- Make sure CMake uses the latest version of README.rst
  by using configure_file instead of file(COPY).
- Improve EXCLUDE_PATTERNS.
- Add NUM_PROC_THREADS.

Signed-off-by: Frank Lichtenheld <frank@lichtenheld.com>
(cherry picked from commit 474de6c93f)
2024-03-07 00:29:36 +02:00
Frank Lichtenheld
c9939d271b CMake: Reorder includes to prefer asio
By adding the asio includes first we have a better
chance to force using "our" asio. This can be important
since some parts of the code require a patched version.

The actual "core" parts of the code work fine with
upstream asio however, so I also do not want to
force the patched asio by requiring a special header
name or directory structure.

So this is a compromise solution which hopefully works
for most use-cases.

Signed-off-by: Frank Lichtenheld <frank@lichtenheld.com>
(cherry picked from commit bc7f4be01b)
2024-03-07 00:29:36 +02:00
Frank Lichtenheld
38ef9f2786 mingw: disable VCPKG_APPLOCAL_DEPS in mingw presets
We do not want to force a dependency on powershell.
Copying the right dlls is rather trivial.

Same change as commit commit e9e49239ce
for build-vcpkg script.

Signed-off-by: Frank Lichtenheld <frank@lichtenheld.com>
(cherry picked from commit 1f5aa58223)
2024-03-07 00:29:36 +02:00
Frank Lichtenheld
a830d1e09c lzo_asym_impl: fix unaligned access
Helpfully the comment above the code actually provided
a solution...

Signed-off-by: Frank Lichtenheld <frank@lichtenheld.com>
(cherry picked from commit db7ea3d96a)
2024-03-07 00:29:36 +02:00
Frank Lichtenheld
8c007de79d client: Explicitely use int as socket type in SWIG
For some reason SWIG doesn't seem to pick this
up automatically from the typedefs.

Signed-off-by: Frank Lichtenheld <frank@lichtenheld.com>
2024-03-06 13:00:04 +01:00
Frank Lichtenheld
37fb7c2efc CMake: clean up dependency handling
Always use find_package for all libraries.
Add missing Find*.cmake modules.
Always define an IMPORTED library in Find*

Signed-off-by: Frank Lichtenheld <frank@lichtenheld.com>
(cherry picked from commit d7b3419f8e)
2024-03-04 12:58:23 +02:00
Frank Lichtenheld
25ca35d71d CMake: add CMakePresets.json and switch GHA to use it
For now define vcpkg builds for MSVC and MinGW

Signed-off-by: Frank Lichtenheld <frank@lichtenheld.com>
(cherry picked from commit 63499ba7ac)
2024-03-04 12:58:23 +02:00
Frank Lichtenheld
f845f7dd95 vcpkg-ports/asio: copy update asio-config.cmake from vcpkg
Fixes problems when calling find_package on asio multiple
times.

Originally fixed by commit cba75f1aa08374733dcc79abebeca262ae94118a
in vcpkg#28299.

Signed-off-by: Frank Lichtenheld <frank@lichtenheld.com>
(cherry picked from commit 71cf5f48fe)
2024-03-04 12:58:23 +02:00
Frank Lichtenheld
ac01ae47e9 mingw: disable VCPKG_APPLOCAL_DEPS in build-vcpkg
We do not want to force a dependency on powershell.
Copying the right dlls is rather trivial.

Signed-off-by: Frank Lichtenheld <frank@lichtenheld.com>
(cherry picked from commit e9e49239ce)
2024-03-04 12:58:23 +02:00
Frank Lichtenheld
3614c1a004 CMake: move architecture detection closer to the actual executable
This makes it easier to see what is going on when looking at
individual CMakeLists.

Signed-off-by: Frank Lichtenheld <frank@lichtenheld.com>
(cherry picked from commit 4c81069564)
2024-03-04 12:58:23 +02:00
Frank Lichtenheld
0dcae2690b CMake: support BUILD_TESTING option
This is important since it allows us to avoid
the JsonCPP dependency on non-Win/non-Apple
systems.

Signed-off-by: Frank Lichtenheld <frank@lichtenheld.com>
(cherry picked from commit a9570cb780)
2024-03-04 12:58:23 +02:00
Frank Lichtenheld
fa99c85cb9 CMake: Generalize add_json_library
Make sure we find vcpkg and system packages on all
platforms.

Signed-off-by: Frank Lichtenheld <frank@lichtenheld.com>
(cherry picked from commit e720bf3aba)
2024-03-04 12:58:23 +02:00
Frank Lichtenheld
4e0de88c03 CMake: Fix issues in FindmbedTLS
Use add_library to define a target so that we do not
need to apply all the setting manually.
Use find_package_message() to avoid printing the
message more than once.

Signed-off-by: Frank Lichtenheld <frank@lichtenheld.com>
(cherry picked from commit 2fb5d08ea0)
2024-03-04 12:58:23 +02:00
Frank Lichtenheld
7c9eeca1ee vcpkg.json: Allow to use on Linux
- Fix PATCHES to work on Linux
- While here, fix version number

Signed-off-by: Frank Lichtenheld <frank@lichtenheld.com>
(cherry picked from commit fb9bee5ad6)
2024-03-04 12:58:23 +02:00
Frank Lichtenheld
cdcf942c24 CMake: small improvements
- Increase required version to 3.10. That is the version in
  Ubuntu Bionic and currently the oldest one we still want
  to support.
- Enable CTest for test target

Signed-off-by: Frank Lichtenheld <frank@lichtenheld.com>
(cherry picked from commit 50271ee02a)
2024-03-04 12:58:23 +02:00
Arne Schwabe
10fe3b82d4
Change year 2018 in MD5 warning to "near future".
With the change to OpenSSL 3 and introducing insecure as profile we
actually allowed MD5 again. Update the warning to reflect this.

Signed-off-by: Arne Schwabe <arne@openvpn.net>
2024-02-29 15:31:37 +01:00
Arne Schwabe
282075fee9 Allow test_sslctx to work with mbed TLS
Signed-off-by: Arne Schwabe <arne@openvpn.net>
2024-02-23 15:32:58 +01:00
Arne Schwabe
c1bcf78d2e Add support for mbed TLS 3.0
This currently still depends on the mbed TLS compat API functionality.

Signed-off-by: Arne Schwabe <arne@openvpn.net>
2024-02-23 15:32:58 +01:00
Mark Deric
ade5f80f8a Add doxygen comments to simplified logging files
Signed-off-by: Mark Deric <jmark@openvpn.net>
2024-02-21 10:04:12 -08:00
Mark Deric
9ffa263bc8 Remove old and/or unneeded code from logging
Also, update copyright dates

Signed-off-by: Mark Deric <jmark@openvpn.net>
2024-02-21 08:58:43 -08:00
Mark Deric
e5c850cc82 Untangle log header macro/class globs
The purpose of this change is to allow headers that require the
logbase.hpp classes to compile in executables using logsimple.hpp.

By munging classes and macros into both headers, an avoidable conflict
of macro re-definition is created.  This commit separates the classes
from the macros into new headers. Then propagates the mistake into the
current headers so none of the existing code is broken. ;-)

Signed-off-by: Mark Deric <jmark@openvpn.net>
2024-02-21 07:27:38 -08:00
David Sommerseth
bae10062b3
Merging in changes from OpenVPN 3 Core version 3.8.4
Signed-off-by: David Sommerseth <davids@openvpn.net>
2024-02-19 22:46:53 +01:00
David Sommerseth
8f4cd953b2
Release: OpenVPN 3 Core Library, version 3.8.4
Signed-off-by: David Sommerseth <davids@openvpn.net>
2024-02-13 18:07:01 +01:00
Lev Stipakov
b4a400f6fe Improve handling of unknown options
Currently we error out on the first unsupported
option which belongs to the "fatal" category, such as
"removed deprecated option" or "Option allowed only to
be pushed by the server".

To improve user experice and allow application code
to display all problematic options and their categories,
collect options into a category->options map and then
serialize it into multiline string:

  cat1: opt1,opt2
  cat2: opt3

Introduce a new error code UNUSED_OPTIONS, which is
placed into ClientAPI::Status::status. The serialized
options map is placed into ClientAPI::Status::message.

Signed-off-by: Lev Stipakov <lev@openvpn.net>
2024-02-07 17:03:45 +02:00
Charlie Vigue
cb9ce3d71c
Add notes to sslctx and add unit tests
- Add notes regarding some unexpected behaviors in sslctx
- Add unit tests specifically for sslctx, including simple in-memory
handshaking with both success and failure examples.

Signed-off-by: Charlie Vigue <charlie.vigue@openvpn.com>
2024-02-01 13:29:21 +01:00
Frank Lichtenheld
fe40d7288f
Change some arguments to const refs
Triggered by move suggestions from Coverity.

Signed-off-by: Frank Lichtenheld <frank@lichtenheld.com>
2024-01-31 17:02:47 +01:00
Frank Lichtenheld
fdf55e8776
ovpncli: simplify Client::open_url()
Remove unused argument "flags".

Signed-off-by: Frank Lichtenheld <frank@lichtenheld.com>
2024-01-31 17:02:46 +01:00
Frank Lichtenheld
eaf9147fcd
Add various moves as suggested by Coverity
Out of all the suggestions by Coverity I picked
the ones that move non-Ptr objects into variables
or attributes.

Signed-off-by: Frank Lichtenheld <frank@lichtenheld.com>
2024-01-31 17:02:45 +01:00
Frank Lichtenheld
853169a566
Fix various "auto causes copy" Coverity warnings
No reason not to fix those.

Signed-off-by: Frank Lichtenheld <frank@lichtenheld.com>
2024-01-31 17:02:28 +01:00
Arne Schwabe
afdfe1bb3f
Fix accessing a null pointer when PKCS7 is invalid
If we get a valid but almost empty PKCS7 structure we otherwise try
to access invalid fields.

CVE: CVE-2023-6247
Reported-by: Bahaa Naamneh <bahaa.cpl@gmail.com>
Signed-off-by: Arne Schwabe <arne@openvpn.net>
2024-01-25 12:02:12 +01:00
Charlie Vigue
f4f8caa400
Refactor RC - readability and doxygen
- Split big classes into declaration and definition
- Added doxygen

The goal here is to add make the classes easier to reason about by
splitting them into declaration and definition and then adding
doxygen.

The notify parts are left intentionally undocumented for now.

Signed-off-by: Charlie Vigue <charlie.vigue@openvpn.com>
2024-01-24 19:17:12 +01:00
Charlie Vigue
9f3d32b2f4
Add virtual default DTOR to ClientEvent::Base
ClientEvent::Base is the base class for many other classes including
a few that add data members. If at some point one of these enhanced
derived classes is referenced and then deleted via a base class
pointer, some memory could leak.

I don't think we do that yet, but it seems worth preventing.

Signed-off-by: Charlie Vigue <charlie.vigue@openvpn.com>
2024-01-24 16:24:14 +01:00
Charlie Vigue
b06252bb5d Cleanup API for JSON, map() --> asObject() etc
- .map() --> .asObject()
- .array() --> .asArray()

Required by changes in JSON API

Signed-off-by: Charlie Vigue <charlie.vigue@openvpn.com>
2024-01-23 13:21:53 +00:00
Arne Schwabe
1824aaed1d
Use OpenSSL 3.0 API for generating TLS 1.0 PRF
When compiling against OpenSSL 3.0, use the newer API for generating the
TLS 1.0 PRF.  Older OpenSSL versions will use the OpenSSL 1.x API.

Signed-off-by: Arne Schwabe <arne@openvpn.net>
2024-01-10 21:01:46 +01:00
Charlie Vigue
6bc9c0bd59
Check length of response before accessing it
The NTLM protocol implementation does not validate the length of
the proxy server’s response. If the response is shorter than
expected, the code will access the response buffer out of bounds,
which will raise an exception. This change checks and explicitly
raises an exception with an informative message if the response
is too short.

This was never a security issue as such but might result in a client
terminating early and without a nice diagnostic.

Signed-off-by: Charlie Vigue <charlie.vigue@openvpn.com>
2024-01-08 21:32:17 +01:00
Arne Schwabe
8ad83b5ae8 Add missing length check in parsing ACC messages, add more related tests
Signed-off-by: Arne Schwabe <arne@openvpn.net>
2024-01-04 17:51:23 +01:00
Arne Schwabe
8bfdc2809b Implement various fixes to avoid copying argument related to appcontrol 2024-01-04 17:51:23 +01:00
Frank Lichtenheld
44aa9acab2
ClientProto::Session: fix coverity issue "declaration hides parameter"
CID 11873: (#12 of 12): Parse warning (PW.PARAMETER_HIDDEN)
parameter_hidden: declaration hides parameter "e"

Signed-off-by: Frank Lichtenheld <frank@lichtenheld.com>
2023-12-20 23:18:33 +01:00
Frank Lichtenheld
185426c5e8
ServerProto::Session: fix coverity issue "declaration hides parameter"
CID 11809: (#2 of 3): Parse warning (PW.PARAMETER_HIDDEN)
parameter_hidden: declaration hides parameter "e"

Signed-off-by: Frank Lichtenheld <frank@lichtenheld.com>
2023-12-20 23:18:33 +01:00
Frank Lichtenheld
b4082c93cb
WS::Client::HTTPCore: fix coverity issue "declaration hides parameter"
CID 11948: (#2 of 2): Parse warning (PW.PARAMETER_HIDDEN)
parameter_hidden: declaration hides parameter "error"

Signed-off-by: Frank Lichtenheld <frank@lichtenheld.com>
2023-12-20 23:18:33 +01:00
Frank Lichtenheld
9524e33727
ClientOptions: fix coverity error "Structurally dead code"
CID 11851: (#1 of 1): Structurally dead code (UNREACHABLE)
unreachable: This code cannot be reached

Signed-off-by: Frank Lichtenheld <frank@lichtenheld.com>
2023-12-20 23:18:32 +01:00
Mark Deric
5b3294202c Prefer special purpose accessor to public
Instead of exposing protected data to the global environment, provide
a special purpose accessor to satisfy AppControl needs.

Signed-off-by: Mark Deric <jmark@openvpn.net>
2023-12-20 08:29:55 -08:00
Arne Schwabe
c151efc908 Allow specifying different client and server reasons for disconnect
Currently PG only allows to either send or withhold the reason to the
client but there are certain circumstances where you want to have more
detailed internal reason but still want to send some reason to the
client.

Signed-off-by: Arne Schwabe <arne@openvpn.net>
2023-12-13 16:51:22 +01:00
Arne Schwabe
2910164ebf Add helper method for reliable uniform int for unit tests
Signed-off-by: Arne Schwabe <arne@openvpn.net>
2023-12-13 16:51:22 +01:00
Arne Schwabe
95b821a2fd Allow to string methods of IP::Addr to display mapped IPv4 as plain IPv4
Some systems like to see the mapped IPv4 addresses as real IP addresses.
This commit adds the ability to show IP addresses as such.

Signed-off-by: Arne Schwabe <arne@openvpn.net>
2023-12-13 16:51:22 +01:00
Arne Schwabe
f97c00fc72 Make IV_PROTO defines public
This allows other code to use the values without having to repeat
the values.

Signed-off-by: Arne Schwabe <arne@openvpn.net>
2023-12-13 16:51:22 +01:00
Arne Schwabe
9afc0b2310 Allow ovpn::string::join to work also with other contains than std::vector
Signed-off-by: Arne Schwabe <arne@openvpn.net>
2023-12-13 16:51:22 +01:00
Arne Schwabe
f1ac7e500f Allow a client to announce custom control channel support
Signed-off-by: Arne Schwabe <arne@openvpn.net>
2023-12-13 16:51:22 +01:00
Arne Schwabe
e9ade86de7 Implement logic to send and receive custom control channel messages
This adds the capability to implement a custom app level protocol
that support message passing over the OpenVPN control channel.
The protocol is agnostic to the data that is transported over it
and the message splitting/reassmbly is handled transparently by the
OpenVPN library itself.

Signed-off-by: Arne Schwabe <arne@openvpn.net>
2023-12-13 16:51:22 +01:00