]> git.ipfire.org Git - thirdparty/openvpn.git/log
thirdparty/openvpn.git
23 months agoSet WINS servers via interactice service
Lev Stipakov [Thu, 27 Jul 2023 15:47:06 +0000 (18:47 +0300)] 
Set WINS servers via interactice service

At the moments WINS servers are set either:

 - via DHCP, which works only for tap-windows6 driver
 - via netsh when running without interactice service

This means that in 2.6 default setup (interactive service and dco)
WINS is silently ignored.

Add WINS support for non-DHCP drivers (like dco) by passing
WINS settings to interactive service and set them there with
netsh call, similar approach as we use for setting DNS.

Fixes https://github.com/OpenVPN/openvpn/issues/373

Change-Id: I47c22dcb728011dcedaae47cd03a57219e9c7607
Signed-off-by: Lev Stipakov <lev@openvpn.net>
Acked-by: Frank Lichtenheld <frank@lichtenheld.com>
Message-Id: <20230728131246.694-1-lstipakov@gmail.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg26903.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
2 years agoconfigure.ac: fix typ0 in LIBCAPNG_CFALGS
Antonio Quartulli [Tue, 25 Jul 2023 06:58:40 +0000 (08:58 +0200)] 
configure.ac: fix typ0 in LIBCAPNG_CFALGS

Github: fixes OpenVPN/openvpn#371

Reported-by: Matt Whitlock <gentoo@mattwhitlock.name>
Change-Id: Ic473fbc447741e54a9aac83c70bc4e6d87d91080
Signed-off-by: Antonio Quartulli <a@unstable.cc>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20230725065840.24568-1-a@unstable.cc>
URL: https://www.mail-archive.com/search?l=mid&q=20230725065840.24568-1-a@unstable.cc
Signed-off-by: Gert Doering <gert@greenie.muc.de>
2 years agoImprove signal handling using POSIX sigaction
Selva Nair [Sat, 28 Jan 2023 21:59:00 +0000 (16:59 -0500)] 
Improve signal handling using POSIX sigaction

Currently we use the old signal API which follows system-V or
BSD semantics depending on the platform and/or feature-set macros.
Further, signal has many weaknesses which makes proper masking
(deferring) of signals during update not possible.

Improve this:

- Use sigaction to properly mask signals when modifying.

Notes:

Updating signal_reset() is handled in a follow up patch

SIG_SOURCE_CONNECTION_FAILED is retained in a hackish way. This value
has the same meaning as SIG_SOURCE_SOFT everywhere except where the
signal is printed. Looks cosmetic --- could be eliminated?

In pre_init_signal_catch() we ignore some unix signals, but the same
signals from management are not ignored though both are treated as "HARD"
signals.  For example, during auth-user-pass query, "kill -SIGUSR1 <pid>"
will be ignored, but "signal SIGUSR1" from management interface will
cause M_FATAL and exit.  This is the current behaviour, but could be improved?

This patch was originally submitted as 5/5 of the signals series. Now this
is 1/2 of a new series with signal_reset changes moved to 2/2

Signed-off-by: Selva Nair <selva.nair@gmail.com>
Acked-by: Frank Lichtenheld <frank@lichtenheld.com>
Message-Id: <20230128215901.2207208-1-selva.nair@gmail.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg26087.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
2 years agoGHA: Add macos-13
Frank Lichtenheld [Tue, 18 Jul 2023 10:52:41 +0000 (12:52 +0200)] 
GHA: Add macos-13

Change-Id: Ica2e4b5a6b8da1368b487a33cd4b03ed9fc36011
Signed-off-by: Frank Lichtenheld <frank@lichtenheld.com>
Acked-by: Arne Schwabe <arne@rfc2549.org>
Message-Id: <20230718105241.620221-1-frank@lichtenheld.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg26869.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
2 years agoGHA: refactor mingw UTs and add missing tls_crypt
Frank Lichtenheld [Tue, 18 Jul 2023 10:52:33 +0000 (12:52 +0200)] 
GHA: refactor mingw UTs and add missing tls_crypt

I thought instead about moving this into a loop inside
powershell. But then error handling becomes annoying.
So let's GitHub handle it.

Change-Id: I9831f352c07b5c58a4e2d6a3dd5417842e0887d2
Signed-off-by: Frank Lichtenheld <frank@lichtenheld.com>
Acked-by: Arne Schwabe <arne@rfc2549.org>
Message-Id: <20230718105233.620193-1-frank@lichtenheld.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg26868.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
2 years agoImplement using --peer-fingerprint without CA certificates
Arne Schwabe [Wed, 24 May 2023 13:24:24 +0000 (15:24 +0200)] 
Implement using --peer-fingerprint without CA certificates

This is implements --peer-fingerprint command to support OpenVPN
authentication without involving a PKI.

The current implementation in OpenVPN for peer fingerprint has been already
extensively rewritten from the original submission from Jason [1]. The
commit preserved the original author since it was based on Jason code/idea.

This commit is based on two previous commits that prepare the infrastructure
to use a simple to use --peer-fingerprint directive instead of using
a --tls-verify script like the v1 of the patch proposed.  The two commits
preparing this are:

 - Extend verify-hash to allow multiple hashes
 - Implement peer-fingerprint to check fingerprint of peer certificate

These preceding patches make this actual patch quite short. There are some
lines in this patch that bear some similarity to the ones like

    if (!preverify_ok && !session->opt->verify_hash_no_ca)

vs

    if (!preverify_ok && !session->opt->ca_file_none)

But these similarities are one line fragments and dictated by the
surrounding style and program flow, so even a complete black box
implementation will likely end up with the same lines.

[1] https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg16781.html

Change-Id: Ie74c3d606c5429455c293c367462244566a936e3
Signed-off-by: Arne Schwabe <arne@rfc2549.org>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20230524132424.3098475-2-arne@rfc2549.org>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg26723.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
2 years agoRevert commit 423ced962d
Arne Schwabe [Wed, 24 May 2023 13:24:23 +0000 (15:24 +0200)] 
Revert commit 423ced962d

This reverts commit 423ced962db3129b4ed551c489624faba4340652, which
has Jason A. Donenfeld listed as author as the patch was based on his
initial submission.

We have not received permission to relicense the original patch.

Change-Id: I8142753928498169032450c56d0497a5042bdc9b
Signed-off-by: Arne Schwabe <arne@rfc2549.org>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20230524132424.3098475-1-arne@rfc2549.org>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg26722.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
2 years agoCheck if the -wrap argument is actually supported by the platform's ld
Arne Schwabe [Wed, 12 Jul 2023 09:55:29 +0000 (11:55 +0200)] 
Check if the -wrap argument is actually supported by the platform's ld

This avoids build errors on macOS. Also the test_tls_crypt command works
just fine on FreeBSD with its linkers, so do not make that test Linux only.

Patch v2: allow running with old cmake version (cmake 3 on RHEL7 with EPEL
          is only 3.17)
Patch v3: add OPTIONAL keyword to Incldue required by some cmake versions

Change-Id: Id26676bdc576c7d3d6726afa43fe6c7a397c579b
Signed-off-by: Arne Schwabe <arne@rfc2549.org>
Acked-by: Frank Lichtenheld <frank@lichtenheld.com>
Message-Id: <20230712095529.570306-1-arne@rfc2549.org>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg26850.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
2 years agoMock openvpn_exece on win32 also for test_tls_crypt
Arne Schwabe [Wed, 12 Jul 2023 09:54:12 +0000 (11:54 +0200)] 
Mock openvpn_exece on win32 also for test_tls_crypt

This function is needed to commpile on win32 as run_command.c defines it
on Unix Linux but on windows it is defined in win32.c which pulls in too
many other unresolvable symbols.

Patch v2: Also add mock_win32_execve.c to automake files

Change-Id: I8c8fe298eb30e211279f3fc010584b9d3bc14b4a
Signed-off-by: Arne Schwabe <arne@rfc2549.org>
Acked-by: Frank Lichtenheld <frank@lichtenheld.com>
Message-Id: <20230712095412.570106-1-arne@rfc2549.org>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg26849.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
2 years agoIgnore Ipv6 route delete request on Android and set ipv4 verbosity to 7
Arne Schwabe [Wed, 12 Jul 2023 09:46:20 +0000 (11:46 +0200)] 
Ignore Ipv6 route delete request on Android and set ipv4 verbosity to 7

Android has no facility nor need one to delete routes as routes are
automatically cleaned up when the tun interface is closed. Also adjust
the IPv4 message to be only shown and verb 7 and rephrase the message.

Change-Id: If8f920d378c31e9ea773ce1f56f3df50f1ec36cd
Signed-off-by: Arne Schwabe <arne@rfc2549.org>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20230712094620.569273-1-arne@rfc2549.org>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg26848.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
2 years agomanage.c: document missing KID parameter
Lev Stipakov [Fri, 14 Jul 2023 11:18:02 +0000 (14:18 +0300)] 
manage.c: document missing KID parameter

Commit a261e173 ("Make sending plain text control message session
aware") added KID parameter to "client-pending-auth" management command,
but forgot to mention it in the output of management help.

Change-Id: I201bdaa5fe4020d15a9dd1674aba5e0c45170731
Signed-off-by: Lev Stipakov <lev@openvpn.net>
Acked-by: Arne Schwabe <arne@rfc2549.org>
Message-Id: <20230714111802.1773-1-lstipakov@gmail.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg26856.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
2 years agofix typo: dhcp-options to dhcp-option in vpn-network-options.rst
George Pchelkin [Fri, 14 Jul 2023 09:25:57 +0000 (11:25 +0200)] 
fix typo: dhcp-options to dhcp-option in vpn-network-options.rst

Closes: OpenVPN/openvpn#313
Signed-off-by: Frank Lichtenheld <frank@lichtenheld.com>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20230714092557.229260-1-frank@lichtenheld.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg26855.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
2 years agotun.c: enclose DNS domain in single quotes in WMIC call
Lev Stipakov [Mon, 10 Jul 2023 11:21:22 +0000 (14:21 +0300)] 
tun.c: enclose DNS domain in single quotes in WMIC call

This is needed to support domains with hyphens.

Not using double quotes here, since our code replaces
them with underbars (see
https://github.com/OpenVPN/openvpn/blob/master/src/openvpn/win32.c#L980).

Github: fixes OpenVPN/openvpn#363

Change-Id: Iab536922d0731635cef529b5caf542f637b8d491
Signed-off-by: Lev Stipakov <lev@openvpn.net>
Acked-by: Selva Nair <selva.nair@gmail.com>
Message-Id: <20230710112122.576-1-lstipakov@gmail.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg26841.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
2 years agoPrint a more user-friendly error when tls-crypt-v2 client auth fails
Arne Schwabe [Mon, 22 May 2023 09:12:31 +0000 (11:12 +0200)] 
Print a more user-friendly error when tls-crypt-v2 client auth fails

While it might be clear to people being (too?) well versed in
typical crypto applications that an authentication failure probably
mean wrong decryption key, this is not really obvious for the typical
user/server admin.

Change-Id: If0f0e7d53f915d39ab69aaaac43dc73bb9c26ae9
Signed-off-by: Arne Schwabe <arne@rfc2549.org>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20230522091231.2837468-1-arne@rfc2549.org>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg26718.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
2 years agoREADME.cmake.md: Add new documentation for CMake buildsystem
Frank Lichtenheld [Fri, 7 Jul 2023 15:05:23 +0000 (17:05 +0200)] 
README.cmake.md: Add new documentation for CMake buildsystem

While here, adapt and update some of the Windows-build
references in the other README files.

Change-Id: Id067774bde7511a736e156fc599b07837242336c
Signed-off-by: Frank Lichtenheld <frank@lichtenheld.com>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20230707150523.385264-1-frank@lichtenheld.com>
URL: https://www.mail-archive.com/search?l=mid&q=20230707150523.385264-1-frank@lichtenheld.com
Signed-off-by: Gert Doering <gert@greenie.muc.de>
2 years agoRemove old Travis CI related files
Frank Lichtenheld [Fri, 7 Jul 2023 14:46:28 +0000 (16:46 +0200)] 
Remove old Travis CI related files

They are not used or mainained anymore. So just remove them.

Change-Id: I704f7c9a9fe9a2b988410c4586183302392e690d
Signed-off-by: Frank Lichtenheld <frank@lichtenheld.com>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20230707144628.378541-1-frank@lichtenheld.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg26834.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
2 years agoFix CR_RESPONSE mangaement message using wrong key_id
Arne Schwabe [Mon, 22 May 2023 10:11:38 +0000 (12:11 +0200)] 
Fix CR_RESPONSE mangaement message using wrong key_id

the management interface expects the management key id instead
of the openvpn key id. In the past they often were the same for low ids
which hid the bug quite well.

Also do not pick uninitialised keystates (management key_id is not valid
in these).

Patch v2: do not add logging

Change-Id: If9fa1165a0e886b570b3738546ed810a32367cbe
Signed-off-by: Arne Schwabe <arne@rfc2549.org>
Tested-By: Jemmy Wang
Github: fixes OpenVPN/openvpn#359
Acked-by: Selva Nair <selva.nair@gmail.com>
Message-Id: <20230522101138.2842378-2-arne@rfc2549.org>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg26719.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
2 years agowork around false positive warning with mingw 12
Heiko Hund [Thu, 6 Jul 2023 17:19:22 +0000 (19:19 +0200)] 
work around false positive warning with mingw 12

When cross compiling for Windows with Ubuntu 23.04 mingw complains about

  route.c:344:26: warning: ‘special.S_un.S_addr’ may be used uninitialized

which is wrong technically. However the workaround isn't really
intrusive and while there are other warnings caused by libtool, the
cmake mingw build completes with -Werror now.

Change-Id: I8a0f59707570722eab41af2db76980ced04e6d54
Signed-off-by: Heiko Hund <heiko@ist.eigentlich.net>
Acked-by: Arne Schwabe <arne@rfc2549.org>
Message-Id: <20230706171922.752429-1-heiko@ist.eigentlich.net>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg26831.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
2 years agoCMake: Support doc builds on Windows machines that do not have .py file association
Frank Lichtenheld [Tue, 4 Jul 2023 13:09:02 +0000 (15:09 +0200)] 
CMake: Support doc builds on Windows machines that do not have .py file association

On Windows we might need to call python because .py files are not
directly executable. This is true e.g. for GHA runners.
For now we assume that rst2html and rst2man can be handled in the same
way and do not test both of them.

Commit e8881ec6dd63bd80ce05202573eac54ab8657fcb unconditionally
used $PYTHON, but that broke build on systems where the default
python can't be used and we need to respect the shebang.
Commit 5dbec1c019d14880ae7bf364b062d3589c7fd9e7 unconditionally
did not use $PYTHON, but that broke build on the aformentioned
GHA runners.
This commit tries to establish a solution that works for both
systems.

Signed-off-by: Frank Lichtenheld <frank@lichtenheld.com>
Acked-by: Arne Schwabe <arne@rfc2549.org>
Message-Id: <20230704130902.105585-1-frank@lichtenheld.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg26813.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
2 years agoopenvpnmsica: link C runtime statically
Lev Stipakov [Wed, 5 Jul 2023 12:25:28 +0000 (15:25 +0300)] 
openvpnmsica: link C runtime statically

By default CMake links C runtime dynamically,
which doesn't work on Windows 7, for example.

This is not an issue with other openvpn binaries,
since we bundle C runtime, but it is not yet available
during installation.

Change-Id: Ib2b014f075908e7db0d9115abaa2240e47fd27b9
Signed-off-by: Lev Stipakov <lev@openvpn.net>
Acked-by: Frank Lichtenheld <frank@lichtenheld.com>
Message-Id: <20230705122528.1625-1-lstipakov@gmail.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg26821.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
2 years agofix warning with gcc 12.2.0 (compiler bug?)
Arne Schwabe [Sun, 27 Nov 2022 08:59:33 +0000 (09:59 +0100)] 
fix warning with gcc 12.2.0 (compiler bug?)

Changing the argument of check_malloc_return from const void* to void*
removes the warning from gcc 12.2.0:

In file included from ../../../openvpn-git/src/openvpn/crypto_openssl.c:40:
../../../openvpn-git/src/openvpn/buffer.h: In function ‘hmac_ctx_new’:
../../../openvpn-git/src/openvpn/buffer.h:1030:9: warning: ‘ctx’ may be
used uninitialized [-Wmaybe-uninitialized]
 1030 |         check_malloc_return((dptr) = (type *)
malloc(sizeof(type))); \
      |         ^~~~~~~~~~~~~~~~~~~
../../../openvpn-git/src/openvpn/buffer.h:1076:1: note: by argument 1 of
type ‘const void *’ to ‘check_malloc_return’ declared here
 1076 | check_malloc_return(const void *p)
      | ^~~~~~~~~~~~~~~~~~~

This more a quick fix/heads up for other people encountering the issue
on GCC 12.2.0 like on Ubuntu 22.10 until we figure out if this is a bug in
our code or a compiler bug.

Signed-off-by: Arne Schwabe <arne@rfc2549.org>
Acked-by: Heiko Hund <heiko@ist.eigentlich.net>
Message-Id: <20221127085933.3487177-1-arne@rfc2549.org>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg25549.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
2 years agoCMake: Throw a clear error when config.h in top-level source directory
Frank Lichtenheld [Mon, 3 Jul 2023 15:39:25 +0000 (17:39 +0200)] 
CMake: Throw a clear error when config.h in top-level source directory

This causes weird, difficult to debug compilation errors. Usually
caused by trying to run CMake against a source that had an
in-tree autoconfig build.

Note that you're able to do out-of-tree autoconfig builds and
they can obviously mix with out-of-tree cmake builds.

Signed-off-by: Frank Lichtenheld <frank@lichtenheld.com>
Acked-by: Arne Schwabe <arne@rfc2549.org>
Message-Id: <20230703153925.48990-1-frank@lichtenheld.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg26809.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
2 years agoOnly add -Wno-stringop-truncation on supported compilers
Arne Schwabe [Thu, 29 Jun 2023 21:56:08 +0000 (23:56 +0200)] 
Only add -Wno-stringop-truncation on supported compilers

The -Wno-stringop-truncation flag is only supported by some GCC versions
and not by Clang (macOS, FreeBSD) at all.

Move the includes to the top the file to have them available when running
the check_c_compiler_flag.

Change-Id: I452bc4ee935d13f8e9095d0a31805a3bbaff0cec
Signed-off-by: Arne Schwabe <arne@rfc2549.org>
Acked-by: Frank Lichtenheld <frank@lichtenheld.com>
Message-Id: <20230629215611.3292788-3-arne@rfc2549.org>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg26791.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
2 years agoDo not blindly assume python3 is also the interpreter that runs rst2html
Arne Schwabe [Thu, 29 Jun 2023 21:56:07 +0000 (23:56 +0200)] 
Do not blindly assume python3 is also the interpreter that runs rst2html

On my system python3 is the macOS system python3 while rst2html has

   #!/opt/homebrew/opt/python@3.9/bin/python3.9

as its first line. Running that with a different python results in missing
python modules. So directly execute the rst2html script instead.

Change-Id: I7e27ae031179c91cc1bca8122caf2453d6396ec0
Signed-off-by: Arne Schwabe <arne@rfc2549.org>
Acked-by: Frank Lichtenheld <frank@lichtenheld.com>
Message-Id: <20230629215611.3292788-2-arne@rfc2549.org>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg26790.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
2 years agoAvoid unused function warning/error on FreeBSD (and potientially others)
Arne Schwabe [Sat, 1 Jul 2023 20:24:53 +0000 (22:24 +0200)] 
Avoid unused function warning/error on FreeBSD (and potientially others)

the funktion is_on_link is not used on FreeBSD and triggers a
warning/error (-Werror) on FreeBSD.

Patch v2: use actual platforms instead an ifndef FreeBSD

Change-Id: I6757d6509ff3ff522d6de417372a21e73ccca3ba
Signed-off-by: Arne Schwabe <arne@rfc2549.org>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20230701202453.3517822-2-arne@rfc2549.org>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg26804.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
2 years agotest_tls_crypt: Improve mock() usage to be more portable
Frank Lichtenheld [Fri, 30 Jun 2023 12:39:08 +0000 (14:39 +0200)] 
test_tls_crypt: Improve mock() usage to be more portable

Use the casting variants of mock(). Using the mock_ptr_type
fixes an existing bug where test_tls_crypt.c couldn't
build in MinGW 32bit:

test_tls_crypt.c:127:27: error:
cast to pointer from integer of different size
[-Werror=int-to-pointer-cast]
  127 |     const char *pem_str = (const char *) mock();

Change-Id: I6c03313b8677fa07c07e718b1f85f7efd3c4dea8
Signed-off-by: Frank Lichtenheld <frank@lichtenheld.com>
Acked-by: Arne Schwabe <arne@rfc2549.org>
Message-Id: <20230630123908.82588-1-frank@lichtenheld.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg26796.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
2 years agoGHA: update to run-vcpkg@v11
Frank Lichtenheld [Tue, 20 Jun 2023 13:53:10 +0000 (15:53 +0200)] 
GHA: update to run-vcpkg@v11

This improves binary cache handling.

Change-Id: I4183edacc0295e9671c586cfcd77cf687015a22c
Signed-off-by: Frank Lichtenheld <frank@lichtenheld.com>
Acked-by: Lev Stipakov <lstipakov@gmail.com>
Message-Id: <20230620135310.94455-6-frank@lichtenheld.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg26755.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
2 years agoCMake: Add /Brepro to MSVC link options
Frank Lichtenheld [Tue, 20 Jun 2023 13:53:09 +0000 (15:53 +0200)] 
CMake: Add /Brepro to MSVC link options

So that we get reproducible builds.

Change-Id: Iffdd3ac5f266cc7d592ab678afc14c122acbb351
Signed-off-by: Frank Lichtenheld <frank@lichtenheld.com>
Acked-by: Lev Stipakov <lstipakov@gmail.com>
Message-Id: <20230620135310.94455-5-frank@lichtenheld.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg26757.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
2 years agoRemove all traces of the previous MSVC build system
Frank Lichtenheld [Tue, 20 Jun 2023 13:53:08 +0000 (15:53 +0200)] 
Remove all traces of the previous MSVC build system

Completely replaced by the CMake build system now.

v3:
 - rebase on top of my dist fixes

Change-Id: I807cffa40f18faa1adec4e15e84c032877a2b92e
Signed-off-by: Frank Lichtenheld <frank@lichtenheld.com>
Acked-by: Lev Stipakov <lstipakov@gmail.com>
Message-Id: <20230620135310.94455-4-frank@lichtenheld.com>
URL: https://www.mail-archive.com/search?l=mid&q=20230620135310.94455-4-frank@lichtenheld.com
Signed-off-by: Gert Doering <gert@greenie.muc.de>
2 years agoCMake: Add complete MinGW and MSVC build
Frank Lichtenheld [Tue, 20 Jun 2023 13:53:07 +0000 (15:53 +0200)] 
CMake: Add complete MinGW and MSVC build

This is based on the initial CMake patch by
Arne Schwabe, but extends that to provide
a complete replacement for existing MinGW
build (autotools based) and MSVC build
(openvpn.sln).

The following features are added while switching
these builds to CMake:
 - vcpkg support for MinGW build, allowing for
   trivial cross-compilation on Linux
 - Add unittests to MSVC build
 - Rework MSVC config header generation, removing
   need for separate headers between autotools
   and MSVC

The following advantages are reasons for switching
to CMake over the existing MSVC build:
 - Easier to maintain CMake files without IDE
   than the sln and vcxproj files
 - Able to maintain MSVC and MinGW build side-by-side

The plan is to completely remove the existing MSVC
build system but leave the existing autotools builds
in place as-is, including MinGW support.

CMake is not the intended build system for Unix-like
platforms and there are no current plans to switch
to it.

v2:
 - Reduce default warning level for MSVC to /W2. With
   /W3 the build is just much too noisy, making it
   difficult to spot new warnings.
 - Change MSVC CMake presets to have hardcoded build
   type. When using pkg_search_module MSVC Multi-Config
   builds do not work correctly at all since PkgConfig
   doesn't seem to be able to create multi-config
   libraries like find_package does.
 - Change minGW presets to be Multi-Config capable.
 - Remove OPENVPN_VERSION_MAJOR, OPENVPN_VERSION_MINOR,
   OPENVPN_VERSION_PATCH from config.h.cmake.in.
   They are not required and cause macro redefinition
   warnings in MSVC (with openvpn-plugin.h). gcc doesn't
   warn about this because the definitions are identical
   so no need to fix this in autoheader config.h.in.
v3:
 - Apply fixes by Lev Stipakov to match MSVC compile
   options better to previous build.
 - Apply change by Lev Stipakov to enable generation
   of PDB files.
 - Move /Brepro to its own commit. This is a behavior
   change that should be more visible.
 - Rebase on top of my dist fixes.

Change-Id: I237f28eca618d4fc476225b887c0be26cca362b1
Signed-off-by: Frank Lichtenheld <frank@lichtenheld.com>
Acked-by: Lev Stipakov <lstipakov@gmail.com>
Message-Id: <20230620135310.94455-3-frank@lichtenheld.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg26754.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
2 years agoadd basic CMake based build
Arne Schwabe [Tue, 20 Jun 2023 13:53:06 +0000 (15:53 +0200)] 
add basic CMake based build

This helps with IDE integration among other things.

This is a basic implementation for development purposes
that can't replace any of the existing release builds.

Change-Id: I666314a223d324ca72dbe7ba7d22f764996d3ca2
Signed-off-by: Arne Schwabe <arne@rfc2549.org>
Signed-off-by: Frank Lichtenheld <frank@lichtenheld.com>
Acked-by: Lev Stipakov <lstipakov@gmail.com>
Message-Id: <20230620135310.94455-2-frank@lichtenheld.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg26758.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
2 years agodco-linux: fix counter print format
Sergey Korolev [Mon, 26 Jun 2023 13:09:39 +0000 (16:09 +0300)] 
dco-linux: fix counter print format

Avoid compilation warnings on 32 bit platforms.

dco_linux.c: In function 'dco_update_peer_stat':
dco_linux.c:830:26: error: format '%lu' expects argument of type
'long unsigned int', but argument 4 has type 'counter_type'
{aka 'long long unsigned int'} [-Werror=format=]
  830 |         msg(D_DCO_DEBUG, "%s / dco_read_bytes: %lu", __func__,
      |                          ^~~~~~~~~~~~~~~~~~~~~~~~~~
  831 |             c2->dco_read_bytes);
      |             ~~~~~~~~~~~~~~~~~~
      |               |
      |               counter_type {aka long long unsigned int}

Signed-off-by: Sergey Korolev <sergey.korolev@keenetic.com>
Acked-by: Antonio Quartulli <a@unstable.cc>
Message-Id: <20230626130939.3267280-1-sergey.korolev@keenetic.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg26767.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
2 years agodist: Include all documentation in distribution
Frank Lichtenheld [Mon, 19 Jun 2023 13:29:34 +0000 (15:29 +0200)] 
dist: Include all documentation in distribution

No need to deprive tar ball users of this information.

Signed-off-by: Frank Lichtenheld <frank@lichtenheld.com>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20230619132934.76085-5-frank@lichtenheld.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg26749.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
2 years agounit_tests: Add missing cert_data.h to source list for unit tests
Frank Lichtenheld [Mon, 19 Jun 2023 13:29:33 +0000 (15:29 +0200)] 
unit_tests: Add missing cert_data.h to source list for unit tests

Document the dependency. Also fixes cert_data.h missing from
distribution.

Signed-off-by: Frank Lichtenheld <frank@lichtenheld.com>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20230619132934.76085-4-frank@lichtenheld.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg26750.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
2 years agovcpkg-ports/pkcs11-helper: rename patches to make file names shorter
Frank Lichtenheld [Mon, 19 Jun 2023 13:29:32 +0000 (15:29 +0200)] 
vcpkg-ports/pkcs11-helper: rename patches to make file names shorter

Remove the number prefixes we do not use anyway.

And then rename Allow-the-build-to-succeed-if-configured-with-disabl.patch
to make it short enough that it can fit in a tar archive
built with --old-archive. Otherwise make dist might not include it:

tar:
openvpn-2.7_git/contrib/vcpkg-ports/pkcs11-helper/Allow-the-build-to-succee
d-if-configured-with-disabl.patch:
file name is too long (max 99); not dumped

Signed-off-by: Frank Lichtenheld <frank@lichtenheld.com>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20230619132934.76085-3-frank@lichtenheld.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg26747.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
2 years agodist: add more missing files only used in the MSVC build
Frank Lichtenheld [Mon, 19 Jun 2023 13:29:31 +0000 (15:29 +0200)] 
dist: add more missing files only used in the MSVC build

So it is possible to build with MSVC from the release
tarballs.

Fixes #344.

Signed-off-by: Frank Lichtenheld <frank@lichtenheld.com>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20230619132934.76085-2-frank@lichtenheld.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg26748.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
2 years agoRemove key_type argument from generate_key_random
Arne Schwabe [Thu, 1 Jun 2023 10:25:06 +0000 (12:25 +0200)] 
Remove key_type argument from generate_key_random

This part of the function is not used by any part of
our source code. It looks also broken if called with kt!=NULL
The function cipher_kt_key_size expects its argument to be not
NULL and would break. So remove the unused code instead of fixing
it.

Found by Coverity.

Change-Id: Id56628cfb3dfd2f306bd9bdcca2e567ac0ca9ab2
Signed-off-by: Arne Schwabe <arne@rfc2549.org>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20230601102506.4068185-1-arne@rfc2549.org>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg26737.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
2 years agoFix use-after-free with EVP_CIPHER_free
Arne Schwabe [Thu, 1 Jun 2023 09:57:21 +0000 (11:57 +0200)] 
Fix use-after-free with EVP_CIPHER_free

In many scenarios the context will still have a reference to the cipher, so
this use-after-free does not explode but it is still wrong.

Change-Id: I59002d6613eaef36d5a47b20b56073e399cfa1df
Signed-off-by: Arne Schwabe <arne@rfc2549.org>
Acked-by: Antonio Quartulli <a@unstable.cc>
Message-Id: <20230601095721.4065834-1-arne@rfc2549.org>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg26735.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
2 years agomsvc-generate: include version.m4.in in tarball
Frank Lichtenheld [Sat, 27 May 2023 09:55:04 +0000 (11:55 +0200)] 
msvc-generate: include version.m4.in in tarball

Github: Fixes OpenVPN/openvpn#344

Change-Id: I7d8a25df8ef62a1e46fdb4a2358972eb4419c564
Signed-off-by: Frank Lichtenheld <frank@lichtenheld.com>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20230527095504.17915-1-frank@lichtenheld.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg26732.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
2 years agooptions: remove --key-method from usage message
Frank Lichtenheld [Thu, 25 May 2023 14:46:57 +0000 (16:46 +0200)] 
options: remove --key-method from usage message

Commit 36bef1b52b49ebbc3790635be230e2f30f0532a7 removed
the option but did not delete it from usage text.

Change-Id: I68d3c90c2bdf6f426a9eef81f852fcae2ea47ce9
Signed-off-by: Frank Lichtenheld <frank@lichtenheld.com>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20230525144657.40732-1-frank@lichtenheld.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg26726.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
2 years agotapctl: generate driver-specific adapter names
Lev Stipakov [Fri, 19 May 2023 08:25:48 +0000 (11:25 +0300)] 
tapctl: generate driver-specific adapter names

At the moment if --name is not specified, adapter names
are generated by Windows and they look a bit confusing
like "Local Area Connection 2".

This is also behavior of "Add a new <driver-name> virtual network
adapter" shortcuts.

This makes tapctl generate driver-specific names for adapters
if --name is missing, inclusing resolving duplicates. For instance
following commands:

  tapctl.exe create --hwid ovpn-dco

will create an adapter named

  OpenVPN Data Channel Offload

If the name is taken, the next one will be

  OpenVPN Data Channel Offload #1

and so on up to 100.

Fixes https://github.com/OpenVPN/openvpn/issues/337

Change-Id: Ic5afb470d14ac7b231d91f0f5de0a0046043a7e0
Signed-off-by: Lev Stipakov <lev@openvpn.net>
Acked-by: Selva Nair <selva.nair@gmail.com>
Message-Id: <20230519082548.1714-1-lstipakov@gmail.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg26712.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
2 years agoInteractive service: do not force a target desktop for openvpn.exe
Selva Nair [Thu, 18 May 2023 17:33:45 +0000 (13:33 -0400)] 
Interactive service: do not force a target desktop for openvpn.exe

Setting the desktop as "winsta0\default" does not always work when run
from a non-interactive session which may not have access to the
the window station "Winsta0". Leave this as NULL to let the system
automatically assign a window station and desktop.

Test runs on Win10 confirm that "Winsta0\Default" still gets selected
when run interactively (e.g., using the GUI or from task scheduler as
an interactive job). This is the same behaviour as now.

The change allows "interactive service" to be used for launching
OpenVPN from non-interactive sessions. For example, when service client
is a non-interactive task from the task scheduler, the default desktop
in a custom window station gets assigned to openvpn.exe.

Note that we already run openvpn.exe in a non-interactive window
station when directly launched by "automatic service".

Github: Fixes OpenVPN/openvpn-gui#626

Signed-off-by: Selva Nair <selva.nair@gmail.com>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20230518173345.2722530-1-selva.nair@gmail.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg26705.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
2 years agodco-win: support for --dev-node
Lev Stipakov [Thu, 18 May 2023 11:00:58 +0000 (14:00 +0300)] 
dco-win: support for --dev-node

With --dev-node on Windows, one can specify GUID
of the adapter openvpn should use. Those can be listed with:

  C:\Program Files\OpenVPN\bin>openvpn.exe --show-adapters

While on it, remove "TAP-WIN32 / Wintun" from --show-adapters output.

Github: Fixes OpenVPN/openvpn#336

Change-Id: I57de4d3c069465fb730bb635bfdbdf360fc8c475
Signed-off-by: Lev Stipakov <lev@openvpn.net>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20230518110058.1382-1-lstipakov@gmail.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg26702.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
2 years agosrc/openvpn/dco_freebsd.c: handle malloc failure
Ilya Shipitsin [Thu, 18 May 2023 21:21:39 +0000 (23:21 +0200)] 
src/openvpn/dco_freebsd.c: handle malloc failure

malloc was not checked against NULL, I was able
to get core dump in case of failure

Signed-off-by: Ilya Shipitsin <chipitsine@gmail.com>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20230518212139.1261-1-chipitsine@gmail.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg26707.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
2 years agobuffer: use memcpy in buf_catrunc
Frank Lichtenheld [Wed, 17 May 2023 11:36:19 +0000 (13:36 +0200)] 
buffer: use memcpy in buf_catrunc

Since we use strlen() to determine the length
and then check it ourselves, there is really
no point in using strncpy.

But the compiler might complain that we use
the output of strlen() for the length of
strncpy which is usually a sign for bugs:

error: ‘strncpy’ specified bound depends
 on the length of the source argument
 [-Werror=stringop-overflow=]

Warning was at least triggered for
mingw-gcc version 10-win32 20220113.

Also change the type of len to size_t
which avoids potential problems with
signed overflow.

v2:
 - make len size_t and change code to avoid any theoretical overflows
 - remove useless casts
v3:
 - fix off-by-one introduced by v2 %)
v4:
 - ignore unsigned overflow to simplify code

Change-Id: If4a67adac4d2e870fd719b58075d39efcd67c671
Signed-off-by: Frank Lichtenheld <frank@lichtenheld.com>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20230517113619.82808-1-frank@lichtenheld.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg26683.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
2 years agotest_buffer: add tests for buf_catrunc and its caller format_hex_ex
Frank Lichtenheld [Wed, 17 May 2023 08:44:22 +0000 (10:44 +0200)] 
test_buffer: add tests for buf_catrunc and its caller format_hex_ex

Just some very basic tests.

v2:
 - fix off-by-one

Change-Id: I73fc893136387d1da05f4aea98cb37b02d6c3230
Signed-off-by: Frank Lichtenheld <frank@lichtenheld.com>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20230517084422.70547-2-frank@lichtenheld.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg26680.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
2 years agotests: Allow to override openvpn binary used
Frank Lichtenheld [Thu, 11 May 2023 10:12:53 +0000 (12:12 +0200)] 
tests: Allow to override openvpn binary used

This makes it easy to test an installed binary for
example.

Signed-off-by: Frank Lichtenheld <frank@lichtenheld.com>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20230511101253.369196-1-frank@lichtenheld.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg26648.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
2 years agoCorrectly handle Unicode names for exit event
Selva Nair [Tue, 16 May 2023 02:42:32 +0000 (22:42 -0400)] 
Correctly handle Unicode names for exit event

Currently we use the ANSI version of CreateEvent causing name of the
exit event to be interpreted differently depending on the code page
in effect. Internally all strings parsed from command line and config
file are stored as UTF8-encoded Uniode. When passed to Windows API calls,
these should be converted to UTF16 and wide character version of the API
should be used.

CreateEvent calls for unnamed events are left unchanged as there is no
text-encoding dependence in those cases.

Signed-off-by: Selva Nair <selva.nair@gmail.com>
Acked-by: Lev Stipakov <lstipakov@gmail.com>
Message-Id: <20230516024232.2680491-1-selva.nair@gmail.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg26666.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
2 years agosample-plugins: Fix memleak in client-connect example plugin
Frank Lichtenheld [Tue, 16 May 2023 09:35:34 +0000 (11:35 +0200)] 
sample-plugins: Fix memleak in client-connect example plugin

I was looking for memleaks in the code and found
this one with cppcheck. Only an example, but no
need to leave this bug in it.

Also fix fortify problem in keying-material-exporter-demo
so I can actually test the compilation of the sample
plugins.

v2:
 - remove unneccessary usages of snprintf, replace
   with strncpy.

Change-Id: Ibd1b282afc4a28768be3f165f84ab60ca4d24a9b
Signed-off-by: Frank Lichtenheld <frank@lichtenheld.com>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20230516093534.26384-1-frank@lichtenheld.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg26668.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
2 years agoFix two unused assignments
Frank Lichtenheld [Mon, 15 May 2023 15:54:07 +0000 (17:54 +0200)] 
Fix two unused assignments

A fallout of my memleak investigation. These are
not leaks, we just assign a value that is never
read before overwritten. Not critical, but since
I already stumbled over it...

Change-Id: I761ea3d289f49a20e42a3d1bfccebce3c7447afe
Signed-off-by: Frank Lichtenheld <frank@lichtenheld.com>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20230515155407.38647-1-frank@lichtenheld.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg26662.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
2 years agoDCO: fix memory leak in dco_get_peer_stats_multi for Linux
Frank Lichtenheld [Mon, 15 May 2023 14:21:16 +0000 (16:21 +0200)] 
DCO: fix memory leak in dco_get_peer_stats_multi for Linux

Leaks a small amount of memory every 15s.

Signed-off-by: Frank Lichtenheld <frank@lichtenheld.com>
Acked-by: Antonio Quartulli <a@unstable.cc>
Message-Id: <20230515142116.33135-1-frank@lichtenheld.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg26659.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
2 years agodco_linux: properly close dco version file
Frank Lichtenheld [Fri, 12 May 2023 15:50:23 +0000 (17:50 +0200)] 
dco_linux: properly close dco version file

Since we only call this once, it is not a bad
leak, but still.

Change-Id: Id85766738c3ece4f2d1860f7d101e4446a894aed
Signed-off-by: Frank Lichtenheld <frank@lichtenheld.com>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20230512155023.444406-1-frank@lichtenheld.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg26650.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
2 years agoBugfix: dangling pointer passed to pkcs11-helper
Selva Nair [Tue, 9 May 2023 17:05:17 +0000 (13:05 -0400)] 
Bugfix: dangling pointer passed to pkcs11-helper

Github: Fixes OpenVPN/openvpn#323

Signed-off-by: Selva Nair <selva.nair@gmail.com>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20230509170517.2637245-1-selva.nair@gmail.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg26640.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
2 years agovcpkg-ports/pkcs11-helper: reference upstream PRs in patches
Frank Lichtenheld [Fri, 31 Mar 2023 15:42:14 +0000 (17:42 +0200)] 
vcpkg-ports/pkcs11-helper: reference upstream PRs in patches

So it is easier to check the merge status.

Change-Id: Ia1f8a8d26d4752a7dda1a20521c59ded06bc7c52
Signed-off-by: Frank Lichtenheld <frank@lichtenheld.com>
Acked-by: Lev Stipakov <lstipakov@gmail.com>
Message-Id: <20230331154214.613245-4-frank@lichtenheld.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg26569.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
2 years agovcpkg-ports/pkcs11-helper: Convert CONTROL to vcpkg.json
Frank Lichtenheld [Fri, 31 Mar 2023 15:42:13 +0000 (17:42 +0200)] 
vcpkg-ports/pkcs11-helper: Convert CONTROL to vcpkg.json

To be in line with current vcpkg packaging policies.

Change-Id: Ifad0965a2b724b0b278783ba9c0ad5a82274445d
Signed-off-by: Frank Lichtenheld <frank@lichtenheld.com>
Acked-by: Lev Stipakov <lstipakov@gmail.com>
Message-Id: <20230331154214.613245-3-frank@lichtenheld.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg26571.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
2 years agovcpkg-ports/pkcs11-helper: Make compatible with mingw build
Frank Lichtenheld [Fri, 31 Mar 2023 15:42:12 +0000 (17:42 +0200)] 
vcpkg-ports/pkcs11-helper: Make compatible with mingw build

Annoyingly this requires custom vcpkg triplets because
the mingw toolchain definition and the vcpkg_configure_make
function use incompatible default triplets (-pc-mingw32 vs
-w64-mingw32).

Change-Id: I4e671938220e9bfd798f91819f34b6f8ceaa45f5
Signed-off-by: Frank Lichtenheld <frank@lichtenheld.com>
Acked-by: Lev Stipakov <lstipakov@gmail.com>
Message-Id: <20230331154214.613245-2-frank@lichtenheld.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg26572.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
2 years agoFix compile error on TARGET_ANDROID
Arne Schwabe [Mon, 17 Apr 2023 13:40:46 +0000 (15:40 +0200)] 
Fix compile error on TARGET_ANDROID

Commit 3132bead49 accidentially was submitted with a missing semicolon
at the end of the line. Whoops.

Signed-off-by: Arne Schwabe <arne@rfc2549.org>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20230417134046.81761-1-arne@rfc2549.org>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg26593.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
2 years agofix typo in help text: --ignore-unknown-option
Michael Nix [Mon, 17 Apr 2023 12:54:46 +0000 (14:54 +0200)] 
fix typo in help text: --ignore-unknown-option

Signed-off-by: Frank Lichtenheld <frank@lichtenheld.com>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20230417125446.27247-1-frank@lichtenheld.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg26592.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
2 years agotests: do not include t_client.sh in dist
Frank Lichtenheld [Tue, 18 Apr 2023 13:49:41 +0000 (15:49 +0200)] 
tests: do not include t_client.sh in dist

It is generated from t_client.sh.in by configure,
so no need to ship it. Due to the dependency on
the configuration it also might break reproducibility
of the dist tarball.

Signed-off-by: Frank Lichtenheld <frank@lichtenheld.com>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20230418134941.86637-1-frank@lichtenheld.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg26596.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
2 years agoman page: Remove cruft from --topology documentation
Frank Lichtenheld [Wed, 3 May 2023 13:59:21 +0000 (15:59 +0200)] 
man page: Remove cruft from --topology documentation

None of this is likely relevant for a current reader.

Signed-off-by: Frank Lichtenheld <frank@lichtenheld.com>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20230503135922.54871-1-frank@lichtenheld.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg26621.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
2 years agoDCO: support key rotation notifications
Kristof Provost [Fri, 14 Apr 2023 09:42:27 +0000 (11:42 +0200)] 
DCO: support key rotation notifications

Allow the kernel driver to notify us that it's time to renegotiate keys.
The intent is to avoid IV re-use after 2^32 packets.

This is a first draft intended for discussion. The accompanying kernel
change for FreeBSD can be found in https://reviews.freebsd.org/D39570

Signed-off-by: Kristof Provost <kprovost@netgate.com>
Acked-by: Antonio Quartulli <antonio@openvpn.net>
Message-Id: <20230414094227.9153-1-kprovost@netgate.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg26590.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
2 years agoFormat Windows error message in Unicode
Selva Nair [Tue, 18 Apr 2023 14:14:46 +0000 (10:14 -0400)] 
Format Windows error message in Unicode

- We assume that all text passed to the management interface
  and written to log file are in Unicode (UTF-8). This is broken by
  the use of the ANSI version of FormatMessage() for Windows error
  messages. Fix by using FormatMessageW() and converting the UTF-16
  result to UTF-8.

v2: assign return value of FormatMessageW() to DWORD, not int

Github: fixes OpenVPN/openvpn#319

Signed-off-by: Selva Nair <selva.nair@gmail.com>
Acked-by: Frank Lichtenheld <frank@lichtenheld.com>
Message-Id: <20230418141446.1755363-1-selva.nair@gmail.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg26598.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
2 years agoAdd Apache2 linking with for new commits
Arne Schwabe [Wed, 26 Apr 2023 09:49:31 +0000 (11:49 +0200)] 
Add Apache2 linking with for new commits

After first round of mailing people with more than 10 commits we have
almost all committers have agreed. This put this license in the realm
of having a realistic change to work. Had any of these contributers
disagreed, rewriting all their code might have been not feasible.

The rationale of adding this exception now is to avoid having to
have a second round of agreement for new contributers and ensure
that all new code will include the exemption.

patch v2: add explaination and use exception rather than excemption
patch v3: actually send v3

Change-Id: Ide83f914f383b53ef37ddf628e4da5a78e241bf0
Signed-off-by: Arne Schwabe <arne@rfc2549.org>
Acked-by: David Sommerseth <davids@openvpn.net>
Message-Id: <20230426094931.1168078-1-arne@rfc2549.org>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg26610.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
2 years agoRemove unused variable line
Arne Schwabe [Sun, 30 Apr 2023 17:22:02 +0000 (19:22 +0200)] 
Remove unused variable line

The newer compilers started to complain about this.

Change-Id: I784def4d941b7d21c7979f84f8681719c9ff7a53
Signed-off-by: Arne Schwabe <arne@rfc2549.org>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20230430172202.206528-1-arne@rfc2549.org>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg26612.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
2 years agodoc: run rst2* with --strict to catch warnings
Frank Lichtenheld [Fri, 31 Mar 2023 13:24:29 +0000 (15:24 +0200)] 
doc: run rst2* with --strict to catch warnings

Basically -Werror for docutils.

Fix all issues raised by this. The following issue
classes were reported:

Possible title underline, too short for the title.
Treating it as ordinary text because it's so short.
(:: at the start of the line directly below text,
either add empty line of merge into : on previous line)

Enumerated list start value not ordinal-1
(error in numbering)

Change-Id: Id3b0f7be4602f70115c60e6ddb89f6ed58e94e64
Signed-off-by: Frank Lichtenheld <frank@lichtenheld.com>
Acked-by: Arne Schwabe <arne@rfc2549.org>
Message-Id: <20230331132429.601635-1-frank@lichtenheld.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg26567.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
2 years agoSupport of DNS domain for DHCP-less drivers
Lev Stipakov [Thu, 6 Apr 2023 07:15:46 +0000 (10:15 +0300)] 
Support of DNS domain for DHCP-less drivers

We set DNS domain either via interactve service or DHCP.
When interactive service is not used, for example,
when profiles are started by OpenVPNService, this option
is not working for DCO and wintun.

This implements setting DNS domain via WMIC command,
similar to implementation in interactive service.
This is done when:

 - interactive service is not used

 - DHCP is not used (ip-win32 is either NETSH or IPAPI,
   or IPv4 address is not pushed)

Github: fixes OpenVPN/openvpn#306

Change-Id: Ic72a4ecd0414c0d7bf013415f52640fd122cb739
Signed-off-by: Lev Stipakov <lev@openvpn.net>
Acked-by: Selva Nair <selva.nair@gmail.com>
Message-Id: <20230406071546.1056-1-lstipakov@gmail.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg26582.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
2 years agoversion.sh: remove
Frank Lichtenheld [Thu, 30 Mar 2023 09:42:26 +0000 (11:42 +0200)] 
version.sh: remove

This was added back in commit
6187644b660ce284d0a706811eae2dce7cb411b2
to support the NSIS windows installer.

It is now unused.

Signed-off-by: Frank Lichtenheld <frank@lichtenheld.com>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20230330094226.487951-1-frank@lichtenheld.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg26560.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
2 years agoDo not include net/in_systm.h
Frank Lichtenheld [Thu, 30 Mar 2023 09:42:15 +0000 (11:42 +0200)] 
Do not include net/in_systm.h

This only defines three types and none of them is
used anywhere in our source code.

Signed-off-by: Frank Lichtenheld <frank@lichtenheld.com>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20230330094215.487924-1-frank@lichtenheld.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg26559.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
2 years agovcpkg: request "tools" feature of openssl for MSVC build
Frank Lichtenheld [Thu, 30 Mar 2023 10:15:36 +0000 (12:15 +0200)] 
vcpkg: request "tools" feature of openssl for MSVC build

We need this for the MSI build. Previously this was enabled
by default.

Signed-off-by: Frank Lichtenheld <frank@lichtenheld.com>
Acked-by: Lev Stipakov <lstipakov@gmail.com>
Message-Id: <20230330101536.533080-1-frank@lichtenheld.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg26561.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
2 years agoMake cert_data.h and test_cryptoapi/pkcs11.c MSVC compliant
Selva Nair [Mon, 27 Mar 2023 11:49:37 +0000 (07:49 -0400)] 
Make cert_data.h and test_cryptoapi/pkcs11.c MSVC compliant

- Do not use non-literal initializers for static objects
- Replace empty initializer {} by {0}

Signed-off-by: Selva Nair <selva.nair@gmail.com>
Co-authored-by: Frank Lichtenheld <frank@lichtenheld.com>
Acked-by: Frank Lichtenheld <frank@lichtenheld.com>
Message-Id: <20230327114937.28246-1-selva.nair@gmail.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg26525.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
2 years agoEnable pkcs11 an dtest_pkcs11 in github actions
Selva Nair [Wed, 22 Mar 2023 22:14:56 +0000 (18:14 -0400)] 
Enable pkcs11 an dtest_pkcs11 in github actions

- Enabled for the Ubuntu 22.04 build (OpenSSL 3) and one of the
  Ubuntu 20.04 builds (OpenSSL 1.1.1).

Signed-off-by: Selva Nair <selva.nair@gmail.com>
Acked-by: Frank Lichtenheld <frank@lichtenheld.com>
Message-Id: <20230322221456.1660425-3-selva.nair@gmail.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg26485.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
2 years agoUnit tests: Test for PKCS#11 using a softhsm2 token
Selva Nair [Wed, 22 Mar 2023 22:14:55 +0000 (18:14 -0400)] 
Unit tests: Test for PKCS#11 using a softhsm2 token

- Load some test certificate/key pairs into a temporary softhsm2 token
  and enumerate available objects through pkcs11-helper interface

- For each object, load it into SSL_CTX and test sign (if using OpenSSL 3)
  or check the certificate and public-key match (if using OpenSSl 1.1.1.).
  The pkcs11-id for each object is specified directly or
  through a mocked management callback to test pkcs11-id-management

Limitations:
  Depends on libsofthsm2.so and p11tool (install softhsm2 and gnutls-bin
  packages). Mbed-TLS/pkcs11-helper combination is not tested.

  If locations of these binaries are not auto-detected or need to be
  overridden, use -DSOFTHSM2_UTIL=<path> -DP11TOOL=<path> to configure.
  Location of SOFTHSM2_MODULE is not auto-detected and defaults to
  /usr/lib/softhsm/libsofthsm2.so. It may be changed by passing
  -DSOFTHSM2_MODULE=/some-path/libsofthsm2.so to configure.
  Also see "configure --help".

  The test is enabled only if --enable-pkcs11 is in use, and SOFTHSM2_UTIL
  & P11TOOL are found in path or manually defined during configuring.

Changes relative to github PR
  - Explicitly disable building the test on Windows: need to port mkstemp,
    mkdtemp, setenv etc., before enabling this on Windows.

Signed-off-by: Selva Nair <selva.nair@gmail.com>
Acked-by: Frank Lichtenheld <frank@lichtenheld.com>
Message-Id: <20230322221456.1660425-2-selva.nair@gmail.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg26483.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
2 years agoMove digest_sign_verify out of test_cryptoapi.c
Selva Nair [Wed, 22 Mar 2023 22:14:54 +0000 (18:14 -0400)] 
Move digest_sign_verify out of test_cryptoapi.c

- This function will be reused for testing pkcs11

Signed-off-by: Selva Nair <selva.nair@gmail.com>
Acked-by: Frank Lichtenheld <frank@lichtenheld.com>
Message-Id: <20230322221456.1660425-1-selva.nair@gmail.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg26484.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
2 years agoGHA: remove Ubuntu 18.04 builds
Frank Lichtenheld [Tue, 28 Mar 2023 10:09:26 +0000 (12:09 +0200)] 
GHA: remove Ubuntu 18.04 builds

Github will stop supporting them on April, 1st.

Signed-off-by: Frank Lichtenheld <frank@lichtenheld.com>
Acked-by: Matthias Andree <matthias.andree@gmx.de>
Message-Id: <20230328100926.138233-1-frank@lichtenheld.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg26541.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
2 years agoBug-fix: segfault in dco_get_peer_stats()
Selva Nair [Mon, 27 Mar 2023 17:12:36 +0000 (13:12 -0400)] 
Bug-fix: segfault in dco_get_peer_stats()

  We persist peer-stats when restarting, but an early restart
  before open_tun results in a segfault in dco_get_peer_stats().
  To reproduce, trigger a TLS handshake error due to lack of common
  protocols, for example.

  Fix by checking  that tuntap is defined before dereferencing it.

Signed-off-by: Selva Nair <selva.nair@gmail.com>
Acked-by: Antonio Quartulli <a@unstable.cc>
Message-Id: <20230327171236.51771-1-selva.nair@gmail.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg26530.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
2 years agoDon't overwrite socket flags when using DCO on Windows
Lev Stipakov [Fri, 24 Mar 2023 12:18:18 +0000 (14:18 +0200)] 
Don't overwrite socket flags when using DCO on Windows

Socket flags can be pushed, in which case they overwrite
existing value. We use socket flags to distingust between
DCO handle and socket on Windows. If server pushes --socket-flags,
we treat DCO handle as socket and everything explodes.

Fix by making link_socket_update_flags() update flags
(like name suggests) instead of overwriting them. Also
do not set TCP_NODELAY on DCO handle on Windows because
it doesn't make sense.

Change-Id: Ia34d73ca49041cb0ce22b84751cdbff57de96048
Signed-off-by: Lev Stipakov <lev@openvpn.net>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20230324121818.2358-1-lstipakov@gmail.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg26513.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
2 years agoParse compression options and bail out when compression is disabled
Arne Schwabe [Fri, 24 Mar 2023 12:10:50 +0000 (13:10 +0100)] 
Parse compression options and bail out when compression is disabled

This change keeps the option parsing of compression options even when
compression is disabled. This allows OpenVPN to also refuse/reject
connections that try to use compression when compression is completely
disabled.

Patch v4: fix one missing USE_COMP

Change-Id: I9d7afd8f1d67d2455b4ec6bc12f4dcde80140c4f
Signed-off-by: Arne Schwabe <arne@rfc2549.org>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20230324121050.1350913-1-arne@rfc2549.org>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg26512.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
2 years agoAdd 'allow-compression stub-only' internally for DCO
Arne Schwabe [Fri, 24 Mar 2023 10:06:40 +0000 (11:06 +0100)] 
Add 'allow-compression stub-only' internally for DCO

This changes the "no" setting of allow-compression to also refuse framing
if DCO is active.  This is important for our DCO implementations as these
do not implement framing.

This behaviour surfaced when a commercial VPN provider was pushing
"comp-lzo no" to a client with DCO. While we are technically at fault here
for announcing comp-lzo no support by announcing IV_LZO_STUB=1, the
VPN provider continues to push "comp-lzo no" even in absense of that
flag.

As the new default we default to 'allow-compression no' if DCO is
enabled and to 'allow-compression stub' otherwise.

This will now also bail out if the server pushes a compression setting that
we do not support as mismatching compression is almost never a working
connection. In the case of lz4-v2 and lzo-v2 you might have a connection
that works mostly but some packets will be dropped since they compressed
which is not desirable either since it becomes very hard to debug.

Patch v2: bail out if server pushes an unsupported method. Also include this
          bail out logic when OpenVPN is compiled without compression support.

Patch v3: always parse all compression option and move logic to check method
Patch v4: fix for not setting correct default for non-dco

Change-Id: Ibd0c77af24e2214b3055d585dc23a4b06dccd414
Signed-off-by: Arne Schwabe <arne@rfc2549.org>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20230324100640.1340535-1-arne@rfc2549.org>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg26509.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
2 years agoRefuse connection if server pushes an option contradicting allow-compress
Arne Schwabe [Thu, 23 Mar 2023 17:05:59 +0000 (18:05 +0100)] 
Refuse connection if server pushes an option contradicting allow-compress

This removes also the checks in options.c itself as they we now bail out
later and no longer need to ignore them during parsing.

Change-Id: I872c06f402c35112194ba77c3d6aee78e22547cb
Signed-off-by: Arne Schwabe <arne@rfc2549.org>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20230323170601.1256132-2-arne@rfc2549.org>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg26503.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
2 years agoSimplify --compress parsing in options.c
Arne Schwabe [Thu, 23 Mar 2023 17:05:58 +0000 (18:05 +0100)] 
Simplify --compress parsing in options.c

This removes a level of identation and make the "stub" condition
easier to see.

Change-Id: Iae47b191f522625f81eedd3a237b272cb7374d90
Signed-off-by: Arne Schwabe <arne@rfc2549.org>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20230323170601.1256132-1-arne@rfc2549.org>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg26501.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
2 years agodco-linux: implement dco_get_peer_stats{, multi} API
Antonio Quartulli [Wed, 22 Mar 2023 19:27:57 +0000 (20:27 +0100)] 
dco-linux: implement dco_get_peer_stats{, multi} API

With this API it is possible to retrieve the stats for a specific peer
or for all peers and then update the userspace counters with the value
reported by DCO.

Change-Id: Ia3990b86b1be7ca844fb1674b39ce0d60528ccff
Signed-off-by: Antonio Quartulli <a@unstable.cc>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20230322192757.20767-1-a@unstable.cc>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg26481.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
2 years agoPrint DCO client stats on SIGUSR2
Lev Stipakov [Wed, 22 Mar 2023 11:32:49 +0000 (13:32 +0200)] 
Print DCO client stats on SIGUSR2

Change-Id: I465febdf7ee5fe573e88255844f718efb60f8e8a
Signed-off-by: Lev Stipakov <lev@openvpn.net>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20230322113249.2039-1-lstipakov@gmail.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg26471.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
2 years agodco-freebsd: use m->instances[] instead of m->hash
Antonio Quartulli [Thu, 23 Mar 2023 08:03:41 +0000 (09:03 +0100)] 
dco-freebsd: use m->instances[] instead of m->hash

When retrieving the multi_instance of a specific peer,
there is no need to peform a linear search across the
whole m->hash list. We can directly access the needed
object via m->instances[peer-id] in constant time (and
just one line of code).

Adapt the dco-freebsd code to do so.

v4: use "peerid" everywhere as that's what FreeBSD does, change message
text

Cc: Kristof Provost <kp@FreeBSD.org>
Change-Id: I8d8af6f872146604a9710edf443db65df48ac3cb
Signed-off-by: Antonio Quartulli <a@unstable.cc>
Acked-by: Arne Schwabe <arne@rfc2549.org>
Acked-by: Kristof Provost <kp@freebsd.org>
Message-Id: <20230323080341.51624-1-gert@greenie.muc.de>
URL: https://www.mail-archive.com/search?l=mid&q=20230323080341.51624-1-gert@greenie.muc.de
Signed-off-by: Gert Doering <gert@greenie.muc.de>
2 years agoMake error in setting metric for IPv6 interface non-fatal
Selva Nair [Wed, 22 Mar 2023 15:15:50 +0000 (11:15 -0400)] 
Make error in setting metric for IPv6 interface non-fatal

- Unfortunately there are still users out there who disable IPv6
  on tun/tap/dco interfaces or even system-wide.

Github: fixes OpenVPN/openvpn#294
Signed-off-by: Selva Nair <selva.nair@gmail.com>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20230322151550.1596669-1-selva.nair@gmail.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg26477.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
2 years agoFix '--inactive <time> 0' behavior for DCO
Lev Stipakov [Wed, 22 Mar 2023 11:34:08 +0000 (13:34 +0200)] 
Fix '--inactive <time> 0' behavior for DCO

Make sure we exit if <bytes> is 0 (not set) and no traffic
was produced.

According to man page and non-DCO --inactive implementation,
we exit if amount of bytes produced is less than <bytes> specified.
DCO implementation will do off-by-ones, but we consider it as okay
since we don't want to complicate code to handle both bytes=0 and >0
cases.

Change-Id: I4c089e486728a43bfe42596787c00355838311da
Signed-off-by: Lev Stipakov <lev@openvpn.net>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20230322113408.2057-1-lstipakov@gmail.com>
URL: https://www.mail-archive.com/search?l=mid&q=20230322113408.2057-1-lstipakov@gmail.com
Signed-off-by: Gert Doering <gert@greenie.muc.de>
2 years agodns option: allow up to eight addresses per server
Heiko Hund [Fri, 10 Mar 2023 05:08:12 +0000 (06:08 +0100)] 
dns option: allow up to eight addresses per server

This change allows configuration of more than one address per family
for a DNS server. This way you can specify backup addresses in case a
server is not reachable. During closer inspection of the various DNS
backend in supported operation systems it turned out that our previous
idea to have more than one DNS server applied in order of priority does
not work in most cases. Thus it became important to be able to specify
backup addresses. So instead of doing

  dns server 1 address 1.2.3.4 2001::1
  dns server 2 address 5.6.7.8 2001::2

to specify a backup addresses, this is now done like so:

  dns server 1 address 1.2.3.4 2001::1
  dns server 1 address 5.6.7.8 2001::2

or you can have all the addresses on one line if you like:

  dns server 1 address 1.2.3.4 2001::1 2001::2 5.6.7.8

This also saves some repeated options when (backup) servers share the
same settings like "resolve-domains" compared to the originally intended
way.

The order in which addresses are given is retained for backends that
support this sort of cross address family ordering.

Change-Id: I9bd3d6d05da4e61a5fa05c0e455fc770b1fe186a
Signed-off-by: Heiko Hund <heiko@ist.eigentlich.net>
Acked-by: Arne Schwabe <arne@rfc2549.org>
Message-Id: <20230310050814.67246-1-heiko@ist.eigentlich.net>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg26386.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
2 years agomulti: don't call DCO APIs if DCO is disabled
Antonio Quartulli [Tue, 21 Mar 2023 10:28:42 +0000 (11:28 +0100)] 
multi: don't call DCO APIs if DCO is disabled

The agreement with the DCO submodule is that no API should be called if
DCO is actually disabled. For this reason, every invocation must happen
only after having checked that dco_enabled() returns true.

Add missing checks before invoking dco_get_peer_stats_multi()

Reported-by: Lev Stipakov <lev@openvpn.net>
Signed-off-by: Antonio Quartulli <a@unstable.cc>
Acked-by: Lev Stipakov <lstipakov@gmail.com>
Message-Id: <20230321102842.10780-1-a@unstable.cc>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg26458.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
2 years agoImprove description of compat-mode
Arne Schwabe [Mon, 20 Mar 2023 16:55:38 +0000 (17:55 +0100)] 
Improve description of compat-mode

Explicitly say that the version specified is the one of the peer and not
the version we try to emulate.

Patch v2: Improve grammar.
Change-Id: I3bd27a8d34d8cb4896a3b78508b7d16911571543

Change-Id: If4fb45b3426f5e0dbe6c87d5bd05681b9d733827
Signed-off-by: Arne Schwabe <arne@rfc2549.org>
Acked-by: Frank Lichtenheld <frank@lichtenheld.com>
Message-Id: <20230320165538.902965-1-arne@rfc2549.org>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg26445.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
2 years agodco-linux: remove M_ERRNO flag when printing netlink error message
Antonio Quartulli [Mon, 20 Mar 2023 19:58:20 +0000 (20:58 +0100)] 
dco-linux: remove M_ERRNO flag when printing netlink error message

Netlink has its own error space and reports errors via the return
value of its functions.

For this reason remove the M_ERRNO flag when printing its errors.
At the moment we get something like this:

netlink reports error (-7): Invalid input data or parameter: Interrupted
system call (errno=4)

where the errno=4 (and its human readable representation) is a leftover
from the previous recv() interrupted by a signal and it is totally
unrelated to this netlink failure.

Signed-off-by: Antonio Quartulli <a@unstable.cc>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20230320195820.6675-1-a@unstable.cc>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg26452.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
2 years agoImprove error message on short read from socks proxy
Selva Nair [Sat, 18 Mar 2023 14:13:30 +0000 (10:13 -0400)] 
Improve error message on short read from socks proxy

Change-Id: Id00006bf8ea705d02eff2cbfba7d841e1cdb6ae1
Signed-off-by: Selva Nair <selva.nair@gmail.com>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20230318141330.1315235-1-selva.nair@gmail.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg26437.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
2 years agoUnit tests: add test for SSL_CTX_use_Cryptoapi_certificate()
Selva Nair [Sat, 18 Mar 2023 14:43:25 +0000 (10:43 -0400)] 
Unit tests: add test for SSL_CTX_use_Cryptoapi_certificate()

- This is the only remaining function in cryptoapi.c that has no
  direct or indirect test.

  This test confirms that an SSL_CTX context gets a certificate and
  private key loaded into it and the public key in the certificate
  matches the private key. As signing with certificate/key pairs
  fetched from the store is independently tested by the 'cryptoapi_sign'
  test, signing is not re-tested here.

  The functions "setup_/teardown_cryptoapi_sign()" are renamed to
  "setup_/teardown_xkey_provider()" to better reflect their purpose.
  These are also reused for the new test.

  While touching this context, also fix a memory leak in
  test_cryptoapi_sign: X509_get_pubkey() -> X509_get0_pubkey()

Signed-off-by: Selva Nair <selva.nair@gmail.com>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20230318144325.1316320-1-selva.nair@gmail.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg26438.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
2 years agoOnly update frame calculation if we have a valid link sockets
Arne Schwabe [Wed, 1 Mar 2023 13:44:55 +0000 (14:44 +0100)] 
Only update frame calculation if we have a valid link sockets

Without this, we will caculate a pointer to the linksocket relative to a
null pointer in get_link_socket_info(), which itself does not crash and
the pointer seems not to be accessed later, so we do not get a crash here.

This is still not the correct behaviour and the undefined behaviour
sanitiser from llvm/clang finds this.

Change-Id: I82a20ac72f60f8770ea1b4ab0c8cdea31868abe7
Signed-off-by: Arne Schwabe <arne@rfc2549.org>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20230301134455.2810114-1-arne@rfc2549.org>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg26318.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
2 years agoMake sending plain text control message session aware
Arne Schwabe [Wed, 1 Mar 2023 13:53:53 +0000 (14:53 +0100)] 
Make sending plain text control message session aware

The control messages coming from auth pending should always be on the
session that triggered them (i.e. INITIAL or ACTIVE) and not always on the
active session.  Rework the code path that trigger those messsages from
management and plugin/script to specify the TLS session.

We only support the two TLS sessions that are supposed to be active. TLS
sessions in any lame slot (TM_LAME or KS_LAME) are not considered to be
candidates for sending messages as these slots only serve to keep key
material around.

Unfortunately, this fix requires the management interface to be changed
to allow including the specific session the messages should to go to. As
there are very few users of this interface with auth-pending, I made this
a hard change instead of adding hacky workaround code that is not always
working correctly anyway.

send_control_channel_string() will continue to only use the primary session
and key but the current users of that (push replys and exit notification)
already require the established session to be the active one, so there
no changes needed at the moment.

Github: fixes OpenVPN/openvpn#256

Signed-off-by: Arne Schwabe <arne@rfc2549.org>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20230301135353.2811069-2-arne@rfc2549.org>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg26320.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
2 years agoUse key_state instead of multi for tls_send_payload parameter
Arne Schwabe [Wed, 1 Mar 2023 13:53:52 +0000 (14:53 +0100)] 
Use key_state instead of multi for tls_send_payload parameter

Currently, this function and other parts of OpenVPN assume that
multi->session[TM_ACTIVE].key[KS_PRIMARY] is always the right session
to send control message.

This assumption was only achieve through complicated session moving and
shuffling in our state machine in the past. The old logic basically also
always assumed that control messages are always for fully authenticated
clients. This assumption was never really true (see AUTH_FAILED message)
but has been broken even more by auth-pending. Cleaning up the state machine
transitions in 7dcde87b7a broke this assumption even more.

This change now allows to specify the key_state/TLS session that is used to
send the control message.

Signed-off-by: Arne Schwabe <arne@rfc2549.org>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20230301135353.2811069-1-arne@rfc2549.org>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg26319.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
2 years agousing OpenSSL3 API for EVP PKEY type name reporting
Michael Baentsch [Sun, 19 Mar 2023 07:54:41 +0000 (08:54 +0100)] 
using OpenSSL3 API for EVP PKEY type name reporting

Signed-off-by: Michael Baentsch <info@baentsch.ch>
Acked-by: Arne Schwabe <arne@rfc2549.org>
Message-Id: <20230319075441.13021-1-info@baentsch.ch>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg26439.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
2 years agoSupport --inactive option for DCO
Lev Stipakov [Wed, 15 Mar 2023 13:38:08 +0000 (15:38 +0200)] 
Support --inactive option for DCO

When DCO is in use, userland doesn't see any traffic
which breaks --inactive option.

Fix by adding inactivity check to inactivity timeout
callback. Get the cumulative tun bytes count (ping packets
are excluded) from DCO and compare it to the previous value
stored in c2.inactivity_bytes. Reset inactivity timer and
update c2.inactivity_bytes if amount of new bytes exceeds
inactivity_minimum_bytes, otherwise terminate session
due to inactivity.

Github: Fixes OpenVPN/openvpn#228

Currently works only on Windows, since we don't yet have
single peer stats implementation for Linux and FreeBSD.

Change-Id: Ib417b965bc4a2c17b51935b43c9627b106716526
Signed-off-by: Lev Stipakov <lev@openvpn.net>
Acked-by: Heiko Hund <heiko@ist.eigentlich.net>
Message-Id: <20230315133808.1550-1-lstipakov@gmail.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg26421.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
2 years agoAdd a test for signing with certificates in Windows store
Selva Nair [Wed, 15 Mar 2023 01:35:16 +0000 (21:35 -0400)] 
Add a test for signing with certificates in Windows store

- For each sample certificate/key pair imported into the store,
  load the key into xkey-provider and sign a test message.
  As the key is "provided", signing will use appropriate
  backend (Windows CNG in this case).

  The signature is then verified using OpenSSL.

Change-Id: I520b34ba51e8c6d0247a82edc52bde181ab5a717
Signed-off-by: Selva Nair <selva.nair@gmail.com>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20230315013516.1256700-5-selva.nair@gmail.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg26416.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
2 years agoRefactor SSL_CTX_use_CryptoAPI_certificate()
Selva Nair [Wed, 15 Mar 2023 01:35:15 +0000 (21:35 -0400)] 
Refactor SSL_CTX_use_CryptoAPI_certificate()

- Loading the certificate and key into the provider is split out of
  setting up the SSL context. This allows testing of signing by
  cryptoapi-provider interface without dependence on SSL context
  or link-time wrapping.

Change-Id: I269b94589636425e1ba9bf953047d238fa830376
Signed-off-by: Selva Nair <selva.nair@gmail.com>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20230315013516.1256700-4-selva.nair@gmail.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg26414.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
2 years agoAdd tests for finding certificates in Windows cert store
Selva Nair [Wed, 15 Mar 2023 01:35:14 +0000 (21:35 -0400)] 
Add tests for finding certificates in Windows cert store

- find_certificate_in_store tested using 'SUBJ:', 'THUMB:'
  and 'ISSUER:' select strings. Uses test certificates
  imported into the store during the import test.

Change-Id: Ib5138465e6228538af592ca98b3d877277355f59
Signed-off-by: Selva Nair <selva.nair@gmail.com>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20230315013516.1256700-3-selva.nair@gmail.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg26415.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
2 years agoImport some sample certificates into Windows store for testing
Selva Nair [Wed, 15 Mar 2023 01:35:13 +0000 (21:35 -0400)] 
Import some sample certificates into Windows store for testing

- A few sample certificates are defined and imported into
  Windows certificate store (user store).
  This only tests the import process. Use of these certs to test the
  core functionality of 'cryptoapicert' are in following commits.

Change-Id: Ida5fc12c5bad5fde202da0bf0e8cdc71efe548c2
Signed-off-by: Selva Nair <selva.nair@gmail.com>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20230315013516.1256700-2-selva.nair@gmail.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg26417.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>