]> git.ipfire.org Git - thirdparty/openvpn.git/log
thirdparty/openvpn.git
2 years agoLinux: Retain CAP_NET_ADMIN when dropping privileges
Timo Rothenpieler [Sat, 14 May 2022 10:37:17 +0000 (12:37 +0200)] 
Linux: Retain CAP_NET_ADMIN when dropping privileges

On Linux, when dropping privileges, interaction with
the network configuration, such as tearing down routes
or ovpn-dco interfaces will fail when --user/--group are
used.

This patch sets the CAP_NET_ADMIN capability, which grants
the needed privileges during the lifetime of the OpenVPN
process when dropping root privileges.

Signed-off-by: Timo Rothenpieler <timo@rothenpieler.org>
Reviewed-By: David Sommerseth <davids@openvpn.net>
Acked-by: Frank Lichtenheld <frank@lichtenheld.com>
Message-Id: <20220514103717.235-1-timo@rothenpieler.org>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg24360.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
2 years agoRemove outdated information from ChangeLog, point at release branches.
Gert Doering [Wed, 10 Aug 2022 08:47:01 +0000 (10:47 +0200)] 
Remove outdated information from ChangeLog, point at release branches.

ChangeLog is not maintained in "master", document as such.

Signed-off-by: Gert Doering <gert@greenie.muc.de>
Acked-by: Arne Schwabe <arne@rfc2549.org>
Message-Id: <20220810084701.13226-1-gert@greenie.muc.de>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg24854.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
2 years agotun.c: remove unused gc_arena from init_tun()
Lev Stipakov [Tue, 9 Aug 2022 07:22:20 +0000 (10:22 +0300)] 
tun.c: remove unused gc_arena from init_tun()

Signed-off-by: Lev Stipakov <lev@openvpn.net>
Acked-by: Antonio Quartulli <a@unstable.cc>
Message-Id: <20220809072220.255-1-lstipakov@gmail.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg24851.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
2 years agoconfig-version.h: remove unused includes
Frank Lichtenheld [Mon, 8 Aug 2022 08:54:11 +0000 (10:54 +0200)] 
config-version.h: remove unused includes

We only need to include this when we want the
git version.

Signed-off-by: Frank Lichtenheld <frank@lichtenheld.com>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20220808085411.9159-1-frank@lichtenheld.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg24839.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
2 years agoCleanup: get rid of 'dynamic' argument of open_tun_generic()
Gert Doering [Sun, 7 Aug 2022 19:35:35 +0000 (21:35 +0200)] 
Cleanup: get rid of 'dynamic' argument of open_tun_generic()

All callers of open_tun_generic() always set dynamic=true - so just
get rid of it.  While at it, move "int i" into the for() loop.

Signed-off-by: Gert Doering <gert@greenie.muc.de>
Acked-by: Antonio Quartulli <antonio@openvpn.net>
Message-Id: <20220807193535.15377-1-gert@greenie.muc.de>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg24838.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
2 years agodco: turn supported ciphers list into a function
Antonio Quartulli [Sun, 7 Aug 2022 10:04:04 +0000 (12:04 +0200)] 
dco: turn supported ciphers list into a function

Other platforms may need more complex logic to decide whether a cipher
is supported or not, therefore turn hardcoded list into a function that
can be implemented by each platform independently.

Signed-off-by: Lev Stipakov <lev@openvpn.net>
Signed-off-by: Antonio Quartulli <a@unstable.cc>
Acked-by: Heiko Hund <heiko@ist.eigentlich.net>
Message-Id: <20220807100404.8618-1-a@unstable.cc>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg24835.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
2 years agodco: disable DCO if --allow-compress yes/asym was specified
Antonio Quartulli [Sun, 7 Aug 2022 09:53:29 +0000 (11:53 +0200)] 
dco: disable DCO if --allow-compress yes/asym was specified

Allowing compression means that we may accept a pushable compress
setting.
This scenario can't work with DCO therefore disable it when compression
is allowed.

Signed-off-by: Antonio Quartulli <a@unstable.cc>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20220807095329.28819-1-a@unstable.cc>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg24834.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
2 years agoopenvpnmsica: remove OpenVPNService state check code
Lev Stipakov [Thu, 28 Jul 2022 11:17:12 +0000 (14:17 +0300)] 
openvpnmsica: remove OpenVPNService state check code

This code reads the state of OpenVPNService,
such as startup mode and running, and sets MSI
property value. If that property is set, installer
selects OpenVPNService as a feature to be installed.

This has been superseded by change in installer:

  https://github.com/OpenVPN/openvpn-build/pull/261

which, in addition to checking the state of OpenVPNService,
applies that state to the newly installed service.

  - by default, OpenVPNService feature is now checked
and service is installed

  - in clean installation, service startup mode is set to "manual"
and service is not started

  - in upgrade, installer preserves the service state, such
as startup mode and started/stopped

With all those changes to installer, we don't need this code
in openvpnmsica.

Signed-off-by: Lev Stipakov <lev@openvpn.net>
Acked-by: Selva Nair <selva.nair@gmail.com>
Message-Id: <20220728111712.94-1-lstipakov@gmail.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg24752.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
2 years agoReduce usage of __DATE__
Frank Lichtenheld [Thu, 4 Aug 2022 15:03:01 +0000 (17:03 +0200)] 
Reduce usage of __DATE__

To increase the reproducibility of builds
we shouldn't use __DATE__. However, for
the development builds there is some demand
for leaving this in.

So as suggested by Gert Doering go for a
compromise where we only use __DATE__ if
we also include the git information. This
will remove this information from release
builds, but not from builds done directly
from the git checkout.

Signed-off-by: Frank Lichtenheld <frank@lichtenheld.com>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20220804150301.62856-2-frank@lichtenheld.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg24807.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
2 years agodco: perform pull options check only if we pulled any option
Antonio Quartulli [Fri, 5 Aug 2022 15:08:37 +0000 (17:08 +0200)] 
dco: perform pull options check only if we pulled any option

The do_deferred_options() function is invoked also on the server side in
order to process all negotiated bits.

However, in this case we should not perform any pull options check, as
it's required only on the client side.

Move check within the "if (options.pull)" block to ensure we perform the
check only when required.

Reported-By: Gert Doering <gert@greenie.muc.de>
Signed-off-by: Antonio Quartulli <a@unstable.cc>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20220805150837.8169-1-a@unstable.cc>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg24824.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
3 years agodco: implement dco support for p2mp/server code path
Antonio Quartulli [Fri, 5 Aug 2022 06:45:55 +0000 (08:45 +0200)] 
dco: implement dco support for p2mp/server code path

This change introduces ovpn-dco support along the p2mp/server code path.
Some code seems to be duplicate of the p2p version, but details are
different, so it couldn't be shared.

Signed-off-by: Antonio Quartulli <a@unstable.cc>
Acked-by: Heiko Hund <heiko@ist.eigentlich.net>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20220805064555.13385-1-a@unstable.cc>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg24811.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
3 years agoBreak 'try 256 dco devices' loop on EPERM
Gert Doering [Thu, 4 Aug 2022 08:25:02 +0000 (10:25 +0200)] 
Break 'try 256 dco devices' loop on EPERM

If we get a permission denied error on one DCO device, trying 255 more
times will not succeed, and just fill the log file with errors.

Also, remove the msg() call there because it was at debug level
(needed --verb 4 to be seen), didn't see the correct errno, and the
sitnl code already prints the error.

v2: use "else if"

Signed-off-by: Gert Doering <gert@greenie.muc.de>
Acked-by: Antonio Quartulli <a@unstable.cc>
Message-Id: <20220804082502.1750074-1-gert@greenie.muc.de>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg24799.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
3 years agodco: add documentation for ovpn-dco-linux
Antonio Quartulli [Fri, 5 Aug 2022 09:37:03 +0000 (11:37 +0200)] 
dco: add documentation for ovpn-dco-linux

Signed-off-by: Antonio Quartulli <a@unstable.cc>
Acked-by: Frank Lichtenheld <frank@lichtenheld.com>
Message-Id: <20220805093703.27940-1-a@unstable.cc>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg24817.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
3 years agodco: implement dco support for p2p/client code path
Antonio Quartulli [Thu, 4 Aug 2022 07:14:01 +0000 (09:14 +0200)] 
dco: implement dco support for p2p/client code path

With this change we introduce ovpn-dco support only along the p2p/client
code path. Server codebase is still unchanged.

Signed-off-by: Antonio Quartulli <a@unstable.cc>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20220804071401.12410-1-a@unstable.cc>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg24798.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
3 years agodco: check that pulled options are compatible
Antonio Quartulli [Thu, 4 Aug 2022 06:40:16 +0000 (08:40 +0200)] 
dco: check that pulled options are compatible

A server may push options that are not compatible with DCO.
In this case we should log a message and bail out.

Signed-off-by: Antonio Quartulli <a@unstable.cc>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20220804064016.20414-1-a@unstable.cc>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg24797.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
3 years agopush: fix compilation with --disable-management and --enable-werror
Antonio Quartulli [Wed, 3 Aug 2022 15:40:49 +0000 (17:40 +0200)] 
push: fix compilation with --disable-management and --enable-werror

The authfail_extended and buf variables are only used when
ENABLE_MANAGEMENT is defined. However, they are currently declared
outside of any ifdefs, thus triggering a warning.

Move the declaration of these 2 down, right before their usage (within
the existing "#ifdef ENABLE_MANAGEMENT" block.

Fixes: ("Cleanup receive_auth_failed and simplify method")
Cc: Arne Schwabe <arne@rfc2549.org>
Signed-off-by: Antonio Quartulli <a@unstable.cc>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20220803154049.1213-1-a@unstable.cc>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg24792.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
3 years agodco: split option parsing routines
Antonio Quartulli [Wed, 3 Aug 2022 09:50:12 +0000 (11:50 +0200)] 
dco: split option parsing routines

DCO will try to install keys upon generating them, however, this happens
when parsing pushed cipher options (due to NCP).

For this reason we need to postpone parsing pushed cipher options to
*after* the tunnel interface has been opened, otherwise we would have
no DCO netdev object to operate on.

At the same time we split the parsing code, so that we can ensure that
the NEW_PEER call can happen after the received peer-id has been parsed
(it is required by all DCO API calls).

Signed-off-by: Antonio Quartulli <a@unstable.cc>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20220803095012.24975-1-a@unstable.cc>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg24789.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
3 years agodco: periodically check and possibly rotate/delete keys
Antonio Quartulli [Tue, 2 Aug 2022 15:16:04 +0000 (17:16 +0200)] 
dco: periodically check and possibly rotate/delete keys

Data channel keys are periodically regenerated and installed in ovpn-dco.
However, there is a certain moment when keys are rotated in order
to elect the new primary one.

Check the key status in userspace so that kernelspace can be informed as
well when rotations happen.

Signed-off-by: Antonio Quartulli <a@unstable.cc>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20220802151604.2801-1-a@unstable.cc>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg24785.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
3 years agoCleanup receive_auth_failed and simplify method
Arne Schwabe [Fri, 20 May 2022 21:32:48 +0000 (23:32 +0200)] 
Cleanup receive_auth_failed and simplify method

This simplifies the buffer handling in the method and adds a quick
return instead of wrapping the whole method in a if (pull) block

Patch V2: remove uncessary ifdef/endif and unnecassary block
Acked-by: Frank Lichtenheld <frank@lichtenheld.com>
Message-Id: <20220520213250.3126372-3-arne@rfc2549.org>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg24412.html

Signed-off-by: Gert Doering <gert@greenie.muc.de>
3 years agoAllow a few levels of recursion in virtual_output_callback()
Selva Nair [Thu, 28 Jul 2022 03:45:08 +0000 (23:45 -0400)] 
Allow a few levels of recursion in virtual_output_callback()

Without this, replies to commands from the management client
are sometimes lost if the server is writing when a command
comes in and leads to a recursive call to this function.

For some reason I've not been able to trigger this on Linux,
but it does sometimes happen on Windows during intense write
activity by openvpn.exe sending log lines to the management
client.

Signed-off-by: Selva Nair <selva.nair@gmail.com>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20220728034508.15180-2-selva.nair@gmail.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg24751.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
3 years agoDo not skip ERROR:/SUCCESS: response from management interface
Selva Nair [Thu, 28 Jul 2022 03:45:07 +0000 (23:45 -0400)] 
Do not skip ERROR:/SUCCESS: response from management interface

Generally we expect a response of SUCCESS: or ERROR: to every
command sent to the management interface. But, while in
the management-hold state, sending "signal foo" returns only
the following reply (with foo = SIGHUP, SIGUSR1 etc.):

>HOLD:Waiting for hold release:0

Fix by always responding

ERROR: signal 'foo' is currently ignored"
followed by the above line.

Though this is seldom seen in practice[*], such violation of the
protocol could stall clients like the GUI. So fix it.

[*] One way this happens is with SIGHUP sent before the daemon
is on hold state which it enters before the SIGHUP is received.

Signed-off-by: Selva Nair <selva.nair@gmail.com>
Acked-by: Arne Schwabe <arne@rfc2549.org>
Message-Id: <20220728034508.15180-1-selva.nair@gmail.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg24750.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
3 years agodisable DCO if no --dev was specified
Antonio Quartulli [Mon, 1 Aug 2022 15:08:12 +0000 (17:08 +0200)] 
disable DCO if no --dev was specified

The DCO logic is unable to proceed without --dev argument, therefore
just disable DCO if no --dev was specified by the user.

Right now, calling openvpn with DCO enabled (default) and no --dev
specified leads to a crash, because --dev is assumed to always be there.

Reported-by: Frank Lichtenheld <frank@lichtenheld.com>
Signed-off-by: Antonio Quartulli <a@unstable.cc>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20220801150812.32561-1-a@unstable.cc>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg24772.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
3 years agoxkey_provider: fix building with --disable-management
Selva Nair [Wed, 27 Jul 2022 22:18:30 +0000 (18:18 -0400)] 
xkey_provider: fix building with --disable-management

v2: also fix building test_provider
 - ifdefs in test_provider.c
 - include integer.h for min_int as manage.h
   may not always pull it in

Too many ifdefs, unfortunately..

Signed-off-by: Selva Nair <selva.nair@gmail.com>
Acked-by: Frank Lichtenheld <frank@lichtenheld.com>
Message-Id: <20220727221830.31861-1-selva.nair@gmail.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg24749.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
3 years agodco: configure keys in DCO right after generating them
Antonio Quartulli [Thu, 28 Jul 2022 15:20:12 +0000 (17:20 +0200)] 
dco: configure keys in DCO right after generating them

The ovpn-dco kernel module needs to be informed about the keys to be
used to encrypt/decrypt data traffic to/from a peer.

Configure keys in DCO right afte they are generated by the SSL code, to
avoid keeping them in memory longer than needed.

Signed-off-by: Antonio Quartulli <a@unstable.cc>
Acked-by: Arne Schwabe <arne@rfc2549.org>
Message-Id: <20220728152012.18643-1-a@unstable.cc>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg24758.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
3 years agoExtract check_session_cipher into standalone function
Arne Schwabe [Fri, 29 Jul 2022 12:37:48 +0000 (14:37 +0200)] 
Extract check_session_cipher into standalone function

This allow the code later to check if the cipher is okay to use and
update it for the calculation for the max MTU size.

Signed-off-by: Arne Schwabe <arne@rfc2549.org>
Patch v2: Name function check_session_cipher to better reflect its
          function
Acked-by: Frank Lichtenheld <frank@lichtenheld.com>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20220729123748.3267207-1-arne@rfc2549.org>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg24766.html

Signed-off-by: Gert Doering <gert@greenie.muc.de>
3 years agosystemd: remove generated service files on clean
Frank Lichtenheld [Tue, 26 Jul 2022 08:33:13 +0000 (10:33 +0200)] 
systemd: remove generated service files on clean

Found this when trying to build the Debian package
twice in a row. Which failed since then there were
additional files.

Signed-off-by: Frank Lichtenheld <frank@lichtenheld.com>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20220726083313.14067-1-frank@lichtenheld.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg24740.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
3 years agodco: initialize context and save pointer in TLS object
Antonio Quartulli [Wed, 20 Jul 2022 12:30:21 +0000 (14:30 +0200)] 
dco: initialize context and save pointer in TLS object

Signed-off-by: Antonio Quartulli <a@unstable.cc>
Acked-By: Arne Schwabe <arne@rfc2549.org>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20220720123021.24281-1-a@unstable.cc>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg24714.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
3 years agodco: introduce open_tun_dco_generic() to open dynamic or fixed-name DCO devices
Antonio Quartulli [Thu, 21 Jul 2022 18:24:25 +0000 (20:24 +0200)] 
dco: introduce open_tun_dco_generic() to open dynamic or fixed-name DCO devices

This function is similar to the essence of open_tun_generic(), but
calling open_tun_dco() instead of trying to do a file open on
"/dev/%s"

Previous attempts to save code duplication by including this into
open_tun_generic() created additional #ifdef plus confusing call
paths.  So this is a clean new function, leaving the door open for
a cleanup of open_tun_generic().

Also, introduce tun_dco_enabled(tt) to avoid the negative
"!tt->options.disable_dco" calls.

v11:
  - add new function open_tun_dco_generic() for Linux (and FreeBSD, later)
    instead of lumping this into open_tun_generic()
  - pick up tun_dco_enabled() from a later patch in the series
    (easier to bring this in right now than to convert the code back
    and then patch it again later)

Signed-off-by: Antonio Quartulli <a@unstable.cc>
Signed-off-by: Gert Doering <gert@greenie.muc.de>
Acked-by: Antonio Quartulli <antonio@openvpn.net>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20220721182425.1569798-1-gert@greenie.muc.de>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg24717.html

Signed-off-by: Gert Doering <gert@greenie.muc.de>
3 years agoFix error message about extended errors for IPv4-only sockets.
Gert Doering [Sat, 23 Jul 2022 12:19:09 +0000 (14:19 +0200)] 
Fix error message about extended errors for IPv4-only sockets.

The new code to enable IPv6 extended error reporting will cause
an error ("Protocol not available (errno=92)") if trying to enable
that setsockopt() option on an IPv4-only socket.

Fix: pass sock->info.af to set_sock_extended_error_passing(), only
apply to AF_INET6 sockets.

To make that work, ensure that sock->info.af is set to not only
the value coming from config (which might be AF_UNSPEC) but to the
actual value used in socket creation (credits: Arne Schwabe).

Add comments to make explicit that the asymmetry here (IPv4 extended
socket error reporting is enabled on all sockets) is intentional.

Signed-off-by: Gert Doering <gert@greenie.muc.de>
Acked-by: Frank Lichtenheld <frank@lichtenheld.com>
Message-Id: <20220723121909.21943-1-gert@greenie.muc.de>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg24731.html

Signed-off-by: Gert Doering <gert@greenie.muc.de>
3 years agoIn x_check_status() read errno early
Selva Nair [Fri, 22 Jul 2022 20:40:07 +0000 (16:40 -0400)] 
In x_check_status() read errno early

The correct errno can get overwritten by the call to
format_extended_socket_error() which may set errno to EAGAIN
losing the original error and cause to bypass the error reporting
below. Fix by reading the errno of interest at the top of the
function.

Reported by: Gert Doering <gert@greenie.muc.de>
Signed-off-by: Selva Nair <selva.nair@gmail.com>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20220722204007.7537-1-selva.nair@gmail.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg24728.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
3 years agot_client: Allow to force FAIL on prerequisite fails
Frank Lichtenheld [Fri, 22 Jul 2022 13:49:02 +0000 (15:49 +0200)] 
t_client: Allow to force FAIL on prerequisite fails

In automated tests we want the build to fail if the
worker node is configured incorrectly.

Signed-off-by: Frank Lichtenheld <frank@lichtenheld.com>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20220722134902.22092-1-frank@lichtenheld.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg24723.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
3 years agoFix segfault when no --config argument is given
Arne Schwabe [Fri, 22 Jul 2022 13:46:52 +0000 (15:46 +0200)] 
Fix segfault when no --config argument is given

Commit 4df5003 introduced a check against options->config but
did not ensure that this variable is non-null.

Signed-off-by: Arne Schwabe <arne@rfc2549.org>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20220722134652.2446598-1-arne@rfc2549.org>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg24722.html

Signed-off-by: Gert Doering <gert@greenie.muc.de>
3 years agoError out if both remap-usr1 SIGHUP and config stdin are used
Arne Schwabe [Fri, 22 Jul 2022 13:02:24 +0000 (15:02 +0200)] 
Error out if both remap-usr1 SIGHUP and config stdin are used

OpenVPN for Android uses config stdin to avoid writing the config
file containing private keys to 'disk'. However using stdin means
that config cannot be reread using SIGHUP. While there might be other
corner cases that trigger SIGHUP, this is an obvious one, so we
error out if we detect this misconfiguration.

Signed-off-by: Arne Schwabe <arne@rfc2549.org>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20220722130224.2442759-1-arne@rfc2549.org>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg24720.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
3 years agotun: extract close_tun_handle into its own fucntion and print correct type
Arne Schwabe [Fri, 24 Jun 2022 08:38:01 +0000 (10:38 +0200)] 
tun: extract close_tun_handle into its own fucntion and print correct type

This moves closing the tun handle into its own function and also prints
the adapter type we are operating on, instead hardcoding it to
tap-windows.

While at it, set the handle to NULL after closing, to prevent a double
close due to multiple invocations of this helper.

Signed-off-by: Arne Schwabe <arne@rfc2549.org>
Signed-off-by: Antonio Quartulli <a@unstable.cc>
Acked-by: Frank Lichtenheld <frank@lichtenheld.com>
Message-Id: <20220624083809.23487-18-a@unstable.cc>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg24527.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
3 years agoGitHub Actions: add Linux DCO build (on Ubuntu 20.04)
Antonio Quartulli [Fri, 24 Jun 2022 08:38:00 +0000 (10:38 +0200)] 
GitHub Actions: add Linux DCO build (on Ubuntu 20.04)

Signed-off-by: Antonio Quartulli <a@unstable.cc>
Acked-by: Frank Lichtenheld <frank@lichtenheld.com>
Message-Id: <20220624083809.23487-17-a@unstable.cc>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg24523.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
3 years agodco: allow user to disable it at runtime
Antonio Quartulli [Mon, 18 Jul 2022 22:19:23 +0000 (00:19 +0200)] 
dco: allow user to disable it at runtime

Signed-off-by: Antonio Quartulli <a@unstable.cc>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20220718221923.2033-1-a@unstable.cc>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg24702.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
3 years agodco: add option check - disable DCO if conflict is detected
Antonio Quartulli [Mon, 18 Jul 2022 22:17:57 +0000 (00:17 +0200)] 
dco: add option check - disable DCO if conflict is detected

Signed-off-by: Antonio Quartulli <a@unstable.cc>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20220718221757.545-1-a@unstable.cc>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg24701.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
3 years agoLog address of management client on accept
Selva Nair [Thu, 30 Jun 2022 19:05:49 +0000 (15:05 -0400)] 
Log address of management client on accept

Currently when we are listening on the management
interface, the local address/port is logged as that of
the connecting client.

Fix it.

Signed-off-by: Selva Nair <selva.nair@gmail.com>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20220630190549.16675-3-selva.nair@gmail.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg24619.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
3 years agoLog the actual management interface port in use
Selva Nair [Thu, 30 Jun 2022 19:05:47 +0000 (15:05 -0400)] 
Log the actual management interface port in use

When the port is specified as zero, log the actual port
bound to, instead of 0.

Signed-off-by: Selva Nair <selva.nair@gmail.com>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20220630190549.16675-1-selva.nair@gmail.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg24617.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
3 years agoRemove management_write_peer_info_file and related code
Selva Nair [Fri, 1 Jul 2022 00:07:26 +0000 (20:07 -0400)] 
Remove management_write_peer_info_file and related code

Use of this has never been documented and the code was
dead for a long while now.

Signed-off-by: Selva Nair <selva.nair@gmail.com>
Acked-by: Arne Schwabe <arne@rfc2549.org>
Message-Id: <20220701000726.8198-1-selva.nair@gmail.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg24624.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
3 years agoFix crash in xkey-provider in msvc builds
Selva Nair [Thu, 7 Jul 2022 03:51:51 +0000 (23:51 -0400)] 
Fix crash in xkey-provider in msvc builds

The function signature for xkey_load_generic_key had
function pointers defined as function types that seems
to work in gcc but not in msvc.

Fix it by changing the function signatures to what was intended.

Also revert part of commit 627d1a3d28638... as that workaround
should be no longer required.

Reported by: Lev Stipakov https://github.com/lstipakov

Signed-off-by: Selva Nair <selva.nair@gmail.com>
Acked-by: Arne Schwabe <arne@rfc2549.org>
Message-Id: <20220707035151.25469-1-selva.nair@gmail.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg24664.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
3 years agotun: create tun_name_is_fixed helper
Antonio Quartulli [Tue, 12 Jul 2022 22:16:55 +0000 (00:16 +0200)] 
tun: create tun_name_is_fixed helper

This helper encloses the (simple) logic used by OpenVPN to determine if
the name passed to --dev has to be considered a fixed interface name or
just a pattern.

Having a helper is useful because when this logic is required elsewhere,
we can just re-use this logic without duplicating the code (which may
mean introducing bugs if a future logic change should not update all
spots).

The logic is actually fairly simple: check if the name contains a number
(i.e. tun0). If so, consider the name a fixed device name.

While at it make has_digit() accept a signed argument because strings
are normally signed (also isdigit() accepts a signed argument).

Signed-off-by: Antonio Quartulli <a@unstable.cc>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20220712221655.19333-1-a@unstable.cc>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg24676.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
3 years agonetworking: add net_iface_type API
Antonio Quartulli [Wed, 13 Jul 2022 12:43:32 +0000 (14:43 +0200)] 
networking: add net_iface_type API

This new API can be used to retrieve the type of a specific interface.
It's mostly platform dependant, but right now expected values are
"ovpn-dco", "tun" or "tap".

Other values are possible too, but they are not of interest to us.

This commit also extends the networking unit-test by using the newly
introduced API in conjunction with iface_new and iface_del.

The t_net.sh script has been slightly adapted to allow running these
tests in standalone (as they don't require any iproute2 counterpart).

Signed-off-by: Antonio Quartulli <a@unstable.cc>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20220713124332.16147-1-a@unstable.cc>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg24688.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
3 years agonetworking_sitnl: always return negative error code in case of failure
Antonio Quartulli [Wed, 13 Jul 2022 12:14:16 +0000 (14:14 +0200)] 
networking_sitnl: always return negative error code in case of failure

The API is designed to always return a negative error code in case of
failure, therefore we should return '-errno' when ifindex has failed.

Signed-off-by: Antonio Quartulli <a@unstable.cc>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20220713121416.1912-1-a@unstable.cc>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg24686.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
3 years agoHandle exceeding 'max-clients'
Kristof Provost [Wed, 13 Jul 2022 08:34:04 +0000 (10:34 +0200)] 
Handle exceeding 'max-clients'

If 'max-clients' is set multi_create_instance() can return NULL (for any
client that would take us over the client limit).

If mi is NULL we don't add it to the hash map, but we do potentially
dereference it to increment the session count.
Do not attempt to do so if 'mi == NULL'.

Signed-off-by: Kristof Provost <kprovost@netgate.com>
Acked-by: Arne Schwabe <arne@rfc2549.org>
Message-Id: <20220713083404.13227-2-kprovost@netgate.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg24678.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
3 years agooptions: don't export local function pre_connect_save()
Antonio Quartulli [Mon, 11 Jul 2022 12:23:48 +0000 (14:23 +0200)] 
options: don't export local function pre_connect_save()

The pre_connect_save() function is not used outside of options.c,
therefore it should not be exported.

Make it static and move definition before its invocation.
Move also pre_connect_restore() along with it in order to keep the two
close to each other.

Cc: Arne Schwabe <arne@rfc2549.org>
Signed-off-by: Antonio Quartulli <a@unstable.cc>
Acked-by: Heiko Hund <heiko@ist.eigentlich.net>
Message-Id: <20220711122348.8756-1-a@unstable.cc>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg24666.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
3 years agonetworking: fix doc for net_iface_new() API
Antonio Quartulli [Tue, 5 Jul 2022 09:18:42 +0000 (11:18 +0200)] 
networking: fix doc for net_iface_new() API

Some auto correction must have sneaked in.
Restore proper wording.

Signed-off-by: Antonio Quartulli <a@unstable.cc>
Acked-by: Heiko Hund <heiko@ist.eigentlich.net>
Message-Id: <20220705091842.24053-1-a@unstable.cc>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg24636.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
3 years agomake %x destination unsigned
Heiko Hund [Thu, 12 May 2022 23:19:01 +0000 (01:19 +0200)] 
make %x destination unsigned

The %x specifier requires for the argument to be an unsigned int.

Signed-off-by: Heiko Hund <heiko@ist.eigentlich.net>
Acked-by: Frank Lichtenheld <frank@lichtenheld.com>
Message-Id: <20220512231901.1077306-1-heiko@ist.eigentlich.net>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg24336.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
3 years agodco: use specific metric when installing routes
Antonio Quartulli [Tue, 28 Jun 2022 18:56:23 +0000 (20:56 +0200)] 
dco: use specific metric when installing routes

When using DCO iroutes and routes all live in the same routing table,
However, the latter should always come after the former.

for this reason assign a default metric of 200 to routes. iroutes will
later get a metric of 100.

Signed-off-by: Antonio Quartulli <a@unstable.cc>
Acked-by: Arne Schwabe <arne@rfc2549.org>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20220628185623.1734-1-a@unstable.cc>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg24599.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
3 years agotls-crypt-v2: bail out if the client key is too small
Antonio Quartulli [Tue, 28 Jun 2022 09:41:44 +0000 (11:41 +0200)] 
tls-crypt-v2: bail out if the client key is too small

The tls-crypt-v2 key should be at least 2 bytes long in order to read
the actual length. Bail out if the key is too short.

This looks like it could be abused to trigger a read of uninitialized
memory, but after close checking it won't:

  We read from BEND(), so this is defined for TCP since the minimum
  length there is 3 bytes (pkt len + opcode)

  For UDP we might read past the beginning of the packet but since they
  are buffers coming from the packet stack we have the headroom/tailroom,
  so might read some random data (but not out of bound!).

  So we copy some more or less random number into net_len/wkc_len but without
  actually reading from undefined memory.

  The next line will then almost definitively fail (buf_advance()).

While at it improve the error message a bit.

Signed-off-by: Antonio Quartulli <a@unstable.cc>
Acked-by: Arne Schwabe <arne@rfc2549.org>
Message-Id: <20220628094144.17471-1-a@unstable.cc>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg24580.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
3 years agodco: create DCO interface using SITNL
Antonio Quartulli [Fri, 24 Jun 2022 08:37:48 +0000 (10:37 +0200)] 
dco: create DCO interface using SITNL

Signed-off-by: Antonio Quartulli <a@unstable.cc>
Acked-by: Arne Schwabe <arne@rfc2549.org>
Message-Id: <20220624083809.23487-5-a@unstable.cc>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg24514.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
3 years agodco: add helper function to detect if DCO is enabled or not
Antonio Quartulli [Fri, 24 Jun 2022 08:37:46 +0000 (10:37 +0200)] 
dco: add helper function to detect if DCO is enabled or not

Signed-off-by: Antonio Quartulli <a@unstable.cc>
Acked-by: Arne Schwabe <arne@rfc2549.org>
Message-Id: <20220624083809.23487-3-a@unstable.cc>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg24513.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
3 years agodco: introduce low-level code for handling ovpn-dco in the Linux kernel
Antonio Quartulli [Fri, 24 Jun 2022 08:37:45 +0000 (10:37 +0200)] 
dco: introduce low-level code for handling ovpn-dco in the Linux kernel

Signed-off-by: Antonio Quartulli <a@unstable.cc>
Acked-by: Arne Schwabe <arne@rfc2549.org>
Message-Id: <20220624083809.23487-2-a@unstable.cc>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg24512.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
3 years agosignal --dns support in peer info
Heiko Hund [Fri, 13 May 2022 09:37:40 +0000 (11:37 +0200)] 
signal --dns support in peer info

Have clients set a bit in IV_PROTO, so that servers can make an informed
decision on whether to push --dns to the client. While unknown options
are ignored by clients when pushed, they generate a warning in the log.
That can be circumvented by server backends by checking if bit 7 is set.

Signed-off-by: Heiko Hund <heiko@ist.eigentlich.net>
Acked-by: David Sommerseth <davids@openvpn.net>
Message-Id: <20220513093740.1091639-1-heiko@ist.eigentlich.net>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg24350.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
3 years agodns: also (re)place foreign dhcp options in env
Heiko Hund [Fri, 27 May 2022 01:24:57 +0000 (03:24 +0200)] 
dns: also (re)place foreign dhcp options in env

Override DNS related foreign_options with values set by the --dns
option. This is done so that scripts looking for these options continue
to work if only --dns option were pushed, or the values in the
--dhcp-options differ from what's pushed in --dns.

Signed-off-by: Heiko Hund <heiko@ist.eigentlich.net>
Acked-by: Frank Lichtenheld <frank@lichtenheld.com>
Message-Id: <20220527012457.1819262-5-heiko@ist.eigentlich.net>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg24432.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
3 years agoSet o->use_peer_id flag for p2p mode
Lev Stipakov [Tue, 24 May 2022 09:19:16 +0000 (12:19 +0300)] 
Set o->use_peer_id flag for p2p mode

There are two flags to indicate peer-id usage, one is
in tls_multi struct and another one is in options.

For P2P mode we don't set this flag in options,
which is used in MTU calculation. As a result,
automatically calculated MSS value in P2P mode is wrong,

Fix by bring use_peer_id flag in options and tls_multi
into sync for P2P.

Signed-off-by: Lev Stipakov <lev@openvpn.net>
Acked-by: Antonio Quartulli <a@unstable.cc>
Message-Id: <20220524091916.145-1-lstipakov@gmail.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg24430.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
3 years agoInline frame_add_to_extra_tun function and remove frame_defined
Arne Schwabe [Tue, 21 Jun 2022 16:16:45 +0000 (18:16 +0200)] 
Inline frame_add_to_extra_tun function and remove frame_defined

This function has only one usage and is so trivial that an extra
function makes little sense anymore.

frame_defined is no longer used, so remove the function.

Signed-off-by: Arne Schwabe <arne@rfc2549.org>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20220621161649.2872985-2-arne@rfc2549.org>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg24492.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
3 years agoRemove leftover frame_set_mtu_dynamic definitions in mtu.h
Arne Schwabe [Tue, 21 Jun 2022 16:16:44 +0000 (18:16 +0200)] 
Remove leftover frame_set_mtu_dynamic definitions in mtu.h

The frame_set_mtu_dynamic function and it defines were removed during
the buffer rework but this definitions were overlooked.

Signed-off-by: Arne Schwabe <arne@rfc2549.org>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20220621161649.2872985-1-arne@rfc2549.org>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg24494.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
3 years agoUpdate the replay-window backtrack log message
Martin Janů [Fri, 10 Jun 2022 12:04:05 +0000 (12:04 +0000)] 
Update the replay-window backtrack log message

The man pages reference a logging message which has been rephrased
in ac1310528a248c99e039e7afaf48724ad1b7f10e. This commit updates the
man page message to reflect the change for improved grep-ability.

Signed-off-by: Martin Janů <martin.janu@protonmail.com>
Acked-by: Frank Lichtenheld <frank@lichtenheld.com>
Message-Id: <SVrvuTydxR6Qs_mvwvG7mqT8iLV0inlcCMXoenZTMI8M0LkosV4pZsH9m_XCTwcRWAPN5H8Zdro0ubhJrnSp6v5KC2ZNAL9So0Y2SKiSe7g=@protonmail.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg24472.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
3 years agofix compilation issues with small and w/o debug
Ilya Ponetayev [Fri, 17 Jun 2022 04:13:26 +0000 (07:13 +0300)] 
fix compilation issues with small and w/o debug

Acked-by: Frank Lichtenheld <frank@lichtenheld.com>
Message-Id: <20220617041326.2744668-1-i.ponetaev@ndmsystems.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg24476.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
3 years agoGitHub Actions: trigger openvpn-build GHA on success
Lev Stipakov [Sun, 5 Jun 2022 00:40:13 +0000 (03:40 +0300)] 
GitHub Actions: trigger openvpn-build GHA on success

After successfult builds on all platforms,
start openvpn-build GHA which produces
Windows MSI installers.

Signed-off-by: Lev Stipakov <lev@openvpn.net>
Acked-by: Samuli Seppänen <samuli@openvpn.net>
Patchwork-Id: 2508
URL: https://patchwork.openvpn.net/patch/2508/
Message-Id: <20220605004013.319-1-lstipakov@gmail.com>
Signed-off-by: David Sommerseth <davids@openvpn.net>
3 years agoRemove useless empty line from CR_RESPONSE message
Arne Schwabe [Mon, 30 May 2022 22:41:49 +0000 (00:41 +0200)] 
Remove useless empty line from CR_RESPONSE message

The out buffer is not filled and this adds an extra empty line for
CR_RESPONSE outputs. Also make minor style fixes.

Signed-off-by: Arne Schwabe <arne@rfc2549.org>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20220530224149.201883-1-arne@rfc2549.org>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg24447.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
3 years agodoc: fix literal block in tls-options.rst
Heiko Hund [Wed, 11 May 2022 12:10:38 +0000 (14:10 +0200)] 
doc: fix literal block in tls-options.rst

Signed-off-by: Heiko Hund <heiko@ist.eigentlich.net>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20220511121038.1002898-1-heiko@ist.eigentlich.net>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg24320.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
3 years agorename foreign_option() and move it up
Heiko Hund [Fri, 27 May 2022 01:24:56 +0000 (03:24 +0200)] 
rename foreign_option() and move it up

Add setenv_ prefix to foreign_option funtion so it is more obvious what
it does. Move it further up within options.c, so it is defined before
all future callers. Also declare all argv strings const.

Signed-off-by: Heiko Hund <heiko@ist.eigentlich.net>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20220527012457.1819262-4-heiko@ist.eigentlich.net>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg24436.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
3 years agoremove dead foreign-option parsing code
Heiko Hund [Fri, 27 May 2022 01:24:55 +0000 (03:24 +0200)] 
remove dead foreign-option parsing code

Signed-off-by: Heiko Hund <heiko@ist.eigentlich.net>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20220527012457.1819262-3-heiko@ist.eigentlich.net>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg24434.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
3 years agoremove foreign_option() call for IPv6 DNS servers
Heiko Hund [Fri, 27 May 2022 01:24:54 +0000 (03:24 +0200)] 
remove foreign_option() call for IPv6 DNS servers

The call survived since the initial commit 94bfc256d, where it was added
as a fallback, since no IPv6 DNS server handling was implemented at the
time. Now there's dhcp_option_dns6_parse() which adds the servers to the
tuntap options, just like how it is done with the v4 servers.

Signed-off-by: Heiko Hund <heiko@ist.eigentlich.net>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20220527012457.1819262-2-heiko@ist.eigentlich.net>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg24433.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
3 years agoFix client-pending-auth error message to say ERROR instead of SUCCESS
Arne Schwabe [Mon, 23 May 2022 09:17:24 +0000 (11:17 +0200)] 
Fix client-pending-auth error message to say ERROR instead of SUCCESS

Signed-off-by: Arne Schwabe <arne@rfc2549.org>
Acked-by: Frank Lichtenheld <frank@lichtenheld.com>
Message-Id: <20220523091724.3418887-1-arne@rfc2549.org>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg24421.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
3 years agoTranslate OpenSSL 3.0 digest names to OpenSSL 1.1 digest names
Arne Schwabe [Mon, 23 May 2022 10:35:46 +0000 (12:35 +0200)] 
Translate OpenSSL 3.0 digest names to OpenSSL 1.1 digest names

Since we used the OpenSSL <=1.1 names as part of our OCC message, they
are now unfortunately part of our wire protocol.

OpenSSL 3.0 will still accept the "old" names so we do not need to use
this translation table for forward lookup, only for returning the name
with md_kt_name()

Signed-off-by: Arne Schwabe <arne@rfc2549.org>
Acked-by: Antonio Quartulli <a@unstable.cc>
Message-Id: <20220523103546.3425388-2-arne@rfc2549.org>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg24423.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
3 years agoImplement ED448 and ED25519 support in xkey_provider
Arne Schwabe [Mon, 16 May 2022 10:48:07 +0000 (12:48 +0200)] 
Implement ED448 and ED25519 support in xkey_provider

OpenSSL's implementation of ED448 and ED25519 has a few idiosyncrasies.
Instead of belonging to the elliptic curve type or to a common Edwards
curve type, ED448 and ED25519 have each their own type.

Also, OpenSSL expects signatures using these curves to be done with the
EVP_DigestSign API instead of the EVP_Sign API but using md=NULL.

This has been tested using a "fake" external key that used a normal
software key instead of a hardware implementation but that makes no
difference from the perspective of xkey_provider/management interface.

Patch v2: remove name functions from ed448/ed25519, ensure md is NULL
          for ed448/ed25519 and handle NULL/none better in general.
Patch v3: do not pass NULL as string for the OSSL params.

Signed-off-by: Arne Schwabe <arne@rfc2549.org>
Acked-by: Selva Nair <selva.nair@gmail.com>
Message-Id: <20220516104807.2568937-1-arne@rfc2549.org>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg24363.html

Signed-off-by: Gert Doering <gert@greenie.muc.de>
3 years agopre-commit: uncrustify based on staged changes
Heiko Hund [Tue, 17 May 2022 21:01:21 +0000 (23:01 +0200)] 
pre-commit: uncrustify based on staged changes

Previously the generated patch was based on the file(s) in the working
directory. This is a problem if you have not to be commited changes
there and these changes fix formatting issues that exist in the staging
area. This effectively circumventes the script from rejecting the
commit.

An example:
   git add file.c
   git commit
   ... pre-commit hooks complains about formatting ...
   ... you fix the file manually, forget to git add ...
   git commit
   ... succeeds, even though the commit still has issues ...

Signed-off-by: Heiko Hund <heiko@ist.eigentlich.net>
Acked-by: Frank Lichtenheld <frank@lichtenheld.com>
Acked-by: Antonio Quartulli <a@unstable.cc>
Message-Id: <20220517210121.1312072-1-heiko@ist.eigentlich.net>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg24376.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
3 years agouncrustify: have exactly one newline at the end of files
Frank Lichtenheld [Wed, 18 May 2022 10:51:57 +0000 (12:51 +0200)] 
uncrustify: have exactly one newline at the end of files

Avoid the ugly "No newline at end of file" in git diffs.

Signed-off-by: Frank Lichtenheld <frank@lichtenheld.com>
Acked-by: Antonio Quartulli <a@unstable.cc>
Message-Id: <20220518105157.9026-1-frank@lichtenheld.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg24386.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
3 years agocipher-negotiation.rst missing from doc/Makefile.am
Jan Mikkelsen [Wed, 18 May 2022 18:37:15 +0000 (20:37 +0200)] 
cipher-negotiation.rst missing from doc/Makefile.am

Trac: #1461
Signed-off-by: Jan Mikkelsen <janm@transactionware.com>
Acked-by: Frank Lichtenheld <frank@lichtenheld.com>
Message-Id: <20220518183715.931-1-frank@lichtenheld.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg24394.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
3 years agouncrustify: add sp_after_comma=add
Frank Lichtenheld [Thu, 19 May 2022 08:54:28 +0000 (10:54 +0200)] 
uncrustify: add sp_after_comma=add

Signed-off-by: Frank Lichtenheld <frank@lichtenheld.com>
Acked-by: Antonio Quartulli <a@unstable.cc>
Message-Id: <20220519085428.6783-3-frank@lichtenheld.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg24397.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
3 years agoReformat for sp_after_comma=add
Frank Lichtenheld [Thu, 19 May 2022 08:54:27 +0000 (10:54 +0200)] 
Reformat for sp_after_comma=add

It is our usual style.

Signed-off-by: Frank Lichtenheld <frank@lichtenheld.com>
Acked-by: Antonio Quartulli <a@unstable.cc>
Message-Id: <20220519085428.6783-2-frank@lichtenheld.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg24399.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
3 years agoPass proper sockaddr_* structure for IPv6 socket errors.
Gert Doering [Fri, 13 May 2022 10:15:26 +0000 (12:15 +0200)] 
Pass proper sockaddr_* structure for IPv6 socket errors.

commit 043c67f363429 enhances format_extended_socket_error() by
recognizing IPv6 extended socket errors, but neglected to change
the "sockaddr_in" buffer passed to recvmsg() to "sockaddr_storage".

According to documentation, recvmsg() should not have overrun
that buffer (we pass the size of the struct), but according to
ASAN it does... so, pass a pointer to the correct structure.

Signed-off-by: Gert Doering <gert@greenie.muc.de>
Acked-by: Arne Schwabe <arne@rfc2549.org>
Message-Id: <20220513101526.11486-1-gert@greenie.muc.de>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg24352.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
3 years agoFix non-compliant whitespace introduced by commit 54800aa975418fe35.
Gert Doering [Thu, 12 May 2022 06:53:04 +0000 (08:53 +0200)] 
Fix non-compliant whitespace introduced by commit 54800aa975418fe35.

Uncrustify fix.

Signed-off-by: Gert Doering <gert@greenie.muc.de>
3 years agoFix M_ERRNO behavior on Windows
Lev Stipakov [Tue, 3 May 2022 00:28:40 +0000 (03:28 +0300)] 
Fix M_ERRNO behavior on Windows

We use M_ERRNO flag in logging to display error code
and error message. This has been broken on Windows,
where we use error code from GetLastError() and
error description from strerror(). strerror() expects
C runtime error code, which is quite different from
last error code from WinAPI call. As a result, we got
incorrect error description.

The ultimate fix would be introducing another flag
for WinAPI errors, like M_WINERR and use either that or
M_ERRNO depends on context. However, the change would be
quite intrusive and in some cases it is hard to say which
one to use without looking into internals.

Instead we stick to M_ERRNO and in Windows case we
first try to obtain error code from GetLastError() and
if it returns ERROR_SUCCESS (which is 0), we assume that
we have C runtime error and use errno. To get error
description we use strerror_win32() with GetLastError()
and strerror() with errno.

strerror_win32() uses FormatMessage() internally, which
is the right way to get WinAPI error description.

Signed-off-by: Lev Stipakov <lev@openvpn.net>
Acked-by: Selva Nair <selva.nair@gmail.com>
Message-Id: <20220503002840.295-1-lstipakov@gmail.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg24270.html

Signed-off-by: Gert Doering <gert@greenie.muc.de>
3 years agoImplement --mtu-disc for IPv6 UDP sockets.
Gert Doering [Tue, 22 Feb 2022 14:35:14 +0000 (15:35 +0100)] 
Implement --mtu-disc for IPv6 UDP sockets.

Commit 4225114b96 repaired "--mtu-disc yes" brokenness for IPv4 UDP sockets
(caused by autoconf/ifdef issues).  This patch adds new functionality
to do --mtu-disc for IPv6 sockets as well.

Half of it (setsockopt(IPV6_MTU_DISCOVER)) was already there, but
receiving of detailed socket errors was missing the enablement of
setsockopt(IPV6_RECVERR) and parsing of IPPROTO_IPV6/IPV6_RECVERR
messages received.

With that, we now get (sending over a route with "mtu 1300"):

2022-02-22 15:28:07 write UDPv6 [EMSGSIZE Path-MTU=1300]: Message too long
(fd=3,code=90)
2022-02-22 15:28:07 Note adjusting 'mssfix 1400 mtu' to 'mssfix 1300 mtu'
according to path MTU discovery
2022-02-22 15:28:07 Note adjusting 'fragment 1400 mtu' to 'fragment 1300
mtu' according to path MTU discovery

Signed-off-by: Gert Doering <gert@greenie.muc.de>
Acked-by: Arne Schwabe <arne@rfc2549.org>
Message-Id: <20220222143514.3480-1-gert@greenie.muc.de>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg23879.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
3 years agoAdd ubuntu 22.04 to Github Actions
Arne Schwabe [Fri, 6 May 2022 13:28:36 +0000 (15:28 +0200)] 
Add ubuntu 22.04 to Github Actions

This adds Ubuntu 22.04 to the Github actions. mbed TLS in 22.04 is still
old enough (2.28) to build with OpenVPN and GPL licensed.

Signed-off-by: Arne Schwabe <arne@rfc2549.org>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20220506132836.1318985-2-arne@rfc2549.org>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg24299.html

Signed-off-by: Gert Doering <gert@greenie.muc.de>
3 years agoAdd uncrustify check to github actions
Arne Schwabe [Fri, 6 May 2022 13:28:35 +0000 (15:28 +0200)] 
Add uncrustify check to github actions

This adds checking if the code style is still clean github actions with the
exact version of uncrustify that is required and might also be helpful for
external commiters to get notified about code style problem when running
the Github actions on their own repository.

Signed-off-by: Arne Schwabe <arne@rfc2549.org>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20220506132836.1318985-1-arne@rfc2549.org>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg24300.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
3 years agoExtract read_incoming_tls_plaintext into its own function
Arne Schwabe [Tue, 3 May 2022 11:29:00 +0000 (13:29 +0200)] 
Extract read_incoming_tls_plaintext into its own function

This makes the tls_process_state function a bit easier to read
and allows extending the read_incoming_tls_plaintext function
later without making tls_process_state even longer.

Patch v2: fix compile error.

Signed-off-by: Arne Schwabe <arne@rfc2549.org>
Acked-by: Frank Lichtenheld <frank@lichtenheld.com>
Message-Id: <20220503112900.933975-1-arne@rfc2549.org>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg24268.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
3 years agoOptimise three-way handshake condition for S_PRE_START to S_START
Arne Schwabe [Fri, 22 Apr 2022 14:29:48 +0000 (16:29 +0200)] 
Optimise three-way handshake condition for S_PRE_START to S_START

We move to the S_START when we have finished the three-way handshake. After
the three way handshake is done, the client will send the TLS Client Hello
packet.

Currently we consider the three way handshake only complete if all
outgoing packets have been acked (which in this case is the one
HARD_RESET_CLIENT or HARD_RESET_SERVER) and also all ACKs for incoming
packets have been sent out.

Waiting for the ack of our own packet is important as it signals that the
other side is really responding. However, the need to also send out all
ACKs for packets we received before moving to the next state breaks
piggybacking the ACKs onto the next control packet.

With this change both server and client will only send a P_CONTROL_V1 with
the TLS Client Hello and the TLS Server Hello with piggybacked ack instead
sending an P_ACK_V1 + P_CONTROL_V1, reducing the number of packets in a
handshake by 2.

This also allows the server to avoid resending P_CONTROL_HARD_RESET_V2
to complete the three-way handshake with HMAC. Only packets with
an ACK contain the remote session id that we need for HMAC session id
verification. The ACK_V1 packet that complets this three-way handshake
can get lost. But the P_CONTROL_V1 with the piggybacked ACK will get
retransmitted. This allows to put the burden of retransmission fully on
the client.

The S_GOT_KEY/S_SENT_KEY -> S_ACTIVE is similar. We do not need to wait
for the ack packet to be sent to move the state forward. This has however
no effect on actual packets since there are normally no outstanding ACKs
here.

Signed-off-by: Arne Schwabe <arne@rfc2549.org>
Acked-by: Frank Lichtenheld <frank@lichtenheld.com>
Message-Id: <20220422142953.3805364-14-arne@rfc2549.org>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg24161.html

Signed-off-by: Gert Doering <gert@greenie.muc.de>
3 years agoImplement HMAC based session id for tls-crypt v2
Arne Schwabe [Thu, 5 May 2022 13:03:48 +0000 (15:03 +0200)] 
Implement HMAC based session id for tls-crypt v2

Tls-crypt v2 is more complicated to implement a proper stateless
handshake. To allow state handshake this commit does

 - introduce a new packet CONTROL_WKC_V1 that repeats the wrapped
   client key.
 - introduce a way to negotiate the support for this packet in the
   three way handshake

Details about the protocol changes are in tls-crypt-v2.txt. Optional
arguments to the tls-crypt-v2 option have been added to explicitly
allow or disallow client that do not support the stateless handshake.

Signed-off-by: Arne Schwabe <arne@rfc2549.org>
Patch v3: improve grammar, style, comments, fix unit tests
Patch v4: remove explicit flag for ability to resend WKc,
          clean up comments, improve code style in some instances
Acked-by: Antonio Quartulli <antonio@openvpn.net>
Message-Id: <20220505130348.1183195-1-arne@rfc2549.org>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg24287.html

Signed-off-by: Gert Doering <gert@greenie.muc.de>
3 years agoRemove workaround for Android 4.4
Arne Schwabe [Wed, 4 May 2022 11:18:02 +0000 (13:18 +0200)] 
Remove workaround for Android 4.4

Android 4.4 is now 9 years old and the main user of this API (OpenVPN
for Android) does not support this OS anymore. This workaround
is now safe to remove.

Signed-off-by: Arne Schwabe <arne@rfc2549.org>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20220504111802.1050648-1-arne@rfc2549.org>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg24276.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
3 years agoFix format specifier for printing size_t on 32bit size_t platforms
Arne Schwabe [Wed, 4 May 2022 11:31:58 +0000 (13:31 +0200)] 
Fix format specifier for printing size_t on 32bit size_t platforms

Today even 32 bit platform generally use a 64bit size_t but Android
armeabi-v7a is an expection to that and uses a 32bit size_t. Use
z as correct specifier for a size_t.

Clang complained about this:

warning: format specifies type 'unsigned long' but the
argument has type 'size_t' (aka 'unsigned int') [-Wformat]

Signed-off-by: Arne Schwabe <arne@rfc2549.org>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20220504113158.1051861-1-arne@rfc2549.org>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg24277.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
3 years agovcpkg: switch to manifest
Lev Stipakov [Thu, 5 May 2022 12:14:49 +0000 (15:14 +0300)] 
vcpkg: switch to manifest

Add vcpkg manifest file which lists
dependencies and enable manifest usage in
project file.

This simplifies build process by eliminating
separate "vcpkg install" step to install dependencies.

Since vcpkg added openssl3 port, remove ours.

Signed-off-by: Lev Stipakov <lev@openvpn.net>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20220505121449.347-1-lstipakov@gmail.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg24285.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
3 years agoExclude the last two whitespace-only uncrustify fixes from git blame output.
Gert Doering [Thu, 5 May 2022 11:46:59 +0000 (13:46 +0200)] 
Exclude the last two whitespace-only uncrustify fixes from git blame output.

(The Great Reformatting of 2022 and the small trailing-whitespace patch
of today)

Signed-off-by: Gert Doering <gert@greenie.muc.de>
3 years agoExtract read_incoming_tls_ciphertext into function
Arne Schwabe [Fri, 22 Apr 2022 14:29:46 +0000 (16:29 +0200)] 
Extract read_incoming_tls_ciphertext into function

This makes the code a bit more structured and easier to read.
Acked-by: Frank Lichtenheld <frank@lichtenheld.com>
Message-Id: <20220422142953.3805364-12-arne@rfc2549.org>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg24152.html

Signed-off-by: Gert Doering <gert@greenie.muc.de>
3 years agoFix trailing-whitespace errors in last patch.
Gert Doering [Thu, 5 May 2022 11:38:12 +0000 (13:38 +0200)] 
Fix trailing-whitespace errors in last patch.

When rewrapping comments and a single code line in b364711486dc6,
some trailing whitespace escaped.  Fix.

Signed-off-by: Gert Doering <gert@greenie.muc.de>
3 years agoImplement stateless HMAC-based sesssion-id three-way-handshake
Arne Schwabe [Mon, 2 May 2022 15:43:10 +0000 (17:43 +0200)] 
Implement stateless HMAC-based sesssion-id three-way-handshake

OpenVPN currently has a bit of a weakness in its early three way handshake

A single client reset packet (first packet of the handshake) will
  - trigger creating a session on the server side leading to potential
    ressource exhaustion
  - make the server respond with 3 answers trying to get an ACK for its
    P_CONTROL_HARD_RESET_SERVER_V2 answer making it an amplification

Instead of allocating a connection for each client on the initial packet
OpenVPN will now calculate a session id based on a HMAC that serves as
verifiable cookie that can be checked for authenticity when the client
responds with it. This eliminates the amplification attack and resource
exhaustion attacks.

For tls-crypt-v2 clients the HMAC based handshake is not used yet (will
be added in one of the next patches).

Patch v2: rebase on master
patch v3: fix unit tests, improve comment/style of code

Signed-off-by: Arne Schwabe <arne@rfc2549.org>
Acked-by: Frank Lichtenheld <frank@lichtenheld.com>
Message-Id: <20220502154310.836947-1-arne@rfc2549.org>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg24262.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
3 years agoImplement constructing a control channel reset client as standalone function
Arne Schwabe [Wed, 27 Apr 2022 22:34:18 +0000 (00:34 +0200)] 
Implement constructing a control channel reset client as standalone function

This implements creating a reset packet without needing to setup
a full control session.

Patch v2: fix unit test not working without further commits

Signed-off-by: Arne Schwabe <arne@rfc2549.org>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20220427223419.241904-1-arne@rfc2549.org>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg24240.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
3 years agoChange reliable_get_buf_sequenced to reliable_get_entry_sequenced
Arne Schwabe [Fri, 22 Apr 2022 14:29:45 +0000 (16:29 +0200)] 
Change reliable_get_buf_sequenced to reliable_get_entry_sequenced

This returns not just the buffer of a reliable_entry but the whole
entry. This allows the caller to also inspect the original opcode
and packet id.

Signed-off-by: Arne Schwabe <arne@rfc2549.org>
Acked-by: Frank Lichtenheld <frank@lichtenheld.com>
Message-Id: <20220422142953.3805364-11-arne@rfc2549.org>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg24153.html

Signed-off-by: Gert Doering <gert@greenie.muc.de>
3 years agoMove CRL reload to key_state_init from S_START transition
Arne Schwabe [Fri, 22 Apr 2022 14:29:41 +0000 (16:29 +0200)] 
Move CRL reload to key_state_init from S_START transition

The current place that we reload is a bit more efficient since it only
triggers reload after a completed 3way handshake. On the other hand the
key_state_init is a much more logical place and with the upcoming
HMAC based UDP code and TCP code, the initialisation will only be done
after a 3way handshake.

Signed-off-by: Arne Schwabe <arne@rfc2549.org>
Acked-by: Antonio Quartulli <antonio@openvpn.net>
Message-Id: <20220422142953.3805364-7-arne@rfc2549.org>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg24156.html

Signed-off-by: Gert Doering <gert@greenie.muc.de>
3 years agoRemove pointless indentation from tls_process.
Arne Schwabe [Fri, 22 Apr 2022 14:29:40 +0000 (16:29 +0200)] 
Remove pointless indentation from tls_process.

This is probably a result from earlier code that still needed to be
C89 compatible add probably added this to allow variable decleration
Acked-by: Frank Lichtenheld <frank@lichtenheld.com>
Message-Id: <20220422142953.3805364-6-arne@rfc2549.org>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg24166.html

Signed-off-by: Gert Doering <gert@greenie.muc.de>
3 years agoMove tls_process_state into its own function
Arne Schwabe [Fri, 22 Apr 2022 14:29:39 +0000 (16:29 +0200)] 
Move tls_process_state into its own function

This function does most of the state transitions in the TLS state
machine. Moving it into its own function removes an intention area and
makes tls_process function easier to understand as the loop is more
obvious.

This is largely just a code move with small expection. bool active is
no longer directly set but inferred from to_link->len

Acked-by: Frank Lichtenheld <frank@lichtenheld.com>
Message-Id: <20220422142953.3805364-5-arne@rfc2549.org>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg24157.html

Signed-off-by: Gert Doering <gert@greenie.muc.de>
3 years agoExtract session_move_active into its own function
Arne Schwabe [Tue, 26 Apr 2022 13:23:24 +0000 (15:23 +0200)] 
Extract session_move_active into its own function

This makes the tls_process function smaller and easier to understand and
this state easier to understand in its own function.

Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20220426132324.76517-2-arne@rfc2549.org>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg24212.html

Signed-off-by: Gert Doering <gert@greenie.muc.de>
3 years agoChange FULL_SYNC macro to no_pending_reliable_packets function
Arne Schwabe [Tue, 26 Apr 2022 13:23:23 +0000 (15:23 +0200)] 
Change FULL_SYNC macro to no_pending_reliable_packets function

This changes this macro to a better named inline function. This
introduces a slight whitespace problem but the next refactoring will
move the incorrectly intended block to its own function anyway.

Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20220426132324.76517-1-arne@rfc2549.org>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg24213.html

Signed-off-by: Gert Doering <gert@greenie.muc.de>
3 years agoExtract session_move_pre_start as own function, use local buffer variable
Arne Schwabe [Fri, 22 Apr 2022 14:29:37 +0000 (16:29 +0200)] 
Extract session_move_pre_start as own function, use local buffer variable

This changes the C90 struct buffer declaration to a C99 style one. Also
move the state transition from S_INITIAL to S_PE_START into its own
function.
Acked-by: Frank Lichtenheld <frank@lichtenheld.com>
Message-Id: <20220422142953.3805364-3-arne@rfc2549.org>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg24151.html

Signed-off-by: Gert Doering <gert@greenie.muc.de>
3 years agoRefactor tls-auth/tls-crypt wrapping into into own function
Arne Schwabe [Fri, 22 Apr 2022 14:29:36 +0000 (16:29 +0200)] 
Refactor tls-auth/tls-crypt wrapping into into own function

This allows the the wrapping to be easier reused by a function that
does not have access to a full TLS session.
Acked-by: Frank Lichtenheld <frank@lichtenheld.com>
Message-Id: <20220422142953.3805364-2-arne@rfc2549.org>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg24150.html

Signed-off-by: Gert Doering <gert@greenie.muc.de>
3 years agofix GitHub workflow working directories in MinGW builds
Marc Becker [Mon, 25 Apr 2022 21:58:22 +0000 (23:58 +0200)] 
fix GitHub workflow working directories in MinGW builds

replace hardcoded directory names with env variable version info
bump pkcs11-helper version to 1.29.0
bump OpenSSL version to 1.1.1n
add OpenSSL version to cache key
use release file for pkcs11-helper archive
use OpenSSL URL endpoint with all/current versions

Signed-off-by: Marc Becker <becm@gmx.de>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20220425215822.18569-1-becm@gmx.de>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg24202.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>