]> git.ipfire.org Git - thirdparty/openvpn.git/log
thirdparty/openvpn.git
7 years agomanpage: improve description of --status and --status-version 103/head
Gert van Dijk [Sat, 11 Nov 2017 16:11:21 +0000 (17:11 +0100)] 
manpage: improve description of --status and --status-version

Signed-off-by: Gert van Dijk <gert@gertvandijk.net>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20171111161122.30087-1-gert@gertvandijk.net>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg15818.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
(cherry picked from commit 308c9d7f001a97daebcccf503f255947c0e09183)

7 years agoAvoid overflow in wakeup time computation
Selva Nair [Tue, 6 Mar 2018 06:09:28 +0000 (01:09 -0500)] 
Avoid overflow in wakeup time computation

Time interval arithmetic can overflow especially when user
defined intervals are involved. E.g., see Trac #922.

Avoid this by reordering the arithmetic operation in
event_timeout_trigger(). Also avoid unnecessary casting of time
variable to int.

Time until wakeup is now calculated like:

time_t wakeup = (last - now) + delay

Here delay is of type int, but is +ve by construction. Time backtrack
protection in OpenVPN ensures (last - now) <= 0. Then the above
expression cannot overflow (provided time_t is at least as large
as int).

A similar expression in interval.h is also changed.

(This patch grew out of patch 168 by Steffan Karger.)

Trac: #922

Signed-off-by: Selva Nair <selva.nair@gmail.com>
Acked-by: Steffan Karger <steffan.karger@fox-it.com>
Message-Id: <1520316568-8983-1-git-send-email-selva.nair@gmail.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg16634.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
(cherry picked from commit f158c0e1df13ae1b697cdc7f189ddd1575a0c1aa)

7 years agoCheck for more data in control channel
Steffan Karger [Thu, 4 Jan 2018 12:07:50 +0000 (13:07 +0100)] 
Check for more data in control channel

If control channel packets arrive quickly after each other, or out of
order, there might be more data available than we can read in one
tls_process() call.  If that happened, and no further control channel
packet arrived (e.g. because the last two packets arrived out-of-order),
we would wait for 16 second ("coarse timer") before we would read the
remaining data.  To avoid that, always schedule ourself again if there
was control channel data, to check whether more data is available.

For mbedtls, we could implement a slightly more elegant "is there more
data?" function, instead of blindly rescheduling.  But I can't find a way
to implement that for OpenSSL, and the current solution is very simple and
still has quite low overhead.

Signed-off-by: Steffan Karger <steffan.karger@fox-it.com>
Acked-by: David Sommerseth <davids@openvpn.net>
Message-Id: <1515067670-13094-1-git-send-email-steffan.karger@fox-it.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg16151.html
Signed-off-by: David Sommerseth <davids@openvpn.net>
(cherry picked from commit b00d56e1b0cf4d71dc4944ef14ea7eca2fc8c519)

7 years agoManagement: warn about password only when the option is in use
Selva Nair [Mon, 5 Mar 2018 15:28:00 +0000 (10:28 -0500)] 
Management: warn about password only when the option is in use

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

7 years agoMake return code external tls key match docs
Joost Rijneveld [Wed, 28 Feb 2018 13:52:40 +0000 (14:52 +0100)] 
Make return code external tls key match docs

In tls_ctx_use_external_private_key, the return codes were inverted
compared to what is documented in ssl_backend.h (and what can
reasonably be expected). Internally the return code is never checked,
so this did not directly result in any change of behavior.
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20180228135240.22945-1-joost@joostrijneveld.nl>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg16577.html

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

7 years agoAdd missing #ifdef SSL_OP_NO_TLSv1_1/2
Simon Matter [Fri, 2 Mar 2018 07:49:31 +0000 (08:49 +0100)] 
Add missing #ifdef SSL_OP_NO_TLSv1_1/2

Release/2.4 supports older OpenSSL versions than master, so when
cherrypicking f8a92a4393a -> 2d705accea3e53 these code bits should
have received an #ifdef to ensure compatibility (as done for the
same define in other places in 2.4 already).  Add them now.

Signed-off-by: Gert Doering <gert@greenie.muc.de>
Acked-by: Selva Nair <selva.nair@gmail.com>
Message-Id: <52e860ea74ac958309368374049f14bd.squirrel@webmail.bi.invoca.ch>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg16588.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
7 years agoDelete the IPv6 route to the "connected" network on tun close
Selva Nair [Thu, 1 Mar 2018 20:34:44 +0000 (15:34 -0500)] 
Delete the IPv6 route to the "connected" network on tun close

This was missing on Windows when interactive service is in use.

v3: Mar 1, 2017: avoid code repetition and rebase to master

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

7 years agoCorrect version in ChangeLog - should be 2.4.5, was mistyped as 2.4.4
Gert Doering [Thu, 1 Mar 2018 09:11:08 +0000 (10:11 +0100)] 
Correct version in ChangeLog - should be 2.4.5, was mistyped as 2.4.4

Signed-off-by: Gert Doering <gert@greenie.muc.de>
7 years agomanagement: Warn if TCP port is used without password
David Sommerseth [Wed, 28 Feb 2018 13:19:18 +0000 (14:19 +0100)] 
management: Warn if TCP port is used without password

It is not recommended to use --management on a TCP port without also
adding a password authentication, as this can easily be abused by other
users or processes being able to connect to the managmement interface.

Thus issue a warning that this configuration is strongly discouraged.

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

7 years agoPreparing for release v2.4.5 (ChangeLog, version.m4, Changes.rst) v2.4.5
Gert Doering [Wed, 28 Feb 2018 20:56:54 +0000 (21:56 +0100)] 
Preparing for release v2.4.5 (ChangeLog, version.m4, Changes.rst)

Signed-off-by: Gert Doering <gert@greenie.muc.de>
7 years agoDon't throw fatal errors from create_temp_file()
Steffan Karger [Wed, 1 Nov 2017 22:03:41 +0000 (23:03 +0100)] 
Don't throw fatal errors from create_temp_file()

This function is called in response to connecting clients, and can fail
when I/O fails for some (possibly temporary) reason.  In such cases we
should not exit the process, but just reject the connecting client.

This commit changes the function to actually return NULL on errors, and
(where needed) changes the callers to check for and handle errors.

Since the tls-crypt-v2 metadata code also calls create_temp_file() when
clients connect, I consider this a prerequisite for tls-crypt-v2.

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

7 years agoman: Reword --management to prefer unix sockets over TCP
David Sommerseth [Wed, 28 Feb 2018 13:19:17 +0000 (14:19 +0100)] 
man: Reword --management to prefer unix sockets over TCP

It is more secure to use unix sockets instead of TCP ports for the
management interface, so reword it and provide some details why TCP is
not recommended.

Also re-arranged this section to be somewhat easier to read and clearer
on a few related details.

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

7 years agoman: Add .TQ groff support macro
David Sommerseth [Wed, 28 Feb 2018 13:19:16 +0000 (14:19 +0100)] 
man: Add .TQ groff support macro

This introduces the .TQ groff macro.  Even though this can be found
in newer groff versions, not all platforms we support carries this one.

This macro makes it possible to have mulitple lines of options as
headers before describing all of these options in the same segment.

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

7 years agoWarn if tls-version-max < tls-version-min
Steffan Karger [Sat, 24 Feb 2018 17:04:49 +0000 (18:04 +0100)] 
Warn if tls-version-max < tls-version-min

This adds warnings for when a user or our code tries to set a maximum
TLS version that's smaller then the current configured minimum TLS
version.

(And fixes some related whitespace now I touch it anyway.)

Signed-off-by: Steffan Karger <steffan@karger.me>
Acked-by: Selva Nair <selva.nair@gmail.com>
Message-Id: <20180224170449.25194-1-steffan@karger.me>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg16545.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
(cherry picked from commit f8a92a4393aae32fc44e03241b5cc891ca6e58a4)

7 years agombedtls: don't use API deprecated in mbed 2.7
Steffan Karger [Wed, 7 Feb 2018 12:22:46 +0000 (13:22 +0100)] 
mbedtls: don't use API deprecated in mbed 2.7

The void-returning mbedtls_sha256() was deprecated in mbed TLS 2.7.
Use our own md_full() abstraction instead.

(The new function can theoretically fail, but only in case of highly
unlikely digest function failures.  The personalisation on random using
the certificate is a best-effort measure, so we simply log a warning and
skip the personalisation if such highly unlikely errors occur.)

Signed-off-by: Steffan Karger <steffan.karger@fox-it.com>
Acked-by: Antonio Quartulli <a@unstable.cc>
Message-Id: <1518006166-14285-1-git-send-email-steffan.karger@fox-it.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg16445.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
(cherry picked from commit f22e89bd2311d3cab511e574746c6f82f1fa1a54)

7 years agoFix removal of on-link prefix on windows with netsh
Gert Doering [Tue, 20 Feb 2018 16:00:16 +0000 (17:00 +0100)] 
Fix removal of on-link prefix on windows with netsh

When adding / removing IPv6 routes, the host bits need to be zeroed or
netsh.exe will refuse to handle the route.

Commit a24dd2e31 changed the way this is done, breaking removal of
the on-link IPv6 prefix for windows + netsh.exe.

Fix by adding explicitly calling route_ipv6_clear_host_bits() from
delete_route_connected_v6_net().

Trac: #1003

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

7 years agoFix format spec errors in Windows builds
Selva Nair [Thu, 22 Feb 2018 04:33:37 +0000 (23:33 -0500)] 
Fix format spec errors in Windows builds

- Correct an instance of %s used for wchar_t * (should be %ls)
  and some %d for DWORD or %lu for int.
- Cast socket descriptor to (int) during i/o as its unsigned int
  or int64 in Windows but signed int in other platforms.

Signed-off-by: Selva Nair <selva.nair@gmail.com>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <1519274017-19921-1-git-send-email-selva.nair@gmail.com>
URL: https://www.mail-archive.com/search?l=mid&q=1519274017-19921-1-git-send-email-selva.nair@gmail.com
Signed-off-by: Gert Doering <gert@greenie.muc.de>
7 years agomanpage: fix simple typ0
Antonio Quartulli [Fri, 12 Jan 2018 09:14:14 +0000 (17:14 +0800)] 
manpage: fix simple typ0

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

7 years agoGet rid of ax_check_compile_flag.m4
Steffan Karger [Tue, 20 Feb 2018 20:25:08 +0000 (21:25 +0100)] 
Get rid of ax_check_compile_flag.m4

The macro was too new for some of the platforms we still support.  In
particular, centos/rhel 6 and opensolaris 10.  To work around that, we
introduce our own simpler and more tailored ACL_CHECK_ADD_COMPILE_FLAGS
macro, that not only checks but also sets the flags in CFLAGS if it is
accepted.  Since this doesn't use new-and-shine autoconf features, it
should also work on the legacy platforms.

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

7 years agoAdapt to RegGetValue brokenness in Windows 7
Selva Nair [Wed, 21 Feb 2018 05:38:30 +0000 (00:38 -0500)] 
Adapt to RegGetValue brokenness in Windows 7

- RegGetValue with flags = RRF_RT_REG_SZ|RRF_RT_REG_EXPAND_SZ
  fails in Windows 7 with an "invalid parameter" error.
  Fix by using RRF_RT_REG_SZ alone.

Note: This is not a regression as in no released version did the
service support expandable strings (ones with embedded %FOO%) in
the registry. However, the GUI does expand such strings. The two
can be made consistent by explicitly expanding the strings -- that
is left for a future patch.

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

7 years agotravis-ci: modify openssl build script to support openssl-1.1.0
Ilya Shipitsin [Mon, 15 Jan 2018 08:05:55 +0000 (13:05 +0500)] 
travis-ci: modify openssl build script to support openssl-1.1.0

get rid of no-multilib, as it is not supported on openssl-1.1.0

Signed-off-by: Ilya Shipitsin <chipitsine@gmail.com>
Acked-by: Steffan Karger <steffan.karger@fox-it.com>
Message-Id: <20180115080555.18202-1-chipitsine@gmail.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg16229.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
(cherry picked from commit 437be780996501becb18f0d34c256ab9c9fe27af)

7 years agoUse lowest metric interface when multiple interfaces match a route
Selva Nair [Wed, 24 Jan 2018 17:31:45 +0000 (12:31 -0500)] 
Use lowest metric interface when multiple interfaces match a route

Currently a route addition using IPAPI or service is skipped if the
route gateway is reachable by multiple interfaces. This changes that
to use the interface with lowest metric. Implemented by

(i)  Do not over-write the return value with TUN_ADAPTER_INDEX_INVALID in
     windows_route_find_if_index() if multiple interfaces match a route.
(ii) Select the interface with lowest metric in adapter_index_of_ip()
     instead of the first one found when multiple interfaces match.

Reported by Jan Just Keijser <janjust@nikhef.nl>

Signed-off-by: Selva Nair <selva.nair@gmail.com>
Tested-by: Jan Just Keijser <janjust@nikhef.nl>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <1516815105-17882-1-git-send-email-selva.nair@gmail.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg16347.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
(cherry picked from commit 3854d4040e0d6fd2a58292e8bb1c1fbae5c17bb1)

7 years agoMake most registry values optional
Selva Nair [Sat, 18 Nov 2017 17:40:58 +0000 (12:40 -0500)] 
Make most registry values optional

Not all installations need registry values such as log_dir and
config_dir especially if automatic service is not in use.
This patch provides reasonable defaults for registry values.

- Read the default value of HKLM\Software\PACKAGE_NAME to get the
  install path and construct defaults for exe_path, config_dir,
  log_dir from it. Use "ovpn", "0", NORMAL_PRIORITY as the defaults
  for config file extension, log-append flag and process priority.

The only remaining required registry entry is the root key (usually
HKLM\Software\OpenVPN) whose default value should be set to the
installation path.

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

7 years agoEnsure strings read from registry are null-terminated
Selva Nair [Sat, 18 Nov 2017 17:40:57 +0000 (12:40 -0500)] 
Ensure strings read from registry are null-terminated

- Strings stored in registry are not guaranteed to be null-terminated.
  So, use RegGetValue() instead of RegQueryValueEx() as the former
  adds null termination to the returned string if missing.
  (Needs Windows Vista+)

- While at it also add a default value parameter to GetRegString()
  to process optional registry values (such as ovpn_admin_group)
  without causing an otherwise confusing error logged to the
  eventlog[*].

[*] see Trac: #892

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

7 years agoshow the right string for key-direction
Arne Schwabe [Wed, 31 Jan 2018 09:53:00 +0000 (10:53 +0100)] 
show the right string for key-direction

V2: print also a nice string if direction is not set
V3: really include V2 changes
Acked-by: Steffan Karger <steffan.karger@fox-it.com>
Message-Id: <1517392380-21597-1-git-send-email-arne@rfc2549.org>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg16415.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
(cherry picked from commit 7f7f00da88eeea847da57f4f34c66c1f4a935a73)

7 years agoEnable stricter compiler warnings by default
Steffan Karger [Thu, 1 Feb 2018 15:45:21 +0000 (16:45 +0100)] 
Enable stricter compiler warnings by default

This by default enables the compiler warnings one could previously
enable using the --enable-strict configure option.  I think it is
okay to do so now, because we've taken care of many warnings in the
more standard builds.  (Most of those were totally harmless, but they
prevented us from spotting new more serious mistakes.)

The --enable-strict flag now enables two extra warning flags that I
think can be useful:

-Wsign-compare warns when the compiler promotes a signed type to
unsigned before comparing, which can lead to unexpected behaviour.

-Wuninitialized adds extra warnings about usage of uninitialized variables
or struct elements.

Signed-off-by: Steffan Karger <steffan@karger.me>
Acked-by: Selva Nair <selva.nair@gmail.com>
Message-Id: <20180201154521.7642-1-steffan@karger.me>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg16426.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
(cherry picked from commit adbf68c00bf40089489c5e039138f855fc5e2392)

7 years agoLog pre-handshake packet drops using D_MULTI_DROPPED
Steffan Karger [Sun, 11 Feb 2018 10:19:29 +0000 (11:19 +0100)] 
Log pre-handshake packet drops using D_MULTI_DROPPED

We have a debug level packets dropped by the TLS layer - use that for this
packet drop too.  This changes this message from 'verb 3' to 'verb 4'
(which should result in less user reports about this almost always
harmless warning).

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

7 years agoFix format errors when cross-compiling for Windows
Steffan Karger [Fri, 16 Feb 2018 13:45:39 +0000 (14:45 +0100)] 
Fix format errors when cross-compiling for Windows

Not all supported windows formatting libs are C99 compliant and some do not
grasp %ll (similar to %zu).  Use int64_t and PRIi64 to work around that.

Signed-off-by: Steffan Karger <steffan.karger@fox-it.com>
Acked-by: Selva Nair <selva.nair@gmail.com>
Message-Id: <1518788739-16610-1-git-send-email-steffan.karger@fox-it.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg16478.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
7 years agoTreat dhcp-option DNS6 and DNS identical
Arne Schwabe [Wed, 31 Jan 2018 09:41:02 +0000 (10:41 +0100)] 
Treat dhcp-option DNS6 and DNS identical

OpenVPN3 accepts both IPv4 and IPv6 with option-dhcp DNS but throws
an error for option-dhcp DNS6.

This patch makes OpenVPN2 accept IPv4/IPv6 for both DNS and DNS6

V2: Put IPv6 parsing logic into own function similar as for for IPv4 DNS
V3: more documentation / help message adjustments

Acked-by: Selva Nair <selva.nair@gmail.com>
Message-Id: <1517391662-21325-1-git-send-email-arne@rfc2549.org>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg16413.html

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

7 years agoUpdate copyright to include 2018 plus company name change
David Sommerseth [Wed, 31 Jan 2018 14:03:14 +0000 (15:03 +0100)] 
Update copyright to include 2018 plus company name change

The autumn of 2017, OpenVPN Technologies, Inc changed name to just
OpenVPN Inc.  Otherwise, extend the copyright to cover 2018 as well.

With the exception of the company name change, all changes have been
performed by the dev-tools/update-copyright.sh script.

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

7 years agoRefactor get_interface_metric to return metric and auto flag separately
Selva Nair [Wed, 6 Dec 2017 04:28:41 +0000 (23:28 -0500)] 
Refactor get_interface_metric to return metric and auto flag separately

- Instead of returning metric = 0 when automatic metric is in use
  return the actual metric and flag automatic metric through a
  parameter. This makes the function reusable elsewhere.

- Ensure return value can be correctly cast to int and return -1 on
  error.

Signed-off-by: Selva Nair <selva.nair@gmail.com>
Acked-by: Simon Rozman <simon@rozman.si>
Message-Id: <1512534521-14760-1-git-send-email-selva.nair@gmail.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg16039.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
(cherry picked from commit 4229243563bcb22990f71d50e25be9ea6d44f519)

7 years agoPlug memory leak if push is interrupted
Steffan Karger [Wed, 17 Jan 2018 13:16:24 +0000 (14:16 +0100)] 
Plug memory leak if push is interrupted

If a push is interrupted due to a timeout, c->c2.pulled_options_state is
never freed.  Fix that by always cleaning up any remaining pulled
options state when we close a connection.

This changes the mbedtls implementation of md_ctx_cleanup to actually
clean up the context, which was not needed earlier.

Signed-off-by: Steffan Karger <steffan.karger@fox-it.com>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <1516194984-1540-1-git-send-email-steffan.karger@fox-it.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg16265.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
(cherry picked from commit 07036fd3c456ed4ebf1809d8d9f34941d42865d0)

7 years agoDocument missing OpenVPN states
Simon Rozman [Mon, 15 Jan 2018 11:47:28 +0000 (12:47 +0100)] 
Document missing OpenVPN states

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

7 years agoTLS v1.2 support for cryptoapicert -- RSA only
Selva Nair [Sat, 20 Jan 2018 04:52:54 +0000 (23:52 -0500)] 
TLS v1.2 support for cryptoapicert -- RSA only

- If an NCRYPT handle for the private key can be obtained, use
  NCryptSignHash from the Cryptography NG API to sign the hash.

  This should work for all keys in the Windows certifiate stores
  but may fail for keys in a legacy token, for example. In such
  cases, we disable TLS v1.2 and fall back to the current
  behaviour. A warning is logged unless TLS version is already
  restricted to <= 1.1

Signed-off-by: Selva Nair <selva.nair@gmail.com>
Acked-by: Steffan Karger <steffan.karger@fox-it.com>
Message-Id: <1516423974-22159-1-git-send-email-selva.nair@gmail.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg16288.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
(cherry picked from commit 51d57d7dad6c6380df7b76bbec1897ea4f98474d)

7 years agoAdd SSL_CTX_get_max_proto_version() not in openssl 1.0
Selva Nair [Sat, 20 Jan 2018 17:11:34 +0000 (12:11 -0500)] 
Add SSL_CTX_get_max_proto_version() not in openssl 1.0

- No change in functionality. This is used in a subsequent
  patch for extending TLS1.2 support with cryptoapicert

Signed-off-by: Selva Nair <selva.nair@gmail.com>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <1516468294-32635-1-git-send-email-selva.nair@gmail.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg16304.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
(cherry-picked with 2.4/0.9.8 amendments from commit
 9e272106029a41b2110c10334ba8cae0f4afb1b4)

7 years agoAdd support for TLS 1.3 in --tls-version-{min, max}
Steffan Karger [Sun, 26 Nov 2017 14:15:54 +0000 (15:15 +0100)] 
Add support for TLS 1.3 in --tls-version-{min, max}

Tested with the current openssl master branch for TLS 1.3 support.

mbed TLS has no public builds with TLS 1.3 support yet, so nothing to do
there right now.

Signed-off-by: Steffan Karger <steffan@karger.me>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20171126141555.25930-2-steffan@karger.me>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg15932.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
(cherry picked from commit 8ca9eda119638a88863118affd69dfaf8b867c92)

7 years agoFix --tls-version-min and --tls-version-max for OpenSSL 1.1+
Steffan Karger [Sat, 20 Jan 2018 09:42:28 +0000 (10:42 +0100)] 
Fix --tls-version-min and --tls-version-max for OpenSSL 1.1+

As described in <80e6b449-c536-dc87-7215-3693872bce5a@birkenwald.de> on
the openvpn-devel mailing list, --tls-version-min no longer works with
OpenSSL 1.1.  Kurt Roeckx posted in a debian bug report:

"This is marked as important because if you switch to openssl 1.1.0
the defaults minimum version in Debian is currently TLS 1.2 and
you can't override it with the options that you're currently using
(and are deprecated)."

This patch is loosely based on the original patch by Kurt, but solves the
issue by adding functions to openssl-compat.h, like we also did for all
other openssl 1.1. breakage.  This results in not having to add more ifdefs
in ssl_openssl.c and thus cleaner code.

Signed-off-by: Steffan Karger <steffan@karger.me>
Acked-by: Selva Nair <selva.nair@gmail.com>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20180120094228.13285-1-steffan@karger.me>
URL: https://www.mail-archive.com/search?l=mid&q=20180120094228.13285-1-steffan@karger.me
Signed-off-by: Gert Doering <gert@greenie.muc.de>
(cherry picked with 2.4 amendments from commit 0e8a30c0b05c1e2b59a1dea0a6eab5daa1d9d9a1)

7 years agoBring cryptoapi.c upto speed with openssl 1.1 101/head
Selva Nair [Sun, 14 Jan 2018 19:04:22 +0000 (14:04 -0500)] 
Bring cryptoapi.c upto speed with openssl 1.1

- Replace direct access to internals of openssl structs
  by corresponding methods.

v2: Remove the call to EVP_PKEY_id() as its slated for removal
    from the compat layer (see also review by Stefan)

Signed-off-by: Selva Nair <selva.nair@gmail.com>
Acked-by: Steffan Karger <steffan.karger@fox-it.com>
Message-Id: <1515956662-30572-1-git-send-email-selva.nair@gmail.com>
URL: https://www.mail-archive.com/search?l=mid&q=1515956662-30572-1-git-send-email-selva.nair@gmail.com
Signed-off-by: Gert Doering <gert@greenie.muc.de>
(cherry picked from commit 862cbe538b6d53435f60065b0235639095c9ad0d)

7 years agoUse RSA_meth_free instead of free
Selva Nair [Sat, 13 Jan 2018 23:00:46 +0000 (18:00 -0500)] 
Use RSA_meth_free instead of free

- RSA_meth_new allocates memory for the name string
  and must be released using RSA_meth_free

Signed-off-by: Selva Nair <selva.nair@gmail.com>
Acked-by: Emmanuel Deloget <logout@free.fr>
Acked-by: Steffan Karger <steffan.karger@fox-it.com>
Message-Id: <1515884446-27152-1-git-send-email-selva.nair@gmail.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg16207.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
(cherry picked from commit 508741c1cf99b8a24205601800fa5056c6d0192b)

7 years agoOpenSSL: check EVP_PKEY key types before returning the pkey
Emmanuel Deloget [Fri, 12 Jan 2018 16:48:24 +0000 (17:48 +0100)] 
OpenSSL: check EVP_PKEY key types before returning the pkey

The internal EVP_PKEY::pkey member is an union thus we need to check for
the real key type before we can return the corresponding RSA, DSA or EC
public key.

Reported-by: Selva Nair <selva.nair@gmail.com>
Signed-off-by: Emmanuel Deloget <logout@free.fr>
Acked-by: Steffan Karger <steffan.karger@fox-it.com>
Message-Id: <e8333f0b838670e558a9fe292cea8988484cd77f.1515775195.git.logout@free.fr>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg16202.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
(cherry picked from commit e603afabb845d2552198843a987b5d9b0b7ac404)

7 years agotravis: use clang's -fsanitize=address to catch more bugs
Steffan Karger [Fri, 29 Dec 2017 09:47:37 +0000 (10:47 +0100)] 
travis: use clang's -fsanitize=address to catch more bugs

The clang address sanitizer is able to catch quite a number of
memory-related bugs, such add memory leaks and buffer under/overruns.
So, enable the address sanitizer for one openssl and one mbedtls build.

This would have caught the buffer list unittest memory leak that
<1512724338-22197-1-git-send-email-steffan@karger.me> wants to fix.

Signed-off-by: Steffan Karger <steffan.karger@fox-it.com>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <1514540857-19290-1-git-send-email-steffan.karger@fox-it.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg16102.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
(cherry picked from commit 7b11915ddfe97d8c28f998db54c40384a4eafb93)

7 years agotravis-ci: add brew cache, remove ccache
Ilya Shipitsin [Thu, 4 Jan 2018 19:37:10 +0000 (00:37 +0500)] 
travis-ci: add brew cache, remove ccache

1-2 minutes speedup osx builds by using brew cache.
Also, ccache was removed for a while (builds fail
after travis-ci upgraded clang to version 5.0.0)
Acked-by: Steffan Karger <steffan.karger@fox-it.com>
Message-Id: <20180104193710.23778-1-chipitsine@gmail.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg16154.html

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

7 years agossl_openssl: fix compiler warning by removing getbio() wrapper
Steffan Karger [Thu, 14 Dec 2017 10:21:37 +0000 (11:21 +0100)] 
ssl_openssl: fix compiler warning by removing getbio() wrapper

An API change in openssl 1.1 made the BIO_METHOD * returned by BIO_f_ssl()
and BIO_s_mem() const, as well as the BIO_METHOD * argment of BIO_new()
const.  This meant that our getbio() function would either have an API
inconsistent with 1.0 or 1.1.

The wrapper was basically an ASSERT, so fix this by replacing the wrapper
with an ASSERT.

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

7 years agoFix types around buffer_list_push(_data)
Steffan Karger [Wed, 10 Jan 2018 08:34:19 +0000 (09:34 +0100)] 
Fix types around buffer_list_push(_data)

In C, strings are char pointers, not unsigned char pointers.  And
arbitrary data is represented by a void pointer.  Change buffer_list_push
and buffer_list_push_data to follow these rules, and remove any now
unneeded casts.

Signed-off-by: Steffan Karger <steffan.karger@fox-it.com>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <1515573259-20968-1-git-send-email-steffan.karger@fox-it.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg16186.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
(cherry picked from commit b395f36e578b2def9da8e9347c0afa79814c0c7d)

7 years agobuffer_list_aggregate_separator(): prevent 0-byte malloc
Steffan Karger [Fri, 29 Dec 2017 09:54:00 +0000 (10:54 +0100)] 
buffer_list_aggregate_separator(): prevent 0-byte malloc

As pointed out in finding OVPN-05 of the cryptograpy engineering audit
(funded by Private Internet Access), buffer_list_aggregate_separator()
could perform a 0-byte malloc when called with a list of 0-length buffers
and a "" separator.  If other could would later try to access that buffer
memory, this would result in undefined behaviour.  To prevent this, always
malloc() 1 byte.

To simplify as we go, use alloc_buf() to allocate the buffer.  This has
the additional benefit that the actual buffer data (not the contents) is
zero-terminated, because alloc_buf() calls calloc() and we have 1 extra
byte of data.

Signed-off-by: Steffan Karger <steffan.karger@fox-it.com>
Acked-by: Antonio Quartulli <antonio@openvpn.net>
Message-Id: <1514541240-19536-1-git-send-email-steffan.karger@fox-it.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg16106.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
(cherry picked from commit 748902f46260fe11cb25726d2bf93bb06ad338f2)

7 years agobuffer_list_aggregate_separator(): don't exceed max_len
Steffan Karger [Fri, 29 Dec 2017 09:53:11 +0000 (10:53 +0100)] 
buffer_list_aggregate_separator(): don't exceed max_len

buffer_list_aggregate_separator() would merge buffer_list entries until it
had exceeded the provided max_len, instead of stopping *before* exceeding
the max value.

Signed-off-by: Steffan Karger <steffan.karger@fox-it.com>
Acked-by: Antonio Quartulli <antonio@openvpn.net>
Message-Id: <1514541191-19471-1-git-send-email-steffan.karger@fox-it.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg16104.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
(cherry picked from commit fb6138dd32cf01922d7ef670d502148596511268)

7 years agobuffer_list_aggregate_separator(): update list size after aggregating
Steffan Karger [Fri, 29 Dec 2017 09:52:24 +0000 (10:52 +0100)] 
buffer_list_aggregate_separator(): update list size after aggregating

After aggregating a buffer_list, the size should be adjusted accordingly.

Signed-off-by: Steffan Karger <steffan.karger@fox-it.com>
Acked-by: Antonio Quartulli <antonio@openvpn.net>
Message-Id: <1514541144-19407-1-git-send-email-steffan.karger@fox-it.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg16103.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
(cherry picked from commit 463afdf57c52891936b9a856e1030b7ebc55e75c)

7 years agoFix typo in error message: "optione" -> "option"
Bertrand Bonnefoy-Claudet [Tue, 2 Jan 2018 14:09:38 +0000 (15:09 +0100)] 
Fix typo in error message: "optione" -> "option"

Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20180102140938.16467-1-bertrandbc@gmail.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg16131.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
(cherry picked from commit f447bc63c3928fd9b71e3df3768900a328f4f41a)

7 years agoReturn NULL if GetAdaptersInfo fails
Selva Nair [Wed, 3 Jan 2018 04:02:03 +0000 (23:02 -0500)] 
Return NULL if GetAdaptersInfo fails

- Currently a pointer to potentially uninitialized IP_ADAPTER_INFO
  struct is returned on error causing ill-defined behaviour.

Signed-off-by: Selva Nair <selva.nair@gmail.com>
Acked-by: Steffan Karger <steffan.karger@fox-it.com>
Acked-by: Simon Rozman <simon@rozman.si>
Message-Id: <1514952123-26616-1-git-send-email-selva.nair@gmail.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg16139.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
(cherry picked from commit 5050c5b1ec3f2aa04140ab83f2498b3329381ee4)

7 years agoFix memory leak in buffer unit tests
Steffan Karger [Fri, 8 Dec 2017 09:12:18 +0000 (10:12 +0100)] 
Fix memory leak in buffer unit tests

buffer_list_push_data does not take ownership of the memory, so just feed
it stack data to plug the leak.

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

7 years agombedtls: fix typ0 in comment 100/head
Antonio Quartulli [Tue, 5 Dec 2017 08:57:11 +0000 (16:57 +0800)] 
mbedtls: fix typ0 in comment

the function used to set the verify callback in mbedTLS is
actually called mbedtls_ssl_conf_verify() and it is invoked
in key_state_ssl_init().

Fix comment accordingly.

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

7 years agoAllow learning iroutes with network made up of all 0s (only if netbits < 8)
Antonio Quartulli [Wed, 6 Dec 2017 15:43:56 +0000 (23:43 +0800)] 
Allow learning iroutes with network made up of all 0s (only if netbits < 8)

It is plausible for a user to be willing to add a route for a network
made up of all 0s via a VPN client (i.e. 0.0.0.0/1), therefore such
iroute should be supported.

As of now the option parsing code will accept such iroute, but
the learning routine will (silently) reject it after a sanity check.

Such check prevents routes with network made up of all 0s to be
learnt at all..

Change the sanity check so that it will reject iroutes to network
made up of 0s only when netbits is greater than 7.

The reason for choosing 7 is because anything within 0.0.0.0/8 is not
really routable among networks.

While at it, make the sanity check louder so that it can print the
reason why a route is being rejected.

Trac: #726
Signed-off-by: Antonio Quartulli <a@unstable.cc>
Acked-by: David Sommerseth <davids@openvpn.net>
Message-Id: <20171206154356.30764-1-a@unstable.cc>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg16044.html
Signed-off-by: David Sommerseth <davids@openvpn.net>
(cherry picked from commit a19c56db9bd42b7b8c4a8f353f7db92781397cec)

7 years agoreload HTTP proxy credentials when moving to the next connection profile
Antonio Quartulli [Mon, 4 Dec 2017 04:49:07 +0000 (12:49 +0800)] 
reload HTTP proxy credentials when moving to the next connection profile

The HTTP proxy credentials are stored in a static variable that is
possibly initialized before each connection attempt.

However, the variable is never "released" therefore get_user_pass()
refuses to overwrite its content and leaves it as it is.
Consequently, if the user config contains multiple connection profiles
with different http-proxy, each having its own credentials, only the
first user/pass couple is loaded and the others are all ignored.
This leads to connection failures because the proper credentials are
not associated with the right proxy server.

The root of the misbehaviour seems to be located in the fact that,
despite the argument force passed to get_user_pass_http() being true,
no action is taken to release the static object containing the
credentials.

Fix the misbehaviour by releasing the http-proxy credential object
when the reload is "forced".

Trac: #836
Signed-off-by: Antonio Quartulli <a@unstable.cc>
Acked-by: Steffan Karger <steffan@karger.me>
Tested-by: David Sommerseth <davids@openvpn.net>
Acked-by: David Sommerseth <davids@openvpn.net>
Message-Id: <20171204044907.32261-1-a@unstable.cc>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg16007.html
Signed-off-by: David Sommerseth <davids@openvpn.net>
(cherry picked from commit 86b58ceb29cf1cc3acf32e2ff370d9a4af68c051)

7 years agoopenvpnserv: Add support for multi-instances
Simon Rozman [Sun, 3 Dec 2017 21:16:54 +0000 (22:16 +0100)] 
openvpnserv: Add support for multi-instances

While openvpn.exe can run multiple concurrent processes, openvpnserv.exe
is usually only one single globally unique running process.

This patch extends openvpnserv.exe to support multiple service instances
in parallel allowing side-by-side OpenVPN installations.

Alternate instances must be installed as `SERVICE_WIN32_OWN_PROCESS`
(Type 0x10) and must use the newly introduced service command line
parameter:
-instance <name> <id>
<name> can be `automatic` or `interactive`.

- The service settings will be loaded from `HKLM\Software\OpenVPN<id>`
  registry key.

- The automatic service will use `openvpn<id>_exit_1` exit event.

- The interactive service will accept requests on
  `\\.\pipe\openvpn<id>\service` named pipe, and run IPC with
  openvpn.exe on `\\.\pipe\openvpn<id>\service_<pid>`.

This patch preserves backward compatibility, by defaulting to
`SERVICE_WIN32_SHARE_PROCESS` and `<empty string>` as service ID.

Acked-by: Selva Nair <selva.nair@gmail.com>
Message-Id: <20171203211654.1044-1-simon@rozman.si>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg16002.html

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

7 years agoUse P_DATA_V2 for server->client packets too
Steffan Karger [Fri, 24 Nov 2017 13:58:23 +0000 (14:58 +0100)] 
Use P_DATA_V2 for server->client packets too

P_DATA_V2 introduced the peer-id.  This allows clients to float, but as a
side-effect 32-bit aligns the encrypted data.  That alignment improves
performance particularly on cheaper/older CPUs.  So although servers don't
actually have a peer-id, still use the V2 packet format (with a zero-id)
for server->client traffic too.

Signed-off-by: Steffan Karger <steffan@karger.me>
Acked-by: Antonio Quartulli <antonio@openvpn.net>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <1511531903-19349-1-git-send-email-steffan.karger@fox-it.com>
URL: https://www.mail-archive.com/search?l=mid&q=1511531903-19349-1-git-send-email-steffan.karger@fox-it.com
Signed-off-by: Gert Doering <gert@greenie.muc.de>
(cherry picked from commit 3b9cce657b0ba876c56ee6f14664a8a77f5b82d5)

7 years agoFix build with LibreSSL
Jeremie Courreges-Anglas [Sun, 19 Nov 2017 21:57:56 +0000 (22:57 +0100)] 
Fix build with LibreSSL

Detect the presence of SSL_CTX_set_security_level(), don't check
OPENSSL_VERSION_NUMBER.

Signed-off-by: Jeremie Courreges-Anglas <jca@wxcvbn.org>
Acked-by: Steffan Karger <steffan.karger@fox-it.com>
Message-Id: <8760a6kjwc.fsf@ritchie.wxcvbn.org>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg15902.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
7 years agoAdd --tls-cert-profile option.
Steffan Karger [Sun, 12 Nov 2017 16:36:36 +0000 (17:36 +0100)] 
Add --tls-cert-profile option.

This allows the user to specify what certificate crypto algorithms to
support.  The supported profiles are 'preferred', 'legacy' (default) and
'suiteb', as discussed in <84590a17-1c48-9df2-c48e-4160750b2e33@fox-it.com>
(https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg14214.
html).

This fully implements the feature for mbed TLS builds, because for mbed it
is both more easy to implement and the most relevant because mbed TLS 2+
is by default somewhat restrictive by requiring 2048-bit+ for RSA keys.

For OpenSSL, this implements an approximation based on security levels, as
discussed at the hackathon in Karlsruhe.

This patch uses 'legacy' as the default profile following discussion on
the openvpn-devel mailing list.  This way this patch can be applied to
both the release/2.4 and master branches.  I'll send a follow-up patch for
the master branch to change the default to 'preferred' later.

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

7 years agoRemove warning on pushed tun-ipv6 option.
Gert Doering [Sat, 11 Nov 2017 14:22:30 +0000 (15:22 +0100)] 
Remove warning on pushed tun-ipv6 option.

tun-ipv6 is a no-op nowadays, and we print a warning to let users know -
which is not helpful for server-pushed tun-ipv6 (which might be the
result of --server-ipv6 automatically pushing this).  So, remove the
warning if parsing pushed options.

Also, remove the VERIFY_PERMISSION() call here which has side effects
on the "which class of options got pushed, do we need to act on them
later on?" flag set.

v2: use existing pull_mode flag

Signed-off-by: Gert Doering <gert@greenie.muc.de>
Acked-by: Steffan Karger <steffan.karger@fox-it.com>
Acked-by: Arne Schwabe <arne@rfc2549.org>
Message-Id: <20171111142230.3288-1-gert@greenie.muc.de>
URL: https://www.mail-archive.com/search?l=mid&q=20171111142230.3288-1-gert@greenie.muc.de
Signed-off-by: Gert Doering <gert@greenie.muc.de>
(cherry picked from commit 7a216d9dba558281d4b6a04124912081a79fcb88)

7 years agobuffer_list_aggregate_separator(): add unit tests
Steffan Karger [Sat, 4 Nov 2017 22:45:50 +0000 (23:45 +0100)] 
buffer_list_aggregate_separator(): add unit tests

Before refactoring this function, add tests to verify the new
implementation.

While writing the tests, it became clear that this function is not
behaving very well.  We'll fix that in follow-up commits.

Signed-off-by: Steffan Karger <steffan.karger@fox-it.com>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20171104224551.3079-1-steffan@karger.me>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg15748.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
(cherry picked from commit 2ddb527abe38f5866ff01e91f8ee89d0f9700762)

7 years agosystemd: Add and ship README.systemd
David Sommerseth [Mon, 27 Mar 2017 22:16:20 +0000 (00:16 +0200)] 
systemd: Add and ship README.systemd

This new README file describes how to use the new
openvpn-client@.service and openvpn-server@.service unit files properly.

The purpose of this file is primarily for all systemd based
distributions to have a common set of documentation.

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

7 years agoMSVC meta files added to .gitignore list
Simon Rozman [Tue, 10 Oct 2017 23:11:25 +0000 (01:11 +0200)] 
MSVC meta files added to .gitignore list

Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20171010231130.6832-8-simon@rozman.si>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg15585.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
(cherry picked from commit 289ba682c70f9ea801fabca297115409acc437c9)

7 years agoUniform swprintf() across MinGW and MSVC compilers
Simon Rozman [Fri, 13 Oct 2017 09:50:08 +0000 (11:50 +0200)] 
Uniform swprintf() across MinGW and MSVC compilers

Legacy _snwprintf() and snwprintf() functions replaced with ISO C
swprintf().

Assigning _snwprintf() return value to unused variable was also removed
at one occasion.
Acked-by: Selva Nair <selva.nair@gmail.com>
Message-Id: <20171013095008.8288-1-simon@rozman.si>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg15633.html

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

7 years agoFix typo in "verb" command examples
Simon Rozman [Wed, 11 Oct 2017 13:49:02 +0000 (15:49 +0200)] 
Fix typo in "verb" command examples

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

7 years agoDocument ">PASSWORD:Auth-Token" real-time message
Simon Rozman [Wed, 11 Oct 2017 13:45:30 +0000 (15:45 +0200)] 
Document ">PASSWORD:Auth-Token" real-time message

Authentication tokens are security enhancement eliminating client
need to cache passwords, and are indispensable at two factor
authentication methods, such as HOTP or TOTP.

The ">PASSWORD:Auth-Token" message was not mentioned anywhere in
the OpenVPN Management Interface Notes. This patch adds a simple use
case example, while the more detailed feature description remains
explained in the OpenVPN manual.
Acked-by: David Sommerseth <davids@openvpn.net>
Message-Id: <20171011134530.6676-1-simon@rozman.si>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg15599.html

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

7 years agoFix local #include to use quoted form
Simon Rozman [Thu, 12 Oct 2017 10:34:48 +0000 (12:34 +0200)] 
Fix local #include to use quoted form

.h include files from the same folder or addressed relatively to the
same folder should be #included using quoted form in MSVC. The angled
form is reserved for include files from folders specified using /I
path.

Using angled form, MSVC fails to locate local #include file, unless
current folder is added to the include search path: /I .
Acked-by: Selva Nair <selva.nair@gmail.com>
Message-Id: <20171012103448.7632-1-simon@rozman.si>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg15622.html

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

7 years agoCast time_t to long long in order to print it.
Jeremie Courreges-Anglas [Wed, 4 Oct 2017 23:43:33 +0000 (01:43 +0200)] 
Cast time_t to long long in order to print it.

time_t is only specified as an integer type per POSIX.  To reliably
print it, better cast it to "long long", which is at least 64 bits wide
and can represent values beyond 2038.

Printing as a "long" could cause problems on ILP32 systems using a 64
bits time_t (eg OpenBSD/armv7).

Signed-off-by: Jeremie Courreges-Anglas <jca@wxcvbn.org>
Acked-by: Steffan Karger <steffan.karger@fox-it.com>
Message-Id: <87efq4havl.fsf@ritchie.wxcvbn.org>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg15640.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
(cherry picked from commit 4ac769fb848619dcb39589af29302d8c2d698258)

7 years agoautoconf: Fix engine checks for openssl 1.1
James Bottomley [Sun, 29 Oct 2017 15:34:48 +0000 (15:34 +0000)] 
autoconf: Fix engine checks for openssl 1.1

In openssl 1.1, ENGINE_cleanup became a #define instead of a function
(because it's no longer needed as engines are self cleaning).  Update
the autoconf.ac script to check for ENGINE_cleanup as a declaration to
avoid falsely undefinig HAVE_OPENSSL_ENGINE in openssl 1.1+

Signed-off-by: James Bottomley <James.Bottomley@HansenPartnership.com>
Acked-by: Steffan Karger <steffan.karger@fox-it.com>
Message-Id: <1509291288.3116.14.camel@HansenPartnership.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg15676.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
(cherry picked from commit 6b5dbf6c8da0ff82fa1dca4eb4665be0a4fe31d3)

7 years agolz4: Rebase compat-lz4 against upstream v1.7.5
David Sommerseth [Tue, 21 Feb 2017 19:27:36 +0000 (20:27 +0100)] 
lz4: Rebase compat-lz4 against upstream v1.7.5

This rebase is done using the new lz4-rebaser.sh tool

The lz4 v1.7.5 is based on commit 7bb64ff2b69a9f8367 in
git://github.com/lz4/lz4

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

7 years agoRemove references to keychain-mcd in Changes.rst
David Sommerseth [Thu, 5 Oct 2017 21:22:23 +0000 (23:22 +0200)] 
Remove references to keychain-mcd in Changes.rst

In commit 59e7e9fce8de6ea90d13baeaede83adc0b594e22 the contrib/keychain-mcd
code was completely removed.  But it was not removed from Changes.rst.

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

7 years agoFix missing check for return value of malloc'd buffer
Selva Nair [Sun, 15 Oct 2017 19:05:15 +0000 (15:05 -0400)] 
Fix missing check for return value of malloc'd buffer

- Use utf8to16 from common.c for utf8 to wide conversion and
  check its return value

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

7 years agomake struct key * argument of init_key_ctx const
Steffan Karger [Mon, 23 Oct 2017 09:40:13 +0000 (11:40 +0200)] 
make struct key * argument of init_key_ctx const

This can be const, and should thus be const.  (Also, resolves a compiler
warning.)

Signed-off-by: Steffan Karger <steffan.karger@fox-it.com>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <1508751613-23728-1-git-send-email-steffan.karger@fox-it.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg15660.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
7 years agoAvoid illegal memory access when malformed data is read from the pipe
Selva Nair [Fri, 20 Oct 2017 17:25:56 +0000 (13:25 -0400)] 
Avoid illegal memory access when malformed data is read from the pipe

- If only 1 byte is read from the interactive service client pipe, that
  evaluates to zero wide characters and subsequent check for NUL
  termination in the data buffer segfaults.
  Fix: reject clients that send less than a complete wide character.

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

7 years agoSimplify iphlpapi.dll API calls
Simon Rozman [Thu, 12 Oct 2017 08:07:20 +0000 (10:07 +0200)] 
Simplify iphlpapi.dll API calls

Dynamically locating API function addresses at run-time using
GetProcAddress() was a leftover from the early days of the interactive
service development. It was required before `NTDDI_VERSION` was raised
from Windows XP to Windows Vista.

After NTDDI_VERSION API level was raised to NTDDI_VISTA, the direct
calling of Vista introduced API functions is possible and much
simpler.

This patch simplifies the code while in the same time it removes
controversial function type definitions that caused interactive service
not to compile on MSVC.
Acked-by: Selva Nair <selva.nair@gmail.com>
Message-Id: <20171012080720.7764-1-simon@rozman.si>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg15614.html

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

7 years agoRtlIpv6AddressToStringW() and RtlIpv4AddressToStringW() require mstcpip.h
Simon Rozman [Tue, 10 Oct 2017 23:11:20 +0000 (01:11 +0200)] 
RtlIpv6AddressToStringW() and RtlIpv4AddressToStringW() require mstcpip.h

Acked-by: Selva Nair <selva.nair@gmail.com>
Message-Id: <20171010231130.6832-3-simon@rozman.si>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg15582.html

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

7 years agoMixing wide and regular strings in concatenations is not allowed in MSVC.
Simon Rozman [Tue, 10 Oct 2017 23:11:19 +0000 (01:11 +0200)] 
Mixing wide and regular strings in concatenations is not allowed in MSVC.

Acked-by: Selva Nair <selva.nair@gmail.com>
Message-Id: <20171010231130.6832-2-simon@rozman.si>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg15579.html

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

7 years agoLocal functions are not supported in MSVC. Bummer.
Simon Rozman [Tue, 10 Oct 2017 23:11:21 +0000 (01:11 +0200)] 
Local functions are not supported in MSVC. Bummer.

Acked-by: Selva Nair <selva.nair@gmail.com>
Message-Id: <20171010231130.6832-4-simon@rozman.si>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg15587.html

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

7 years agolz4: Fix broken builds when pkg-config is not present but system library is
David Sommerseth [Mon, 2 Oct 2017 19:07:32 +0000 (21:07 +0200)] 
lz4: Fix broken builds when pkg-config is not present but system library is

In commit f91e4863bc1382 we fixed an issue where LZ4_LIBS could be
overwritten in some situations.  But on systems where lz4 is installed on
the system but is lacking pkg-config information, the linker will not know
about the lz4 library when completing the build.

This fixes the issue by explicitly setting LZ4_LIBS to contain -llz4
if pkg-config test was run and failed verifying the installed lz4 version
number.  This also ensures that LZ4_LIBS will not be overwritten if it
has been provided on the ./configure command line.

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

7 years agolz4: Fix confused version check
David Sommerseth [Mon, 2 Oct 2017 16:18:12 +0000 (18:18 +0200)] 
lz4: Fix confused version check

Older LZ4 library versions used a version number > 100 and not the
current x.y.z versioning scheme.  This results in version 122 being
numberically higher than the check we have liblz4 > 1.7.1.  And
since that old version (122) does not have the LZ4_compress_default(),
the building explodes later on.

This patch enhances the version check to also ensure the version
number is lower than 100.  In addition the function checking we
had was not triggered if system library was found via pkg-config,
so this have now been reworked to really check if we have at least
two of the most important LZ4 functions - as long as a system
library have been found or been accepted via the LZ4_{CFLAGS,LIBS}
variables.

There are more ways to check for functions in autoconf.  I opted
for AC_CHECK_LIB() instead of AC_CHECK_FUNC{,S}() as the latter
ones does not test if a function exists in a specific library. This
have the downside of needing to tests instead of AC_CHECK_FUNCS()
which could test for more functions in one go.  We also do not
overwrite the LZ4_LIBS variable on success, as that could change
already set library paths (-L)

Finally, a stupid typo got fixed as well.

Trac: 939
Signed-off-by: David Sommerseth <davids@openvpn.net>
Tested-by: Richard Bonhomme <fragmentux@gmail.com>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20171002161812.9376-1-davids@openvpn.net>
URL: https://www.mail-archive.com/search?l=mid&q=20171002161812.9376-1-davids@openvpn.net
Signed-off-by: Gert Doering <gert@greenie.muc.de>
(cherry picked from commit f91e4863bc138213a07a2cf53ad71d8a4532abef)

7 years agoCheck whether in pull_mode before warning about previous connection blocks
Selva Nair [Fri, 15 Sep 2017 18:46:15 +0000 (14:46 -0400)] 
Check whether in pull_mode before warning about previous connection blocks

In particular, this eliminates the message that says "explicit-exit-notify
is ignored by previous <connection> blocks" when the option is pushed.

Note: pull_mode is identified as "allowed & OPT_P_PULL_MODE" matching
with the definition in add_options().

Reported by: Eike Lohmann e.lohmann@ic3s.de
https://www.mail-archive.com/openvpn-users@lists.sourceforge.net/msg04052.h
tml

v2: move the check to verify_permissions() as suggested by
    Gert <gert@greenie.muc.de>

Signed-off-by: Selva Nair <selva.nair@gmail.com>
Acked-by: Antonio Quartulli <antonio@openvpn.net>
Message-Id: <1505501175-9016-1-git-send-email-selva.nair@gmail.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg15452.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
(cherry picked from commit 422ecdac4a2738cd269361e048468d8b58793c4e)

7 years agoFix '--bind ipv6only'
hashiz [Thu, 28 Sep 2017 03:16:20 +0000 (12:16 +0900)] 
Fix '--bind ipv6only'

Commit 3d6a4cded2b20fb81 introduced checking for "too many parameters"
at option processing, and neglected to take "ipv6only" as possible
(and optional) argument to "--bind" into account.

Trac: #938

Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20170928031620.22331-1-hashiz@meridiani.jp>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg15522.html

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

7 years agoPrepare the release of OpenVPN 2.4.4 v2.4.4
David Sommerseth [Mon, 25 Sep 2017 19:30:38 +0000 (21:30 +0200)] 
Prepare the release of OpenVPN 2.4.4

Signed-off-by: David Sommerseth <davids@openvpn.net>
7 years agolz4: Move towards a newer LZ4 API
David Sommerseth [Thu, 7 Sep 2017 17:20:04 +0000 (19:20 +0200)] 
lz4: Move towards a newer LZ4 API

We are using a deprecated function, LZ4_compress_limitedOutput(), which
will be removed with time.  The correct function to use is
LZ4_compress_default().  Both function takes the same number of
arguments and data types, so the change is minimal.

This patch will also enforce the system LZ4 library to be at least v1.7.1.
If the system library is not found or it is older, it will be build using
the bundled LZ4 library.  The version number requirement is based on the
LZ4 version we ship.

The changes in configure.ac for the version check is modelled around the
same approach we use for OpenSSL.  Plus it does a few minor reformats and
improvements to comply with more recommend autoconf coding style.

This patch is a result of the discussions in this mail thread:
https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg14135.html

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

7 years agoFix bounds check in read_key()
Steffan Karger [Tue, 15 Aug 2017 08:04:33 +0000 (10:04 +0200)] 
Fix bounds check in read_key()

The bounds check in read_key() was performed after using the value, instead
of before.  If 'key-method 1' is used, this allowed an attacker to send a
malformed packet to trigger a stack buffer overflow.

Fix this by moving the input validation to before the writes.

Note that 'key-method 1' has been replaced by 'key method 2' as the default
in OpenVPN 2.0 (released on 2005-04-17), and explicitly deprecated in 2.4
and marked for removal in 2.5.  This should limit the amount of users
impacted by this issue.

CVE: 2017-12166
Signed-off-by: Steffan Karger <steffan.karger@fox-it.com>
Acked-by: Gert Doering <gert@greenie.muc.de>
Acked-by: David Sommerseth <davids@openvpn.net>
Message-Id: <80690690-67ac-3320-1891-9fecedc6a1fa@fox-it.com>
URL: https://www.mail-archive.com/search?l=mid&q=80690690-67ac-3320-1891-9fecedc6a1fa@fox-it.com
Signed-off-by: David Sommerseth <davids@openvpn.net>
(cherry picked from commit 3b1a61e9fb27213c46f76312f4065816bee8ed01)

7 years agosystemd: Enable systemd's auto-restart feature for server profiles
David Sommerseth [Wed, 6 Sep 2017 23:52:02 +0000 (01:52 +0200)] 
systemd: Enable systemd's auto-restart feature for server profiles

Systemd supervises services it has started and can act upon unexpected
scenarios.  This change will restart OpenVPN after 5 seconds if the OpenVPN
process exits unexpectedly.

The on-failure mode is the recommended mode by upstream systemd.

This change have been tested on a test server for some month, and it
works indeed as intended when provoking the OpenVPN process to stop.

Signed-off-by: David Sommerseth <davids@openvpn.net>
Acked-by: David Sommerseth <davids@openvpn.net>
Message-Id: <20170906235202.26551-1-davids@openvpn.net>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg15370.html
Signed-off-by: David Sommerseth <davids@openvpn.net>
(cherry picked from commit a4686e99b047081f0ef6f7945450183088464aa5)

7 years agotcp-server: ensure AF family is propagated to child context
Antonio Quartulli [Thu, 7 Sep 2017 09:55:30 +0000 (17:55 +0800)] 
tcp-server: ensure AF family is propagated to child context

Commit 23d61c56 introduced the AF_UNSPEC socket family
to be used when we don't know the actual one until the local
socket binding is performed.

In such case AF_UNSPEC is stored in the `ce.af` member of
the `c->options` object, indicating that the family has to be
determined at runtime.

However, the determined value is never propagated back to the
`options` object, which remains AF_UNSPEC and that is
later used to initialize the TCP children contexts (UDP
children contexts are unaffected).

This unexpected setting can trigger weird behaviours, like
the one reported in ticket #933.
In this case the value AF_UNSPEC in combination with the
changes implemented in 2bed089d are leading to a TCP
server quitting with M_FATAL upon client connection.

Note that the misbehaviour described in #933 can only be
triggered when running a TCP server with mtu-disc set
in the config (no matter the value).

Fix this inconsistency by always propagating the AF
family from the top to the child context when running
in TCP server mode.

As a direct consequence, this patch fixes Trac #933.

Trac: 933
Signed-off-by: Antonio Quartulli <antonio@openvpn.net>
Acked-by: Arne Schwabe <arne@rfc2549.org>
Message-Id: <20170907095530.15972-1-a@unstable.cc>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg15380.html
Signed-off-by: David Sommerseth <davids@openvpn.net>
(cherry picked from commit 682e7feac3bd57e6ce7e60504cb4da5c894d0e18)

7 years agosystemd: Ensure systemd shuts down OpenVPN in a proper way
David Sommerseth [Wed, 6 Sep 2017 23:47:05 +0000 (01:47 +0200)] 
systemd: Ensure systemd shuts down OpenVPN in a proper way

By default, when systemd is stopping OpenVPN it will send the SIGTERM
to all processes within the same process control-group.  This can come
as a surprise to plug-ins which may have fork()ed out child processes.

So we tell systemd to only send the SIGTERM signal to the main OpenVPN
process and let OpenVPN take care of the shutdown process on its own.

If the main OpenVPN process does not stop within 90 seconds (unless
changed), it will send SIGKILL to all remaining processes within
the same process control-group.

This issue have been reported in both Debian and Fedora.

Trac: 581
Message-Id: <20170906234705.26202-1-davids@openvpn.net>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg15369.html
Signed-off-by: David Sommerseth <davids@openvpn.net>
[DS: Applied lazy-ack policy]
(cherry picked from commit 29446a18e1f2b52d20f359253b085e96fe458367)

7 years agoOpenSSL: Always set SSL_OP_CIPHER_SERVER_PREFERENCE flag
Szilárd Pfeiffer [Mon, 4 Sep 2017 08:10:12 +0000 (10:10 +0200)] 
OpenSSL: Always set SSL_OP_CIPHER_SERVER_PREFERENCE flag

* safe bet to say that server admins are better at updating their configs
  than client users are and if client do want to restrict their ciphers,
  they should simply evict the ciphers they don't want from their cipher
  suite
* mbed TLS and OpenSSL behave more similar with the
  SSL_OP_CIPHER_SERVER_PREFERENCE flag

Signed-off-by: Szilárd Pfeiffer <coroner@pfeifferszilard.hu>
Acked-by: Steffan Karger <steffan.karger@fox-it.com>
Message-Id: <20170904081012.1975-1-coroner@pfeifferszilard.hu>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg15356.html
Signed-off-by: David Sommerseth <davids@openvpn.net>
(cherry picked from commit 5fd8e94d311825571931414064e4d13ed808f9b5)

7 years agoWarn that DH config option is only meaningful in a tls-server context
Gert van Dijk [Sun, 27 Aug 2017 16:15:15 +0000 (18:15 +0200)] 
Warn that DH config option is only meaningful in a tls-server context

If specified in a tls-client context, don't try to open the file as it's
not used. Worse even, if 'none' was specified to disable explicitly, it
complained that the file 'none' could not be found.

[DS: On-the-fly update - Prefixed the message with 'WARNING: ']

Signed-off-by: Gert van Dijk <gert@gertvandijk.net>
Acked-by: Steffan Karger <steffan.karger@fox-it.com>
Acked-by: David Sommerseth <davids@openvpn.net>
Message-Id: <20170827161515.2424-1-gert@gertvandijk.net>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg15332.html
Signed-off-by: David Sommerseth <davids@openvpn.net>
(cherry picked from commit 47a0a80b7718fe88451c82bdfe838e5a6e3c4248)

7 years agofragment.c: simplify boolean expression
Antonio Quartulli [Thu, 24 Aug 2017 07:55:47 +0000 (15:55 +0800)] 
fragment.c: simplify boolean expression

!A || (A && B) is equivalent to the simpler !A || B
therefore it is preferable to use the second version as
it is simpler to parse while reading the code.

Signed-off-by: Antonio Quartulli <a@unstable.cc>
Acked-by: David Sommerseth <davids@openvpn.net>
Message-Id: <20170824075547.29844-1-a@unstable.cc>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg15313.html
Signed-off-by: David Sommerseth <davids@openvpn.net>
(cherry picked from commit 10ae9ed5fe7f09c7edb5af266149a9b5e9bcbaa4)

7 years agodocs: Replace all PolarSSL references to mbed TLS
David Sommerseth [Tue, 22 Aug 2017 11:47:15 +0000 (13:47 +0200)] 
docs: Replace all PolarSSL references to mbed TLS

There were references in our documentation to the now deprecated PolarSSL
library, which have changed name upstream to mbed TLS.

In addition, where appropriate, the documentation now considers only
mbed TLS 2.0 and newer.  This is in accordance with the requirements
./configure sets.

[DS: On-the-fly change - Updated Makefile.am to use README.mbedtls
     instead of README.polarssl. This ensures make dist and buildbots
     won't explode]

Signed-off-by: David Sommerseth <davids@openvpn.net>
Acked-by: Steffan Karger <steffan.karger@fox-it.com>
Message-Id: <20170822114715.14225-1-davids@openvpn.net>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg15309.html
Signed-off-by: David Sommerseth <davids@openvpn.net>
(cherry picked from commit ed0e79938e801ec656d70cf02bcea4cdd0b79532)

7 years agotravis: reorder matrix to speed up build
Steffan Karger [Sun, 20 Aug 2017 09:19:04 +0000 (11:19 +0200)] 
travis: reorder matrix to speed up build

The OSX and mingw builds are much slower than the other jobs.  Our free
travis account can only use 4 build executors in parallel. Run the slow
builds earlier, so that when one or more of these finish, the free build
executors will start building the configure variants in parallel with the
slow ones.  (Instead of doing the slow ones last, which results in using
only 1-2 executors during the end stage.)

Signed-off-by: Steffan Karger <steffan@karger.me>
Acked-by: Antonio Quartulli <a@unstable.cc>
Message-Id: <1503220744-5569-1-git-send-email-steffan@karger.me>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg15302.html
Signed-off-by: David Sommerseth <davids@openvpn.net>
(cherry picked from commit e0a6afa12ea14685d0497ab27453ccc2b09e6e1f)

7 years agoman: Corrections to doc/openvpn.8
Richard Bonhomme [Sat, 19 Aug 2017 20:37:35 +0000 (21:37 +0100)] 
man: Corrections to doc/openvpn.8

Correct usage example: --verify-x509-name name-stub- name-prefix

  This was to correct "--verfiy-x509-name Server -name-prexif"
                   to "--verify-x509-name Server- name-prefix"

Escape all dashes (with some exceptions)

[DS: On-the-fly change - Updated copyright year from 2010 to 2017]

Signed-off-by: Richard Bonhomme <fragmentux@gmail.com>
Acked-by: David Sommerseth <davids@openvpn.net>
Message-Id: <20170819203735.8681-1-fragmentux@gmail.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg15297.html
Signed-off-by: David Sommerseth <davids@openvpn.net>
(cherry picked from commit 510c8ade804566868a1e0aa4e046a69e576f4478)

7 years agofix a couple of typ0s in comments and strings
Antonio Quartulli [Sat, 19 Aug 2017 07:52:09 +0000 (15:52 +0800)] 
fix a couple of typ0s in comments and strings

Signed-off-by: Antonio Quartulli <a@unstable.cc>
Acked-by: David Sommerseth <davids@openvpn.net>
Message-Id: <20170819075209.28520-1-a@unstable.cc>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg15293.html
Signed-off-by: David Sommerseth <davids@openvpn.net>
(cherry picked from commit 42d9f324f7362abfb9b51b24ef0fb7635b0194fc)

7 years agotls-crypt: don't leak memory for incorrect tls-crypt messages
Steffan Karger [Wed, 16 Aug 2017 17:04:50 +0000 (19:04 +0200)] 
tls-crypt: don't leak memory for incorrect tls-crypt messages

If tls_crypt_unwrap() failed, we would jump to cleanup and forget to free
the buffer.  Instead, allocate the buffer through gc, which is free'd in
the cleanup section.

Signed-off-by: Steffan Karger <steffan@karger.me>
Acked-by: David Sommerseth <davids@openvpn.net>
Message-Id: <20170816170450.10415-1-steffan@karger.me>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg15282.html
Signed-off-by: David Sommerseth <davids@openvpn.net>
(cherry picked from commit fca89379c53fe2c145db96a5bcd32327c4bcfa78)

7 years agoroute: avoid definition of unused variables in certain configurations
Antonio Quartulli [Wed, 16 Aug 2017 12:55:04 +0000 (20:55 +0800)] 
route: avoid definition of unused variables in certain configurations

Although this patch adds more ifdefs, this is an easy
fix towards a no-warning-build process.

A proper cleanup should be carried out later on route.c.

Signed-off-by: Antonio Quartulli <antonio@openvpn.net>
Reviewed-by: Steffan Karger <steffan.karger@fox-it.com>
Acked-by: David Sommerseth <davids@openvpn.net>
Message-Id: <20170816125504.21181-1-a@unstable.cc>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg15272.html
Signed-off-by: David Sommerseth <davids@openvpn.net>
(cherry picked from commit 22e75ca1a88b83e83a12b7d7d0095651f547411d)

7 years agoAdd coverity static analysis to Travis CI config
Steffan Karger [Tue, 8 Aug 2017 15:55:41 +0000 (17:55 +0200)] 
Add coverity static analysis to Travis CI config

Enable coverity analysis for the release/2.4 branch.

We can only do a limited number of coverity scans per week with our FOSS
account, but since we only occasionally push commits, that should work out
fine.  But this limit is the reason we don't use the standard travis addon,
because that would cause the coverity script to run on all of our matrix
builds.  That would cause us to reach our limit faster, and waste travis'
resources.

Since our FOSS coverity account doesn't handle multiple branches very well,
we have to pick one branch to run coverity on.  I think it's best to use
the most recent stable branch for that (i.e. for now, release/2.4).
Though for ease of maintenance, it's probably best to apply the patch to
both master and release/2.4.

Signed-off-by: Steffan Karger <steffan.karger@fox-it.com>
Acked-by: Antonio Quartulli <a@unstable.cc>
Message-Id: <1502207741-31750-1-git-send-email-steffan.karger@fox-it.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg15176.html
Signed-off-by: David Sommerseth <davids@openvpn.net>
(cherry picked from commit 4a05f15c9aafe314ae4d3642813ebf234c09276e)

7 years agocrypto: create function to initialize encrypt and decrypt key
Steffan Karger [Fri, 7 Jul 2017 04:47:04 +0000 (12:47 +0800)] 
crypto: create function to initialize encrypt and decrypt key

Instead of always initialize the encrypt and decrypt keys separately,
implement an helper function init_key_ctx_bi() that takes care of
both of them for us.

Reduces code duplication and improves readability.

Signed-off-by: Steffan Karger <steffan@karger.me>
Acked-by: Antonio Quartulli <a@unstable.cc>
Message-Id: <20170707044704.7239-1-a@unstable.cc>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg15011.html
Signed-off-by: David Sommerseth <davids@openvpn.net>
(cherry picked from commit 974513ea64020c956b531b1cabd76fdbac6655d8)

7 years agorename mroute_extract_addr_ipv4 to mroute_extract_addr_ip
Antonio Quartulli [Mon, 24 Jul 2017 14:35:59 +0000 (22:35 +0800)] 
rename mroute_extract_addr_ipv4 to mroute_extract_addr_ip

mroute_extract_addr_ipv4() is able to extract an IPv4 as well as an
IPv6. Remove the "v4" suffix from its name to make this behaviour more
explicit.

Signed-off-by: Antonio Quartulli <a@unstable.cc>
Acked-by: David Sommerseth <davids@openvpn.net>
Message-Id: <20170724143559.11503-1-a@unstable.cc>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg15129.html
Signed-off-by: David Sommerseth <davids@openvpn.net>
(cherry picked from commit 3b38c43b8d7aa22b3df12029ff43e0414891e48c)

7 years agoUse consistent version references
David Sommerseth [Tue, 15 Aug 2017 20:53:01 +0000 (22:53 +0200)] 
Use consistent version references

A simple clean-up where the version references have been unified
all those places I could find now.  The versioning scheme used is:

    * OpenVPN 2.x
    * v2.x

We want to avoid:
    * 2.x  (2.4 can be just an ordindary decimal number,
            OID reference, a version number or anything else)
    * OpenVPN v2.x (OpenVPN indicates we're talking about a version)

In addition, several places where it made sense I tried to ensure
the first version reference uses "OpenVPN 2.x" and the following
references in the same section/paragraph uses "v2.x", to set the
context for the version reference.

In Changes.rst modified paragraphs exceeding 80 chars lines where
reformatted as well.

Signed-off-by: David Sommerseth <davids@openvpn.net>
Acked-by: Steffan Karger <steffan@karger.me>
Message-Id: <20170815205301.14542-1-davids@openvpn.net>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg15260.html
Signed-off-by: David Sommerseth <davids@openvpn.net>
(cherry picked from commit 500854c3fc956b274790991e4d6771ad9bf6f641)

7 years agoHighlight deprecated features
David Sommerseth [Tue, 15 Aug 2017 21:54:51 +0000 (23:54 +0200)] 
Highlight deprecated features

We have quite a list of deprecated options currently.  Ensure this
is highlighted both in documentation and code.

This patch builds on the wiki page [1] enlisting all deprecated features
and their status.  There are also some options not listed here, as
there exists patches in release/2.4 which awaits an update for git master.

[1] https://community.openvpn.net/openvpn/wiki/DeprecatedOptions

Signed-off-by: David Sommerseth <davids@openvpn.net>
Acked-by: Steffan Karger <steffan@karger.me>
Message-Id: <20170815215451.21662-1-davids@openvpn.net>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg15261.html
Signed-off-by: David Sommerseth <davids@openvpn.net>
(cherry picked from commit 6e4a817589de85481a5cbfe5bcae4fa872c9fb5d)