]> git.ipfire.org Git - thirdparty/openvpn.git/log
thirdparty/openvpn.git
4 years agoDocument common uses of 'echo' directive, re-enable logging for 'echo'. 147/head
Gert Doering [Mon, 18 Jan 2021 16:28:50 +0000 (17:28 +0100)] 
Document common uses of 'echo' directive, re-enable logging for 'echo'.

The 'echo' command can be used to signal information to an OpenVPN
GUI driving the openvpn core via management interface.  Which commands
exists and their syntax has so far been mostly undocumented.

Condense the long and good discussion between Selva Nair and
Jonathan K. Bullard into doc/gui-notes.txt (initial draft from
Jonathan, comments from Selva and Arne), with a pointer added
to doc/management-notes.txt.

See:

https://sourceforge.net/p/openvpn/mailman/openvpn-users/thread/CAEsd45T%2Bd
6FUJ9Po0KHwtHjfuL9Q2D-poG8yFtY45Qyh%2BtHjkg%40mail.gmail.com/#msg36136236

and

https://sourceforge.net/p/openvpn/mailman/openvpn-devel/thread/CAKuzo_jPThh
vXTJAtzhqVUVOLPW1VGu6h2jQhVsHicY8P2WRqA%40mail.gmail.com/#msg36141193

for the details.

Re-enable logging of 'echo' statements, but only for the particular
class of messages starting with 'echo msg...'.

v2:
  incorporate feedback from Selva Nair, correct >ECHO examples

v3:
  add "msg*" support status for Windows GUI (11.22.0) and Android (Planned)

Signed-off-by: Gert Doering <gert@greenie.muc.de>
Acked-by: Selva Nair <selva.nair@gmail.com>
Message-Id: <20210118162850.24214-1-gert@greenie.muc.de>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg21443.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
(cherry picked from commit ef2405a6bf5e8159d2e51e45107bc280fd6d0bd3)

4 years agoFix tls-auth mismatch OCC message when tls-cryptv2 is used.
Arne Schwabe [Fri, 11 Dec 2020 12:59:57 +0000 (13:59 +0100)] 
Fix tls-auth mismatch OCC message when tls-cryptv2 is used.

A server with tls-cryptv2 and tls-auth produces the warning:

  WARNING: 'tls-auth' is present in local config but missing in remote
config, local='tls-auth'"

The tls-auth option has no argument so the strpefix with the space
included does not match it.

Signed-off-by: Arne Schwabe <arne@rfc2549.org>
Acked-by: Steffan Karger <steffan@karger.me>
Message-Id: <20201211125957.7764-1-arne@rfc2549.org>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg21358.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
(cherry picked from commit 15daa9886b64a8378a6c5d68f79076dc44095696)

4 years agoMan page sections corrections
Richard Bonhomme [Tue, 19 Jan 2021 21:56:17 +0000 (21:56 +0000)] 
Man page sections corrections

Signed-off-by: Richard Bonhomme <tincanteksup@gmail.com>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20210119215617.116886-1-tincanteksup@gmail.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg21451.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
(cherry picked from commit 3b1ded3902b051b3c25f6e77da834ecd1b9f7eca)

4 years agoSkip DHCP renew with Wintun adapter
Domagoj Pensa [Tue, 15 Dec 2020 17:30:04 +0000 (18:30 +0100)] 
Skip DHCP renew with Wintun adapter

Wintun does not support DHCP.
Running  DHCP renew with Wintun adapter fails with a logged warning.

Fixed so that DHCP renewing is called only for TAP-Windows6 adapters.
Acked-by: Lev Stipakov <lstipakov@gmail.com>
Message-Id: <20201215173004.26170-1-domagoj@pensa.hr>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg21364.html

Signed-off-by: Gert Doering <gert@greenie.muc.de>
(cherry picked from commit e0e7625c6b15f85b81d4f11d02f3daf4f32f1200)

4 years agoRemove 1 second delay before running netsh
Domagoj Pensa [Thu, 24 Dec 2020 11:59:10 +0000 (12:59 +0100)] 
Remove 1 second delay before running netsh

When running various netsh commands before each 1 second sleep is added.
As more netsh commands are run, especially for Wintun adapters, that can
add to a noticable delayed connecting time.

This should be safe. No problems were found in tests and all netsh
commands executed properly with delay removed. Also, no delays are used
in a similar code in interactive service and netsh command executions
are guarded with a semaphore.

Instead of removing management_sleep(1), management_sleep(0) is used as
a replacement to allow processing any pending actions on the management
interface without any wait.

Signed-off-by: Domagoj Pensa <domagoj@pensa.hr>
Acked-by: Lev Stipakov <lstipakov@gmail.com>
Message-Id: <20201224115910.10129-1-domagoj@pensa.hr>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg21405.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
(cherry picked from commit b1a8213ee3fe35a4617608ec7653e4dffea79207)

4 years agoClarify --block-ipv6 intent and direction.
Gert Doering [Fri, 25 Dec 2020 16:42:14 +0000 (17:42 +0100)] 
Clarify --block-ipv6 intent and direction.

--block-ipv6 is a fairly special-purpose option, and only blocks packet
in the client->server direction.  This is implied by not ever mentioning
the other direction in the existing documentation, but not written down.

Make this explicit, avoid confusion.

Also, point why this option exist (avoid IPv6 leakage from dual-stacked
clients around IPv4-only VPN offerings).

Trac: #1351

Signed-off-by: Gert Doering <gert@greenie.muc.de>
Acked-by: Richard Bonhomme <tincanteksup@gmail.com>
Message-Id: <20201225164214.22771-1-gert@greenie.muc.de>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg21407.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
(cherry picked from commit 8a8ee283aa7a4b409a9dafc082a6c65b5539308b)

4 years agoZero initialise msghdr prior to calling sendmesg
Arne Schwabe [Tue, 5 Jan 2021 13:17:58 +0000 (14:17 +0100)] 
Zero initialise msghdr prior to calling sendmesg

This ensure that all unused fields in msg are zero.

Spotted by Coverity:

Using uninitialized value "msg". Field "msg.msg_flags" is uninitialized
when calling "sendmsg".

Signed-off-by: Arne Schwabe <arne@rfc2549.org>
Acked-by: Antonio Quartulli <antonio@openvpn.net>
Message-Id: <20210105131758.20311-1-arne@rfc2549.org>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg21418.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
(cherry picked from commit aa58035a955a2ae7ffa2b93ca2c8d2c6e5472695)

4 years agoFix too early argv freeing when registering DNS
Domagoj Pensa [Tue, 15 Dec 2020 17:16:00 +0000 (18:16 +0100)] 
Fix too early argv freeing when registering DNS

When registering DNS on Windows, argv is freed after being used in first
ipconfig command (/flushdns).

Then same argv is used uninitialized in next ipconfig command
(/registerdns)
causing heap exception and subprocess crash.

As a consequence second command is never executed and locked netcmd
semaphore is not cleanly released.

Removing argv freeing between ipconfig calls solves the problem.

This issue was introduced in commit 870e240 (argv: do fewer memory
re-allocations). After a quick glance at commit no similar problem was
spotted in rest of the argv related changes.

Signed-off-by: Domagoj Pensa <domagoj@pensa.hr>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20201215171600.25534-1-domagoj@pensa.hr>
URL: https://www.mail-archive.com/search?l=mid&q=20201215171600.25534-1-domagoj@pensa.hr
Signed-off-by: Gert Doering <gert@greenie.muc.de>
(cherry picked from commit ab4688e3bd78d010ccc96adec66ab552bd009328)

4 years agoFix line number reporting on config file errors after <inline> segments
Gert Doering [Sun, 6 Dec 2020 12:57:11 +0000 (13:57 +0100)] 
Fix line number reporting on config file errors after <inline> segments

<inline> segments neglected to increment the "current line number
in config file" variable (line_num), so after the first <inline>,
errors reported have the wrong line number.

Fix by introducing an extra argument to read_inline_file() function:
"so many lines in the inline block", and changing the return values of
the "check_inline*()" functions to "int", changing this from "false/true"
to "0 = no inline, 1...N = inline with <N> lines".

On calling add_options() this is implicitly converted back to bool.

v2: use int return value, not extra call-by-reference parameter

Trac: #1325
Acked-by: Antonio Quartulli <antonio@openvpn.net>
Message-Id: <20201206125711.12071-1-gert@greenie.muc.de>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg21334.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
(cherry picked from commit a686f7e29af012783371f401f394ac1e62e5b75f)

4 years agoFix port-share option with TLS-Crypt v2
Arne Schwabe [Mon, 30 Nov 2020 12:38:13 +0000 (13:38 +0100)] 
Fix port-share option with TLS-Crypt v2

The port-share option assumed that all openvpn initial reset packets
are between 14 and 255 bytes long. This is not true for tls-crypt-v2.

Patch V2: use correct length for TLS-Crypt v2, use length variable
          non-tlscryptv2 test

Signed-off-by: Arne Schwabe <arne@rfc2549.org>
Acked-by: Steffan Karger <steffan.karger@foxcrypto.com>
Message-Id: <20201130123813.21388-1-arne@rfc2549.org>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg21290.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
(cherry picked from commit 1387f52682dcd3789c56c9979ccedca281ff88f4)

4 years agotls-crypt-v2: also preload tls-crypt-v2 keys (if --persist-key)
Steffan Karger [Thu, 3 Dec 2020 15:49:51 +0000 (16:49 +0100)] 
tls-crypt-v2: also preload tls-crypt-v2 keys (if --persist-key)

This allows tls-crypt-v2 servers to drop privileges after reading the
keys. Without it, the server would try to read the key file for each
connecting client. (And clients for each reconnect.)

As with the previous patch, the pre-loading was developed in parallel
with tls-crypt-v2, and the tls-crypt-v2 patches were never amended to
implement the pre-loading.

Also as with the previous patch, it would be nicer if servers would not
reload the tls-crypt-v2 server key for each connecting client. But let's
first fix the issue, and see if we can improve later.

Signed-off-by: Steffan Karger <steffan@karger.me>
Acked-by: Arne Schwabe <arne@rfc2549.org>
Message-Id: <20201203154951.29382-2-steffan@karger.me>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg21307.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
(cherry picked from commit 4d307ed431bf18d554f524ebaf111f5e136147fe)

4 years agotls-crypt-v2: fix server memory leak
Steffan Karger [Thu, 3 Dec 2020 18:22:30 +0000 (19:22 +0100)] 
tls-crypt-v2: fix server memory leak

tls-crypt-v2 was developed in parallel with the changes that allowed to
use tls-auth/tls-crypt in connection blocks. The tls-crypt-v2 patch set
was never updated to the new reality after commit 5817b49b, causing a
memory leak of about 600 bytes for each connecting client.

It would be nicer to not reload the tls-crypt-v2 server key for each
connecting client, but that requires more refactoring (and thus more time
to get right). So for now just plug the leak by free'ing the memory when
we close a client connection.

To test this easily, compile openvpn with -fsanity=address, run a server
with tls-crypt-v2, connect a client, stop the server.

Signed-off-by: Steffan Karger <steffan@karger.me>
Acked-by: Antonio Quartulli <antonio@openvpn.net>
Message-Id: <20201203182230.33552-1-steffan@karger.me>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg21310.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
(cherry picked from commit fb169c3b8fdfa9792c0eee8441956f062dfd7982)

4 years agoRemove auth_user_pass.wait_for_push variable
Arne Schwabe [Wed, 2 Dec 2020 11:59:28 +0000 (12:59 +0100)] 
Remove auth_user_pass.wait_for_push variable

This variable was first introduce in earlier attempt to fix the
auth-token problems with auth-nocache before user_password and
auth_token were split into two variables. The idea of the variable it
is being set if --pull is in use. However the variable was not always
set correctly, especially if username/password are queried after an
expired auth-token. Instead using that variable use session->opt->pull
directly.

Patch V2: rename delayed_auth_pass_purge to ssl_clean_user_pass to give
          a more fitting name since this function is not only used in
          the delayed code path and also the new name aligns with
          ssl_clean_auth_token. Also fix a leftover wait_for_push
          in that function

Signed-off-by: Arne Schwabe <arne@rfc2549.org>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20201202115928.16615-1-arne@rfc2549.org>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg21297.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
(cherry picked from commit dfd624b52bce7ddd0eeaab516df9848e432f3242)

4 years agoFix auth-token not being updated if auth-nocache is set
Arne Schwabe [Mon, 30 Nov 2020 12:39:28 +0000 (13:39 +0100)] 
Fix auth-token not being updated if auth-nocache is set

This fixes the auth-token not being updated if auth-nocache is set. Our
set_auth_token method ensures that the auth-token always has a username
but is a little bit too strict in the check.

Also add doxygen documentation and remove null checks. We use this function
only with non-null pointers and it makes it a bit nicer to read.

Signed-off-by: Arne Schwabe <arne@rfc2549.org>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20201130123928.21837-1-arne@rfc2549.org>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg21291.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
(cherry picked from commit fb789947ab1eba3e68fb8e4b3551d095a53962bd)

4 years agobuild: Fix missing install of man page in certain environments
David Sommerseth [Thu, 29 Oct 2020 21:32:59 +0000 (22:32 +0100)] 
build: Fix missing install of man page in certain environments

It turns out the logic for dist_man_MANS was incorrectly put inside the
HAVE_PYDOCUTILS block.  This results in the man page being installed
only if python-docutils is installed and available.

The solution is simple, move the dist_man_MANS part outside the
python-docutils block.  The openvpn.8 file is prebuilt in source
tarballs and will thus be available.

Reported-By: Philip Brown <philip@pbdigital.org>
Tested-By: Philip Brown <philip@pbdigital.org>
Signed-off-by: David Sommerseth <davids@openvpn.net>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20201029213259.1636-1-davids@openvpn.net>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg21236.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
(cherry picked from commit fc25ca3a7cf720fbb53889fdba6ac0154c7c9c1a)

4 years agoChange travis build scripts to use https when fetching prerequisites.
Gert Doering [Tue, 24 Nov 2020 16:13:13 +0000 (17:13 +0100)] 
Change travis build scripts to use https when fetching prerequisites.

Reported by "jub0bs" on hackerone.com (#1039504)

Signed-off-by: Gert Doering <gert@greenie.muc.de>
Acked-by: Arne Schwabe <arne@rfc2549.org>
Message-Id: <20201124161313.18831-1-gert@greenie.muc.de>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg21264.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
(cherry picked from commit 0d4069e41d3ba7178be30f78f1174f689dbdfa59)

4 years agoPreparing release 2.5.0 v2.5.0
Gert Doering [Tue, 27 Oct 2020 20:10:50 +0000 (21:10 +0100)] 
Preparing release 2.5.0

version.m4, ChangeLog

no other changes relative to 2.5_rc3

Signed-off-by: Gert Doering <gert@greenie.muc.de>
4 years agoPreparing release 2.5_rc3 v2.5_rc3
Gert Doering [Thu, 15 Oct 2020 13:39:08 +0000 (15:39 +0200)] 
Preparing release 2.5_rc3

Version.m4, ChangeLog

Signed-off-by: Gert Doering <gert@greenie.muc.de>
4 years agoAvoid passing NULL to argv_printf_cat() in temp_file error case.
Gert Doering [Tue, 13 Oct 2020 20:47:58 +0000 (22:47 +0200)] 
Avoid passing NULL to argv_printf_cat() in temp_file error case.

To pass username + password to verify_user_pass_script(), OpenVPN
can either put both into environment, or create a temp file, and
pass that file name to the "user-pass-verify" script.  The file
name is initialized as "", so if no file is desired, it's well
defined - but if the file can not be created, the pointer is NULL
afterwards.

Change the sequence of events, setting up the argv before the
"if (file)" conditional, and add the file name only inside that
clause, if creating the temp file succeeded.

commit a4eeef17b2 did not create the problem, but modified the
code enough so that the static analyzer in gcc 9.2.0 *now* noticed
and issued a warning.

 ssl_verify.c:1132:5: warning: '%s' directive argument is null
              1132 |     argv_printf_cat(&argv, "%s", tmp_file);

Signed-off-by: Gert Doering <gert@greenie.muc.de>
Acked-by: David Sommerseth <davids@openvpn.net>
Message-Id: <20201013204758.2472-1-gert@greenie.muc.de>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg21204.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
(cherry picked from commit bbcada8abb410d077f7bc13b8157198b4bf6a3d1)

4 years agoAdd function for common env setting of verify user/pass calls
Arne Schwabe [Mon, 5 Oct 2020 11:16:14 +0000 (13:16 +0200)] 
Add function for common env setting of verify user/pass calls

This removes the code duplication in verify_user_pass_script,
verify_user_pass_plugin and verify_user_pass_management.

This also fixes a bug that username is not set if auth-gen-token is
used without the external-auth flag as without calling any external auth
method, the environment would not be setup for connect-client calls.

This patch also removes an indentation level in most of touched functions
so diffing without whitespaces is recommended for review.

Signed-off-by: Arne Schwabe <arne@rfc2549.org>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20201005111614.29325-1-arne@rfc2549.org>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg21174.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
(cherry picked from commit a4eeef17b20541a7afde0f1cbeae4a4e2b0c455a)

4 years agonetworking_iproute2: fix memory leak in net_iface_mtu_set()
Steffan Karger [Fri, 9 Oct 2020 13:46:03 +0000 (15:46 +0200)] 
networking_iproute2: fix memory leak in net_iface_mtu_set()

ASAN yelled at me that someone forgot to call argv_free(). Fix that.

Signed-off-by: Steffan Karger <steffan@karger.me>
Acked-by: Antonio Quartulli <a@unstable.cc>
Message-Id: <20201009134603.36263-1-steffan@karger.me>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg21189.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
(cherry picked from commit 1e6e083e8888042d58f9541bf74d343d52fc5681)

4 years agoAllow 'none' cipher being specified in --data-ciphers
Arne Schwabe [Thu, 8 Oct 2020 11:59:59 +0000 (13:59 +0200)] 
Allow 'none' cipher being specified in --data-ciphers

Although we want to get rid of none as cipher, we still have not
deprecated it. In order to use it currently you need
--ncp-disable together with --cipher none to use the none cipher
otherwise OpenVPN will spit out an error about an unrecognised
cipher in --data-ciphers.

In our current situation allowing none to be specified in data-ciphers
is the lesser evil.

This commit also fixes that we use '[null-cipher]' instead 'none' when
setting remote_cipher.

Note that negotiating to cipher 'none' can the same the same problems
with frame size calculation as any other non AEAD cipher. If
--cipher none is also specified in the configuration, the workaround
of commit e539c95dc will also apply to cipher none.

Patch V2: Also work correctly if remote_cipher is NULL.
Patch V3: fix unit tests, add note about corner case

Signed-off-by: Arne Schwabe <arne@rfc2549.org>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20201008115959.21151-1-arne@rfc2549.org>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg21181.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
(cherry picked from commit c018fc00be25aee5921d234531f87753a3a7aec7)

4 years agoFix redirecting of IPv4 default gateway if connecting over IPv6.
Gert Doering [Fri, 2 Oct 2020 17:57:36 +0000 (19:57 +0200)] 
Fix redirecting of IPv4 default gateway if connecting over IPv6.

Commit aa34684972eb0 fixed a long-standing bug in setting the
"route-list" flag RTSA_REMOTE_HOST for IPv4 ("we have a well-defined
remote_host == VPN server IP address") even if connecting over IPv6.

Unfortunately the logic in redirect_default_route_to_vpn() was also
wrong, and refused cooperation if that flag is not set, triggering
the message
    "NOTE: unable to redirect IPv4 default gateway -- Cannot
     obtain current remote host address"

Correct operation: if RTSA_REMOTE_HOST is not set, or remote_host
is IPV4_INVALID_ADDR (= 255.255.255.255), do not try to install a
host route for continued connectivity to the VPN server - which is
not needed when connecting over IPv6.  But the actual *routes*
(/0 or 2 x /1) can be installed just fine.

There is a second bug here, which hits if there is no IPv4 gateway
at all.  In that case, the same function triggers the message
    "NOTE: unable to redirect IPv4 default gateway -- Cannot
     read current default gateway from system"

This is caused by using "IPV4_INVALID_ADDR" as a flag for "do we
know the remote_host?" - which worked before, but after the commit
referenced above, the "remote_host" field is not well-defined unless
RTSA_REMOTE_HOST is set.  So, change the condition to check that.

Reported-By: François Kooman <fkooman@tuxed.net>
Reported-By: Thomas Schäfer <tschaefer@t-online.de>
Trac: #1332

Signed-off-by: Gert Doering <gert@greenie.muc.de>
Acked-by: Antonio Quartulli <a@unstable.cc>
Message-Id: <20201002175736.82609-1-gert@greenie.muc.de>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg21152.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
(cherry picked from commit 23e11e591347080efa3b933beca7f620dd059d5c)

4 years agoAdded 'route_ipv6_metric_NN' environment variable for IPv6 route metric.
Jan Seeger [Wed, 30 Sep 2020 06:48:45 +0000 (08:48 +0200)] 
Added 'route_ipv6_metric_NN' environment variable for IPv6 route metric.

Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20200930064845.28022-1-jan.seeger@thenybble.de>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg21110.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
(cherry picked from commit bfb288454aa43f8c2d0131bc87b48a37e4ab01b4)

4 years agoSpeedup TCP remote hosts connections
Vladislav Grishenko [Thu, 1 Oct 2020 22:53:19 +0000 (03:53 +0500)] 
Speedup TCP remote hosts connections

For non-blocking TCP/Unix connection, OpenVPN checks was it established in
loop and if not - sleeps or handles management for next one second. Since
the first check is made right after the connection attempt, it will likely
be always unsuccessful, causing redundant wait for one or more seconds:

    00:00:00.667607 fcntl(5, F_SETFL, O_RDONLY|O_NONBLOCK) = 0
    00:00:00.667713 connect(5, {...}, 16) = -1 EINPROGRESS (Operation now
in progress)
    00:00:00.667832 poll([{fd=5, events=POLLOUT}], 1, 0) = 0 (Timeout)
    00:00:00.667954 nanosleep({tv_sec=1, tv_nsec=0}, 0x7fff52450270) = 0
    00:00:01.668608 poll([{fd=5, events=POLLOUT}], 1, 0) = 1 ([{fd=5,
revents=POLLOUT}])

After this patch openvpn_connect() will perform blocking wait for
connection
establishment (if possible) and just check for management events once in
one
second (if management enabled) w/o sleep. This speedups TCP/Unix connection
establishment and provides almost real connection time that can be used for
detection of the fastest remote server in subsequent patches:

    00:00:00.790510 fcntl(5, F_SETFL, O_RDONLY|O_NONBLOCK) = 0
    00:00:00.790616 connect(5, {...}, 16) = -1 EINPROGRESS (Operation now
in progress)
    00:00:00.790877 poll([{fd=5, events=POLLOUT}], 1, 1000) = 0 (Timeout)
    00:00:01.792880 poll([{fd=5, events=POLLOUT}], 1, 1000) = 1 ([{fd=5,
revents=POLLOUT}])

Or, with management interface enabled:

    00:00:00.906421 fcntl(5, F_SETFL, O_RDONLY|O_NONBLOCK) = 0
    00:00:00.906527 connect(6, {...}, 16) = -1 EINPROGRESS (Operation now
in progress)
    00:00:00.906779 poll([{fd=6, events=POLLOUT}], 1, 1000) = 0 (Timeout)
    00:00:01.910418 poll([{fd=3, events=POLLIN|POLLPRI}], 1, 0) = 0
(Timeout)
    00:00:01.911365 poll([{fd=6, events=POLLOUT}], 1, 1000) = 0 ([{fd=6,
revents=POLLOUT}])

v2: cosmetics, decrease connection_timeout to avoid wait more than it
v3: teach management_sleep() to handle zero timeout and reject negative
    use 1s timeout for connection and 0s timeout for management events

Signed-off-by: Vladislav Grishenko <themiron@yandex-team.ru>
Acked-by: Arne Schwabe <arne@rfc2549.org>
Message-Id: <20201001225319.25125-1-themiron@yandex-team.ru>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg21139.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
(cherry picked from commit b68aa00603332357e6c711e91c5b4ba04d78294b)

4 years agoSelectively reformat too long lines
Vladislav Grishenko [Thu, 24 Sep 2020 09:10:04 +0000 (14:10 +0500)] 
Selectively reformat too long lines

Per https://community.openvpn.net/openvpn/wiki/CodeStyle the maximum line
length is 80 characters. This patch allows to split upcoming changes into
CodeStyle-conformant (w/o real code change) and more feature-specific.
Upcoming changes adds new PROTO_AUTO, so existing proto_names array is
reformatted as well.

v7: prefer line breaks before long string parameters
    reformat proto_names array

Signed-off-by: Vladislav Grishenko <themiron@yandex-team.ru>
Acked-by: Arne Schwabe <arne@rfc2549.org>
Message-Id: <20200924091004.29065-1-themiron@yandex-team.ru>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg21083.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
(cherry picked from commit a5409c0d34bf02cacdee61d61ba7b3e1f72e132f)

4 years agocompat/lz4: Update to v1.9.2
David Sommerseth [Thu, 1 Oct 2020 15:46:58 +0000 (17:46 +0200)] 
compat/lz4: Update to v1.9.2

It's a long while since the bundled lz4 library has received an update.
It pulls in a lot of various fixes and enhancements, some of the changes
fixes compiler warnings and hardens the code a bit too.

Signed-off-by: David Sommerseth <davids@openvpn.net>
Acked-by: Arne Schwabe <arne@rfc2549.org>
Message-Id: <20201001154658.9798-1-davids@openvpn.net>
URL: https://www.mail-archive.com/search?l=mid&q=20201001154658.9798-1-davids@openvpn.net
Signed-off-by: Gert Doering <gert@greenie.muc.de>
(cherry picked from commit 0f44a9080530df70410106c244e9efc7f2d8a802)

4 years agoImprove error msg when all TAP adapters are in use 'or disabled'
Richard Bonhomme [Thu, 6 Aug 2020 19:01:40 +0000 (20:01 +0100)] 
Improve error msg when all TAP adapters are in use 'or disabled'

Ref: https://github.com/OpenVPN/openvpn-gui/issues/356

Signed-off-by: Richard Bonhomme <tincanteksup@gmail.com>
Acked-by: Arne Schwabe <arne@rfc2549.org>
Message-Id: <20200806190140.9637-1-tincanteksup@gmail.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg20651.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
(cherry picked from commit 43cdb0c702dd184541d4fa5e0c2b2899966371a0)

4 years agoPreparing release 2.5_rc2 v2.5_rc2
Gert Doering [Wed, 30 Sep 2020 08:03:36 +0000 (10:03 +0200)] 
Preparing release 2.5_rc2

Version.m4, ChangeLog

Signed-off-by: Gert Doering <gert@greenie.muc.de>
4 years agoFix update_time() and openvpn_gettimeofday() coexistence
Vladislav Grishenko [Tue, 22 Sep 2020 17:08:41 +0000 (22:08 +0500)] 
Fix update_time() and openvpn_gettimeofday() coexistence

With TIME_BACKTRACK_PROTECTION defined, openvpn_gettimeofday() uses and
updates global variable "now_usec" along with "now" only if current time
is ahead of the previsouly stored, taking nanoseconds into account.
But, update_time() function updates only "now" leaving "now_usec" as
is with any previously value stored.
This breaks openvpn_gettimeofday() results and leads to time jumps in the
future within one second, can affect shaper and user timers.

Example:
100.900 openvpn_gettimeofday():
    now set to 100s, now_usec set to 900ns, stored time is 100.900
101.300 update_time():
    now set to 101s, but now_usec is not updated and still 900ns, stored
    time jumps to the future 101.900
101.600 openvpn_gettimeofday():
    current time 101.600 is in the past relatively stored time 101.900,
    now & now_usec variables are not updated, returned time 101.900 is
    still and again incorrect
102.100 openvpn_gettimeofday():
    current time 102.100 is no longer in the past relatively stored time
    101.900, so now & now_usec get updated with wrong time delta from
    previous openvpn_gettimeofday() call or now/now_usec math

Since update_time() and openvpn_gettimeofday() calls are mixed in runtime,
there're several options to fix the things:

1. Allow update_time() to reset "now_usec" value backward to 0, since it's
   used directly only in time ajusting and always invalidate it in
   openvpn_gettimeofday() unless time has drifted backwards.
   Quick solution that only fixes openvpn_gettimeofday() and keeps current
   level of time performance and backward-protection handling way.

2. Switch update_time() to gettimeofday() not only for windows, but for all
   platforms: "now_usec" will be updated accordingly. As a disadvantage,
   gettimeofday() may have performance penalty on older or platforms w/o
VDSO
   where expensive kernel syscall will be made. And it will still need time
   adjusting code, doubt it's feasible.

3. Switch update_time() and openvpn_gettimeofday() to clock_gettime() on
   Linux/BSD platforms with CLOCK_REALTIME_FAST/CLOCK_REALTIME_COARSE
   clock sources. According tests it'll be faster with VDSO than
gettimeofday()
   or CLOCK_REALTIME/CLOCK_REALTIME_PRECISE, but still may require
adjusting
   code to protect from time jumps on devices with no RTC (ex. routers)
where
   NTP is the only way to get correct time after boot. Since not every
*libc
   have clock_gettime() and corresponding CLOCK_* defines and/or running
   kernel may have no VDSO/corresponding CLOCK_* support - related
autotools
   checks and fallback code can still be necessary.

4. Switch update_time() and openvpn_gettimeofday() to clock_gettime() on
   Linux/BSD platforms with CLOCK_MONOTONIC_FAST/CLOCK_MONOTONIC_COARSE
   clock sources. This may allow to get rid of time adjusting code at all
   with the acceptable performance on modern systems, but may still require
   to fallback to gettimeofday() with adj friends on older platforms (most
   likely to be Linux CPE/routers). From the effort point of view,
splitting
   the whole OpenVPN code into realtime/monotonic is most significant and
   desired task among the above, several parts still needs to use realtime
   due API or storage or output reasons.

This patch implements the first stage only.

v2: move from gettimeofday() (1st way) back to time(), don't check previous
    value of "now_usec" in update_usec() instead
v3: recover "now_usec" checks against time jumps within one second, zero it
    in update_time() calls instead to pass the check.

Signed-off-by: Vladislav Grishenko <themiron@yandex-team.ru>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20200922170841.13729-1-themiron@yandex-team.ru>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg21070.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
(cherry picked from commit e9e47f498674f6db8c3b88b32c877c5beb09a888)

4 years agoAlias ADAPTER_DOMAIN_SUFFIX to DOMAIN
Lev Stipakov [Tue, 22 Sep 2020 10:00:21 +0000 (13:00 +0300)] 
Alias ADAPTER_DOMAIN_SUFFIX to DOMAIN

ADAPTER_DOMAIN_SUFFIX is an openvpn3 replacement for
DOMAIN, which is used there for split-dns. This option is pushed
by modern Access Server.

This change improves compatibility between OpenVPN
community client and Access Server.

Signed-off-by: Lev Stipakov <lev@openvpn.net>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20200922100021.20329-1-lstipakov@gmail.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg21107.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
(cherry picked from commit d6720203fa9ba446497798a284c17093b92de1dc)

4 years agoImprove documentation of --username-as-common-name
Selva Nair [Sun, 27 Sep 2020 18:46:00 +0000 (14:46 -0400)] 
Improve documentation of --username-as-common-name

Trac #1079

Signed-off-by: Selva Nair <selva.nair@gmail.com>
Acked-by: David Sommerseth <davids@openvpn.net>
Message-Id: <1601232360-14096-1-git-send-email-selva.nair@gmail.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg21098.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
(cherry picked from commit 66ad8727935a371e237a5bada142c9f5f467c3f8)

4 years agoSet DNS Domain using iservice
Selva Nair [Sat, 26 Sep 2020 02:04:46 +0000 (22:04 -0400)] 
Set DNS Domain using iservice

Use wmic instead of directly editing the registry
as the former does not take full effect unless the dns
client service is restarted.

Editing the registry appears to work erratically depending
on whether its followed with a dchp renew or ipconfig /registerdns
etc.

DOMAIN-SEARCH is not handled here as wmic only supports
setting the global search list which will over-ride all
interface specific values.  Editing the registry directly
combined with a wmic command to reset the global SearchList
is an option that could be considered in a separate patch.

Trac # 1209, 1331

v2 changes
- Separate DNS domain setting from DNS server setting and call
  only once either during IPv4 processing or IPv6 processing
  if the former is not active. (file changed: tun.c)
- Null terminate domain and interface_name received from the
  client. (file changed: interactive.c)
  Its done using a const cast-away of msg in a limited scope.
  Not pretty, but alternatives are no better.

Signed-off-by: Selva Nair <selva.nair@gmail.com>
Acked-by: Lev Stipakov <lstipakov@gmail.com>
Message-Id: <1601085886-10351-1-git-send-email-selva.nair@gmail.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg21097.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
(cherry picked from commit 70882f3e40df1c70c553b8c22c747b468d5a0dc7)

4 years agoopenvpnmsica: Simplify find_adapters() to void return
Simon Rozman via Openvpn-devel [Thu, 24 Sep 2020 06:55:19 +0000 (08:55 +0200)] 
openvpnmsica: Simplify find_adapters() to void return

As the find_adapters() failure is not critical and FindSystemInfo()
should continue regardless, the find_adapters() has been simplified not
to return result code. It still logs any error though.

Signed-off-by: Simon Rozman <simon@rozman.si>
Acked-by: Lev Stipakov <lstipakov@gmail.com>
Message-Id: <20200924065519.1839-1-simon@rozman.si>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg21077.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
(cherry picked from commit 7f7b05395c3eb634e198d12e212360958c3ca8fb)

4 years agonetsh: Delete WINS servers on TUN close
Simon Rozman via Openvpn-devel [Thu, 24 Sep 2020 06:44:52 +0000 (08:44 +0200)] 
netsh: Delete WINS servers on TUN close

Signed-off-by: Simon Rozman <simon@rozman.si>
Acked-by: Lev Stipakov <lstipakov@gmail.com>
Message-Id: <20200924064452.1001-3-simon@rozman.si>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg21075.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
(cherry picked from commit 370395b3348c4307cdea955abaa36ba315cc128e)

4 years agonetsh: Clear existing IPv6 DNS servers before configuring new ones
Simon Rozman via Openvpn-devel [Thu, 24 Sep 2020 06:44:51 +0000 (08:44 +0200)] 
netsh: Clear existing IPv6 DNS servers before configuring new ones

When there are no IPv6 DNS published, the adapter state is not
sanitized and might contain IPv6 DNS server from a previous session.

netsh_ifconfig_options() clears DNS servers for IPv4 already.

Signed-off-by: Simon Rozman <simon@rozman.si>
Acked-by: Lev Stipakov <lstipakov@gmail.com>
Message-Id: <20200924064452.1001-2-simon@rozman.si>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg21078.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
(cherry picked from commit dd754221024cf60226ebaa679ec65ccc23f4e402)

4 years agonetsh: Specify interfaces by index rather than name
Simon Rozman via Openvpn-devel [Thu, 24 Sep 2020 06:44:50 +0000 (08:44 +0200)] 
netsh: Specify interfaces by index rather than name

This is more efficient and less error prone.

Signed-off-by: Simon Rozman <simon@rozman.si>
Acked-by: Lev Stipakov <lstipakov@gmail.com>
Message-Id: <20200924064452.1001-1-simon@rozman.si>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg21076.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
(cherry picked from commit 6020e94bcf9eda89aa6573cb2eb1faf6d267cb46)

4 years agoPreparing release 2.5_rc1 v2.5_rc1
Gert Doering [Mon, 21 Sep 2020 06:34:35 +0000 (08:34 +0200)] 
Preparing release 2.5_rc1

Version.m4, ChangeLog

Signed-off-by: Gert Doering <gert@greenie.muc.de>
4 years agoFix combination of --dev tap and --topology subnet across multiple platforms.
Gert Doering [Mon, 14 Sep 2020 07:08:43 +0000 (09:08 +0200)] 
Fix combination of --dev tap and --topology subnet across multiple platforms.

--topology should have no effect in tap mode (tap is always "subnet"),
but due to the way options are checked, setting "topology subnet" caught
an improper branch on all non-linux and non-win32 platforms.

Easily tested by adding "--topology subnet" to a "--dev tap" t_client
test.

Tested, verified, and fixed on FreeBSD 13.3, NetBSD 8.1, OpenBSD 6.5,
OpenIndiana 2019 (Solaris) and MacOS X Mojave.

This is a forward-port of commit 6c13e24e5709 - the original intent
for "master" was to restructure tun.c in a larger way and clean up
these if() blocks more nicely... which has not happened yet, so this
patch is basically applying exactly the same changes to context that
has changed too much for git to be able to do this automatically.

Trac: #1085

Signed-off-by: Gert Doering <gert@greenie.muc.de>
Acked-by: Antonio Quartulli <a@unstable.cc>
Message-Id: <20200914070843.51678-1-gert@greenie.muc.de>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg20987.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
(cherry picked from commit 860a7bc77ef515f1d042a2860f7e2bd9980e19be)

4 years agoAdd demo plugin that excercises "CLIENT_CONNECT" and "CLIENT_CONNECT_V2" paths
Gert Doering [Thu, 17 Sep 2020 16:19:09 +0000 (18:19 +0200)] 
Add demo plugin that excercises "CLIENT_CONNECT" and "CLIENT_CONNECT_V2" paths

This is a new "samples" plugin which does not do many useful things,
besides
 - show how a plugin is programmed
 - how the various messages get dispatched
 - how to pass back information from a client-connect/v2 plugin
 - how to do async-cc plugins  [not yet implemented]

the operation of the plugin is controlled by UV_WANT_* environment
variables
controlled by the client ("--setenv UV_WANT_CC_FAIL 1 --push-peer-info"),
to "fail CLIENT_CONNECT" or "use async-cc for CLIENT_CONNECT_V2" or
"send 'disable' back from ...") - which is useful for automated testing
of server success/defer/fail code paths for the CLIENT_CONNECT_* functions.

See samples/sample-plugins/client-connect/README for details how to do
this.

v2:
  - implement async / deferred operation both for CLIENT_CONNECT and
    CLIENT_CONNECT_V2 plugin calls
  - implement returning openvpn-controlled (setenv) config snippets
    (so the client side can verify in automated testing that the plugin
    operated correctly, without hard-coding something in the plugin code)

v3:
  - remove -Wno-unused-variable from Makefile
  - remove unused "char ** argv" (commented out, but kept as reference)

v4:
  - upgrade to use the build infra brought by commit 0b5141d8f946
  - remove local Makefile
  - include "config.h" to get what is needed to get rid of the strdup()
    warning
Acked-by: David Sommerseth <davids@openvpn.net>
Message-Id: <20200917161909.11573-1-gert@greenie.muc.de>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg21047.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
(cherry picked from commit 94cebf8261d20a55b0260cce61ad892a98bc24d8)

4 years agoIf IPv6 pool specification sets pool start to ::0 address, increment.
Gert Doering [Thu, 17 Sep 2020 08:59:41 +0000 (10:59 +0200)] 
If IPv6 pool specification sets pool start to ::0 address, increment.

The first IPv6 address in a subnet is not usable (IPv6 anycast address),
but our pool code ignored this.

Instead of assigning an unusable address or erroring out, just log the
fact, and increment the pool start to <pool_base>::1

NOTE: this is a bit simplistic.  A pool that is larger than /96 and
has non-0 bits in the "uppermost bits" will still get the increment
as we only look at the lowermost 32 bits.

NOTE2: if the pool is specified with "--server-ipv6 $base/$bits", this
is a non-issue, as the address for the pool start will be incremented
anyway.

v2: make comment more explicit about "we're only talking about the
    host part here" and "base sees only only 32 bit of the host part"

Reported-by: NicolaF_ in Trac
Trac: #1282

Signed-off-by: Gert Doering <gert@greenie.muc.de>
Acked-by: Antonio Quartulli <a@unstable.cc>
Message-Id: <20200917085941.20972-1-gert@greenie.muc.de>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg21039.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
(cherry picked from commit 4dff236811a1ec9c97a27ad93182ad4beb12377f)

4 years agoFix fatal error at switching remotes (#629)
Vladislav Grishenko [Wed, 16 Sep 2020 14:17:55 +0000 (19:17 +0500)] 
Fix fatal error at switching remotes (#629)

If remote server has been resolved to multiple addresses, at
least one connection attempt has been made and connection to
the last address was skipped by management - resolved earlier
link socket addrinfo objects will not be cleared neither on
instance close nor in the next connection entry loop.
This causes fatal error assert:

    >REMOTE:openvpn.net,1194,udp
    remote ACCEPT
    SUCCESS: remote command succeeded
    >REMOTE:openvpn.net,1194,udp
    remote SKIP
    SUCCESS: remote command succeeded
    >FATAL:Assertion failed at init.c:504
(c->c1.link_socket_addr.current_remote == NULL)

Fix this behaviour by cleaning stale addrinfo objects.

v2: better comment placement and too long length fix

Signed-off-by: Vladislav Grishenko <themiron@yandex-team.ru>
Acked-by: Lev Stipakov <lstipakov@gmail.com>
Message-Id: <20200916141755.1923-1-themiron@yandex-team.ru>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg21019.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
(cherry picked from commit 3ad86c2534a92af137809b6d446d570193e6d01f)

4 years agobuild: Fix make distclean/distcheck
David Sommerseth [Wed, 16 Sep 2020 19:56:16 +0000 (21:56 +0200)] 
build: Fix make distclean/distcheck

In commit 0b5141d8f94 the sample-plugins got partially migrated to
automake.  But since it was not fully integrated within the full
standard build, the sample/sample-plugins/Makefile was not removed
by 'make distclean', which annoys 'make distcheck'.

The simplest way is just to explicitly enlist this Makefile in the list
of files 'make distclean' should remove.

Signed-off-by: David Sommerseth <davids@openvpn.net>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20200916195616.30633-1-davids@openvpn.net>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg21026.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
(cherry picked from commit 6345cea86bde14b22a8024cad5026a7d302db25c)

4 years agosample-plugins: Partially autotoolize the sample-plugins build
David Sommerseth [Wed, 16 Sep 2020 14:19:56 +0000 (16:19 +0200)] 
sample-plugins: Partially autotoolize the sample-plugins build

The sample-plugins have their own set of build/winbuild scripts in each
of these plugin directories.  This does not give a good way to reuse
various macros the autoconf/automake/configure process enables; which
can contain important macros to make some code build without errors or
warnings.

Normally we would embrace the full autoconf/automake approach. But this
is sample code which we only want to build per request and the built
code should not be installed anywhere via 'make install'.  But since we
do use libtool other plug-ins being installed and automake gets kind of
cranky when it comes to define certain build targets not following the
expected use cases, we try to only embrace just enough of automake to
get our main goals achieved.

This changeset kicks out the build scripts and replaces them with a
single Makefile.plugins file, which defines the plugins we want to build
by default when running 'make from the sample-plugins directory.
Neither of these plugins are otherwise built by default.  No sample-plugins
are being installed.  But we have enough strings attached to automake
to grab the CFLAGS and LDFLAGS used by the rest of the code.  This also
makes it easy to use #include "config.h" in sample code, to also get
various macros defined by the ./configure run.

This patch does not touch the winbuild scripts, as it seems building
these sample-plugins on Windows requires a bit different compile and
linking steps than *nix systems in general.

Signed-off-by: David Sommerseth <davids@openvpn.net>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20200916141956.1277-1-davids@openvpn.net>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg21020.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
(cherry picked from commit 0b5141d8f946a274bf27b3592ac07dc9c6b0ee71)

4 years agoFix netbits setting (in TAP mode) for IPv6 on Windows.
Gert Doering [Tue, 15 Sep 2020 09:41:01 +0000 (11:41 +0200)] 
Fix netbits setting (in TAP mode) for IPv6 on Windows.

For TUN interfaces, the IPv6 address needs to be configured with
"address/128" and a local subnet route is needed, pointing to our
fake gateway fe80::8.  There is no ethernet headers or ND outside
the tun/tap interface, so anything but fe80::8 is not resolvable.

For TAP interfaces, the proper subnet mask (netbits) must be configured,
and no connected route to "our local host address" must be configured,
to make make IPv6 ND work inside the local subnet.

Our code was nicely consistent in doing the same thing in tun.c
("gui/openvpn running with admin privileges") and in the requests
to the interactive service ("gui running with user privs").  Fix in
both places.

On tun close, symmetric to addition, remove the on-link subnet route only
for "tun" interfaces.  Address removal works without specifying netbits.

While at it, extend do_address_service() to actually log both IPv4
and IPv6 addresses requested via it.

Tested on Win10/64.

v2:
  - change logging to use D_IFCONFIG
  - fix whitespace on "?" operator

Reported-By: Laurent Fasnacht <l@libres.ch>
Reported-By: Klara Mall <klara.mall@kit.edu>
Trac: #1054

Signed-off-by: Gert Doering <gert@greenie.muc.de>
Acked-by: Lev Stipakov <lstipakov@gmail.com>
Message-Id: <20200915094101.86470-1-gert@greenie.muc.de>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg21008.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
(cherry picked from commit 81b6a7e75b343e324a44b4476c89c596d7b6c74b)

4 years agoAllow --dhcp-option in config file when windows-driver is wintun
Selva Nair [Mon, 14 Sep 2020 23:29:41 +0000 (19:29 -0400)] 
Allow --dhcp-option in config file when windows-driver is wintun

When wintun is in use we mutate ip_win32_type to NETSH
and then complain that ip-win32 option should be dynamic or adaptive
if any --dhcp-option directive is present in the config file. This
causes a fatal error.

How to reproduce: specify a --dhcp-option in the config and change the
--windows-driver to wintun.

Fix this behaviour. A typo in the message is also corrected.

Signed-off-by: Selva Nair <selva.nair@gmail.com>
Acked-by: Lev Stipakov <lstipakov@gmail.com>
Message-Id: <1600126181-16364-1-git-send-email-selva.nair@gmail.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg21005.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
(cherry picked from commit b8625abbd5be21a810b648058e6e411a7ff19702)

4 years agoman: Improve --remote entry
David Sommerseth [Wed, 9 Sep 2020 18:30:12 +0000 (20:30 +0200)] 
man: Improve --remote entry

The --remote entry had a syntax mistake in the argument examples, which
was introduced during the .rst conversion.

In addition this section did not have a good flow.  So the text was
regrouped and re-organized a bit so related text pieces are now gathered
in the same context instead of being more spread out.

Signed-off-by: David Sommerseth <davids@openvpn.net>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20200909183012.7504-1-davids@openvpn.net>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg20935.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
(cherry picked from commit 97ff64360745d27004e97043507ac788db23799c)

4 years agosocks.c: fix alen for DOMAIN type addresses, bump up buffer sizes
Gert Doering [Wed, 9 Sep 2020 12:22:23 +0000 (14:22 +0200)] 
socks.c: fix alen for DOMAIN type addresses, bump up buffer sizes

When a SOCKS5 server sends back a reply, it encodes an "address",
which can be IPv4 (4 bytes), IPv6 (16 bytes) or "a domain name",
which has a lenght (1 byte) and "a string of length <length>" - so
when copying bytes, we need to hande "length +1" bytes.

Our code totally doesn't use this variant of addresses on reception,
but since this has been pointed out by "tpw_rules" in Trac, fix it,
so if/when someone works on this again, the foundation is correct.

While at it, increase buffer size used for sending to handle domain
names longer than 122 characters (length was already checked, so a
longer name would not overflow but just "not work").

v2: increase buf[] len in recv_socks_reply() from 22 to 270 so it
    is large enough to actually copy a domain name

v3: increase buf[] len in establish_socks_proxy_passthru() from 128 to
    270, to handle long domain names in queries

Reported-By: tpw_rules in Trac
Trac: #848

Signed-off-by: Gert Doering <gert@greenie.muc.de>
Acked-by: Antonio Quartulli <a@unstable.cc>
Message-Id: <20200909122223.9222-1-gert@greenie.muc.de>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg20928.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
(cherry picked from commit eebeaa02367d247fc2549df3edf8e598c58c3572)

4 years agomsvc: better support for 32bit architecture
Lev Stipakov [Mon, 14 Sep 2020 08:44:44 +0000 (11:44 +0300)] 
msvc: better support for 32bit architecture

Previously dependency directory was hardcoded to

..\openvpn-build\msvc\image

which means that to build for 32bit architecture,
one needs to rebuild dependencies and do the same again
for 64bit architecture.

Add architecture's "bitness" to dependency directory.

As a bonus, add missing libraries to 32bit targets.

This requires correspondig change to openvpn-build:

https://github.com/OpenVPN/openvpn-build/pull/190
Signed-off-by: Lev Stipakov <lev@openvpn.net>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20200914084444.96-1-lstipakov@gmail.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg20990.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
(cherry picked from commit fb94fbc31f9d6e434af465bf8a345763f89fddc9)

4 years agoFix --show-gateway for IPv6 on NetBSD/i386.
Gert Doering [Sun, 13 Sep 2020 14:56:21 +0000 (16:56 +0200)] 
Fix --show-gateway for IPv6 on NetBSD/i386.

Our ROUNDUP() macro to achieve the required system-specific alignment
for data structures sent to the routing socket was wrong for NetBSD -
unlike OpenBSD/FreeBSD, NetBSD is not using "long" (32/64 bit depending
on OS architecture), and not "uint32_t" either (32/32) like MacOS, but
uint64_t.

So our use of "long" always worked on NetBSD/amd64 and stopped working
on NetBSD/i386 when this was changed on the OS side...

NetBSD conveniently exports a RT_ROUNDUP() macro from <net/route.h> - use
that, and avoid trying to second-guess OS requirements.

While at it, add M_ERRNO to ominous "GDG6: problem writing to routing
socket"
error message to differenciate between "EINVAL" and other errors.

Trac: #734

Signed-off-by: Gert Doering <gert@greenie.net>
Acked-by: Arne Schwabe <arne@rfc2549.org>
Message-Id: <20200913145621.12125-1-gert@greenie.muc.de>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg20983.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
(cherry picked from commit 37aab49b083a9e385970e3ab2dd727ea1a95ff35)

4 years agoHandle NULL returns from calloc() in sample plugins.
Gert Doering [Wed, 9 Sep 2020 10:48:37 +0000 (12:48 +0200)] 
Handle NULL returns from calloc() in sample plugins.

This is basic housekeeping, adding NULL checks to context initialization
of the sample plugin collection which are missing it.  Realistically,
this can never happen, but since these are supposed to be "good examples",
not checking calloc() return isn't one.

Trac: #587

Reported-By: Dogbert (in Trac)
Signed-off-by: Gert Doering <gert@greenie.muc.de>
Acked-by: David Sommerseth <davids@openvpn.net>
Message-Id: <20200909104837.6123-1-gert@greenie.muc.de>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg20922.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
(cherry picked from commit a61c08a2c80d95dcc2bc30ddcb9a54a462e565ed)

4 years agoman: Add missing --server-ipv6
David Sommerseth [Fri, 11 Sep 2020 15:42:59 +0000 (17:42 +0200)] 
man: Add missing --server-ipv6

During the conversion from .8 to .rst and further reorganizing of the
content into separate files, the --server-ipv6 entry got lost.  This
resurrects it again.

Trac: #1324

Signed-off-by: David Sommerseth <davids@openvpn.net>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20200911154259.13837-1-davids@openvpn.net>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg20970.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
(cherry picked from commit 8120e1ad4f20d4ec1fa9e191f3b15740c4aec448)

4 years agoFix description of --client-disconnect calling convention in manpage.
Gert Doering [Wed, 9 Sep 2020 12:29:26 +0000 (14:29 +0200)] 
Fix description of --client-disconnect calling convention in manpage.

The man page claimed that --client-disconnect "is passed the same
pathname as the corresponding --client-connect command", which is
not what the code does.  Fix.

Reported-By: hvenev in Trac
Trac: #884

Signed-off-by: Gert Doering <gert@greenie.muc.de>
Acked-by: Antonio Quartulli <a@unstable.cc>
Message-Id: <20200909122926.9523-1-gert@greenie.muc.de>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg20929.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
(cherry picked from commit 50c7700da09a1f83474e18f8709d59dbc4b509e2)

4 years agoReplace 'echo -n' with 'printf' in tests/t_lpback.sh
Gert Doering [Wed, 9 Sep 2020 13:00:24 +0000 (15:00 +0200)] 
Replace 'echo -n' with 'printf' in tests/t_lpback.sh

"echo -n" is inherently less portable than printf, so the tests look
ugly on (at least) OpenSolaris/Illumos on AIX.

Add a blank at the end of the tls-crypt-v2 messages, so it has the
same look as the cipher messages ("... OK").

Reported-by: mnowak on Trac
Trac: #1196

Signed-off-by: Gert Doering <gert@greenie.muc.de>
Acked-by: Antonio Quartulli <a@unstable.cc>
Message-Id: <20200909130024.24264-1-gert@greenie.muc.de>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg20930.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
(cherry picked from commit 81f9bb3a2ff9a3b0f5a1bdbac1d0daf38747ae7b)

4 years agoAdd a remark on dropping privileges when --mlock is used
Selva Nair [Wed, 9 Sep 2020 22:15:29 +0000 (18:15 -0400)] 
Add a remark on dropping privileges when --mlock is used

trac #1059

Signed-off-by: Selva Nair <selva.nair@gmail.com>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <1599689729-25906-1-git-send-email-selva.nair@gmail.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg20937.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
(cherry picked from commit 5b815eb449314a43e2b73325948edea8a4cfb215)

4 years agoFix handling of 'route remote_host' for IPv6 transport case.
Gert Doering [Fri, 11 Sep 2020 08:59:07 +0000 (10:59 +0200)] 
Fix handling of 'route remote_host' for IPv6 transport case.

If we connect to a VPN server over IPv6, and the config has a
route like this:

  route remote_host default net_gateway

OpenVPN would try to install a route to "255.255.255.255", which
is obviously bogus.

The bug is twofold: init_route_list() should not set RTSA_REMOTE_HOST
for an "IPV4_INVALID_ADDR" remote_host (wrong condition, this is not
a pointer but an integer, and "invalid" is "-1" numerically here),
and init_route() must not ignore "status = false" returns from
get_special_addr().

I have just added the "if (!status)" check, not done refactoring for
init_route() to see whether I could make it "more pretty".

Trac: #1247

Signed-off-by: Gert Doering <gert@greenie.muc.de>
Acked-by: Arne Schwabe <arne@rfc2549.org>
Message-Id: <20200911085907.26004-1-gert@greenie.muc.de>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg20958.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
(cherry picked from commit aa34684972eb01bfa5c355d1c8a8a9d384bf0175)

4 years agoPreparing release 2.5_beta4 v2.5_beta4
Gert Doering [Thu, 10 Sep 2020 09:24:30 +0000 (11:24 +0200)] 
Preparing release 2.5_beta4

Version.m4, ChangeLog

Signed-off-by: Gert Doering <gert@greenie.muc.de>
4 years agoFix best gateway selection over netlink
Vladislav Grishenko [Tue, 8 Sep 2020 12:36:25 +0000 (17:36 +0500)] 
Fix best gateway selection over netlink

Netlink route request with NLM_F_DUMP flag set means to return
all entries matching criteria passed in message content -
matching supplied family & dst address in our case.
So, gateway from the first ipv4 route was always used.

On kernels earlier than 2.6.38 default routes are the last ones,
so arbitrary host/net route w/o gateway is likely be returned as
first, causing gateway to be invalid or empty.
After refactoring in 2.6.38 kernel default routes are on top, so
the problem with older kernels was hidden.

Fix this behavior by selecting first 0.0.0.0/0 if dst was not set
or empty. For IPv6, no behavior is changed - request ::/128 route,
so just clarify the sizes via netlink route api.

Tested on 5.4.0, 4.1.51, 2.6.36 and 2.6.22 kernels.

Signed-off-by: Vladislav Grishenko <themiron@yandex-team.ru>
Acked-by: Antonio Quartulli <a@unstable.cc>
Message-Id: <20200908123625.23179-1-themiron@yandex-team.ru>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg20900.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
(cherry picked from commit 505d5ad8fadcdc56bae07f4b95c05acd93a47c24)

4 years agoFix TUNSETGROUP compatibility with very old Linux systems.
Gert Doering [Wed, 9 Sep 2020 15:37:25 +0000 (17:37 +0200)] 
Fix TUNSETGROUP compatibility with very old Linux systems.

Our code works on "very old Linux" (Fedora-1), but needs a #define
for TUNSETGROUP to compile.  Everything else is there.

While at it, fix TUNSETGROUP error message.

Reported-By: noloader on Trac
Trac: #1152

Signed-off-by: Gert Doering <gert@greenie.muc.de>
Acked-by: Arne Schwabe <arne@rfc2549.org>
Message-Id: <20200909153725.1158-1-gert@greenie.muc.de>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg20932.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
(cherry picked from commit a4e0ac0604460ea2431acb7481d6ffb7a3fc6298)

4 years agoFix error detection / abort in --inetd corner case.
Gert Doering [Tue, 8 Sep 2020 10:51:30 +0000 (12:51 +0200)] 
Fix error detection / abort in --inetd corner case.

Calling "openvpn --inetd" from the CLI (= no socket on stdin) will
lead to endless looping in the accept(4) loop.

Instead of cluttering that function further, detect failure to call
getsockame() in phase2_inetd() already, and trigger a M_FATAL abort
on "errno == ENOTSOCK" ("The argument s is a file, not a socket").

While at it, uncrustify the --bind-dev code (whitespace only).

Trac: #350

Signed-off-by: Gert Doering <gert@greenie.muc.de>
Acked-by: Arne Schwabe <arne@rfc2549.org>
Message-Id: <20200908105130.24171-1-gert@greenie.muc.de>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg20897.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
(cherry picked from commit a09a2fadbadb5dc435f6fccc581163e1f637f43f)

4 years agoDocument that --push-remove is generally more suitable than --push-reset
Gert Doering [Tue, 8 Sep 2020 11:15:11 +0000 (13:15 +0200)] 
Document that --push-remove is generally more suitable than --push-reset

It's a long-standing and well-known problem that --push-reset removes
"critical" options from the push list (like "topology subnet") which
will then lead to non-working client configs.  This can not be
reasonably fixed, because the list of "critical" options depends on
overall server config.

So just document the fact, and point people towards --push-remove as
a more selective tool.

Trac: #29

Signed-off-by: Gert Doering <gert@greenie.muc.de>
Acked-by: Arne Schwabe <arne@rfc2549.org>
Acked-by: David Sommerseth <davids@openvpn.net>
Message-Id: <20200908111511.9271-1-gert@greenie.muc.de>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg20899.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
(cherry picked from commit 5fd66510dfdef628fa95f156c5f9d80af9ae1531)

4 years agoopenvpnmsica: make adapter renaming non-fatal
Lev Stipakov [Wed, 2 Sep 2020 21:36:43 +0000 (00:36 +0300)] 
openvpnmsica: make adapter renaming non-fatal

For some users renaming adapter

    Local Area Connection > OpenVPN TAP-Windows6

mysteriously fails, see https://github.com/OpenVPN/openvpn-build/issues/187

Since renaming is just a "nice to have", make it non-fatal
and, in case of error, only log message and don't display messagebox.

Signed-off-by: Lev Stipakov <lev@openvpn.net>
Acked-by: Simon Rozman <simon@rozman.si>
Message-Id: <20200902213643.401-1-lstipakov@gmail.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg20875.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
(cherry picked from commit b341b1c596931f8a1f77f054ba505b5c1e3547be)

4 years agoIn tap.c use DiInstallDevice to install the driver on a new adapter
Selva Nair [Thu, 3 Sep 2020 23:56:44 +0000 (19:56 -0400)] 
In tap.c use DiInstallDevice to install the driver on a new adapter

As reported in Trac 1321, additional adapter installation
by tapctl.exe fails to fully setup the device node (some registry
keys missing, error in setapi.dev.log etc.).
Although the exact cause of this failure is unclear,
letting the Plug and Play subsystem handle the installation
by calling DiInstallDevice() avoids it.

We let the system automatically choose the best driver
by passing NULL for driverinfo to DiInstallDevice().
This also eliminates the need for enumerating all drivers
in the Net class and selecting a matching one.

Somehow mingw-w64 fails to find DiInstallDriver() in
newdev.lib although the header does define it. Use LoadLibrary()
to locate it at run time (available in Vista and above).

Built using mingw and tested both the msi installer (code shared
with libopenvpnmscia.dll) and tapctl.exe on Windows 10 64 bit.

Fixes: Trac #1321
Signed-off-by: Selva Nair <selva.nair@gmail.com>
Acked-by: Lev Stipakov <lstipakov@gmail.com>
Message-Id: <1599177404-29996-1-git-send-email-selva.nair@gmail.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg20880.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
(cherry picked from commit f3f09541dcff3f0b307067bdf5dcaabc530db4c7)

4 years agoPreparing release 2.5_beta3 v2.5_beta3
Gert Doering [Mon, 31 Aug 2020 13:12:20 +0000 (15:12 +0200)] 
Preparing release 2.5_beta3

Version.m4, ChangeLog

Notable change: define([PRODUCT_VERSION_RESOURCE], [2,5,0,3])
-> that way, the resulting openvpn binary on windows will have a
new version number (2.5.0.3) which will make the .msi installers
replace it on upgrading.

Signed-off-by: Gert Doering <gert@greenie.muc.de>
4 years agoFix client NCP OCC fallback when server and client cipher are identical
Arne Schwabe [Sun, 30 Aug 2020 13:14:40 +0000 (15:14 +0200)] 
Fix client NCP OCC fallback when server and client cipher are identical

If we do not get a cipher pushed we call tls_poor_mans_ncp to determine
whether we can use the server's cipher. Inherited from OpenVPN
2.4's code we only did this check when the ciphers were different.
Since OpenVPN 2.5 does not assume that our cipher we report in OCC
(options->ciphername) is always a valid cipher we always need to perform
this check.

V2: Only call tls_item_in_cipher_list if remote_cipher is non-null to
    avoid calling strcmp with NULL.

Reported-By: Rafael Gava <gava100@gmail.com>
Signed-off-by: Arne Schwabe <arne@rfc2549.org>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20200830131440.10933-1-arne@rfc2549.org>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg20843.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
(cherry picked from commit 6ffe64e34004967a96514cc55abb22215fbe5640)

4 years agoPreparing release 2.5_beta2 v2.5_beta2
Gert Doering [Wed, 26 Aug 2020 12:17:26 +0000 (14:17 +0200)] 
Preparing release 2.5_beta2

version.m4, ChangeLog

Signed-off-by: Gert Doering <gert@greenie.muc.de>
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>
(cherry picked from commit 5e19cc2c1bf22d44f10dc585ba69d48951dc7a86)

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>
(cherry picked from commit 62560e2a29144ffefec231ae7147eb4e9c7dfebf)

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>
(cherry picked from commit 2ab0a92442dce1d82fcb9e2b305313ef668d40bf)

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>
(cherry picked from commit ed47c097db63f8334f32bf9482da488928ff909b)

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>
(cherry picked from commit 2da29362cc93aa1b8c24386e162b9cdd3b55c3b1)

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>
(cherry picked from commit bf911882532f87ae866fc3662bf7e1e136a2195e)

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>
(cherry picked from commit e33f44754a5f81ea013070dba3cdc162f41d1257)

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>
(cherry picked from commit 7e65483d1227adfb855844467e4d30894ffc355d)

4 years agoPreparing release 2.5_beta1 v2.5_beta1
Gert Doering [Wed, 12 Aug 2020 10:30:55 +0000 (12:30 +0200)] 
Preparing release 2.5_beta1

version.m4, ChangeLog, branching off release/2.5 from master.

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>