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

745 Commits

Author SHA1 Message Date
Arne Schwabe
9e5de78347 Document behaviour of Signal class a bit more
Signed-off-by: Arne Schwabe <arne@openvpn.net>
2023-05-10 17:23:33 +02:00
Lev Stipakov
09be60d38d cli.cpp: implement get_password() on Windows
Password is not echoed and submitted when Enter is pressed.
This requires not removing ENABLE_PROCESSED_INPUT and ENABLE_LINE_INPUT
flags.

Signed-off-by: Lev Stipakov <lev@openvpn.net>
2023-04-19 18:47:48 +03:00
Arne Schwabe
8b13cdd7a1 Allow duplicate options without error in configuration files
we often have configuration files where a directive is duplicated and
the later one wins. This is quite common and should not rais an error. We
still warn about these as this might an error/oversight.

Signed-off-by: Arne Schwabe <arne@openvpn.net>
2023-03-08 16:52:51 +01:00
David Sommerseth
ec982a5038
Preparing OpenVPN 3 Core library release v3.8 (QA)
Signed-off-by: David Sommerseth <davids@openvpn.net>
2023-02-02 14:15:43 +01:00
David Sommerseth
dde1574596
Reformatting source code to new coding style
This is the result after running 'clang-format -i' on all C++ files and
headers, with the defined formatting rules in .clang-format.

Only the openvpn/common/unicode-impl.hpp has been excluded, as that is
mostly a copy of an external project.

Signed-off-by: David Sommerseth <davids@openvpn.net>
2023-01-18 19:24:15 +01:00
Mark Deric
e4b1afe148
Design a coercion-safe ostream<< for containers
Adds a library method C2os:cast() that converts an iterable container,
i.e., one that can be a range-expression in a range-based for loop,
into a type that can be inserted into an ostream.  This only addresses
the container semantics in the ostream insertion.  The underlying
contained type T (if the container were stl, the value_type) must work
with ostream<<.

The result of the operator<< insertion is a square bracket enclosed,
comma delimited string of the items in the container.  Note that the
commit includes ideas on expanding choices of container rendering
details.

Attribution to James Yonan.  Made significant contribution to
expanding the scope of collections.  And reduced code complexity.
Also to Charlie Vigue; eliminated the "first" test inside the loop.

Signed-off-by: Mark Deric <jmark@openvpn.net>
2022-12-29 22:47:09 +01:00
David Sommerseth
4996c38ed4
Merge lastest changes from Core v3.7.2 2022-12-14 17:34:29 +01:00
David Sommerseth
7590cb1093
OpenVPN 3 Core library version 3.7.2
Signed-off-by: David Sommerseth <davids@openvpn.net>
2022-12-14 17:28:56 +01:00
Arne Schwabe
d7c16e5878 Always use crypto library memcmp function in favour of our own
The crypto library function from OpenSSL uses custom assembler code
and should be safe. Also the code has been excersised already by the
Android/iOS builds.

Signed-off-by: Arne Schwabe <arne@openvpn.net>
2022-12-08 10:40:43 +01:00
Arne Schwabe
3135d115a0 Replace throw() with noexcept and mark some exception constructors explicit
throw() is the same as noexcept(true), which is the same as noexpect.
(https://en.cppreference.com/w/cpp/language/noexcept_spec)

noexpect is more standard nowadays and less likely to create confusion.
Single argument constructors should be marked explicit so they do not
end up being acidentially called.
2022-11-16 17:22:09 +01:00
Arne Schwabe
3e34d5a6f9 Document UseCount class and make it non-copyable
There might be a better solution than using this class but at the
moment, at least give it a better documentation.
2022-11-16 17:22:09 +01:00
Frank Lichtenheld
5c5d115619 Fix some "variable set but not used" errors with clang 15
Signed-off-by: Frank Lichtenheld <frank@lichtenheld.com>
2022-10-24 13:52:28 +02:00
David Sommerseth
04af83e079
OpenVPN 3 Core library version 3.7.1
Signed-off-by: David Sommerseth <davids@openvpn.net>
2022-10-20 14:38:40 +02:00
David Sommerseth
8c94a8f774
copyright: Update to 2022
Signed-off-by: David Sommerseth <davids@openvpn.net>
2022-09-29 12:00:26 +02:00
Arne Schwabe
5b5d80fad3
Improve dealing with unknown options
This commit add several improvements to dealing with unknown options
in client configuration files:
 - implement ignore-unknown-option
 - categorise the OpenVPN2 options in multiple categories and
   warn/error out depending on the category
 - error out when unsupported/unknown options are found. This avoids
   problems like with --tls-crypt/--tls-crypt-v2 before where client
   would ignore these options and not connect at all

Signed-off-by: Arne Schwabe <arne@openvpn.net>
2022-09-14 17:32:53 +02:00
Frank Lichtenheld
2aea7ac4b5
Merge changes from coming OpenVPN 3 Core library v3.7 bugfix update
- test_cpu_time: fix unused variable
  - Allow GIT version to be reported as part of platform (version) string
  - Update OpenSSL to 3.0.5, build fat lib for macos, drop 32 bit on iOS
  - README.rst: some fixes for macOS instructions
  - extpki.hpp: ignore deprecated EC_KEY_* functions
  - mingw: fix OpenSSL on x86_64
  - mingw: fix broken OpenSSL checkout
  - test_ssl: fix ssl.enablelegacyProvider
  - dco/GeNL: ignore message for unrelated interfaces

Signed-off-by: David Sommerseth <davids@openvpn.net>
2022-08-25 15:32:11 +02:00
Arne Schwabe
ec5ea70de2 Allow GIT version to be reported as part of platform (version) string
Signed-off-by: Arne Schwabe <arne@openvpn.net>
2022-08-15 13:52:35 +02:00
Frank Lichtenheld
ef69cb6230 daemonize: ignore daemon() deprecated on macOS
Since we do not operate any servers on macOS, we
do not want to invest time in fixing this.

In most cases you would want to use launchd anyway
and not use damonize().

Signed-off-by: Frank Lichtenheld <frank@lichtenheld.com>
2022-07-15 13:32:44 +02:00
James Yonan
37d312d3e6 write_binary_atomic(): factored out temporary filename creation into new function tmp_filename()
Signed-off-by: James Yonan <james@openvpn.net>
2022-06-29 08:39:22 -06:00
James Yonan
9351ce8a9d Option: added is_multiline() method
Signed-off-by: James Yonan <james@openvpn.net>
2022-06-29 08:39:22 -06:00
James Yonan
8d1a340991 HostPort::split_host_port(): fixed a bug where unbracketed IPv6 addresses were not being parsed correctly
Signed-off-by: James Yonan <james@openvpn.net>
2022-05-15 11:54:18 -06:00
James Yonan
6e10e45644 Added a new general-purpose exception called signaling_exception
When exceptions are used to trigger a daemon
restart, we use this exception to disable such
behavior.

Signed-off-by: James Yonan <james@openvpn.net>
2022-05-13 19:09:09 -06:00
James Yonan
ed07444722 OptionList::extend(): use range-based for loop and add rvalue reference variant
Signed-off-by: James Yonan <james@openvpn.net>
2022-05-13 19:09:09 -06:00
James Yonan
ae4e358efd write_binary_unix(): added WRITE_BINARY_UNIX_EXISTING flag
Signed-off-by: James Yonan <james@openvpn.net>
2022-05-13 19:09:09 -06:00
Frank Lichtenheld
89774d78be memneq: use boolean operator for boolean operands
clang 14 complains:

    openvpn/common/memneq.hpp:128:38:
     error: use of bitwise '|' with boolean operands
     [-Werror,-Wbitwise-instead-of-logical]
    return memneq_unaligned_ok || (is_aligned<const void *, memneq_t>(a)|is_aligned<const void *, memneq_t>(b));

Signed-off-by: Frank Lichtenheld <frank@lichtenheld.com>
2022-04-19 11:40:53 +02:00
James Yonan
171733b90f Stop: added is_triggered() method
Signed-off-by: James Yonan <james@openvpn.net>
2022-04-11 09:08:47 -06:00
David Sommerseth
797ac13f18
Merge lastest changes from Core v3.7 2022-03-17 18:15:58 +01:00
Lev Stipakov
78410b290e size:hpp: fix 'ssize_t': redefinition error when building swig library on Windows
When building swig library, pyconfig.h is
included which, before version 3.10, defines ssize_t:

/* Define like size_t, omitting the "unsigned" */
#ifdef MS_WIN64
typedef __int64 ssize_t;
#else
typedef _W64 int ssize_t;
#endif
#define HAVE_SSIZE_T 1

which causes redefinition error. Take this into account
and add additional ifdef guard.

Signed-off-by: Lev Stipakov <lev@openvpn.net>
2022-03-16 11:56:09 +01:00
Frank Lichtenheld
b4152600c2 Rename PThreadBarrier::ERROR to fix build issue on Windows
Some Windows header defines an macro ERROR which then
leads to build errors:
...\ovpn3-build\ovpn3\common\tlshttps\tlshttpsclient.cpp(167,28):
error C2589: "constant": Invalid token on the right side of "::"
[...\ovpn3\common\tlshttps\tlshttpsclient.vcxproj]

Signed-off-by: Frank Lichtenheld <frank@lichtenheld.com>
2022-03-16 11:56:09 +01:00
David Sommerseth
81c3f16a66
version: Reset git:master reference to 3.8
Signed-off-by: David Sommerseth <davids@openvpn.net>
2022-03-11 00:31:28 +01:00
David Sommerseth
92751e23aa
Finalizing OpenVPN 3 Core library release v3.7
Signed-off-by: David Sommerseth <davids@openvpn.net>
2022-03-11 00:19:44 +01:00
Frank Lichtenheld
2cd6c9ef5f unicode-impl.hpp: Document source information with PURL
Original source is only available via web archive.
This code should be replaced anyway since the license
is dubious regarding modification.

Signed-off-by: Frank Lichtenheld <frank@lichtenheld.com>
2022-02-25 16:11:30 +01:00
Frank Lichtenheld
17f3a867d0 getopt.hpp: add some sort of PURL
Closest I could identify so far. The fact that it is in
CVS and has no useful tags doesn't make it better.
Probably we can improve upon this.

Signed-off-by: Frank Lichtenheld <frank@lichtenheld.com>
2022-02-25 15:31:58 +01:00
Frank Lichtenheld
aca3d6df21 getopt.hpp: Fix old BSD-4-Clause-UC reference
As per ftp://ftp.cs.berkeley.edu/pub/4bsd/README.Impt.License.Change
the 3rd clause was removed 1999. So remove it here.
This removes also any potential GPL conflicts.
Renumber 4th clause to 3 as all the BSDs seem to have
done so.

While here, add SPDX-License-Identifier

Signed-off-by: Frank Lichtenheld <frank@lichtenheld.com>
2022-02-25 14:12:56 +01:00
James Yonan
026df465cf read_binary_unix_fast(): templatize filename argument to accept std::string or C string
Signed-off-by: James Yonan <james@openvpn.net>
2022-02-07 13:56:13 -07:00
James Yonan
50b066ddef file_mod_time_nanoseconds(): accept filename as either const std::string& or const char *
Also prefix standard C library methods with "::"

Signed-off-by: James Yonan <james@openvpn.net>
2022-02-07 13:56:13 -07:00
Arne Schwabe
292465a3ae
Do not use deprecated vfork on macOS
from the man page:

     The vfork system call can be used to create new processes. As of macOS
     12.0, this system call behaves identically to the fork(2) system call,
     except without calling any handlers registered with pthread_atfork(2).

     This system call is deprecated. In a future release, it may begin to return
     errors in all cases, or may be removed entirely.  It is extremely strongly
     recommended to replace all uses with fork(2) or, ideally, posix_spawn(3).
2022-01-12 18:36:06 +01:00
Arne Schwabe
0de7a58347
Lower xxHash minimum version to 0.7.0
xxHash works just as well and allows us to compile with system libraries
on Ubuntu 20 and Debian 11
2022-01-12 18:34:26 +01:00
David Sommerseth
c4fa5a69c5
option: Extend with std::vector support in Option::from_list()
The Option class is lacking a way to take a std::vector of option values
and append those values to an option.

This is needed when importing an already pre-parsed configuration profile
into an OptionList object.

Signed-off-by: David Sommerseth <davids@openvpn.net>
2021-12-17 00:56:20 +01:00
James Yonan
ff7df50c39 SetUserGroup: extended to support Linux Capabilities
Added SetUserGroupRetainCap, which inherits from SetUserGroup,
and allows a privilege downgrade to retain one or more
Linux Capabilities.

Signed-off-by: James Yonan <james@openvpn.net>
2021-11-24 13:18:35 -07:00
David Sommerseth
93767197a3
endian64: Fix non-Linux builds due to features.h
In commit 0baa4f19eb the features.h file was added to the include
list.  This breaks builds non-Linux platforms.  But it seems it is not
needed to have see the __GLIBC__ macro.

Signed-off-by: David Sommerseth <davids@openvpn.net>
2021-11-18 19:49:05 +01:00
David Sommerseth
0baa4f19eb
endian64: Check of __GLIBC__ availability
When compiling this code using the musl libc instead of glibc, it fails
with this error:

./openvpn3-core/openvpn/common/endian64.hpp: In function 'uint64_t openvpn::Endian::rev64(uint64_t)':
./openvpn3-core/openvpn/common/endian64.hpp:53:14: error: '__bswap_constant_64' was not declared in this scope
   53 |       return __bswap_constant_64(value);
      |              ^~~~~~~~~~~~~~~~~~~

The __bswap_constant_64() is a function provided by the glibc library
and is not available in all other libc implementations.  To avoid this,
we fallback to the same solution used for Clang, which builds fine.  But
to avoid missing a match on the MINGW32 or MSC environments, the #if
condition checks are slightly reordered.

Signed-off-by: David Sommerseth <davids@openvpn.net>
2021-11-15 17:30:46 +01:00
David Sommerseth
8773add86a
endian64: Fix incorrect macro usage
The #if conditional need to check macros using defined(), otherwise the
behaviour is not ending up with the expected code.  In most compilers
these sections will never match.

Signed-off-by: David Sommerseth <davids@openvpn.net>
2021-11-15 17:30:39 +01:00
Mark Deric
6bb4e9c7be
Fix ASAN detected new/delete mismatches
The unique_ptr_slab variation of the std::unique_ptr<T> addresses the
issue of new/delete mismatches in code that allocates a _memory slab_
with the global _operator_ new but de-allocates an _object_ with a
delete _expression_.  The use case that manifests the mismatch is as
follows: Allocate a slab of memory that has a C struct at the head of
the slab, with a "my_type mt[0];" as the head's last member.  The slab
is cast to the type of the C struct, but sized to contain N my_type
items.

The object based de-allocation is the behavior of the
std::default_delete<T> template; it is used by the std::unique_ptr<T>
if the user does not specify an alternative deleter.  The
unique_ptr_slab resolves the mismatch with an alternative deleter that
de-allocates the _memory slab_ with the global _operator_ delete.

Signed-off-by: Mark Deric <jmark@openvpn.net>
2021-10-27 20:14:22 +02:00
Arne Schwabe
da9879f4d3
Silence warnings about signedness mismatch
pid_t vs uid_t is an obvious copy & paste mistake.

we check for (len < 0) before, so casting it to size_t is safe.

Signed-off-by: Arne Schwabe <arne@openvpn.net>
2021-08-18 19:38:05 +02:00
James Yonan
ae02bc347b RunContext: added io_context_ptr() method
Signed-off-by: James Yonan <james@openvpn.net>
2021-08-17 13:07:40 -06:00
James Yonan
7e484e1fa7 clamp: added variant clamp_nonzero() to only clamp non-zero values
This is useful for clamping parameter values to a range,
but where zero is a special case (for example to disable
the parameter).

Signed-off-by: James Yonan <james@openvpn.net>
2021-08-17 13:07:40 -06:00
James Yonan
a504c62790 strneq.hpp: added #pragma once
Signed-off-by: James Yonan <james@openvpn.net>
2021-08-17 13:07:40 -06:00
James Yonan
5a9fd26be7
RunContext: added process_exception() helper method
Signed-off-by: James Yonan <james@openvpn.net>
2021-08-03 10:42:35 +02: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