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

2895 Commits

Author SHA1 Message Date
Arne Schwabe
3a16a8678d Remove always enabled USE_64_BIT_COUNTERS define
Also change the types to use C99 uint64_t and its printf u64 define.

Signed-off-by: Arne Schwabe <arne@rfc2549.org>
Acked-by: Antonio Quartulli <antonio@openvpn.net>
Message-Id: <20210421134348.1950392-3-arne@rfc2549.org>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg22171.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
2021-04-22 10:22:06 +02:00
Max Fillinger
940619c880 Abort if CRL file can't be stat-ed in ssl_init
Now that the path for the CRL file is handled correctly when using
chroot, there's no good reason for the file to be inaccessible during
ssl_init().

This commit ensures that the CRL file is accessed successfully at least
once, which fixes a bug where the mbedtls version of OpenVPN wouldn't
use a reloaded CRL if it initially failed to access the file.

Signed-off-by: Max Fillinger <maximilian.fillinger@foxcrypto.com>
Acked-by: Antonio Quartulli <antonio@openvpn.net>
Message-Id: <20210415093454.18324-1-maximilian.fillinger@foxcrypto.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg22118.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
2021-04-20 13:15:04 +02:00
Max Fillinger
21a0b2494e In init_ssl, open the correct CRL path pre-chroot
When using the chroot option, the init_ssl function can be called before
entering the chroot or, when OpenVPN receives a SIGHUP, afterwards. This
commit ensures that OpenVPN tries to open the correct path for the CRL
file in either situation.

This commit does not address key and certificate files. For these, the
--persist-key option should be used.

Signed-off-by: Max Fillinger <maximilian.fillinger@foxcrypto.com>
Acked-by: Antonio Quartulli <antonio@openvpn.net>
Message-Id: <20210415091248.18149-1-maximilian.fillinger@foxcrypto.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg22117.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
2021-04-20 13:07:40 +02:00
Arne Schwabe
a005044be9 Fix condition to generate session keys
When OpenVPN sees a new (SSL) connection via HARD_RESET or SOFT_RESET with
the same port/ip as an existing session, it will give it the slot of the
renegotiation session (TM_UNTRUSTED). And when the authentication
succeeds it will replace the current session. In the case of a SOFT_RESET
this a renegotiation and we will generated data channel keys at the of
key_method_2_write function as key-id > 0.

For a HARD RESET the key-id is 0. Since we already have gone through
connect stages and set context_auth to CAS_SUCCEEDED, we don't
call all the connect stages again, and therefore also never call
multi_client_generate_tls_keys for this session.

This commit changes postponing the key generation to be done only if
the multi_connect has not yet been finished.

Patch V2: Explain better in the commit message why this change is done.

Trac: #1316

Signed-off-by: Arne Schwabe <arne@rfc2549.org>
Acked-by: Antonio Quartulli <antonio@openvpn.net>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20210328120241.27605-2-arne@rfc2549.org>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg21873.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
2021-04-20 11:39:10 +02:00
Arne Schwabe
0767d5b447 Move context_auth from context_2 to tls_multi and name it multi_state
context_2 and tls_multi have the same life cycle for TLS connections
but so this move does not affect behaviour of the variable.

OpenVPN TLS multi code has a grown a lot more complex and code that
handles multi objects needs to know the state that the object is in.
Since not all code has access to the context_2 struct, the code that
does not have access is often not checking the state directly but
checks other parts of multi that have been affected from a state
change.

This patch also renames it to multi_state as this variable represents
the multi state machine status rather than just the state of the connect
authentication (more upcoming patches will move other states
into this variable).

Patch V2: also rename context_auth to multi_state, explain a bit why this
          change is done.
Patch V3: Add comments for c2->multi NULL check forwarding. Fix compile
          with ENABLE_ASYNC_PUSH.

Signed-off-by: Arne Schwabe <arne@rfc2549.org>
Acked-by: Antonio Quartulli <antonio@openvpn.net>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20210418160111.1494779-1-arne@rfc2549.org>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg22155.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
2021-04-20 10:08:41 +02:00
Arne Schwabe
6fc292d2ed Ensure using const variables with EVP_PKEY_get0_*
These functions return const pointers in OpenSSL 3.0.0alpha14, so
our pointers should be also const to avoid casting the const away.

Signed-off-by: Arne Schwabe <arne@rfc2549.org>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20210408133626.29232-1-arne@rfc2549.org>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg22081.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
2021-04-18 22:05:11 +02:00
Arne Schwabe
8d109f68fd Add parsing of dhcp-option PROXY_HTTP
This adds support for setting a HTTP proxy that should be used after
connecting to a VPN.

The syntax has been picked to have compatibility with OpenVPN3.
Otherwise I would have used HTTP-PROXY instead.

Since this option requires an additional argument compared to the
existing dhcp-option keywords, move checking the number of arguments
to the individual keywords.

Signed-off-by: Arne Schwabe <arne@rfc2549.org>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20210416110955.1162574-1-arne@rfc2549.org>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg22129.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
2021-04-18 16:19:58 +02:00
Vladislav Grishenko
c7f95891a4 Fix IPv4 default gateway with multiple route tables
Current default gateway selection for zero destination address just
dumps and parses all the routing tables. If any of non-main table
with default route comes first, wrong default gateway can be picked.
Since adding/removing routes currently handles only main table,
let's stick to RT_TABLE_MAIN while selecting default route too.

v2: keep gateway address unchanged on lookup error
v3: reduce ammout of gateway address copying

Reported-by: Donald Sharp <donaldsharp72@gmail.com>
Signed-off-by: Vladislav Grishenko <themiron@yandex-team.ru>
Acked-by: Antonio Quartulli <antonio@openvpn.net>
Message-Id: <20210416120708.1532-1-themiron@yandex-team.ru>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg22130.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
2021-04-18 16:04:53 +02:00
Arne Schwabe
2c0ebe0f12 Remove LibreSSL specific defines not needed for modern LibreSSL
Most of the functions remove were either already have a version check
against LibreSSL 2.9.0 or are also now deprecated in LibreSSL as well
according to the man pages in OpenBSD 6.8 like SSL_CTX_set_ecdh_auto
and SSL_library_init.

Signed-off-by: Arne Schwabe <arne@rfc2549.org>
Acked-by: Antonio Quartulli <antonio@openvpn.net>
Message-Id: <20210415114541.1001644-1-arne@rfc2549.org>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg22119.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
2021-04-17 14:45:16 +02:00
Gert Doering
8508092109 Repair --secret deprecation warning.
commit 60f5889ae formally deprecated use of configs without either
"tls-client" or "tls-server" - but got the booleans wrong.

Fix.

Signed-off-by: Gert Doering <gert@greenie.muc.de>
Acked-by: Antonio Quartulli <antonio@openvpn.net>
Message-Id: <20210417100544.5497-1-gert@greenie.muc.de>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg22139.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
2021-04-17 14:11:05 +02:00
Arne Schwabe
57c8d220aa Also restore/save route-gateway options on SIGUSR1 reconnects
Trac: #1396

Signed-off-by: Arne Schwabe <arne@rfc2549.org>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20210416133512.1176870-1-arne@rfc2549.org>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg22132.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
2021-04-17 11:43:05 +02:00
Arne Schwabe
2a414c3c79 Also restore/save compress related options in reconnects
Trac: #1396, #128

Signed-off-by: Arne Schwabe <arne@rfc2549.org>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20210408120029.19438-2-arne@rfc2549.org>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg22078.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
2021-04-17 10:42:10 +02:00
Arne Schwabe
c1150e5b95 Always save/restore pull options
The makes the code path for pull and non-pull more aligned and even
though this might do extra work for non-pull scenarios, saving the
few bytes of memory is not a worthwhile optimisation here.

Additionally with the upcoming P2P mode NCP, the client needs to
save/restore a subset of these options anyway.

Signed-off-by: Arne Schwabe <arne@rfc2549.org>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20210408120029.19438-1-arne@rfc2549.org>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg22079.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
2021-04-16 17:19:06 +02:00
Arne Schwabe
bc36d9d569 Remove OpenSSL configure checks
These checks for the functions take a lot of time in configure call and
also having these checks make it more blurry for which of the supported
OpenSSL versions (and libraries claiming to be OpenSSL) are actually
needed.

Tested with OpenSSL 1.1.1(Ubuntu 20, macOS), 1.0.2 (CentOS7),
1.1.0 (Debian stretch), LibreSSL (OpenBSD 6.8) and wolfSSL

Signed-off-by: Arne Schwabe <arne@rfc2549.org>
Acked-by: Antonio Quartulli <antonio@openvpn.net>
Message-Id: <20210406162518.4075-5-arne@rfc2549.org>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg22051.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
2021-04-13 11:19:47 +02:00
Max Fillinger
e4bd17c86e Fix build with mbedtls w/o SSL renegotiation support
In mbedtls, support for SSL renegotiation can be disabled at
compile-time. However, OpenVPN cannot be built with such a library
because it calls mbedtls_ssl_conf_renegotiation() to disable this
feature at runtime. This function doesn't exist when mbedtls was built
without support for SSL renegotiation.

This commit fixes the build by ifdef'ing out the function call when
mbedtls was built without support for SSL renegotiation.

Signed-off-by: Max Fillinger <maximilian.fillinger@foxcrypto.com>
Acked-by: Antonio Quartulli <antonio@openvpn.net>
Message-Id: <E1lW0eX-00012w-9n@sfs-ml-1.v29.lw.sourceforge.com>
URL: https://www.mail-archive.com/search?l=mid&q=E1lW0eX-00012w-9n@sfs-ml-1.v29.lw.sourceforge.com
Signed-off-by: Gert Doering <gert@greenie.muc.de>
2021-04-13 07:56:10 +02:00
Arne Schwabe
3fbeeda5cd Use EVP_CTRL_AEAD_* instead EVP_CTRL_GCM_*
Use the modern names instead of the old GCM specific ones. AEAD instead
GCM makes especially sense when using Chacha20-Poly1305.

Signed-off-by: Arne Schwabe <arne@rfc2549.org>
Acked-by: Antonio Quartulli <antonio@openvpn.net>
Message-Id: <20210406162518.4075-4-arne@rfc2549.org>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg22050.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
2021-04-07 14:49:11 +02:00
Antonio Quartulli
8af7c6b2d7 ssl: remove unneeded if block
There is no need to check the result of a boolean function and then
assign a constant value to a variable based on that check.

Directly assign the return value of the function to the variable.

Signed-off-by: Antonio Quartulli <antonio@openvpn.net>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20210405122827.16836-1-a@unstable.cc>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg22045.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
2021-04-07 14:45:55 +02:00
Arne Schwabe
b8510baa25 Remove a number of checks for functions/headers that are always present
For the unlink function we actually have code that just ignores
the unlink call if the unlink function is not present. But all
platforms should have an unlink function.

This also removes all conditionals check for the headers that
belong to the C99 standard library header list
(https://en.cppreference.com/w/c/header).

Signed-off-by: Arne Schwabe <arne@rfc2549.org>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20210406162518.4075-3-arne@rfc2549.org>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg22053.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
2021-04-07 08:31:08 +02:00
Arne Schwabe
6287538039 Remove checks for uint* types that are part of C99
Signed-off-by: Arne Schwabe <arne@rfc2549.org>
Acked-by: Antonio Quartulli <antonio@openvpn.net>
Message-Id: <20210406162518.4075-2-arne@rfc2549.org>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg22049.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
2021-04-07 08:30:34 +02:00
Arne Schwabe
17f9133206 Remove check for socket functions and Win XP compatbility code
While the check if all socket related functions are present sounds like
a good idea in theory, in reality it just adds time to configure runs.

Our poll check on windows is currently only depending on sys/poll.h
non-existance. Make the check and comment more explicit.

Signed-off-by: Arne Schwabe <arne@rfc2549.org>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20210406162518.4075-1-arne@rfc2549.org>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg22052.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
2021-04-07 08:24:50 +02:00
Arne Schwabe
725dda00f8 Remove conditionals compilation for P2MP, ENABLE_SHAPER and TIME_BACKTRACK_PROTECTION
Using OpenVPN without P2MP support (pull, TLS) is unrealistic and
building a binary without it is not something we realistically want
to support anyway.  Building P2MP support currently only depended
on HAVE_GETTIMEOFDAY or _WIN32, which has a compat function for it.
So we basically can assume that gettimeofday is always availabe,
either natively or through our compat function.

Remove all the #ifdef P2MP logic, simplify code and reduce maintenance
effort.

This also removes the ENABLE_SHAPER and TIME_BACKTRACK_PROTECTION
defines, which also depended only on the HAVE_GETTIMEOFDAY or _WIN32.

I kept the configure.ac check and ifdef in compat since mingw actually
provides a gettimeofday and we will use that instead of our own compat
function.

Patch V2: Remove dco parts that slipped into the patch, mention the
          other removed defines that are always enabled.

Patch V3: Also remove the TIME_BACKTRACK_PROTECTION defines from otime.h

Message-Id: <20210403184626.23067-1-arne@rfc2549.org>
Signed-off-by: Arne Schwabe <arne@rfc2549.org>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20210404110602.20374-1-arne@rfc2549.org>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg22030.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
2021-04-05 12:58:55 +02:00
Antonio Quartulli
f3c7698957 openssl: avoid NULL pointer dereference
EVP_PKEY_CTX_new_id() may return NULL and for this reason we must check
its return value and bail out in case of failure.

Failing to do so, may result in NULL pointer dereferece when we
pass the returned pointer (NULL) to other functions.

Signed-off-by: Antonio Quartulli <antonio@openvpn.net>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20210405080007.1665-2-a@unstable.cc>
URL: https://www.mail-archive.com/search?l=mid&q=20210405080007.1665-2-a@unstable.cc
Signed-off-by: Gert Doering <gert@greenie.muc.de>
2021-04-05 12:34:09 +02:00
Antonio Quartulli
24e58164b8 openssl: fix EVP_PKEY_CTX memory leak
A context allocated with EVP_PKEY_CTX_new_id() must be ultimately free'd
by Eng VP_PKEY_CTX_free(). Failing to do so will result in a memory leak.

This bug was discovered using GCC with "-fsanitize=address".

Signed-off-by: Antonio Quartulli <antonio@openvpn.net>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20210405080007.1665-1-a@unstable.cc>
URL: https://www.mail-archive.com/search?l=mid&q=20210405080007.1665-1-a@unstable.cc
Signed-off-by: Gert Doering <gert@greenie.muc.de>
2021-04-05 12:32:35 +02:00
Selva Nair
165cda3169 tun.c on WIN32: remove more unused variables
Fixes:
  tun.c: In function ‘do_ifconfig_ipv4’:
  tun.c:1217:17: warning: variable ‘ifconfig_remote_netmask’ set but not
  used [-Wunused-but-set-variable]
     const char *ifconfig_remote_netmask = NULL;

  tun.c:1213:10: warning: unused variable ‘tun’ [-Wunused-variable]
     bool tun = is_tun_p2p(tt);

Signed-off-by: Selva Nair <selva.nair@gmail.com>
Acked-by: Antonio Quartulli <antonio@openvpn.net>
Message-Id: <20210403172403.9452-1-selva.nair@gmail.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg22019.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
2021-04-04 11:04:00 +02:00
Gert Doering
e2acfad40c Fix potential NULL ptr crash if compiled with DMALLOC
In the unlikely case that we are compiled with -DDMALLOC *and*
malloc() returns NULL, there is an uncaught memset() which would
crash then.  Remove the memset(), as the right the next operation
after check_malloc_return() is a mempcy() which will overwrite
the whole memory block anyway.

Trac: #586

Signed-off-by: Gert Doering <gert@greenie.muc.de>
Acked-by: Antonio Quartulli <antonio@openvpn.net>
Message-Id: <20210402173414.14216-1-gert@greenie.muc.de>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg21981.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
2021-04-04 10:56:13 +02:00
Antonio Quartulli
411fc52eb1 tun.c: remove unused variable
Signed-off-by: Antonio Quartulli <antonio@openvpn.net>
Acked-by: Selva Nair <selva.nair@gmail.com>
Message-Id: <20210403155937.32330-1-a@unstable.cc>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg22014.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
2021-04-03 18:33:38 +02:00
Arne Schwabe
5ac8c3c7a2 Fix async push broken after auth deferred refactor
Commit c5fec838e moved the auth control file related
states into its own struct. Unfortunately I forgot
to also do the part inside #if defined(ENABLE_ASYNC_PUSH)

Signed-off-by: Arne Schwabe <arne@rfc2549.org>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20210403122444.17090-1-arne@rfc2549.org>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg22007.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
2021-04-03 15:48:27 +02:00
Arne Schwabe
8ccce69dc1 log file descriptor in more socket related error messages
This add the fd to the epoll event error message and the x_check_status
message. This helps debugging when thing go wrong with event handling.

Also add logging when ep_del fails to remove a socket from the structure.
In constract to ep_ctl that has this as a FATAL message (M_ERR), we only
log here since the code has been ignoring the status forever there might
be corner cases where a FATAL message could trigger an unintened
regression.

PATCH v2: Fix wrong order of fd,code in printed message.

Signed-off-by: Arne Schwabe <arne@rfc2549.org>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20210403123000.17688-1-arne@rfc2549.org>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg22008.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
2021-04-03 15:40:43 +02:00
Arne Schwabe
c5fec838e7 Move auth deferred related members into its own struct
This structures the code a bit nicer and also prepares for deferred
scripts that needs their own set of files.

Signed-off-by: Arne Schwabe <arne@rfc2549.org>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20210317130312.8585-1-arne@rfc2549.org>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg21671.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
2021-04-03 12:03:58 +02:00
Arne Schwabe
6ea62d5072 Remove deprecated option '--keysize'
This option has been deprecated in OpenVPN 2.4 and the ciphers that allow
using this option fall all into the SWEET32 category of ciphers with
64 bit block size.

Patch V2: Remove superflous check in OpenSSL codepath to check keysize

Signed-off-by: Arne Schwabe <arne@rfc2549.org>
Acked-by: Antonio Quartulli <antonio@openvpn.net>
Message-Id: <20210401123751.31756-1-arne@rfc2549.org>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg21943.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
2021-04-03 11:35:04 +02:00
Arne Schwabe
60f5889ae6 Deprecate non TLS mode in OpenVPN
The non-TLS mode is a relict from OpenVPN 1.x or 2.0. When TLS mode was
introduced the advantages of TLS over non-TLS were small but TLS mode
evolved to include a lot more features (NCP, multipeer, AEAD ciphers to
name a few).

Today VPN setups that use --secret are mainly used because this mode is
easier to setup and does not require setting up a PKI.  This shortcoming
of TLS mode should be addressed now with the peer-fingerprint option.

The primary reason to deprecate --secret is that it is not secure enough
anymore for modern environments.  This mode uses a fixed pre-shared key and
no session keys.  Thus, no forward secrecy is possible, which means that
any captured VPN traffic can be decrypted later should the --secret key
get into the wrong hands.  The cryptography overall used here was okay
when --secret was introduced but is not acceptable by today's standard
anymore.

Finally, modern hardware-accelerated crypto modes like AES-GCM can only
be used in TLS mode (due to IV requirements).

Patch V2: Improve commit message

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

Signed-off-by: Gert Doering <gert@greenie.muc.de>
2021-04-03 11:18:01 +02:00
Arne Schwabe
79ff3f79eb Allow running a default configuration with TLS libraries without BF-CBC
Modern TLS libraries might drop Blowfish by default or distributions
might disable Blowfish in OpenSSL/mbed TLS. We still signal OCC
options with BF-CBC compatible strings. To avoid requiring BF-CBC
for this, special this one usage of BF-CBC enough to avoid a hard
requirement on Blowfish in the default configuration.

Signed-off-by: Arne Schwabe <arne@rfc2549.org>

Patch v2: add more clarifying comment, do not warn about OCC only insecure
          ciphers, code improvements

Patch V3: Put ciphername resolution via ciper_kt_name in the right branch

Patch V4: Fix cornercase of BF-CBC in data-ciphers not itialising cipher.

Patch v5: I accidently resend v3 as v4. So v5 is just a resend of the real
v4
Acked-by: Antonio Quartulli <antonio@openvpn.net>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20210219165252.4562-1-arne@rfc2549.org>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg21577.html

Signed-off-by: Gert Doering <gert@greenie.muc.de>
2021-04-03 09:44:17 +02:00
Arne Schwabe
9e702a5d0f Always disable TLS renegotiations
Renegotiations have been troublesome in the past and also the recent
OpenSSL security problem (CVE-2021-3449) is only exploitable if
TLS renegotiation is enabled.

mbed TLS disables it by default and says in the documentation:

Warning: It is recommended to always disable renegotation unless you
know you need it and you know what you're doing. In the past, there
have been several issues associated with renegotiation or a poor
understanding of its properties.

TLS renegotiation can be used to restart a session with different
parameters (e.g. now with client certs). This something that OpenVPN does
not use.

For OpenSSL 1.0.2 the workaround to disable renegotiation is rather
cumbersome. So we keep this to 1.1.1 only since 1.0.2 is on its way to
deprecation anyway.

Furthermore because of all these problems, also TLS 1.3 completely
drops support for renegotiations.

Patch V2: Improve comments and commit message
Patch V3: Only disable renegotiation where the SSL_OP_NO_RENEGOTIATION
          define is available. LibreSSL, wolfSSL and OpenSSL 1.0.2 are
          lacking this macro.
Signed-off-by: Arne Schwabe <arne@rfc2549.org>
Acked-by: Antonio Quartulli <antonio@openvpn.net>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20210401110003.19689-1-arne@rfc2549.org>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg21939.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
2021-04-02 20:07:52 +02:00
Steffan Karger
203afbe95e reliable: retransmit if 3 follow-up ACKs are received
To improve the control channel performance under packet loss conditions,
add a more aggressive retransmit policy similar to what many TCP
implementations do: retransmit a packet if the ACK timeout expires (like
we already do), *or* if three ACKs for follow-up packets are received.

The rationale behind this is that if follow-up packets *are* received, the
connection is apparently functional and we should be able to retransmit
immediately. This significantly improves performance for connections with
low (up to a few percent) packet loss.
Acked-by: Arne Schwabe <arne@rfc2549.org>
Message-Id: <E1lRfW3-0001sy-VM@sfs-ml-4.v29.lw.sourceforge.com>
URL: https://www.mail-archive.com/search?l=mid&q=E1lRfW3-0001sy-VM@sfs-ml-4.v29.lw.sourceforge.com

Signed-off-by: Gert Doering <gert@greenie.muc.de>
2021-04-02 19:57:35 +02:00
Arne Schwabe
343b61195b Remove do_init_socket_2 and do_init_socket_1 wrapper function
These two function basically just pass a number of fields of context to
the linit_socket_init1/2 functions. This wrapper add little to no value
in understanding the code, especially since the linit_socket_init1 will
just copy them to yet another structure.

Remove these wrapper functions and pass context directly to the called
function.

Signed-off-by: Arne Schwabe <arne@rfc2549.org>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20210401131337.3684-15-arne@rfc2549.org>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg21954.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
2021-04-02 17:38:49 +02:00
Arne Schwabe
9fe0b2c287 Extract multi_assign_peer_id into its own function
This makes multi_get_create_instance_udp a bit shorter and better
structured and also prepares this method to be called from the
mutlti TCP context with DCO which will also need to assign unique peer
ids to instances.

Signed-off-by: Arne Schwabe <arne@rfc2549.org>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20210401131337.3684-13-arne@rfc2549.org>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg21959.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
2021-04-02 16:59:37 +02:00
Arne Schwabe
18b4a8380b Remove thread_mode field of multi_context
This is leftover of a never functional multi threaded openvpn
implementation attempt. It serves no purposes anymore.

Signed-off-by: Arne Schwabe <arne@rfc2549.org>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20210401131337.3684-11-arne@rfc2549.org>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg21952.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
2021-04-02 16:52:07 +02:00
Gert Doering
aba8776e67 Fix 'compress migrate' for 2.2 clients.
Commit 8fa8a17528 introduces "compress migrate" to move old clients
that have "compress" or "comp-lzo" in their config towards a connection
without compression.  This is done by looking at incoming OCC strings
to see if the client has compression enabled, and at incoming IV_
strings to see whether it can do "compress stub-v2" or needs to be sent
"comp-lzo no".

That check fails for 2.2 clients that do not send *any* peer-info by
default, so the server will not push back any "disable compression"
command.  It works if the client connects with "--push-peer-info".

Fix: turn around the order of checks, treat "no peer_info" the same
as "peer_info does not contain IV_COMP_STUBv2".

Signed-off-by: Gert Doering <gert@greenie.muc.de>
Acked-by: Arne Schwabe <arne@rfc2549.org>
Message-Id: <20210402134529.27866-1-gert@greenie.muc.de>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg21974.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
2021-04-02 16:47:09 +02:00
Arne Schwabe
8fa8a17528 Implement '--compress migrate' to migrate to non-compression setup
This option allow migration to a non compression server config while
still retraining compatibility with client that have a compression
setting in their config.

For existing setups that used to have comp-lzo no or another
compression setting in their configs it is a difficult to migrate to
a setup without compression without replacing all client configs at
once especially if OpenVPN 2.3 or earlier clients are in the mix that
do not support pushing stub-v2. Even with OpenVPN 2.4 and later clients
that support pushing this is not a satisfying solution as the clients
log occ mismatches and the "push stub-v2" needs to be in the server
config "forever".

If the new migrate option to compress is set and  a client is detected
that indicates that compression is used (via OCC), the server will
automatically add ``--push compress stub-v2`` to the client specific
configuration if stub-v2 is supported by the client and otherwise
switch to ``comp-lzo no`` and add ``--push comp-lzo`` to the client
specific configuration.

Patch v2: better commit message/man page, add USE_COMP ifdefs, various
          style fixes

Signed-off-by: Arne Schwabe <arne@rfc2549.org>
Acked-by: Antonio Quartulli <antonio@openvpn.net>
Message-Id: <20210324220853.31246-1-arne@rfc2549.org>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg21801.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
2021-04-02 14:49:39 +02:00
Arne Schwabe
72e1ecb5b5 Move is_proto function to the socket.h header
These functions are small enough to be inlined and also avoids
dependency on socket.c from unit_tests using those functions.

Signed-off-by: Arne Schwabe <arne@rfc2549.org>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20210401131337.3684-10-arne@rfc2549.org>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg21950.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
2021-04-01 15:57:40 +02:00
Arne Schwabe
9eb285f42f Remove unused variable pass_config_info
Signed-off-by: Arne Schwabe <arne@rfc2549.org>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20210401131337.3684-6-arne@rfc2549.org>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg21948.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
2021-04-01 15:56:07 +02:00
Arne Schwabe
c0b36e9f29 Remove unused function tls_test_auth_deferred_interval
This function appears to completely unused and has not been touched
since 2008.

Signed-off-by: Arne Schwabe <arne@rfc2549.org>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20210401131337.3684-9-arne@rfc2549.org>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg21949.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
2021-04-01 15:53:59 +02:00
Arne Schwabe
3667df1d66 Remove unused field txqueuelen from struct tuntap
The code uses tuntap->options.txqueuelen instead.

Signed-off-by: Arne Schwabe <arne@rfc2549.org>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20210401131337.3684-8-arne@rfc2549.org>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg21947.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
2021-04-01 15:45:39 +02:00
Arne Schwabe
14061e3e06 Remove pointless tun_adjust_frame_parameters function
This functions seem to serve no purpose other than to add confusion.

Signed-off-by: Arne Schwabe <arne@rfc2549.org>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20210401131337.3684-7-arne@rfc2549.org>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg21957.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
2021-04-01 15:44:21 +02:00
Arne Schwabe
137eb6705e Remove code for aligning non-swapped compression
This is an optimisation for memory alignment for lzo. Compression is
deprecated so this optimisation is not very important anymore.

Furthermore it is conditionally compiled on !defined(ENABLE_LZ4), which
makes the code not compiled in by default anyway.

Signed-off-by: Arne Schwabe <arne@rfc2549.org>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20210401131337.3684-2-arne@rfc2549.org>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg21946.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
2021-04-01 15:37:30 +02:00
Arne Schwabe
bdc11ae462 Rename tunnel_server_udp_single_threaded to tunnel_server_udp
This also eliminates the confusing name and eliminates
tunnel_server_udp as wrapper that only calls
tunnel_server_udp_single_threaded

Signed-off-by: Arne Schwabe <arne@rfc2549.org>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20210401131337.3684-4-arne@rfc2549.org>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg21955.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
2021-04-01 15:32:37 +02:00
Arne Schwabe
213fd3ee49 Remove superflous ifdefs around enum like defines
The variables are not used without the configured options but the
ifdef around them does not help readibility either.

Signed-off-by: Arne Schwabe <arne@rfc2549.org>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20210401131337.3684-3-arne@rfc2549.org>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg21958.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
2021-04-01 15:27:58 +02:00
Gert Doering
997b006a26 Get rid of last PLUGIN_DEF_AUTH #ifdef
Commit 99d217b200 attempted to get rid of all #ifdef related to
--disable-def-auth but one of them managed to hide.  Remove.

The effect of this is that the "openvpn_acf_...tmp" files get not
removed after when an async auth plugin is in use.  This is can
get very annoying on a busy server.

Trac: #1186

Signed-off-by: Gert Doering <gert@greenie.muc.de>
Acked-by: Antonio Quartulli <antonio@openvpn.net>
Message-Id: <20210401082934.29922-1-gert@greenie.muc.de>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg21933.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
2021-04-01 11:57:40 +02:00
Tõivo Leedjärv
76ccc62d48 Stop using deprecated getpass()
The getpass() function is present in SUSv2, but marked LEGACY. It is
removed in POSIX.1-2001. Additionally, on Solaris getpass() returns
maximum 9 bytes. This will make longer passwords fail with no
possibility for user to know what is happening.

This patch removes usage of getpass() completely and replaces it with
direct implementation of what getpass() does: opens tty (existing code),
outputs the prompt (existing code), turns off echoing (new code), reads
one line (existing code shared with echoed mode), restores tty state
(new code) and closes tty (existing code).

Patch v2: incorporate review feedback, incl. style fixes, merge
          termios.h check in configure.ac with an existing
          AC_CHECK_HEADERS, add error check and logging after
          tcsettattr() when restoring tty settings

Signed-off-by: Tõivo Leedjärv <toivol@gmail.com>
Acked-by: Antonio Quartulli <antonio@openvpn.net>
Message-Id: <20210328171151.12056-1-toivol@gmail.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg21889.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
2021-04-01 08:10:00 +02:00
Selva Nair
2d5c437f7c Remove automatic service
This has been replaced by openvpnserv2 since 2.4.0 and we have
stopped setting up this service in the installer since 2.5.0.

Get rid of the unused code. The mechanics of supporting multiple
services with the same executable is retained for possible future use.

For backwards compatibility, the command line option -instance
is unchanged as "-instance <name> id" although <name>="interactive"
is the only supported value now.

Signed-off-by: Selva Nair <selva.nair@gmail.com>
Acked-by: Lev Stipakov <lstipakov@gmail.com>
Message-Id: <1616991798-7179-1-git-send-email-selva.nair@gmail.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg21890.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
2021-03-31 17:16:11 +02:00