]> git.ipfire.org Git - thirdparty/openvpn.git/log
thirdparty/openvpn.git
4 years agoWorkaround FreeBSD 12+ race condition on tun/tap open with IPv6.
Gert Doering [Thu, 23 Jul 2020 12:19:49 +0000 (14:19 +0200)] 
Workaround FreeBSD 12+ race condition on tun/tap open with IPv6.

On FreeBSD 12 (tested and verified on 12.1-RELEASE-p2), after "ifconfig
inet6" for a tun/tap interface, there sometimes is a race condition
where the "IFDISABLED" flag shows up after a short time frame, under
a second, and never clears itself.  This disables use of the configured
IPv6 address on the interface, breaking IPv6 over tun/tap operation.

This only happens if ipv6_activate_all_interfaces="YES" is not
set in /etc/rc.conf - but there might be reasons why this is not so.

As a workaround until this can be fixed on the FreeBSD side (or a
better workaround is found), sleep(1) after ifconfig, then call
"ifconfig $dev inet6 -ifdisable".

Yes, this is massively ugly but makes the problem completely go
away for my test systems.

(The same effect can be achieved with an --up script that does this,
but it's even less pretty - see trac ticket)

FreeBSD: https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=248172

v2: reword text, refer to FreeBSD bug with much more details

Trac: 1226
Signed-off-by: Gert Doering <gert@greenie.muc.de>
Acked-by: Arne Schwabe <arne@rfc2549.org>
Message-Id: <20200723121949.78223-1-gert@greenie.muc.de>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg20553.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
4 years agoRefactor key_state_export_keying_material functions
Arne Schwabe [Fri, 14 Aug 2020 14:51:53 +0000 (16:51 +0200)] 
Refactor key_state_export_keying_material functions

This refactors the common code between mbed SSL and OpenSSL into
export_user_keying_material and also prepares the backend functions
to export more than one key.

Also fix checking the return value of SSL_export_keying_material
only 1 is a success, -1 is also an error.

Signed-off-by: Arne Schwabe <arne@rfc2549.org>
Patch V2: Cache secrets for mbed TLS instead generating all ekms
          in the call back function

Patch V3: comment is no longer a lie. (fixed doxygen)

Signed-off-by: Arne Schwabe <arne@rfc2549.org>
Acked-by: Steffan Karger <steffan@karger.me>
Message-Id: <20200814145153.12895-1-arne@rfc2549.org>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg20739.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
4 years agoFixes a bug in management_callback_send_cc_message, should be strlen instead of sizeof
Eric Thorpe [Thu, 20 Aug 2020 01:42:58 +0000 (18:42 -0700)] 
Fixes a bug in management_callback_send_cc_message, should be strlen instead of sizeof

Signed-off-by: Eric Thorpe <eric@sparklabs.com>
Acked-by: Arne Schwabe <arne@rfc2549.org>
Message-Id: <20200820014258.38377-1-eric@sparklabs.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg20783.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
4 years agoFix client's poor man NCP fallback
Arne Schwabe [Fri, 14 Aug 2020 08:06:19 +0000 (10:06 +0200)] 
Fix client's poor man NCP fallback

This commit fixes two separate issues which are closely linked.

First, a 2.5 client cannot connect to a server which does not support NCP
and is not using one of the default --data-ciphers (AES-*-GCM).

This is because the 2.5 client does not use its configured --data-ciphers
cipher in the "fall back to OCC based cipher negotiation" case.  Fix this.

Second, do not allow the 2.5 client to use --data-ciphers-fallback in the
above situation because that is not it's intended use (only to be used if
there is no pushed cipher [NCP] and no OCC provided cipher).

To reproduce the error use a client with only --data-ciphers set against
a server without NCP.

        OPTIONS ERROR: failed to negotiate cipher with server.
        Add the server's cipher  ('AES-256-CBC') to --data-ciphers
        (currently 'AES-256-CBC') if you want to connect to this server.

Reported by: Richard Bonhomme <tincanteksup@gmail.com>

Signed-off-by: Arne Schwabe <arne@rfc2549.org>
Acked-by: Steffan Karger <steffan@karger.me>
Message-Id: <20200814080619.2108-1-arne@rfc2549.org>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg20734.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
4 years agotun.c: enable using wintun driver under SYSTEM
Lev Stipakov [Wed, 19 Aug 2020 07:07:46 +0000 (10:07 +0300)] 
tun.c: enable using wintun driver under SYSTEM

Commit 6d19775a468 has removed SYSTEM elevation hack,
but introduced regression - inability to use wintun without
interactive service.

Proceed with ring buffers registration even if iservice is unavailable
and display relevant error message.

Trac: #1318

Signed-off-by: Lev Stipakov <lev@openvpn.net>
Acked-by: Selva Nair <selva.nair@gmail.com>
Message-Id: <20200819070746.197-1-lstipakov@gmail.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg20780.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
4 years agoImprove the documentation for --dhcp-option
Selva Nair [Sun, 16 Aug 2020 19:06:39 +0000 (15:06 -0400)] 
Improve the documentation for --dhcp-option

- Stress that these are handled internally only on some platforms
- Correct the statement about wintun
- Document DOMAIN-SEARCH

Signed-off-by: Selva Nair <selva.nair@gmail.com>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <1597604799-23135-1-git-send-email-selva.nair@gmail.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg20759.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
4 years agoChanges.rst: fix mistyped option names
Magnus Kroken [Sat, 15 Aug 2020 12:05:21 +0000 (14:05 +0200)] 
Changes.rst: fix mistyped option names

Signed-off-by: Magnus Kroken <mkroken@gmail.com>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20200815120522.1404-2-mkroken@gmail.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg20749.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
4 years agodoc: fix typos in cipher-negotiation.rst
Magnus Kroken [Sat, 15 Aug 2020 12:05:22 +0000 (14:05 +0200)] 
doc: fix typos in cipher-negotiation.rst

Signed-off-by: Magnus Kroken <mkroken@gmail.com>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20200815120522.1404-3-mkroken@gmail.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg20748.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
4 years agoFix stack overflow in OpenSolaris NEXTADDR()
Gert Doering [Thu, 13 Aug 2020 10:13:01 +0000 (12:13 +0200)] 
Fix stack overflow in OpenSolaris NEXTADDR()

Commit 5fde831c5807 fixed NEXTADDR() for all *BSDs and MacOS.

OpenSolaris has to use a slightly different macro due to lack of
sockaddr->sa_len - but it has the same problem, first rounding up,
then memmove()'ing.  Switch order.

Signed-off-by: Gert Doering <gert@greenie.muc.de>
Acked-by: Arne Schwabe <arne@rfc2549.org>
Message-Id: <20200813101301.12720-1-gert@greenie.muc.de>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg20731.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
4 years agoChange version.m4 to 2.6_git
Gert Doering [Wed, 12 Aug 2020 10:34:59 +0000 (12:34 +0200)] 
Change version.m4 to 2.6_git

2.5 has been branched off as release/2.5 now (2.5_beta1),
so this is what will become 2.6.0 one day.

Signed-off-by: Gert Doering <gert@greenie.muc.de>
4 years agoImprove sections about older OpenVPN clients in cipher-negotiation.rst
Arne Schwabe [Wed, 12 Aug 2020 08:54:12 +0000 (10:54 +0200)] 
Improve sections about older OpenVPN clients in cipher-negotiation.rst

 - Explain the IV_NCP=2 client situation in 2.4 a bit better.
 - Make more clear what exact versions are meant in the old client section
 - add a missing - in a heading

Thanks to Richard Bohnhomme for initial proof reading.

Signed-off-by: Arne Schwabe <arne@rfc2549.org>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20200812085412.19178-1-arne@rfc2549.org>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg20714.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
4 years agoChanges.rst updates in preparation to 2.5_beta1
Gert Doering [Wed, 12 Aug 2020 10:08:21 +0000 (12:08 +0200)] 
Changes.rst updates in preparation to 2.5_beta1

Signed-off-by: Gert Doering <gert@greenie.muc.de>
4 years agoAdd depreciation notice for --ncp-disable to protocol-options.rst
Gert Doering [Wed, 12 Aug 2020 10:20:33 +0000 (12:20 +0200)] 
Add depreciation notice for --ncp-disable to protocol-options.rst

Signed-off-by: Gert Doering <gert@greenie.muc.de>
4 years agoCleanup tls_pre_decrypt_lite and tls_pre_encrypt
Arne Schwabe [Mon, 10 Aug 2020 14:36:52 +0000 (16:36 +0200)] 
Cleanup tls_pre_decrypt_lite and tls_pre_encrypt

Mostly C90 -> C99 cleanups and "return immediately" instead of
wrapping function body into if.

(Review with ignore whitespace)

Signed-off-by: Arne Schwabe <arne@rfc2549.org>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20200810143707.5834-3-arne@rfc2549.org>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg20676.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
4 years agoRefactor/Reformat tls_pre_decrypt
Arne Schwabe [Tue, 11 Aug 2020 10:55:41 +0000 (12:55 +0200)] 
Refactor/Reformat tls_pre_decrypt

- Extract data packet handling to its own function
- Replace two instances of
          if (x) { code }
  with
          if (!x) return; code

- Remove extra curly braces that were used for pre C99 code style
  to be able to declare variables in the middle of a block

This patch is easier to review with "ignore white space" as the
diff is then a lot smaller in that case and the changes more obvious.

Patch V2: Fix function name spelling, cleanup goto code in the new
          handle_data_channel_packet function

Signed-off-by: Arne Schwabe <arne@rfc2549.org>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20200811105541.2543-1-arne@rfc2549.org>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg20707.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
4 years agoDocument comp-lzo no and compress being incompatible
Arne Schwabe [Tue, 11 Aug 2020 11:02:48 +0000 (13:02 +0200)] 
Document comp-lzo no and compress being incompatible

Most of the new compress but not v2 version do use swap operation. For
'compress lzo' the swap option is not used for backwards compatibility.
For lz4 the swap option is also not a problem since there is no version
without swap. Unfortunately, compress introduced a second stub format
with swap, contrary to the one in 'comp-lzo no' that does not use swap.

Document this weirdness to let not others fall into this trap.

v2: redo patch for rst man pages

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

Signed-off-by: Gert Doering <gert@greenie.muc.de>
4 years agoRemove S_OP_NORMAL key state.
Arne Schwabe [Mon, 10 Aug 2020 14:37:03 +0000 (16:37 +0200)] 
Remove S_OP_NORMAL key state.

The key state is virtually identical S_ACTIVE and we only did the state
state transition form S_ACTIVE to S_OP_NORMAL at the point where we
normally would have timed out the TLS negotiation. This is not a very
useful information to have and indeed we never use it anywhere.

Signed-off-by: Arne Schwabe <arne@rfc2549.org>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20200810143707.5834-14-arne@rfc2549.org>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg20674.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
4 years agoMove parsing IV_PROTO to separate function
Arne Schwabe [Mon, 10 Aug 2020 14:37:06 +0000 (16:37 +0200)] 
Move parsing IV_PROTO to separate function

Signed-off-by: Arne Schwabe <arne@rfc2549.org>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20200810143707.5834-17-arne@rfc2549.org>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg20679.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
4 years agoSkip existing interfaces on opening the first available utun on macOS
Arne Schwabe [Mon, 10 Aug 2020 14:37:04 +0000 (16:37 +0200)] 
Skip existing interfaces on opening the first available utun on macOS

This avoids the error messages trying to open already used utuns.

Signed-off-by: Arne Schwabe <arne@rfc2549.org>
Acked-by: Lev Stipakov <lstipakov@gmail.com>
Message-Id: <20200810143707.5834-15-arne@rfc2549.org>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg20665.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
4 years agoMerge check_coarse_timers and check_coarse_timers_dowork
Arne Schwabe [Mon, 10 Aug 2020 14:37:02 +0000 (16:37 +0200)] 
Merge check_coarse_timers and check_coarse_timers_dowork

This simplifies the code a bit and makes the code flow clearer as
it only adds three curly brackets in check_coarse_timers. Merging the
resulting check_coarse_timers_dowork function into the caller and
called function as with the other function does not make sense here
since it does more than similar function.

Signed-off-by: Arne Schwabe <arne@rfc2549.org>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20200810143707.5834-13-arne@rfc2549.org>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg20671.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
4 years agoEliminate check_tls wrapper function
Arne Schwabe [Mon, 10 Aug 2020 14:37:01 +0000 (16:37 +0200)] 
Eliminate check_tls wrapper function

Move check into caller.

Remove two in function forward declarations that are not needed from
check_tls_errors.

Signed-off-by: Arne Schwabe <arne@rfc2549.org>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20200810143707.5834-12-arne@rfc2549.org>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg20670.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
4 years agoEliminate check_incoming_control_channel wrapper function
Arne Schwabe [Mon, 10 Aug 2020 14:37:00 +0000 (16:37 +0200)] 
Eliminate check_incoming_control_channel wrapper function

Move the check that calls this function into the calling function.
Also eliminate the if (len) check in the
check_incoming_control_channel_dowork function as it is only called
if len is > 0 anyway and replace it with a ASSERT.

Signed-off-by: Arne Schwabe <arne@rfc2549.org>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20200810143707.5834-11-arne@rfc2549.org>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg20680.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
4 years agoEliminate check_fragment function
Arne Schwabe [Mon, 10 Aug 2020 14:36:59 +0000 (16:36 +0200)] 
Eliminate check_fragment function

This another of the small wrapper function where the check is
better move into the calling function.

Signed-off-by: Arne Schwabe <arne@rfc2549.org>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20200810143707.5834-10-arne@rfc2549.org>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg20672.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
4 years agoRename check_ping_restart_dowork to trigger_ping_timeout_signal
Arne Schwabe [Mon, 10 Aug 2020 14:36:58 +0000 (16:36 +0200)] 
Rename check_ping_restart_dowork to trigger_ping_timeout_signal

Rename the function to better capture its actual function.

Signed-off-by: Arne Schwabe <arne@rfc2549.org>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20200810143707.5834-9-arne@rfc2549.org>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg20675.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
4 years agoSplit pf_check_reload check and check timer in process_coarse_timers
Arne Schwabe [Mon, 10 Aug 2020 14:36:57 +0000 (16:36 +0200)] 
Split pf_check_reload check and check timer in process_coarse_timers

This moves the timer check into process_coarse_timers and makes it
in line with the other functions. The the pf.enabled check is also moved
into process_coarse_timers to make it more clear this only is used if
pf is enabled at all.

Signed-off-by: Arne Schwabe <arne@rfc2549.org>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20200810143707.5834-8-arne@rfc2549.org>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg20664.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
4 years agotravis: don't run t_net.sh test
Antonio Quartulli [Mon, 10 Aug 2020 16:17:23 +0000 (18:17 +0200)] 
travis: don't run t_net.sh test

Not all travis instances are fit for running t_net.sh test due to
various configurations knob that we have no access to.

Prevent failures by not running t_net.sh on travis at all.
The t_net.sh is executed by other test rigs which we have more control
over.

The test is skipped by specifying RUN_SUDO=false which will make any
pre-test fail, forcing the Makefile to skip that particular test.

Signed-off-by: Antonio Quartulli <a@unstable.cc>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20200810161723.25576-1-a@unstable.cc>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg20684.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
4 years agoRemove a number of check/do_work wrapper calls from coarse_timers
Arne Schwabe [Mon, 10 Aug 2020 14:36:56 +0000 (16:36 +0200)] 
Remove a number of check/do_work wrapper calls from coarse_timers

This indirection is not very helpful in understanding the code
flow.  Move the check to process_coarse_timers, remove the
check function, rename the do_work function to the "real" thing
and then drop the do_work wrapper as it does no longer serve a
purpose.

Signed-off-by: Arne Schwabe <arne@rfc2549.org>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20200810143707.5834-7-arne@rfc2549.org>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg20668.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
4 years agoRemove buf argument from link_socket_set_outgoing_addr
Arne Schwabe [Mon, 10 Aug 2020 14:36:55 +0000 (16:36 +0200)] 
Remove buf argument from link_socket_set_outgoing_addr

This was only used in a check that is better suited in the calling
functions. This also removes passing the buf argument to
link_socket_connection_initiated that also does not use that
parameter at all.

Signed-off-by: Arne Schwabe <arne@rfc2549.org>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20200810143707.5834-6-arne@rfc2549.org>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg20677.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
4 years agoClean up a number of leftover C89 initialisations in ssl.c
Arne Schwabe [Mon, 10 Aug 2020 14:36:53 +0000 (16:36 +0200)] 
Clean up a number of leftover C89 initialisations in ssl.c

Signed-off-by: Arne Schwabe <arne@rfc2549.org>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20200810143707.5834-4-arne@rfc2549.org>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg20666.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
4 years agoMinor cleanup in push.c
Arne Schwabe [Mon, 10 Aug 2020 14:36:54 +0000 (16:36 +0200)] 
Minor cleanup in push.c

Signed-off-by: Arne Schwabe <arne@rfc2549.org>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20200810143707.5834-5-arne@rfc2549.org>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg20678.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
4 years agoDocument different behaviour of dynamic cipher negotiation
Arne Schwabe [Mon, 10 Aug 2020 09:00:32 +0000 (11:00 +0200)] 
Document different behaviour of dynamic cipher negotiation

This adds a section in the man page that details the various behaviour
of older client/servers when using OpenVPN 2.5.

Patch V2: Include grammar/spelling fixes from
          Richard Bonhomme <tincanteksup@gmail.com>

Signed-off-by: Arne Schwabe <arne@rfc2549.org>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20200810090032.4220-1-arne@rfc2549.org>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg20660.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
4 years agoRework NCP compability logic and drop BF-CBC support by default
Arne Schwabe [Sun, 9 Aug 2020 14:19:21 +0000 (16:19 +0200)] 
Rework NCP compability logic and drop BF-CBC support by default

This reworks the NCP logic to be more strict about what is
considered an acceptable result of an NCP negotiation. It also
allows us to finally drop support for BF-CBC as default cipher.

All new behaviour is currently limited to server/client
mode with pull enabled. P2p mode without pull does not change.

New Server behaviour:
- when a client announces its supported ciphers through either
  OCC or IV_CIPHER/IV_NCP we reject the client with a
  AUTH_FAILED message if we have no common cipher.

- When a client does not announce any cipher in either
  OCC or NCP we reject it unless data-ciphers-fallback is
  specified in either ccd/ or config.

New client behaviour:
- When no cipher is pushed (or a cipher we refused to support)
  and we also cannot support the server's cipher announced in
  OCC we fail the connection and log why

- If there is no cipher in OCC but data-ciphers-fallback is
  specified we will use the fallback cipher instead of failing the
  connection

Both client and server behaviour:
- We only announce --cipher xyz in occ if we are willing
  to support that cipher (always announce the cipher if
  NCP is disabled or not in --client mode)

  It means that we only announce the fallback-cipher if
  it is also contained in --data-ciphers

Compatibility behaviour:

In 2.5 both client and server will use a --cipher xyz present
in the config to automatically set --data-ciphers-fallback xyz
and also append this cipher to the end of data-ciphers.

We log a warning about this and point to --data-ciphers and
--data-ciphers-fallback This also happens if the configuration
contains an explicit --cipher BF-CBC.

If --cipher is not set, we only warn that previous versions
allowed BF-CBC and point out how to re-enable BF-CBC. This will
break configs where someone connects a 2.3 client (or older)
to a 2.5 server AND has no explicit --cipher setting in the
server config.  We still do it, because at some point we need
to drop the BF-CBC default - and affected users already had the
scary SWEET32 warning in their logs for a long time.

In short: If --cipher is explicitly set then 2.5 will work the
same as 2.4 did. When --cipher is not set, BF-CBC support is
dropped and we warn about it.

Examples how breaking the default BF-CBC will be logged:

Client side:
 - Client connecting to server that does not push cipher but
   has --cipher in OCC

    OPTIONS ERROR: failed to negotiate cipher with server.  Add the
            server's cipher ('BF-CBC') to --data-ciphers (currently
            'AES-256-GCM:AES-128-CBC') if you want to connect to this server.

 - Client connecting to a server that does not support OCC:

    OPTIONS ERROR: failed to negotiate cipher with server. Configure
            --data-ciphers-fallback if you want connect to this server.

Server Side:
- Server has a client only supporting BF-CBC connecting:

  styx/IP PUSH: No common cipher between server and client. Server
          data-ciphers: 'CHACHA20-POLY1305:AES-128-GCM:AES-256-GCM:AES-256-CBC:AES-128-CBC', client supports cipher 'BF-CBC'.

 - Client without OCC:

   styx/IP PUSH:No NCP or OCC cipher data received from peer.
   styx/IP Use --data-ciphers-fallback with the cipher the client is using
           if you want to allow the client to connect

In all cases the client is rejected with this message:

   AUTH: Received control message: AUTH_FAILED,Data channel cipher
         negotiation failed (no shared cipher)

Signed-off-by: Arne Schwabe <arne@rfc2549.org>
Patch V2: rename fallback-cipher to data-ciphers-fallback
          add all corrections from Steffan
          Ignore occ cipher for clients sending IV_CIPHERS
          move client side ncp in its own function
          do not print INSECURE cipher warning if BF-CBC is not allowed

Patch V3: fix minor style, add null check when client sends no peerinfo at
          all

Signed-off-by: Arne Schwabe <arne@rfc2549.org>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20200809141922.7853-1-arne@rfc2549.org>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg20656.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
5 years agoFix compilation with --disable-lzo and --disable-lz4
Lev Stipakov [Wed, 5 Aug 2020 06:25:48 +0000 (06:25 +0000)] 
Fix compilation with --disable-lzo and --disable-lz4

struct compress_options is defined under USE_COMP, therefore
compilation fails when it is referenced without that define.

Since function show_compression_warning, which uses aforementioned
struct, is only called under USE_COMP, it is safe to wrap its definition
under USE_COMP, which fixes compilation issue.

Trac: #1308

Signed-off-by: Lev Stipakov <lstipakov@gmail.com>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20200805062548.38082-1-lstipakov@gmail.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg20637.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
5 years agoLog serial number of revoked certificate
Vladislav Grishenko [Wed, 5 Aug 2020 10:23:33 +0000 (15:23 +0500)] 
Log serial number of revoked certificate

As it appears commit 767e4c56becbfeea525e4695a810593f373883cd "Log
serial number of revoked certificate" hasn't survive refactoring
of CRL handling.

In most of situations admin of OpenVPN server needs to know which
particular certificate is used by client.
In the case when certificate is valid, environment variable can be
used for that but once it is revoked, no user scripts are invoked
so there is no way to get serial number, only subject is logged.

Let's log certificate serial in case it is revoked and additionally
log certificate depth & subject in crl-verify "dir" mode for better
consistency with crl file (non-dir) mode.

v2: log if serial is not availble, require it in crl-verify dir mode

Signed-off-by: Vladislav Grishenko <themiron@yandex-team.ru>
Acked-by: Lev Stipakov <lstipakov@gmail.com>
Message-Id: <20200805102333.3109-1-themiron@yandex-team.ru>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg20642.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
5 years agoclient-connect: Add documentation for the deferred client connect feature
Arne Schwabe [Mon, 20 Jul 2020 14:27:03 +0000 (16:27 +0200)] 
client-connect: Add documentation for the deferred client connect feature

Signed-off-by: David Sommerseth <davids@openvpn.net>
Signed-off-by: Arne Schwabe <arne@rfc2549.org>
Patch V5: Fix typos, clarify man page section about deferred client-connect
          script. Add section to Changes.rst

Patch V6: Convert manpage to rst

          It also incorporates suggested changes from Richard Bonhomme
          <tincanteksup@gmail.com> [0]

[0] Message-ID: <82c2d70f-e2f9-f810-2c55-788358a0cb08@gmail.com>
    URL:
https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg20331.h
tml

Patch V7: Re-include the changes of Changes.rst and openvpn-plugin.h
          Clarify some parts of the documentation.
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20200720142703.3324-1-arne@rfc2549.org>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg20511.html

Signed-off-by: Gert Doering <gert@greenie.muc.de>
5 years agoAbort client-connect handler loop after first handler sets 'disable'.
Gert Doering [Mon, 27 Jul 2020 18:34:36 +0000 (20:34 +0200)] 
Abort client-connect handler loop after first handler sets 'disable'.

The old code would run all (succeeding) handlers, then discover "one of
them set the 'disable' flag for this client", and then unroll all the
handlers.

Moving the 'disable' check into the loop makes it stop after the first
handler that fails or (succeeds and sets 'disable').  This is a bit
more logical in the log files, and has less potential side effects
due to running "later" client-connect handlers when we already know
they will have to be unrolled.

Signed-off-by: Gert Doering <gert@greenie.muc.de>
Acked-by: Arne Schwabe <arne@rfc2549.org>
Message-Id: <20200727183436.6625-2-gert@greenie.muc.de>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg20612.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
5 years agoFix sequence of events for async plugin v1 handler.
Gert Doering [Mon, 27 Jul 2020 18:34:35 +0000 (20:34 +0200)] 
Fix sequence of events for async plugin v1 handler.

If multi_client_connect_call_plugin_v1() goes to "deferred mode",
*and* there is no OPENVPN_CLIENT_CONNECT_DEFER handler, we
would read the "client specific options" file after every
(succeeded-because-not-present) call to plugin_call().

Move this to "after we have checked the deferred-cc file, and we
know for sure that we have CC_RET_SUCCEEDED".

Signed-off-by: Gert Doering <gert@greenie.muc.de>
Acked-by: Arne Schwabe <arne@rfc2549.org>
Message-Id: <20200727183436.6625-1-gert@greenie.muc.de>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg20613.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
5 years agoGently push users towards --data-ciphers in --show-ciphers output
Steffan Karger [Mon, 27 Jul 2020 11:09:24 +0000 (13:09 +0200)] 
Gently push users towards --data-ciphers in --show-ciphers output

Also:
 * fix a typo in the openssl output ("may be use*d*")
 * mention GCM before CBC (we prefer AEAD modes)

Signed-off-by: Steffan Karger <steffan.karger@foxcrypto.com>
Acked-by: Arne Schwabe <arne@rfc2549.org>
Message-Id: <E1k011A-0002yw-8S@sfs-ml-2.v29.lw.sourceforge.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg20608.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
5 years agoFix stack buffer overruns in NEXTADDR() macro:
Matthias Andree [Fri, 17 Jul 2020 17:18:18 +0000 (19:18 +0200)] 
Fix stack buffer overruns in NEXTADDR() macro:

copy first, then round up the length when adding padding
to the advance.

Found by: GCC 9.3.0 (FreeBSD)

Signed-off-by: Matthias Andree <matthias.andree@gmx.de>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20200717171818.230371-1-matthias.andree@gmx.de>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg20461.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
5 years agoAdd a note that ncp-ciphers is replaced by data-ciphers
Arne Schwabe [Fri, 24 Jul 2020 14:25:57 +0000 (16:25 +0200)] 
Add a note that ncp-ciphers is replaced by data-ciphers

This patch adds a message that informs the user that the ncp-cipher
is renamed to data-ciphers. This should address the following concerns:

 - Users being confused by old options.
 - Nudge users to use the modern variant of an option

The man page already documents ncp-ciphers as an old name for
data-ciphers, so looking it up in the man page will also work.

Note that I did not add "deprecated old option" to this message
since I still think that eventually removing the option will only
break configs and we gain almost nothing from that.

Also still accepting the option even though we do not recommend usage of
it also follows the robustness principle of:
"be strict in what you send and tolerant in what you receive"

Signed-off-by: Arne Schwabe <arne@rfc2549.org>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20200724142557.25204-1-arne@rfc2549.org>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg20573.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
5 years agoRename ncp-ciphers to data-ciphers
Arne Schwabe [Fri, 17 Jul 2020 13:47:38 +0000 (15:47 +0200)] 
Rename ncp-ciphers to data-ciphers

The change in name signals that data-ciphers is the preferred way to
configure data channel (and not --cipher). The data prefix is chosen
to avoid ambiguity and make it distinct from tls-cipher for the TLS
ciphers.

Signed-off-by: Arne Schwabe <arne@rfc2549.org>
Acked-by: Steffan Karger <steffan.karger@foxcrypto.com>
Message-Id: <20200717134739.21168-8-arne@rfc2549.org>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg20444.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
5 years agoAvoid sending push request after receving push reply
Arne Schwabe [Sat, 25 Jul 2020 23:48:03 +0000 (01:48 +0200)] 
Avoid sending push request after receving push reply

The introduction of IV_PROTO_REQUEST_PUSH (c290df55) sometimes causes the
server to reply before we setup the push timer. The push reply will then
clear a timer that has not been setup yet. We then start sending push
request after we have gone through the whole initialisation already.

This patch also clears the connestion_established timer that sets up the
push request timer. This lead to the

  management_set_state(management,  OPENVPN_STATE_GET_CONFIG, ...)

function not being called. But to display "waiting for configuration..." or
sending a "getting config state" after "initialisation" does not make sense
anyway.

Also add the IV_PROTO_REQUEST_PUSH feature as new feature in Changes.rst

Signed-off-by: Arne Schwabe <arne@rfc2549.org>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20200725234803.22058-2-arne@rfc2549.org>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg20589.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
5 years agoSimplify calling logic of check_connection_established_dowork
Arne Schwabe [Sat, 25 Jul 2020 23:48:02 +0000 (01:48 +0200)] 
Simplify calling logic of check_connection_established_dowork

The check event_timeout_defined in check_connection_established is
completely redundant as event_timeout_trigger will do the very same
check as first action. Removing this check makes the function
superfluous. To further improve the code  move the call check if the
time is expired into process_coarse_timers

Signed-off-by: Arne Schwabe <arne@rfc2549.org>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20200725234803.22058-1-arne@rfc2549.org>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg20588.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
5 years agoInclude utun device number in utun error messages
Arne Schwabe [Sat, 25 Jul 2020 23:50:23 +0000 (01:50 +0200)] 
Include utun device number in utun error messages

For lack of a better API (or knowledge about a better API) we try to
open utun devices on macOS by trying utun0 to utun255 and use the
first one that works. On my Mac I have already 4 devices that
do nothing but are just there and another VPN connection resulting in a
number of error messages. This explicitly  shows in the log that we
tried the devices instead of some unspecific error.

This changes the log from:

Opening utun (connect(AF_SYS_CONTROL)): Resource busy (errno=16)
Opening utun (connect(AF_SYS_CONTROL)): Resource busy (errno=16)
Opening utun (connect(AF_SYS_CONTROL)): Resource busy (errno=16)
Opening utun (connect(AF_SYS_CONTROL)): Resource busy (errno=16)
Opening utun (connect(AF_SYS_CONTROL)): Resource busy (errno=16)
Opened utun device utun5

to

Opening utun0 failed (connect(AF_SYS_CONTROL)): Resource busy (errno=16)
Opening utun1 failed (connect(AF_SYS_CONTROL)): Resource busy (errno=16)
Opening utun2 failed (connect(AF_SYS_CONTROL)): Resource busy (errno=16)
Opening utun3 failed (connect(AF_SYS_CONTROL)): Resource busy (errno=16)
Opening utun4 failed (connect(AF_SYS_CONTROL)): Resource busy (errno=16)
Opened utun device utun5

Signed-off-by: Arne Schwabe <arne@rfc2549.org>
Feature-ACK-by: "Jonathan K. Bullard" <jkbullard@gmail.com>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20200725235023.22441-1-arne@rfc2549.org>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg20590.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
5 years agowintun: remove SYSTEM elevation hack
Lev Stipakov [Fri, 24 Jul 2020 10:48:41 +0000 (13:48 +0300)] 
wintun: remove SYSTEM elevation hack

As discussed a while ago on the mailing list and
community meetings, having SYSTEM elevation hack
inside openvpn code considered harmful.

Since interactive service is the recommended way
of using openvpn on Windows, limiting wintun usage to
interactive service should not be an issue.

Remove elevation hack code and provide an error message
telling user to use interactive service or do SYSTEM
elevation himself via psexec.

Move implementation of register_ring_buffers() to header
amd delete ring_buffer.c.

Signed-off-by: Lev Stipakov <lev@openvpn.net>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20200724104841.89-1-lstipakov@gmail.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg20567.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
5 years agoRepair --inetd
Gert Doering [Fri, 24 Jul 2020 18:13:24 +0000 (20:13 +0200)] 
Repair --inetd

commit 25a422cc60 deprecated --inetd, which is still something we want.

Unlike all "usual" deprecated option warnings, we cannot print this at
option parsing time, because we need logging to be set up first - otherwise
the deprecation warning is sent via the socket (on stdin/stdout)
towards the connecting client, totally breaking this mode.

(Which is why we want to deprecate it: too special even for us)

Signed-off-by: Gert Doering <gert@greenie.muc.de>
Acked-by: Arne Schwabe <arne@rfc2549.org>
Message-Id: <20200724181324.19037-1-gert@greenie.muc.de>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg20574.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
5 years agoImprove Windows version detection with manifest
Lev Stipakov [Fri, 24 Jul 2020 19:56:34 +0000 (22:56 +0300)] 
Improve Windows version detection with manifest

Add manifest file to detect Windows versions greater than Windows 8.

Below is example output on Windows 10.

Before:
        Windows version 6.2 (Windows 8 or greater) 64bit

After:
        Windows version 10.0 (Windows 10 or greater) 64bit

Signed-off-by: Lev Stipakov <lev@openvpn.net>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20200724195634.493-1-lstipakov@gmail.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg20580.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
5 years agoDeprecate --inetd
Arne Schwabe [Thu, 23 Jul 2020 15:59:37 +0000 (17:59 +0200)] 
Deprecate --inetd

This is a corner case of a corner case option. It only works with tcp,
tap and needs special configuration.

Signed-off-by: Arne Schwabe <arne@rfc2549.org>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20200723155937.1867-1-arne@rfc2549.org>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg20554.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
5 years agoIndicate that a client is in pull mode in IV_PROTO
Arne Schwabe [Tue, 21 Jul 2020 16:38:11 +0000 (18:38 +0200)] 
Indicate that a client is in pull mode in IV_PROTO

This allows us to skip waiting for the first PUSH_REQUEST message from
the client to send the response.

This changes the interpretation of IV_PROTO from a scalar to a bitfield
Since we only have IV_PROTO=2 defined so far and will support DATA_V2
this should not make any problem. This avoid adding another IV_xxx variable
that takes valuable space in the protocol frame.

Signed-off-by: Arne Schwabe <arne@rfc2549.org>
Patch V2: Use bitmask for IV_PROTO_DATA_V2 and add more documentation.

Patch V3: Rewrite IV_PROTO paragraph in man page, incoperate spelling fixes
          by Richard Bonhomme <tincanteksup@gmail.com>

Signed-off-by: Arne Schwabe <arne@rfc2549.org>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20200721163811.22745-1-arne@rfc2549.org>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg20525.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
5 years agoAvoid sending --cipher to clients not supporting NCP
Arne Schwabe [Fri, 17 Jul 2020 13:47:37 +0000 (15:47 +0200)] 
Avoid sending --cipher to clients not supporting NCP

The NCP rework introduced a regression of sending a --cipher
command as part of the push message when the client does not
support NCP. This is is more a cosmetic issue since the client
will log that as warning in the log and ignore it.

Signed-off-by: Arne Schwabe <arne@rfc2549.org>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20200717134739.21168-7-arne@rfc2549.org>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg20437.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
5 years agot_net.sh: drop hard dependency on t_client.rc
Antonio Quartulli [Tue, 21 Jul 2020 19:55:18 +0000 (21:55 +0200)] 
t_net.sh: drop hard dependency on t_client.rc

Right now t_net.sh depends on t_client.rc in order to source the
RUN_SUDO variable only.
However, t_client.rc is something that a few people only have configured
and thus this would result in t_net.sh almost never executed even if it
just could.

Drop dependency on t_client.rc by falling back to RUN_SUDO=sudo when the
file is missing and no RUN_SUDO is passed via env.

While at it, reword the error message to better match the current logic
flow.

Signed-off-by: Antonio Quartulli <a@unstable.cc>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20200721195518.14358-1-a@unstable.cc>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg20533.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
5 years agoImplement tls-groups option to specify eliptic curves/groups
Arne Schwabe [Tue, 21 Jul 2020 15:49:22 +0000 (17:49 +0200)] 
Implement tls-groups option to specify eliptic curves/groups

By default OpenSSL 1.1+ only allows signatures and ecdh/ecdhx from the
default list of X25519:secp256r1:X448:secp521r1:secp384r1. In
TLS1.3 key exchange is independent from the signature/key of the
certificates, so allowing all groups per default is not a sensible
choice anymore and instead a shorter list is reasonable.

However, when using certificates with exotic curves that are not on
the group list, the signatures of these certificates will no longer
be accepted.

The tls-groups option allows to modify the group list to account
for these corner cases.

Patch V2: Uses local gc_arena instead of malloc/free, reword commit
          message. Fix other typos/clarify messages

Patch V3: Style fixes, adjust code to changes from mbedTLS session
          fix

Patch V5: Fix compilation with OpenSSL 1.0.2

Patch V6: Redo the 'while((token = strsep(&tmp_groups, ":"))' change
          which accidentally got lost.

Signed-off-by: Arne Schwabe <arne@rfc2549.org>
Acked-by: Antonio Quartulli <antonio@openvpn.net>
Message-Id: <20200721154922.17144-1-arne@rfc2549.org>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg20521.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
5 years agoRemove ENABLE_OCC #define
Arne Schwabe [Fri, 17 Jul 2020 13:47:36 +0000 (15:47 +0200)] 
Remove ENABLE_OCC #define

Commit 037669f3dd already made occ being unconditionally on. This commit
only removes the #ifdefs

Signed-off-by: Arne Schwabe <arne@rfc2549.org>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20200717134739.21168-6-arne@rfc2549.org>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg20442.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
5 years agoRemove key-method 1
Arne Schwabe [Tue, 21 Jul 2020 10:01:28 +0000 (12:01 +0200)] 
Remove key-method 1

Key-method 1 is only needed to talk to pre OpenVPN 2.0 clients.

Patch V2: Fix style. Make V1 op codes illegal, remove all code handling
          v1 op codes and give a good warning message if we encounter
          them in the legal op codes pre-check.

Patch V3: Add a bit more comments in the existing methods.

Signed-off-by: Arne Schwabe <arne@rfc2549.org>
Acked-by: David Sommerseth <davids@openvpn.net>
Message-Id: <20200721100128.9850-1-arne@rfc2549.org>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg20516.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
5 years agoRemove --client-cert-not-required
David Sommerseth [Mon, 20 Jul 2020 11:30:10 +0000 (13:30 +0200)] 
Remove --client-cert-not-required

This removes support for the --client-cert-not-required option.  To
avoid starting a server with this option just ignored, which would make
it impossible for existing clients to connect it will exit with
instructions to replace this option with --verify-client-cert none.

Signed-off-by: David Sommerseth <davids@openvpn.net>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20200720113010.10450-1-davids@openvpn.net>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg20502.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
5 years agoRemove --ifconfig-pool-linear
David Sommerseth [Mon, 20 Jul 2020 11:51:56 +0000 (13:51 +0200)] 
Remove --ifconfig-pool-linear

This option has been deprecated since OpenVPN 2.1 and it has been
highlighted in the documentation and log files since OpenVPN 2.4.4.

Signed-off-by: David Sommerseth <davids@openvpn.net>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20200720115156.13322-1-davids@openvpn.net>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg20504.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
5 years agoRequire AEAD support in the crypto library
Arne Schwabe [Mon, 20 Jul 2020 12:17:04 +0000 (14:17 +0200)] 
Require AEAD support in the crypto library

All supported crypto libraries have AEAD support and with our
ncp/de facto default cipher AES-256-GCM we do not want to support
the obscure corner case of a library with disabled AEAD.

Signed-off-by: Arne Schwabe <arne@rfc2549.org>
Patch V2: Remove three instances of (harmless) #ifdef Steffan spotted
          that can be removed now too.
Acked-by: Steffan Karger <steffan.karger@foxcrypto.com>
Message-Id: <20200720121704.20333-1-arne@rfc2549.org>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg20506.html

Signed-off-by: Gert Doering <gert@greenie.muc.de>
5 years agoDrop support for OpenSSL 1.0.1
Arne Schwabe [Fri, 17 Jul 2020 13:47:32 +0000 (15:47 +0200)] 
Drop support for OpenSSL 1.0.1

OpenSSL 1.0.1 was supported until 2016-12-31. Rhel6/Centos6 still
use this version but considering that RHEL7 and RHEL8 are already
out, these versions can also stay with OpenVPN 2.4.

All the supported Debian based distributions also come with at
least 1.0.2.

We (accidently) unconditionally compiled some key exporter code on
OpenSSL 1.0.2+ without problems. So always compile the whole
key exporter feature for OpenSSL.

This also allows the tls groups commit to be applied without
adding ifdefs to disable that functionality on OpenSSL 1.0.1

Signed-off-by: Arne Schwabe <arne@rfc2549.org>
Acked-by: Steffan Karger <steffan.karger@foxcrypto.com>
Message-Id: <20200717134739.21168-2-arne@rfc2549.org>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg20441.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
5 years agotravis: Fix make distcheck failure
David Sommerseth [Mon, 20 Jul 2020 10:38:22 +0000 (12:38 +0200)] 
travis: Fix make distcheck failure

Since commit f500c49c8e0, the man page and html documentation need to be
generated when building out of the git repository, as both openvpn.8 and
openvpn.8.html will be shipped pregenerated inside the tarball generated
by 'make dist'.

Travis was lacking the python-docutils package, which made the
'make distcheck' build test fail.

Signed-off-by: David Sommerseth <davids@openvpn.net>
Acked-by: Arne Schwabe <arne@rfc2549.org>
Message-Id: <20200720103822.26088-1-davids@openvpn.net>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg20497.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
5 years agoclient-connect: Implement deferred connect support for plugin API v2
Arne Schwabe [Sun, 19 Jul 2020 17:34:36 +0000 (19:34 +0200)] 
client-connect: Implement deferred connect support for plugin API v2

The V2 API is simpler than the V1 API since there is no passing of
data via files. This also means that with the current API the V2 API
cannot support async notify via files. Adding a file just for async
notify seems very hacky and when needed we should implement a better
option when async is needed for the plugin V2 API.

Signed-off-by: Arne Schwabe <arne@rfc2549.org>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20200719173436.16431-5-arne@rfc2549.org>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg20480.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
5 years agoSeparate handling of non-deferred return values for client-connect-scripts.
Gert Doering [Mon, 20 Jul 2020 07:08:02 +0000 (09:08 +0200)] 
Separate handling of non-deferred return values for client-connect-scripts.

(Only) on "CC_RET_SUCCESS", run multi_client_connect_post().

On "CC_RET_FAILURE", add missing log line, do not call ..._post().

Signed-off-by: Gert Doering <gert@greenie.muc.de>
Acked-by: Arne Schwabe <arne@rfc2549.org>
Message-Id: <20200720070802.18819-1-gert@greenie.muc.de>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg20488.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
5 years agoclient-connect: Add deferred support to the client-connect v1 plugin handler
Fabian Knittel [Sun, 19 Jul 2020 17:34:35 +0000 (19:34 +0200)] 
client-connect: Add deferred support to the client-connect v1 plugin handler

Uses the infrastructure provided and used in the previous patch to provide
deferral support to the v1 client-connect plugin handler as well.

Signed-off-by: Fabian Knittel <fabian.knittel@lettink.de>
PATCH V3: Modify the API to also (optionally) call the plugin on a deferred
call (CLIENT_CONNECT_DEFER).

This allows the plugin authors to be more flexible and make the V1 API more
similar to the CLIENT_CONNECT_V2 API.

Signed-off-by: Arne Schwabe <arne@rfc2549.org>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20200719173436.16431-4-arne@rfc2549.org>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg20483.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
5 years agoclient-connect: Use inotify for the deferred client-connect status file
Arne Schwabe [Sun, 19 Jul 2020 17:34:34 +0000 (19:34 +0200)] 
client-connect: Use inotify for the deferred client-connect status file

As we never do client-connect and authentication at the same time
it is safe to reuse the existing fields for client-connect return
status file

Signed-off-by: Arne Schwabe <arne@rfc2549.org>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20200719173436.16431-3-arne@rfc2549.org>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg20481.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
5 years agoclient-connect: Add deferred support to the client-connect script handler
Fabian Knittel [Sun, 19 Jul 2020 17:34:33 +0000 (19:34 +0200)] 
client-connect: Add deferred support to the client-connect script handler

This patch introduces the concept of a return value file for the
client-connect handlers (this is very similar to the auth value file
used during deferred authentication).  The file name is stored in the
client_connect_state struct.

In addition, the patch also moves the storage of the client config file
name into struct client_connect_state.

Both changes are used by the client-connect script handler to support
deferred client-connection handling.  The deferred return value file
(deferred_ret_file) is passed to the script via the environment.

If the script succeeds and writes the value for deferral (2) into the
deferred_ret_file, the handler knows to indicate deferral.  Later on,
the deferred handler checks whether the value of the deferred_ret_file
has been updated to success or failure.

Signed-off-by: Fabian Knittel <fabian.knittel@lettink.de>
Signed-off-by: Arne Schwabe <arne@rfc2549.org>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20200719173436.16431-2-arne@rfc2549.org>
URL: https://www.mail-archive.com/search?l=mid&q=20200719173436.16431-2-arne@rfc2549.org
Signed-off-by: Gert Doering <gert@greenie.muc.de>
5 years agoRemove CAS_PARTIAL state
Arne Schwabe [Sun, 19 Jul 2020 17:34:32 +0000 (19:34 +0200)] 
Remove CAS_PARTIAL state

This state is used to handle a corner case when multiple connect
handlers are active and one of them fails. Unfortunately, this state
complicates the state machine a bit without a good benefit.

Current behaviour:

First/all connect handler(s) fail:

  - client disconnect handler is not called at all

At least one connect handler succeeds but a subsequent handler fails:

  - client disconect is called when we actually
    disconnect the client (a few seconds later, max tls timeout)

All connect handlers suceed:

  - client disconect is called when we actually
    disconnect the client

This patches changes the behaviour in the second to immediately
call disconnect_handler in this case.

This simplifies the logic that already caused a bug and the
behaviour change is very little and affects only a pretty
exotic corner case.

Signed-off-by: Arne Schwabe <arne@rfc2549.org>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20200719173436.16431-1-arne@rfc2549.org>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg20482.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
5 years agodoc/man: Do not install man *.rst files
David Sommerseth [Sun, 19 Jul 2020 11:48:53 +0000 (13:48 +0200)] 
doc/man: Do not install man *.rst files

When the man page got split up into several .rst files, these files got
listed into dist_doc_DATA=.  This variable will both distribute (package
in the source tarball) and install these files into /usr/share/doc.
This was not intended, and it duplicates the content and makes the doc
dir quite messy.

By moving these files to dist_noinst_DATA= instead, these files are
still distributed but not installed via 'make install'.

Signed-off-by: David Sommerseth <davids@openvpn.net>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20200719114853.24168-1-davids@openvpn.net>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg20476.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
5 years agoRemove --no-iv
David Sommerseth [Fri, 17 Jul 2020 17:15:44 +0000 (19:15 +0200)] 
Remove --no-iv

This finializes the depreacation started in OpenVPN 2.4, where --no-iv
was made into a NOOP option.

Signed-off-by: David Sommerseth <davids@openvpn.net>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20200717171544.21632-1-davids@openvpn.net>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg20460.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
5 years agooptions: don't leak inline'd key material in logfile
Antonio Quartulli [Fri, 17 Jul 2020 21:28:20 +0000 (23:28 +0200)] 
options: don't leak inline'd key material in logfile

With the conversion of the introduction of a bool variable to signal
when a certain string is a filename or the actual (inline'd) key
material, the SHOW_STR() macro is now leaking the inline'd material to
the log file.

This happens because SHOW_STR will just print the content of the passed
argument without any check. With the new logic this should not happen
anymore.

A new macro SHOW_STR_INLINE() is therefore introduced which will check
the appropriate bool member before deciding to print the actual string
content or not.

Trac: #1304
Reported-by: Richard Bonhomme <tincanteksup@gmail.com>
Signed-off-by: Antonio Quartulli <a@unstable.cc>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20200717212820.8998-1-a@unstable.cc>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg20472.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
5 years agoMerge Makefile.am's AUTOMAKE_OPTIONS into configure.ac's AM_INIT_AUTOMAKE.
Matthias Andree [Fri, 17 Jul 2020 17:19:18 +0000 (19:19 +0200)] 
Merge Makefile.am's AUTOMAKE_OPTIONS into configure.ac's AM_INIT_AUTOMAKE.

Else one location overwrites options from the other.

Signed-off-by: Matthias Andree <matthias.andree@gmx.de>
Acked-by: David Sommerseth <davids@openvpn.net>
Message-Id: <20200717171918.230727-1-matthias.andree@gmx.de>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg20462.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
5 years agoclient-connect: Add CC_RET_DEFERRED and cope with deferred client-connect
Arne Schwabe [Thu, 16 Jul 2020 13:43:10 +0000 (15:43 +0200)] 
client-connect: Add CC_RET_DEFERRED and cope with deferred client-connect

This patch moves the state, that was previously tracked within the
multi_connection_established() function, into struct client_connect_state.
The multi_connection_established() function can now be exited and
re-entered as many times as necessary - without losing the client-connect
handling state.

The patch also adds the new return value CC_RET_DEFERRED which indicates
that the handler couldn't complete immediately, and needs to be called
later.  At that point multi_connection_established() will exit without
indicating completion.

Each client-connect handler now has an additional argument: "deferred",
to signal "additional call(s) while in deferred state".  The first call
to a handler always sets "deferred = false".  If that call returns
CC_RET_DEFERRED, the next call to the handler will be "deferred = true".

For some handlers (mda, ccd) this can never happen, so we ASSERT()
on !deferred.  If that ever triggers, something is wrong in our data
structures and we should better abort.

Signed-off-by: Fabian Knittel <fabian.knittel@lettink.de>
Patch V3: Use a static struct in multi_instance instead of using
          malloc/free and use two states (deferred with and without
          result) instead of one to eliminate the counter that was
          only tested for > 0.

Patch V5: Use new states in context_auth instead of the extra state
          that the patch series previously used.

Patch V6: Restructure code to make it a bit more readable, rebase on
          master.

Patch V7: move deferred bool into client connect handler calls, switch
          to switch case

Signed-off-by: Arne Schwabe <arne@rfc2549.org>
Acked-by: Antonio Quartulli <antonio@openvpn.net>
Message-Id: <20200716134315.17742-1-arne@rfc2549.org>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg20395.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
5 years agodoc/man: Add misssing renegotiation.rst to Makefile.am
David Sommerseth [Fri, 17 Jul 2020 11:01:36 +0000 (13:01 +0200)] 
doc/man: Add misssing renegotiation.rst to Makefile.am

This file did not get added to Makefile.am by a mistake during the
man-page overhaul, and the issue this causes is not easily spotted.

If a consumer of a tarball (created with 'make dist' from the git
tree) tries runs 'make clean' and 'make dist' plus have
python-docutils installed from such a tarball, it will explode and
complain about this missing file.

Signed-off-by: David Sommerseth <davids@openvpn.net>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20200717110136.11579-1-davids@openvpn.net>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg20431.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
5 years agodoc/man: Documentation for --bind-dev / VRFs on Linux
David Sommerseth [Fri, 17 Jul 2020 10:54:53 +0000 (12:54 +0200)] 
doc/man: Documentation for --bind-dev / VRFs on Linux

Signed-off-by: Maximilian Wilhelm <max@sdn.clinic>
Signed-off-by: David Sommerseth <davids@openvpn.net>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20200717105453.10718-1-davids@openvpn.net>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg20429.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
5 years agodoc/man: Update --txqueuelen default setting (Now OS default)
Richard Bonhomme [Thu, 16 Jul 2020 22:53:37 +0000 (00:53 +0200)] 
doc/man: Update --txqueuelen default setting (Now OS default)

Signed-off-by: Richard Bonhomme <tincanteksup@gmail.com>
Signed-off-by: David Sommerseth <davids@openvpn.net>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20200716225338.611-8-davids@openvpn.net>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg20415.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
5 years agodoc/man: Adopt compression documentation
David Sommerseth [Thu, 16 Jul 2020 22:53:36 +0000 (00:53 +0200)] 
doc/man: Adopt compression documentation

Commit c67e93b25208be2 updated the man page in reagrds to new
compression options and improving existing compression options.  This
adopts those changes into the .rst format.

Signed-off-by: David Sommerseth <davids@openvpn.net>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20200716225338.611-7-davids@openvpn.net>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg20414.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
5 years agodoc/man: Mark compression options as deprecated
David Sommerseth [Thu, 16 Jul 2020 22:53:35 +0000 (00:53 +0200)] 
doc/man: Mark compression options as deprecated

Due to the VORACLE attack vector, compression in general is deprecated.
Make this clear in the man page.

Also remove an incorrect statement claiming --compress lzo is compatible
with --comp-lzo.  It is not, as --compress lzo uses a different
compression framing than --comp-lzo.

Signed-off-by: David Sommerseth <davids@openvpn.net>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20200716225338.611-6-davids@openvpn.net>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg20417.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
5 years agodoc/man: convert openvpn.8 to split-up .rst files
David Sommerseth [Thu, 16 Jul 2020 22:53:31 +0000 (00:53 +0200)] 
doc/man: convert openvpn.8 to split-up .rst files

To avoid keeping around a full-size openvpn.rst file which is never
needed but will take space in the repo forever, patches 01...04
of the big documentation overhaul projects were squashed togehter,
keeping the individual commit logs and URL references below.

Signed-off-by: Gert Doering <gert@greenie.muc.de>
* This is a combination of 4 commits.
* This is the 1st commit message:

doc/man: Add an .rst formatted version of the man page

This is the first step to move away from a manually editing g/nroff
encoded man page.

Some modifications was needed to ensure formatting was consistent and
rendered reasonably okay in GitHub and that the generated man page
(using rst2man) is looking as a proper man page.  Unsupported options
has also been moved into its own section.  HTML rendering directly
using rst2html has also been used to validate the conversion.

The rst2man and rst2html utilities comes from the python-docutils
project: https://docutils.sourceforge.io/

Signed-off-by: David Sommerseth <davids@openvpn.net>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20200716225338.611-2-davids@openvpn.net>
URL: https://sourceforge.net/p/openvpn/mailman/message/37063370/
Signed-off-by: Gert Doering <gert@greenie.muc.de>
* This is the commit message #2:

doc/man: Replace old man page with generated man page

The doc/openvpn.8 and doc/openvpn.8.html files are now being removed
from the git tree, as it will be generated from the doc/openvpn.8.rst
file using python-docutils.

An additional dist-hook is added so these files are generated
automatically when source tarballs are generated for releases.  This
means users compiling directly from the source tarball will not need
python-docutils installed.

Signed-off-by: David Sommerseth <davids@openvpn.net>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20200716225338.611-3-davids@openvpn.net>
URL: https://sourceforge.net/p/openvpn/mailman/message/37063373/
Signed-off-by: Gert Doering <gert@greenie.muc.de>
* This is the commit message #3:

doc/man: Split up and reorganize main man page

The openvpn.8.rst file is quite long and hard to edit, as it covers
several hundred options.  Some options were even documented multiple
places.  The example has also received some attention, cleaning up
old and outdated infomration.

In this commit the main man page is split up into multiple sections
and options are sorted into each of the corresponding section.
Inside each category, each option is for now sorted alphabetically.
The main openvpn.8.rst file is currently kept unchanged and will be
handled in the next commit.

Many language improvements contributed by Richard Bonhomme has also
been incorproated.

Signed-off-by: David Sommerseth <davids@openvpn.net>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20200716225338.611-4-davids@openvpn.net>
URL: https://sourceforge.net/p/openvpn/mailman/message/37063376/
Signed-off-by: Gert Doering <gert@greenie.muc.de>
* This is the commit message #4:

doc/man: Complete openvpn.8.rst splitting

This rebuilds the openvpn.8.rst content by using the text which was
split out in the previous commit by using RST ..include statements.

Signed-off-by: David Sommerseth <davids@openvpn.net>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20200716225338.611-5-davids@openvpn.net>
URL: https://sourceforge.net/p/openvpn/mailman/message/37063377/
Signed-off-by: Gert Doering <gert@greenie.muc.de>
5 years agoAdd deferred authentication support to plugin-auth-pam
Gert Doering [Wed, 15 Jul 2020 09:01:05 +0000 (11:01 +0200)] 
Add deferred authentication support to plugin-auth-pam

If OpenVPN signals deferred authentication support (by setting
the internal environment variables "auth_control_file" and
"deferred_auth_pam"), do not wait for PAM stack to finish.  Instead,
the privileged PAM process returns RESPONSE_DEFER via the control
socket, which gets turned into OPENVPN_PLUGIN_FUNC_DEFERRED towards
openvpn.

The PAM process will then fork() and handle all the PAM auth in
the new process, signalling success/failure back by means of the
auth_control_file (forking twice, to simplify wait() handling).

With the extra fork(), multiple deferred authentications can run at
the same time - otherwise the first one would block the next auth
call (because the child would not be ready again to read from the
control socket).

Lightly tested on Linux.

Signed-off-by: Gert Doering <gert@greenie.muc.de>
--
v2:
  - only do deferred auth if "deferred_auth_pam" is set (env)
  - put deferred auth logic into do_deferred_pam_auth()
  - line-wrap lines where needed
  - close "background end" of socketpair in deferred auth process
  - remove leftover /* plugin_log() */ lines from initial testing
  - tested over a few hundred "15s delayed" authentication cycles

v3:
  - uncrustify new code
  - do not abort background process if do_deferred_pam_auth() fails
    (this can only happen if fork() fails, which is assumed to be
    temporary, or if something is wrong with the socketpair which we
    should notice on the next read()) --> change do_deferred_pam_auth()
    to "void"
  - add documentation to README.auth-pam and Changes.rst
Acked-by: Selva Nair <selva.nair@gmail.com>
Message-Id: <20200715090105.22296-1-gert@greenie.muc.de>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg20361.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
5 years agoreformat multi_client_generate_tls_keys according to uncrustify
Arne Schwabe [Wed, 15 Jul 2020 14:14:25 +0000 (16:14 +0200)] 
reformat multi_client_generate_tls_keys according to uncrustify

The refactor accidently used a wrong code style template and
ended up using 2 instead of 4 as indent.

Signed-off-by: Arne Schwabe <arne@rfc2549.org>
Acked-by: Antonio Quartulli <a@unstable.cc>
Message-Id: <20200715141425.26293-1-arne@rfc2549.org>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg20371.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
5 years agoclient-connect: Move adding inotify watch into its own function
Arne Schwabe [Sat, 11 Jul 2020 09:36:51 +0000 (11:36 +0200)] 
client-connect: Move adding inotify watch into its own function

This makes the code a more readable and also prepares reusing
the function for client-connect return files

Signed-off-by: Arne Schwabe <arne@rfc2549.org>
Acked-by: Antonio Quartulli <a@unstable.cc>
Message-Id: <20200711093655.23686-10-arne@rfc2549.org>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg20284.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
5 years agoclient-connect: Change cas_context from int to enum
Arne Schwabe [Sat, 11 Jul 2020 09:36:48 +0000 (11:36 +0200)] 
client-connect: Change cas_context from int to enum

This deviates from Fabian's original patch that relied on the now
removed connection_established bool as pointer being NULL or non NULL as
implicit third state and making connection_established as a substate of
(cas_context == CAS_PENDING)

Signed-off-by: Arne Schwabe <arne@rfc2549.org>
Patch V5: extend cas_context with two new states instead adding an
          extra mini state machine.

Signed-off-by: Arne Schwabe <arne@rfc2549.org>
Acked-by: Antonio Quartulli <a@unstable.cc>
Message-Id: <20200711093655.23686-7-arne@rfc2549.org>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg20292.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
5 years agoclient-connect: Refactor client-connect handling to calling a bunch of hooks in a...
Fabian Knittel [Sat, 11 Jul 2020 09:36:47 +0000 (11:36 +0200)] 
client-connect: Refactor client-connect handling to calling a bunch of hooks in a loop

This patch changes the calling of the client-connect functions into an
array of hooks and a block of code that calls them in a loop.

Signed-off-by: Fabian Knittel <fabian.knittel@lettink.de>
Signed-off-by: Arne Schwabe <arne@rfc2549.org>
Patch V5: Rebase on master.

Signed-off-by: Arne Schwabe <arne@rfc2549.org>
Acked-by: Antonio Quartulli <a@unstable.cc>
Message-Id: <20200711093655.23686-6-arne@rfc2549.org>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg20293.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
5 years agoclient-connect: Refactor to use return values instead of modifying a passed-in flag
Fabian Knittel [Sat, 11 Jul 2020 09:36:46 +0000 (11:36 +0200)] 
client-connect: Refactor to use return values instead of modifying a passed-in flag

This patch changes the way the client-connect helper functions communicate
with the main function.  Instead of updating cc_succeeded and cc_succeeded_count,
they now return either CC_RET_SUCCEEDED, CC_RET_FAILED or CC_RET_SKIPPED.

In addition, the client-connect helpers are now called in completely
identical ways.  This is in preparation of handling the helpers as simple
call-backs.

Signed-off-by: Fabian Knittel <fabian.knittel@lettink.de>
Patch V5: Minor style fixes

Signed-off-by: Arne Schwabe <arne@rfc2549.org>
Acked-by: Antonio Quartulli <a@unstable.cc>
Message-Id: <20200711093655.23686-5-arne@rfc2549.org>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg20286.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
5 years agoclient-connect: Move multi_client_connect_setenv into early_setup
Fabian Knittel [Sat, 11 Jul 2020 09:36:45 +0000 (11:36 +0200)] 
client-connect: Move multi_client_connect_setenv into early_setup

This patch moves multi_client_connect_setenv into
multi_client_connect_early_setup and makes sure that every client-connect
handling function updates the virtual address selection.

Background: This unifies how the client-connect handling functions work.

Signed-off-by: Fabian Knittel <fabian.knittel@lettink.de>
Signed-off-by: Arne Schwabe <arne@rfc2549.org>
Patch V5: Rebase on master

Signed-off-by: Arne Schwabe <arne@rfc2549.org>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20200711093655.23686-4-arne@rfc2549.org>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg20288.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
5 years agoclient-connect: Refactor multi_client_connect_source_ccd
Fabian Knittel [Sat, 11 Jul 2020 09:36:44 +0000 (11:36 +0200)] 
client-connect: Refactor multi_client_connect_source_ccd

Refactor multi_client_connect_source_ccd(), so that
options_server_import() (or the success path in general) is only
entered in one place within the function.

Signed-off-by: Fabian Knittel <fabian.knittel@lettink.de>
Patch V5: Simplify the logic even further to make it more easy to
understand.

Signed-off-by: Arne Schwabe <arne@rfc2549.org>
Acked-by: Antonio Quartulli <antonio@openvpn.net>
Message-Id: <20200711093655.23686-3-arne@rfc2549.org>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg20287.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
5 years agoAdded support for DHCP option 119 (dns search suffix list) for Windows.
Jan Just Keijser [Tue, 14 Jul 2020 09:39:10 +0000 (11:39 +0200)] 
Added support for DHCP option 119 (dns search suffix list) for Windows.

As of Windows 10 1809 Windows finally supports this so it makes sense
to add support to OpenVPN as well.

Multiple options can be specified at the same time, with one search
domain per line (in the config, or pushed from server):

  dhcp-option DOMAIN-SEARCH my.company.domain
  dhcp-option DOMAIN-SEARCH some.example.domain

OpenVPN will (on windows) concatenate them all together into a single
"option 119" for the tapv9 DHCP server.  Max length is 254 in total.

DNS label compression is not used - it's complicated, and Windows does
not need it.  See RFC 3397 for more details.

This only works with the tun/tap driver, not with wintun.

On non-windows platforms, these settings are exported in the environment
towards --up scripts (or to the management interface), and need to be
picked up there.

Signed-off-by: Jan Just Keijser <jan.just.keijser@gmail.com>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <c404dd17-e0db-ce61-0d79-864a5736f2d0@nikhef.nl>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg20349.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
5 years agoclient-connect: Split multi_connection_established into separate functions
Fabian Knittel [Sat, 11 Jul 2020 09:36:43 +0000 (11:36 +0200)] 
client-connect: Split multi_connection_established into separate functions

This patch splits up the multi_connection_established() function.  Each new
helper function does a specific job.  Functions that do a similar job
receive a similar calling interface.

The patch tries not to reindent code, so that the real changes are as
clearly visible as possible.  (A follow-up patch will only do indentation
changes.)

Signed-off-by: Fabian Knittel <fabian.knittel@lettink.de>
PATCH v3: Since the code has changed enough from the time the original
patch to the current master, the splitting has been redone from the
current code.  Also some style and minor code changes have been added
doing this patch.  This and the big reformatting done before eliminates
the follow up patch with only indentation changes.

The original patch already replaced some instances of
option_permission_mask with CLIENT_CONNECT_OPT_MASK. The V3 version does
this more consistently.

Patch v4: Move config -> mi->cc_config into its own commit

Patch v5: Clean up some minor issues, add one missing check on
temporary file deletion, rebase on latest master.

Signed-off-by: Arne Schwabe <arne@rfc2549.org>
Acked-by: Antonio Quartulli <antonio@openvpn.net>
Message-Id: <20200711093655.23686-2-arne@rfc2549.org>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg20289.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
5 years agoHandle connecting clients without NCP or OCC without crashing.
Gert Doering [Mon, 13 Jul 2020 09:32:52 +0000 (11:32 +0200)] 
Handle connecting clients without NCP or OCC without crashing.

ssl_ncp.c:ncp_get_best_cipher() would crash if a client connects without
NCP (or with a NCP cipher list that does not contain the first NCP cipher
in the server list) due to a NULL pointer strcmp().

Work around / fix by just assigning an empty string to remote_cipher here
("not NULL but will never match either").

Add new warning message in multi.c for the "we do not know what the
client can do" case (no NCP and non-helpful OCC), rewrapped the existing
message to keep line lenght limit.

Signed-off-by: Gert Doering <gert@greenie.muc.de>
Acked-by: Arne Schwabe <arne@rfc2549.org>
Message-Id: <20200713093252.30916-1-gert@greenie.muc.de>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg20309.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
5 years agoAllow changing fallback cipher from ccd files/client-connect
Arne Schwabe [Sat, 11 Jul 2020 09:36:42 +0000 (11:36 +0200)] 
Allow changing fallback cipher from ccd files/client-connect

This allows to control the fallback cipher that is used when the
client/server do have any common cipher on a per client basis.

The patch is similar to Steffan's

  [PATCH v4] Allow changing cipher from a ccd file.

Steffan's old patch also moves the cipher negotiation to
multi_established_connection() which I independently discovered and
implemented in commit 5e78bf66fa9 (Extract process_incoming_push_reply
from process_incoming_push_msg)

Signed-off-by: Arne Schwabe <arne@rfc2549.org>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20200711093655.23686-1-arne@rfc2549.org>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg20281.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
5 years agoCleanup: Remove special case code for old poor man's NCP.
Arne Schwabe [Thu, 9 Jul 2020 10:16:01 +0000 (12:16 +0200)] 
Cleanup: Remove special case code for old poor man's NCP.

Ever since the NCPv2 the ncp_get_best_cipher uses the global
options->ncp_enabled option and ignore the tls_session->ncp_enabled
option.

The server side's poor man's NCP is implemented as seeing the list
of supported ciphers from the peer as just one cipher so this special
handling for poor man's NCP of the older NCP here is not needed anymore.

Theoretically we can now get rid of tls_session->ncp_enabled but doing
so requires more refactoring since options is not available in the
methods that still use it. And when we remove ncp-disable the variable
will be removed anyway.

This commit moves the data channel key generation for the corner case of a
client not supporting NCP but having the same cipher as the server to
the same function that also generates data channel keys for NCP and
poort man's NCP.

This has an unintended side effect of changing the calculated frame
size for this special case. The old path did call
tls_session_update_crypto_params.
To avoid this change in behaviour, this patch adds a hacky
workaround for this.

A proper solution for this needs still be found but this allows the patch
set to be merged.

Document the remaining usage of tls_poor_mans_ncp better.

Signed-off-by: Arne Schwabe <arne@rfc2549.org>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20200709101603.11941-6-arne@rfc2549.org>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg20251.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
5 years agoGenerate data channel keys after connect options have been parsed
Arne Schwabe [Thu, 9 Jul 2020 10:16:00 +0000 (12:16 +0200)] 
Generate data channel keys after connect options have been parsed

The simplify the control flow, it makes more sense to generate the
data keys when all the prerequisites for generating the data channel
keys (ncp cipher selection etc) are met instead of delaying it to the
next incoming PUSH_REQUEST message.

This also eliminates the need for the hack introduced by commit
3b06b57d9 to generate the data channel keys on the async file close
event.

Signed-off-by: Arne Schwabe <arne@rfc2549.org>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20200709101603.11941-5-arne@rfc2549.org>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg20253.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
5 years agoMove protocol option negotiation from push_prepare to new function
Arne Schwabe [Thu, 9 Jul 2020 10:15:59 +0000 (12:15 +0200)] 
Move protocol option negotiation from push_prepare to new function

This clean ups the code and removes the surprising side effects
of preparing a push reply to also select protocol options.

We also remember if we have seen a push request without async
push. This improves reaction time if deferred auth is involved
like managment interface deferred auth.  The other benefit is
removing a number of ifdefs.

NOTE: this patch breaks asynchronous authentication (via plugins
and possibly also via management interface).  The next commit will
fix this.  This is understood and hereby documented, but the two
individual commits are much cleaner without trying to fix it here
or squash both together.

Signed-off-by: Arne Schwabe <arne@rfc2549.org>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20200709101603.11941-4-arne@rfc2549.org>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg20255.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
5 years agoCode cleanup: remove superflous variable
Arne Schwabe [Thu, 9 Jul 2020 10:16:03 +0000 (12:16 +0200)] 
Code cleanup: remove superflous variable

Signed-off-by: Arne Schwabe <arne@rfc2549.org>
Acked-by: Antonio Quartulli <antonio@openvpn.net>
Message-Id: <20200709101603.11941-8-arne@rfc2549.org>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg20252.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
5 years agoRemoved unused definition
Arne Schwabe [Thu, 9 Jul 2020 10:16:02 +0000 (12:16 +0200)] 
Removed unused definition

Signed-off-by: Arne Schwabe <arne@rfc2549.org>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20200709101603.11941-7-arne@rfc2549.org>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg20256.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
5 years agoExtract process_incoming_push_reply from process_incoming_push_msg
Arne Schwabe [Thu, 9 Jul 2020 10:15:58 +0000 (12:15 +0200)] 
Extract process_incoming_push_reply from process_incoming_push_msg

This is a small refactoring to make both function more readable. It also
eliminates the ret variable in process_incoming_push_msg that now serves
no purpose anymore.

Signed-off-by: Arne Schwabe <arne@rfc2549.org>
Acked-by: Antonio Quartulli <antonio@openvpn.net>
Message-Id: <20200709101603.11941-3-arne@rfc2549.org>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg20254.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
5 years agoMake key_state->authenticated more state machine like
Arne Schwabe [Thu, 9 Jul 2020 10:15:57 +0000 (12:15 +0200)] 
Make key_state->authenticated more state machine like

This order the states from unauthenticated to authenticated and also
changes the comparison for KS_AUTH_FALSE from != to >

It also add comments and documents part using the state machine
better.

Remove a now obsolete comment and two obsolete ifdefs. While
keeping the ifdef in ssl_verify would save a few bytes of code,
this is too minor to justify keeping the ifdef

Signed-off-by: Arne Schwabe <arne@rfc2549.org>
Acked-by: Antonio Quartulli <antonio@openvpn.net>
Message-Id: <20200709101603.11941-2-arne@rfc2549.org>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg20258.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
5 years agoDeprecate ncp-disable and add improved ncp to Changes.rst
Arne Schwabe [Thu, 9 Jul 2020 10:15:56 +0000 (12:15 +0200)] 
Deprecate ncp-disable and add improved ncp to Changes.rst

Signed-off-by: Arne Schwabe <arne@rfc2549.org>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20200709101603.11941-1-arne@rfc2549.org>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg20257.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
5 years agoMake openvpn --version exit with exit code 0
Steffan Karger [Tue, 7 Jul 2020 14:26:21 +0000 (16:26 +0200)] 
Make openvpn --version exit with exit code 0

For some reason, openvpn --version has since the beginning of time
returned exit code 1. A quick sample among common unix utilities confirms
that the rest of the world agrees with me that 0 makes more sense. Let's
make openvpn --version exit with exit code 0 too.

Signed-off-by: Steffan Karger <steffan.karger@foxcrypto.com>
Acked-by: Antonio Quartulli <antonio@openvpn.net>
Message-Id: <E1jsoYQ-0007AZ-BF@sfs-ml-1.v29.lw.sourceforge.com>
URL: https://www.mail-archive.com/search?l=mid&q=E1jsoYQ-0007AZ-BF@sfs-ml-1.v29.lw.sourceforge.com
Signed-off-by: Gert Doering <gert@greenie.muc.de>
5 years agoSimplify multi_connection_established.
Arne Schwabe [Tue, 7 Jul 2020 12:16:13 +0000 (14:16 +0200)] 
Simplify multi_connection_established.

Instead of having the whole function as

        if (x) { func }

do

        if (!x) return;
        func

Due to the whitespace changes in the function body this patch looks
very strange. Ignoring whitespace makes the diff look sane.

Signed-off-by: Arne Schwabe <arne@rfc2549.org>
Acked-by: Antonio Quartulli <antonio@openvpn.net>
Message-Id: <20200707121615.15736-3-arne@rfc2549.org>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg20231.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
5 years agoRemove --writepid file on program exit.
Gert Doering [Tue, 7 Jul 2020 08:42:20 +0000 (10:42 +0200)] 
Remove --writepid file on program exit.

For whatever reason, we never removed the pid file on program exit.

Not only this is unclean, but it also makes testing for "I want this
test case to FAIL" in t_client.sh more annoying to code for "is the
OpenVPN process still around?"...

Do not unlink the file if chroot() is active (might be outside the
chroot arena - testing for realpath etc. is left for someone else).

v2: make this work on M_FATAL exit, by unlinking from openvpn_exit() in
error.h - this requires moving write_pid() to init.c so module hierarchy
is maintained and introducing a static variable to save the PID file
name (otherwise it is no longer available when the top level GC is gone).

Signed-off-by: Gert Doering <gert@greenie.muc.de>
Acked-by: Antonio Quartulli <antonio@openvpn.net>
Message-Id: <20200707084220.45753-1-gert@greenie.muc.de>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg20224.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
5 years agomerge key_state->authenticated and key_state->auth_deferred
Arne Schwabe [Mon, 6 Jul 2020 16:35:16 +0000 (18:35 +0200)] 
merge key_state->authenticated and key_state->auth_deferred

Both are tightly coupled often both are checked at the same time.
Merging them into one state makes the code simpler and also brings
us closer in the direction of a state machine

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