]> git.ipfire.org Git - thirdparty/openvpn.git/log
thirdparty/openvpn.git
8 years agoMake ENABLE_OCC no longer depend on !ENABLE_SMALL
Gert Doering [Sun, 19 Mar 2017 18:41:35 +0000 (19:41 +0100)] 
Make ENABLE_OCC no longer depend on !ENABLE_SMALL

OCC is useful functionality which (according to LEDE devs) adds only
about 3k to the binary size - and if the embedded router folks can
afford this trade-off, everyone else can :-)

Inspired by
https://git.lede-project.org/?p=source.git;a=commit;h=b613c96d94bcdcda7abb3
be68ea1c281ce5fbb47

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

8 years agoFix installation of IPv6 host route to VPN server when using iservice.
Gert Doering [Sun, 19 Mar 2017 19:10:49 +0000 (20:10 +0100)] 
Fix installation of IPv6 host route to VPN server when using iservice.

The "prepare IPv6 route message to interactive service" was properly
handing the correct interface index (r->adapter_index) for this case,
but then always overwrote the gateway address with our magic tun/tap
fe80::8 value.  Only do this for "on tap adapter" routes.

Pinpointed by Selva Nair.

Trac #850

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

8 years agocleanup: Remove faulty env processing functions
David Sommerseth [Sat, 25 Feb 2017 02:02:29 +0000 (03:02 +0100)] 
cleanup: Remove faulty env processing functions

The env_set_add_to_environmenti() and env_set_remove_from_environment()
functions where not used in the code at all and they would cause an
ASSERT() in setenv_str_ex() later on, as it would not allow the
struct env_set *es pointer to be NULL (misc.c:807).

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

8 years agoignore remote-random-hostname if a numeric host is provided
Antonio Quartulli [Mon, 30 Jan 2017 15:26:58 +0000 (23:26 +0800)] 
ignore remote-random-hostname if a numeric host is provided

Although it does not make sense to specify remote-random-hostname
when a numeric hostname is provided (being it the remote, the http
proxy or the socks server), this is still a valid configuration.

For this reason, this combination should still work as expected,
which means ignoring the randomization and directly using the
numeric IP.

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

8 years agoplugin: Improve the handling of default plug-in directory
David Sommerseth [Fri, 27 Jan 2017 14:21:20 +0000 (15:21 +0100)] 
plugin: Improve the handling of default plug-in directory

OpenVPN uses a default plug-in directore, set using PLUGINDIR when
running ./configure.  If this is set, it will use $LIBDIR/openvpn/plugin.

When using --plugin, OpenVPN will load plug-ins from this directory with
the only exception if the plug-in filename is based on an absolute path.
Any other relative paths are relative to the PLUGINDIR.

This patch adds a third variant, using plug-in paths starting with '.'
In this case, OpenVPN will use the relative directory of where OpenVPN
was started, or the directory OpenVPN have changed into due to --cd
being used before the actual --plugin option.

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

8 years agoBe less picky about keyUsage extensions
Steffan Karger [Wed, 15 Mar 2017 21:20:20 +0000 (22:20 +0100)] 
Be less picky about keyUsage extensions

We long recommended users to use --ns-cert-type to distinguish between
client and server certificates, but that extension is long deprecated and
now can even no longer be accurately checked in OpenSSL 1.1+.  We support
a more modern alternative, --remote-cert-tls (which expands to
--remote-cert-ku + --remote-cert-eku), but are overly strict in checking
the keyUsage.  This patch makes our implementation less picky, so that
correct-but-slightly-weird certicates will not immediately be rejected.

We currently allow users to specify a list of allowed keyUsage values, and
require that the remote certificate matches one of these values exactly.
This is for more strict than keyUsage usually requires; which is that a
certificate is okay to use if it can *at least* be used for our intended
purpose.  This patch changes the behaviour to match that, by using the
library-provided mbedtls_x509_crt_check_key_usage() function in mbed TLS
builds, and performing the 'at least bits xyz' check for OpenSSL builds
(OpenSSL unfortunately does not expose a similar function).

Furthermore, this patch adds better error messages when the checking fails;
it now explains that is expects to match either of the supplied values,
and only does so if the check actually failed.

This patch also changes --remote-cert-tls to still require a specific EKU,
but only *some* keyUsage value.  Both our supported crypto libraries will
check the keyUsage value for correctness during the handshake, but only if
it is present.  So this still enforces a correct keyUsage, but is a bit
less picky about certificates that do not exactly match expectations.

This patch should be applied together with the 'deprecate --ns-cert-type'
patch I sent earlier.

Signed-off-by: Steffan Karger <steffan@karger.me>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <1489612820-15284-1-git-send-email-steffan@karger.me>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg14265.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
(cherry picked from commit 92a5b9fb76cbb7f43a6aa86994ff559f06c55c7a)

8 years agoDeprecate --ns-cert-type
Steffan Karger [Sat, 4 Mar 2017 18:49:57 +0000 (19:49 +0100)] 
Deprecate --ns-cert-type

The nsCertType x509 extension is very old, and barely used.  We already
have had an alternative for a long time: --remote-cert-tls uses the far
more common keyUsage and extendedKeyUsage extensions instead.

OpenSSL 1.1 longer exposes an API to (separately) check the nsCertType x509
extension.  Since we want be able to migrate to OpenSSL 1.1, we should
deprecate this option immediately.

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

8 years agoFix non-C99-compliant builds: don't use const size_t as array length
Steffan Karger [Thu, 16 Mar 2017 09:12:17 +0000 (10:12 +0100)] 
Fix non-C99-compliant builds: don't use const size_t as array length

Signed-off-by: Steffan Karger <steffan@karger.me>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <1489655537-19164-1-git-send-email-steffan@karger.me>
URL: http://www.mail-archive.com/search?l=mid&q=1489655537-19164-1-git-send-email-steffan@karger.me
Signed-off-by: Gert Doering <gert@greenie.muc.de>
(cherry picked from commit db1b4d96bfe7e744a0dec8f86cb041c32fb87964)

8 years agoCRL: use time_t instead of struct timespec to store last mtime
Antonio Quartulli [Thu, 16 Mar 2017 08:21:17 +0000 (16:21 +0800)] 
CRL: use time_t instead of struct timespec to store last mtime

As of now, we store the last mtime for the CRL file in a timespec
object. However we store seconds only and we ignore the subsecond
field (this came into being because not all platforms have nanoseconds
precision in timespec).

Given the above, we can safely replace the timespec object with a
simple time_t.

Reported-by: Gert Doering <gert@greenie.muc.de>
Signed-off-by: Antonio Quartulli <a@unstable.cc>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20170316082117.21020-1-a@unstable.cc>
URL: http://www.mail-archive.com/search?l=mid&q=20170316082117.21020-1-a@unstable.cc
Signed-off-by: Gert Doering <gert@greenie.muc.de>
(cherry picked from commit f3705dd1e711ee9f8546b841e4b18e9e9a224975)

8 years agoFix Building Using MSVC
Eric Thorpe [Wed, 15 Mar 2017 22:40:31 +0000 (09:40 +1100)] 
Fix Building Using MSVC

This patch enables the building of OpenVPN for the 2.4 and master
branches using MSVC (Visual Studio 2013 / MSVC v120), which currently
doesn't work with 2.4 or a clone of master. 2013 is being used as it
reduces the complexity of the redistributable requirements and has
mostly complete C99 support. Further changes will be necessary for 2015
support when the switch is made.

Note the changes to config-msvc-version.h.in are more of a work around.
It was a simpler approach when compared to modifying msvc-generate.js to
handle m4 syntax, and so it may be dropped if there is an intention to
update the javascript generator.

Signed-off by: Eric Thorpe <eric@sparklabs.com>

Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <df273b9b-6ca4-a539-cdf5-d4f9f991896b@sparklabs.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg14268.html

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

8 years agoRemove duplicate X509 env variables
Steffan Karger [Thu, 9 Mar 2017 08:13:32 +0000 (09:13 +0100)] 
Remove duplicate X509 env variables

Commit 13b585e8 added support for multiple X509 env variables with the
same name, but as a side effect caused these variables to pile up for
each renegotiation.  The old code would simply overwrite the old variables
(as long as an equally-long chain was used for the new session).

To stop the variables from piling up, this commit removes any old X509
env variables if we start negotiating a new TLS session.

Trac: #854

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

8 years agoFix types in WIN32 socket_listen_accept()
Steffan Karger [Thu, 9 Mar 2017 10:47:35 +0000 (11:47 +0100)] 
Fix types in WIN32 socket_listen_accept()

SOCKET_UNDEFINED is of type socket_descriptor_t (or SOCKET, in MS types),
so new_sd should be too.  Also, the return value of this function is
always stored in a socket_descriptor_t variable, so it should return that
type (which makes sense now, because it returns new_sd) instead of an int.

Signed-off-by: Steffan Karger <steffan.karger@fox-it.com>
Acked-by: Arne Schwabe <arne@rfc2549.org>
Message-Id: <1489056455-6004-1-git-send-email-steffan.karger@fox-it.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg14239.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
(cherry picked from commit 33e1a869fc6edb6bce5816b11dbecfaca57b20d4)

8 years agotravis-ci: remove unused files
Ilya Shipitsin [Sun, 5 Mar 2017 17:21:32 +0000 (20:21 +0300)] 
travis-ci: remove unused files

Those files were commited by mistake. I implemented building
dependencies in 4 separate scripts, later Steffan Karger combined
all 4 scripts into "build-deps.sh".

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

8 years agoOpenSSL: use EVP_CipherInit_ex() instead of EVP_CipherInit()
Emmanuel Deloget [Mon, 20 Feb 2017 14:32:34 +0000 (15:32 +0100)] 
OpenSSL: use EVP_CipherInit_ex() instead of EVP_CipherInit()

The behavior of EVP_CipherInit() changed in OpenSSL 1.1 -- instead
of clearing the context when the cipher parameter was !NULL, it now
clears the context unconditionnaly. As a result, subsequent calls
to the function with additional information now fails.

The bulk work is done by EVP_CipherInit_ex() which has been part of the
OpenSSL interface since the dawn of time (0.9.8 already has it). Thus,
the change allows us to get the old behavior back instead of relying
on dirty tricks.

Signed-off-by: Emmanuel Deloget <logout@free.fr>
Acked-by: Steffan Karger <steffan.karger@fox-it.com>
Message-Id: <2faff7647151d7fe362c1c5db9f97e520444d09b.1487600539.git.logout@free.fr>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg14120.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
(cherry picked from commit 8d00afae88b626c9cf14170a943b33a7ed378070)

8 years agoOpenSSL: SSLeay symbols are no longer available in OpenSSL 1.1
Emmanuel Deloget [Fri, 17 Feb 2017 22:00:52 +0000 (23:00 +0100)] 
OpenSSL: SSLeay symbols are no longer available in OpenSSL 1.1

The old symbols do not exist anymore but the library gained new
equivalent symbols (OSSL). Use them instead of the old ones

Signed-off-by: Emmanuel Deloget <logout@free.fr>
Acked-by: Steffan Karger <steffan.karger@fox-it.com>
Message-Id: <9ce17efda7b1ed100e73554b1916c0bfa687d9d1.1487368114.git.logout@free.fr>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg14089.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
(cherry picked from commit c828ffc648eebda20e2f9087248944fa0f52a582)

8 years agoOpenSSL: don't use direct access to the internal of RSA_METHOD
Emmanuel Deloget [Thu, 23 Feb 2017 14:35:56 +0000 (15:35 +0100)] 
OpenSSL: don't use direct access to the internal of RSA_METHOD

OpenSSL 1.1 does not allow us to directly access the internal of
any data type, including RSA_METHOD. We have to use the defined
functions to do so.

Compatibility with OpenSSL 1.0 is kept by defining the corresponding
functions when they are not found in the library.

Signed-off-by: Emmanuel Deloget <logout@free.fr>
Acked-by: Steffan Karger <steffan.karger@fox-it.com>
Message-Id: <79d89580db6fd92c059dabc4f5f4d83b72bb9d3d.1487859361.git.logout@free.fr>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg14175.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
(cherry picked from commit 09776c5b52df13121504e07894a26d5cd1883317)

8 years agoFix '--dev null'
Gert Doering [Fri, 24 Feb 2017 13:52:22 +0000 (14:52 +0100)] 
Fix '--dev null'

To test whether a server is reachable and all the key handling is
right, openvpn can connect with "--dev null --ifconfig-noexec" to
avoid needing to the client with elevated privileges.

This was erroring out for no good reason (because the "set environment
variables appropriately" code didn't know if this is a tun or tap
device...) - treat --dev null as "tap", done.

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

8 years agofix typo in notification message
Christian Hesse [Fri, 24 Feb 2017 12:22:52 +0000 (13:22 +0100)] 
fix typo in notification message

Signed-off-by: Christian Hesse <mail@eworm.de>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20170224122252.15199-1-list@eworm.de>
URL: http://www.mail-archive.com/search?l=mid&q=20170224122252.15199-1-list@eworm.de
Signed-off-by: Gert Doering <gert@greenie.muc.de>
(cherry picked from commit b13bc6c9570e00d12e26bb3b8e5bf9bdb0b16eff)

8 years agoOpenSSL: 1.1 fallout - fix configure on old autoconf
Steffan Karger [Thu, 23 Feb 2017 10:35:38 +0000 (11:35 +0100)] 
OpenSSL: 1.1 fallout - fix configure on old autoconf

Older versions of autoconf generate an empty "else fi" block for empty
fields in an AC_CHECK_FUNCS() macro.  This breaks on e.g. RHEL6.

Signed-off-by: Steffan Karger <steffan.karger@fox-it.com>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <1487846138-22231-1-git-send-email-steffan.karger@fox-it.com>
URL: http://www.mail-archive.com/search?l=mid&q=1487846138-22231-1-git-send-email-steffan.karger@fox-it.com
Signed-off-by: Gert Doering <gert@greenie.muc.de>
(cherry picked from commit 07372a0fdeb3638204d197d0614f776a0eb73ab9)

8 years agoAdd openssl_compat.h to openvpn_SOURCES
Gert Doering [Thu, 23 Feb 2017 08:49:54 +0000 (09:49 +0100)] 
Add openssl_compat.h to openvpn_SOURCES

Commit b936ddfb63 introduced a new header file but forgot to include
it in the list of openvpn_SOURCES, so it did not get bundled in the
generated tarballs.

Signed-off-by: Gert Doering <gert@greenie.muc.de>
Acked-by: Steffan Karger <steffan.karger@fox-it.com>
Message-Id: <20170223084954.58464-1-gert@greenie.muc.de>
URL: http://www.mail-archive.com/search?l=mid&q=20170223084954.58464-1-gert@greenie.muc.de
Signed-off-by: Gert Doering <gert@greenie.muc.de>
(cherry picked from commit 827c05732b0414dbf3cc05bf4ae6bfda042eadd3)

8 years agoFix segfault when using crypto lib without AES-256-CTR or SHA256
Simon Matter [Tue, 21 Feb 2017 19:34:15 +0000 (20:34 +0100)] 
Fix segfault when using crypto lib without AES-256-CTR or SHA256

Openvpn segfaults on RHEL5/CentOS5 when using --tls-crypt, because it
doesn't have AES-256-CTR support:

openvpn[15330]: OpenVPN 2.4.0 x86_64-redhat-linux-gnu [SSL (OpenSSL)]
[LZO] [LZ4] [EPOLL] [MH/PKTINFO] built on Jan 17 2017
openvpn[15330]: library versions: OpenSSL 0.9.8e-fips-rhel5 01 Jul 2008,
LZO 2.09, LZ4 1.7.5
openvpn[15331]: NOTE: the current --script-security setting may allow this
configuration to call user-defined scripts
kernel: openvpn[15331]: segfault at 0000000000000008 rip 000000000040ebe0
rsp 00007fffdcfc5738 error 4

This patch fixes it so it shows:

openvpn[424]: ERROR: --tls-crypt requires AES-256-CTR support.
openvpn[424]: Exiting due to fatal error

Trac: #825
Acked-by: Steffan Karger <steffan.karger@fox-it.com>
Message-Id: <345db0ac-f6e8-8490-a80a-ffbd81972c07@karger.me>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg14138.html

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

8 years agoOpenSSL: don't use direct access to the internal of X509_OBJECT
Emmanuel Deloget [Fri, 17 Feb 2017 22:00:42 +0000 (23:00 +0100)] 
OpenSSL: don't use direct access to the internal of X509_OBJECT

OpenSSL 1.1 does not allow us to directly access the internal of
any data type, including X509_OBJECT. We have to use the defined
functions to do so.

Compatibility with OpenSSL 1.0 is kept by defining the corresponding
functions when they are not found in the library.

Signed-off-by: Emmanuel Deloget <logout@free.fr>
Acked-by: Steffan Karger <steffan.karger@fox-it.com>
Message-Id: <c849c9778d2b2faa4eb4d31367b37d993da5eb85.1487368114.git.logout@free.fr>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg14080.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
(cherry picked from commit 47191f49890ee5c53fa78a8ce9bf96b9c8d27a82)

8 years agoOpenSSL: don't use direct access to the internal of X509_STORE
Emmanuel Deloget [Fri, 17 Feb 2017 22:00:41 +0000 (23:00 +0100)] 
OpenSSL: don't use direct access to the internal of X509_STORE

OpenSSL 1.1 does not allow us to directly access the internal of
any data type, including X509_STORE. We have to use the defined functions
to do so.

Compatibility with OpenSSL 1.0 is kept by defining the corresponding
functions when they are not found in the library.

Signed-off-by: Emmanuel Deloget <logout@free.fr>
Acked-by: Steffan Karger <steffan.karger@fox-it.com>
Message-Id: <8e6d66e3a9a40abb3d7c99c48ba59bad1037d0ef.1487368114.git.logout@free.fr>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg14076.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
(cherry picked from commit f05665df4150c6a345eec5432a02fd799bea0f2c)

8 years agoOpenSSL: don't use direct access to the internal of SSL_CTX
Emmanuel Deloget [Fri, 17 Feb 2017 22:00:40 +0000 (23:00 +0100)] 
OpenSSL: don't use direct access to the internal of SSL_CTX

OpenSSL 1.1 does not allow us to directly access the internal of
any data type, including SSL_CTX. We have to use the defined functions
to do so.

Compatibility with OpenSSL 1.0 is kept by defining the corresponding
functions when they are not found in the library.

Signed-off-by: Emmanuel Deloget <logout@free.fr>
Acked-by: Steffan Karger <steffan.karger@fox-it.com>
Message-Id: <a77187a66affdba318ef70e0e218b69cdad509d1.1487368114.git.logout@free.fr>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg14088.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
(cherry picked from commit 6554ac9fed9c5680f22aa4722e6e07ebf3aa3441)

8 years agoOpenSSL: don't use direct access to the internal of X509_STORE_CTX
Emmanuel Deloget [Fri, 17 Feb 2017 22:00:48 +0000 (23:00 +0100)] 
OpenSSL: don't use direct access to the internal of X509_STORE_CTX

OpenSSL 1.1 does not allow us to directly access the internal of
any data type, including X509_STORE_CTX. We have to use the defined
functions to do so.

Fortunately, these functions have existed since the dawn of time so
we don't have any compatibility issue here.

Signed-off-by: Emmanuel Deloget <logout@free.fr>
Acked-by: Steffan Karger <steffan.karger@fox-it.com>
Message-Id: <11477a0a3cf636572c84e0110a6f1b726bc60c2c.1487368114.git.logout@free.fr>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg14085.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
(cherry picked from commit 88046ad9e8e333259ae6fb4a295a9931a1a0e47f)

8 years agofix redirect-gateway behaviour when an IPv4 default route does not exist
Antonio Quartulli [Thu, 19 Jan 2017 16:25:18 +0000 (00:25 +0800)] 
fix redirect-gateway behaviour when an IPv4 default route does not exist

When no IPv4 default route exists, the "redirect-gateway" routine
aborts even if the sub-option "local" was specified or if we are
connecting to the remote host using IPv6.

This is not expected because in either case OpenVPN should not
bother checking the existence of the default route as it is not
required at all.

Therefore, skip the IPv4 default route check when "local" is
specified or we are connecting to an IPv6 remote host.

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

8 years agoattempt to add IPv6 route even when no IPv6 address was configured
Antonio Quartulli [Tue, 31 Jan 2017 11:21:31 +0000 (19:21 +0800)] 
attempt to add IPv6 route even when no IPv6 address was configured

Even if no IPv6 address is configured, OpenVPN still supports
transporting IPv6 segments, therefore adding an IPv6 route
should always be allowed.

However, the route might fail to be installed or may just not work
as expected, therefore, a proper warning should be printed to inform
the user of the possible pitfall.

Always allow adding an IPv6 route and print a WARNING when
no IPv6 address is configured for the interface.

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

8 years agoFix user's group membership check in interactive service to work with domains
Selva Nair [Sat, 14 Jan 2017 21:16:29 +0000 (16:16 -0500)] 
Fix user's group membership check in interactive service to work with domains

Currently the username unqualified by the domain is used to validate
a user which fails for domain users. Instead authorize the user

(i) if the built-in admin group or ovpn_admin group is in the process token
(ii) else if the user's SID is in the built-in admin or ovpn_admin groups

The second check is needed to recognize dynamic updates to group membership
on the local machine that will not be reflected in the token.

These checks do not require connection to a domain controller and will
work even when user is logged in with cached credentials.

Trac: #810

v2: include the token check as described above

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

8 years agoOpenSSL: check for the SSL reason, not the full error
Emmanuel Deloget [Fri, 17 Feb 2017 22:00:53 +0000 (23:00 +0100)] 
OpenSSL: check for the SSL reason, not the full error

OpenSSL 1.1 changed the SSLv3 API and removed many SSL_L_SSL3_*
constants. Moreover, new code might use different function
code for the same error.

Thus, we extract the error reason from the error code before
we compare it instead of trying to rebuild an error code
that might not be correct.

The new version is compatible with OpenSSL 1.0.x as well as
with older versions (starting at 0.9.8).

Signed-off-by: Emmanuel Deloget <logout@free.fr>
Acked-by: Steffan Karger <steffan.karger@fox-it.com>
Message-Id: <0e0d4a67192b563cd07d3f06685f85e34c304142.1487368114.git.logout@free.fr>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg14087.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
(cherry picked from commit 6ddc43d1bf9b3ea3ee5db8c50d56a98fe4db4c97)

8 years agoFix building with LibreSSL 2.5.1 by cleaning a hack.
Olivier Wahrenberger [Mon, 13 Feb 2017 18:38:26 +0000 (19:38 +0100)] 
Fix building with LibreSSL 2.5.1 by cleaning a hack.

Similar to what is done in curl: https://github.com/curl/curl/blob/028391df5d84d9fae3433afdee9261d565900355/lib/vtls/openssl.c#L603-L619

Use SSL_CTX_get0_privatekey() for OpenSSL >= 1.0.2

Signed-off-by: Olivier Wahrenberger <olivierw.ml@gmail.com>
Acked-by: Steffan Karger <steffan.karger@fox-it.com>
Message-Id: <20170213183826.73008-1-O2Graphics@users.noreply.github.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg14045.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
(cherry picked from commit dcfd3b6173d8cdb4658de23db1dd0bd932b390d2)

8 years agoResolve several travis-ci issues
Ilya Shipitsin [Sun, 29 Jan 2017 06:58:11 +0000 (11:58 +0500)] 
Resolve several travis-ci issues

MBEDTLS_VERSION, OPENSSL_VERSION were defined twice - in both
.travis.yml  and .travis/build-deps.sh files, the last one
defined OPENSSL_VERSION via nonexistent OPENSSL_VERION
variable, which lead us to use openssl-1.0.1 instead of
openssl-1.0.2, I removed variable definition from build-deps.sh

"cache: [ apt: true ]" is not a travis supported option, it was
introduced by mistake, I removed it

LD_LIBRARY_PATH was defined for the entire test run, it includes
custom openssl build, which was picked by "wget", so "wget"
could not verify SSL cert at https://www.openssl.org sometimes.
We do not want wget to pick our custom LD_LIBRARY_PATH, so I moved
that variable to "script" section

LD_LIBRARY_PATH was defined for both linux and osx environments,
for the second DYLD_LIBRARY_PATH must be defined instead

v2: Upgrade openssl, mbedtls to the most recent versions
v3: DYLD_LIBRARY_PATH was defined via LD_LIBRARY_PATH by mistake

Acked-by: Selva Nair <selva.nair@gmail.com>
Message-Id: <1485673091-7600-1-git-send-email-chipitsine@gmail.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg13983.html
Signed-off-by: David Sommerseth <davids@openvpn.net>
(cherry picked from commit 208c03ea145ed89083c43267733487c99a805069)

8 years agoplugin: Remove GNUism in openvpn-plugin.h generation
Christian Hesse [Fri, 27 Jan 2017 08:49:27 +0000 (09:49 +0100)] 
plugin: Remove GNUism in openvpn-plugin.h generation

The plugin path handling cleanup (4590c383) introduced GNUism and broke
builds on system not using GNU Make (like *BSD).

Revert back to let configure generate the header file. Instead let make
add an extra CFLAG that defines PLUGIN_LIBDIR.

Signed-off-by: Christian Hesse <mail@eworm.de>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20170127084927.21040-1-list@eworm.de>
URL: http://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg13966.html
Signed-off-by: David Sommerseth <davids@openvpn.net>
(cherry picked from commit 631812fe29c69d0034628ab8321cb4016cb4fc2d)

8 years agoClean up plugin path handling
Christian Hesse [Wed, 25 Jan 2017 20:19:47 +0000 (21:19 +0100)] 
Clean up plugin path handling

Drop --with-plugindir, instead use an environment variable PLUGINDIR
to specify the plugin directory.

This puts a define into include/openvpn-plugin.h.in which has the plugin
directory.

The configure script does not know about the final plugin path. Thus we
have to make Make generate the final header file for us.

As the path is always available remove the compile time condition (and
dead code) from src/openvpn/plugin.c.

v2: The configure script can not evaluate the final $libdir path. So
    use make to create a header file on the containing the final path.

v3: Fix whitespace errors and gitignore location.

v4: No extra header file, generate src/openvpn/plugin.h on the fly.
    Remove condition and dead code.

v5: Move the define to include/openvpn-plugin.h.in and let make generate
    the final header file.

Signed-off-by: Christian Hesse <mail@eworm.de>
Acked-by: David Sommerseth <davids@openvpn.net>
Message-Id: <20170125201947.17197-1-list@eworm.de>
URL: http://www.mail-archive.com/search?l=mid&q=20170125201947.17197-1-list@eworm.de
Signed-off-by: David Sommerseth <davids@openvpn.net>
(cherry picked from commit 4590c3831d0400096fab08aa1ed7f909da870ced)

8 years agosystemd: Add more security feature for systemd units
Christian Hesse [Tue, 27 Dec 2016 22:18:32 +0000 (23:18 +0100)] 
systemd: Add more security feature for systemd units

ProtectSystem=true mounts the /usr and /boot directories read-only.

ProtectHome=true makes the directories /home, /root and /run/user
inaccessible and empty for the process.

See systemd.exec(5) [0] for details.

v2: Replace ProtectSystem=strict with ProtectSystem=true. Some
    configurations may want to write to /etc or the like.

[0] https://www.freedesktop.org/software/systemd/man/systemd.exec.html

Signed-off-by: Christian Hesse <mail@eworm.de>
Acked-by: David Sommerseth <davids@openvpn.net>
Message-Id: <20161227221832.610-1-list@eworm.de>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg13743.html
Signed-off-by: David Sommerseth <davids@openvpn.net>
(cherry picked from commit 76096c605fcac4815674b6ae76ac1f31f03a8186)

8 years agosystemd: Do not race on RuntimeDirectory
Christian Hesse [Tue, 24 Jan 2017 14:39:47 +0000 (15:39 +0100)] 
systemd: Do not race on RuntimeDirectory

Different unit instances create and destroy the same RuntimeDirectory.
This leads to running instances where the status file (and possibly
more runtime data) is no longer accessible.

So do not handle this in unit files but provide a tmpfiles.d
configuration and let systemd-tmpfiles do the work.
Nobody will (unintentionally) delete the directories and its content.
As /run is volatile we do not have to care about cleanup.

Signed-off-by: Christian Hesse <mail@eworm.de>
Acked-by: David Sommerseth <davids@openvpn.net>
Message-Id: <20170124143947.27385-2-list@eworm.de>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg13939.html
Signed-off-by: David Sommerseth <davids@openvpn.net>
(cherry picked from commit 3de7be7b17de879a78eea4afe4c918c6104c635d)

8 years agosystemd: Use automake tools to install unit files
Christian Hesse [Tue, 24 Jan 2017 14:39:46 +0000 (15:39 +0100)] 
systemd: Use automake tools to install unit files

If systemd is enabled we install unit files to $libdir/systemd/system
(or the path specified by SYSTEMD_UNIT_DIR).
The unit files are generated on the fly with matching $sbindir.

Signed-off-by: Christian Hesse <mail@eworm.de>
Acked-by: David Sommerseth <davids@openvpn.net>
Message-Id: <20170124143947.27385-1-list@eworm.de>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg13940.html
Signed-off-by: David Sommerseth <davids@openvpn.net>
(cherry picked from commit ca5b4c2aad2370be7862660d274b7485f2d0af71)

8 years agosystemd: Move the READY=1 signalling to an earlier point
David Sommerseth [Tue, 24 Jan 2017 23:23:44 +0000 (00:23 +0100)] 
systemd: Move the READY=1 signalling to an earlier point

Currently, OpenVPN will first tell systemd it is ready once the
log will be appended with "Initialization Sequence Completed".
This turns out to cause some issues several places.

First, it adds challenges if --chroot is used in the configuration;
this is already fixed.  Secondly, it will cause havoc on static key
p2p mode configurations where the log line above will not happen
before either sides have completed establishing a connection.  And
thirdly, if a client configuration fails to establish a connection
within 90 seconds, it will also fail.  For the third case this may
not be a critical issue itself, as the host just needs to get
an Internet access established first - which in some scenarios may
take much longer than those 90 seconds systemd grants after the
OpenVPN client configuration is started.

The approach this patch takes is to consider OpenVPN ready when
all the initial preparations and configurations have completed - but
before a connection to a remote side have been attempted.  This
also removes the need for specially handling the --chroot scenario.

The final "Initialization Sequence Completed" message update is
kept (though slightly simplified) to indicate we're in a good
state - even though this update will not be visible if --chroot
is used (which was the situation also before this patch).

Trac: #827, #801
Signed-off-by: David Sommerseth <davids@openvpn.net>
Acked-by: Gert Doering <gert@greenie.muc.de>
Acked-by: Christian Hesse <mail@eworm.de>
Message-Id: <20170124232344.7825-1-davids@openvpn.net>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg13945.html
Signed-off-by: David Sommerseth <davids@openvpn.net>
(cherry picked from commit e83a8684f0a0d944e9d53cdad2b543cfd1b6fbae)

8 years agoUse SHA256 for the internal digest, instead of MD5
Steffan Karger [Sun, 22 Jan 2017 16:04:41 +0000 (17:04 +0100)] 
Use SHA256 for the internal digest, instead of MD5

Our internal options digest uses MD5 hashes to store the state, instead of
storing the full options string.  There's nothing wrong with that, but it
would still be better to use SHA256 because:
 * That makes it easier to make OpenVPN "FIPS-compliant" (forbids MD5)
 * We don't have to explain anymore that MD5 is fine too

The slightly less bytes for the digest (16 instead of 32) and operations
per connection setup are not worth sticking to MD5.

Note that might SHA256 not be available in de crypto lib, OpenVPN will
refuse to start and shout "Message hash algorithm 'SHA256' not found".

Signed-off-by: Steffan Karger <steffan@karger.me>
Acked-by: David Sommerseth <davids@openvpn.net>
Message-Id: <1485101081-9784-1-git-send-email-steffan@karger.me>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg13926.html
Signed-off-by: David Sommerseth <davids@openvpn.net>
(cherry picked from commit 5b48e8c9f85442936f744c3c550d9d41fe8c7b60)

8 years agogit: Merge .gitignore files into a single file
David Sommerseth [Fri, 20 Jan 2017 21:04:57 +0000 (22:04 +0100)] 
git: Merge .gitignore files into a single file

We already track a lot of files over the whole directory structure
in the main .gitignore file.  But a few additional ones had been
added into some of the subdirectories.

This unifies all these files into a master file for the whole project,
making it easier to know where to look at and edit if changes needs
to be done.

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

8 years agoAdd a check for -Wl, --wrap support in linker
Selva Nair [Wed, 18 Jan 2017 20:42:52 +0000 (15:42 -0500)] 
Add a check for -Wl, --wrap support in linker

- Also make tests that require --wrap option to be
  conditional on this support

[ DS: Removed AC_DEFINE([HAVE_LD_WRAP_SUPPORT],...) at commit time
      as we now see no real use for such a #define in config.h ]

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

8 years agoMore broadly enforce Allman style and braces-around-conditionals
Steffan Karger [Sat, 14 Jan 2017 14:10:20 +0000 (15:10 +0100)] 
More broadly enforce Allman style and braces-around-conditionals

We want { and } aligned, which means also adding a newline between each
for() and {, while() and {, etc.

Also, we agreed to always use braces with conditionals.  The previous
uncrustify config added these for if()s, now also add these for while()
and for().

Signed-off-by: Steffan Karger <steffan@karger.me>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <1484403020-6857-1-git-send-email-steffan@karger.me>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg13875.html
Signed-off-by: David Sommerseth <davids@openvpn.net>
(cherry picked from commit 4cd4899e8e80efae03c584a760fd107251735723)

8 years agomanagement: Remove a redundant #ifdef block
David Sommerseth [Tue, 10 Jan 2017 20:34:33 +0000 (21:34 +0100)] 
management: Remove a redundant #ifdef block

Bascially removes two independent #ifdef ENABLE_MANAGEMENT blocks into
a single block, which makes the logic flow more easy to read.

Signed-off-by: David Sommerseth <davids@openvpn.net>
Cc: Selva Nair <selva.nair@gmail.com>
Acked-by: Selva Nair <selva.nair@gmail.com>
Message-Id: <1484080473-10415-2-git-send-email-davids@openvpn.net>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg13852.html
Signed-off-by: David Sommerseth <davids@openvpn.net>
(cherry picked from commit 7b02cc2aa8318dc8f2677064dadcbec295b2f937)

8 years agomanagement: >REMOTE operation would overwrite ce change indicator
David Sommerseth [Tue, 10 Jan 2017 20:34:32 +0000 (21:34 +0100)] 
management: >REMOTE operation would overwrite ce change indicator

If the management interface on a client received a signal while waiting
for input on the management channel, the "connection entry changed" status
would be overwritten even though nothing was changed.  Which could lead
into connecting to the wrong server.

This patch improves this by adding a check if a bool value was changed to
false.  This change happens only on signals.

Further, the former 'ret' value have been renamed to 'ce_changed', to
clarify what the expected return value contains.  Plus adding some comments
related to this.

And finally do some code style cleanup, breaking up too long lines, adding
some air here and there to improve the readability.

Signed-off-by: David Sommerseth <davids@openvpn.net>
Cc: Selva Nair <selva.nair@gmail.com>
Acked-by: Selva Nair <selva.nair@gmail.com>
Message-Id: <1484080473-10415-1-git-send-email-davids@openvpn.net>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg13851.html
Signed-off-by: David Sommerseth <davids@openvpn.net>
(cherry picked from commit e81f313a71e548638d9e9679226ee84b3b614f13)

8 years agoman: fix formatting for alternative option
Christian Hesse [Wed, 28 Dec 2016 07:54:20 +0000 (08:54 +0100)] 
man: fix formatting for alternative option

This looked like...

    --server-poll-timeout n
        --connect-timeout n when connecting to [...]

... and this patch changes this to...

    --server-poll-timeout n, --connect-timeout n
        When connecting to [...]

... preserving correct highlighting.

Signed-off-by: Christian Hesse <mail@eworm.de>
Acked-by: David Sommerseth <davids@openvpn.net>
Message-Id: <20161228075420.348-1-list@eworm.de>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg13747.html
Signed-off-by: David Sommerseth <davids@openvpn.net>
(cherry picked from commit d0d8a4b5f875bc802117647b20a3caa6d4fdb375)

8 years agoAlways release dhcp address in close_tun() on Windows.
Selva Nair [Tue, 3 Jan 2017 20:38:03 +0000 (15:38 -0500)] 
Always release dhcp address in close_tun() on Windows.

Also make sure --dhcp-pre-release results in not just dhcp_release()
in open_tun() but a subsequent dhcp_renew() as well. Else dhcp transaction
gets aborted as this call to release() happens after the adapter status
is changed to connected.

Fixes Trac #807 (but can't say the same for Trac #665 without knowing
how to reproduce it)

v2: Mark --dhcp-release as obsolete in manpage and option parser, and
remove the unused dhcp_release variable.
Enforce dhcp-renew with dhcp-pre-release while parsing the option
instead of in open_tun().

Trac: #807

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

8 years agoCrash in options.c
Gisle Vanem [Mon, 2 Jan 2017 16:17:51 +0000 (17:17 +0100)] 
Crash in options.c

When compiling with --disable-crypto, openvpn would crash on --help as
commit 5d429efd97 introduce and extra %d into the "usage_message" string
but forgot to add it to the #ifndef ENABLE_CRYPTO fprintf() call.

Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <9d41f9dd-a587-5c1e-2e0d-ebb6c921f4ae@yahoo.no>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg13808.html

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

8 years agoFix push options digest update
Selva Nair [Tue, 3 Jan 2017 21:42:18 +0000 (16:42 -0500)] 
Fix push options digest update

Trac: #812

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

8 years agoPreparing OpenVPN v2.4.0 release v2.4.0
David Sommerseth [Mon, 26 Dec 2016 12:46:05 +0000 (13:46 +0100)] 
Preparing OpenVPN v2.4.0 release

Signed-off-by: David Sommerseth <davids@openvpn.net>
8 years agobuild: Ensure Changes.rst is shipped and installed as a doc file
David Sommerseth [Tue, 27 Dec 2016 10:52:24 +0000 (11:52 +0100)] 
build: Ensure Changes.rst is shipped and installed as a doc file

Signed-off-by: David Sommerseth <davids@openvpn.net>
Acked-by: Arne Schwabe <arne@rfc2549.org>
Message-Id: <1482835944-563-1-git-send-email-davids@openvpn.net>
URL: http://www.mail-archive.com/search?l=mid&q=1482835944-563-1-git-send-email-davids@openvpn.net
(cherry picked from commit 7fb22ea0bc483b5a128bcc23ce9a156c8fadac3a)

8 years agoTextual fixes for Changes.rst
Steffan Karger [Mon, 26 Dec 2016 19:15:43 +0000 (20:15 +0100)] 
Textual fixes for Changes.rst

We will likely refer many people to the Changes.rst file once we've
released 2.4.  This commits tries to polish the language a bit, and
adds two real changes:

 - Remove duplicate mention of the changes --tls-cipher defaults

 - Move the 'redirect-gateway' behavioural change from 'features' to
   'behavioural changes'.

v2 - On the fly commit changes, based on comments from Selva Nair.
     DS also added a few minor corrections on top of that.

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

8 years agoman: Remove references to no longer present IV_RGI6 peer-info
David Sommerseth [Mon, 26 Dec 2016 12:26:43 +0000 (13:26 +0100)] 
man: Remove references to no longer present IV_RGI6 peer-info

Commit 554504c5e2692c3e6cfd3f removed the IV_RGI6 peer-info singaling
but forgot to update the man page.  Removing this reference as well.

Signed-off-by: David Sommerseth <davids@openvpn.net>
Acked-by: Arne Schwabe <arne@rfc2549.org>
Message-Id: <1482755203-23968-1-git-send-email-davids@openvpn.net>
URL: http://www.mail-archive.com/search?l=mid&q=1482755203-23968-1-git-send-email-davids@openvpn.net
(cherry picked from commit 4ba943b02aa728aa077a0b3be79626b0f20ea8a7)

8 years agoRemove IV_RGI6=1 peer-info signalling.
Gert Doering [Sun, 25 Dec 2016 10:59:19 +0000 (11:59 +0100)] 
Remove IV_RGI6=1 peer-info signalling.

This is no longer needed, as anything 2.4 or later is known to have
this functionality, and IV_VER can be used to detect this on the server.

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

8 years agoman: encourage user to read on about --tls-crypt
Steffan Karger [Sun, 25 Dec 2016 22:02:14 +0000 (23:02 +0100)] 
man: encourage user to read on about --tls-crypt

As suggested by krzee in trac #790, refer to the --tls-crypt option
form the --tls-auth section of the man page, to encourage users to
check out the --tls-crypt feature.

Trac: #790
Signed-off-by: Steffan Karger <steffan@karger.me>
Acked-by: David Sommerseth <davids@openvpn.net>
Message-Id: <1482703334-18949-1-git-send-email-steffan@karger.me>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg13713.html
Signed-off-by: David Sommerseth <davids@openvpn.net>
(cherry picked from commit 403dfe1bfdbdf6e5f8abac3401a96852562aec54)

8 years agoDocument that RSA_SIGN can also request TLS 1.2 signatures
Steffan Karger [Sun, 25 Dec 2016 22:38:25 +0000 (23:38 +0100)] 
Document that RSA_SIGN can also request TLS 1.2 signatures

Ever since we support TLS 1.2 (OpenVPN 2.3.3+), the RSA_SIGN might not
only request MD5-SHA1 'TLS signatures', but also other variants.
Document this by updating the implementation hints, and explicitly
stating that we expect a PKCS#1 1.5 signature.

Trac: #764
Signed-off-by: Steffan Karger <steffan@karger.me>
Acked-by: Arne Schwabe <arne@rfc2549.org>
Message-Id: <1482705505-20302-1-git-send-email-steffan@karger.me>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg13714.html
Signed-off-by: David Sommerseth <davids@openvpn.net>
(cherry picked from commit 1e36b814073c0f56c77e4922cc105f00b8558e7e)

8 years agodocs: Further enhance the documentation related to SWEET32
David Sommerseth [Fri, 23 Dec 2016 16:07:44 +0000 (17:07 +0100)] 
docs: Further enhance the documentation related to SWEET32

The git master/2.4 code lacked some useful information about
the changes to --reneg-bytes, SWEET32 and weak ciphers (less
than 128-bits cipher blocks)

v2 - Fixed a couple of grammar/typo issues

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

8 years agoUpdate copyrights
David Sommerseth [Wed, 21 Dec 2016 20:00:54 +0000 (21:00 +0100)] 
Update copyrights

Signed-off-by: David Sommerseth <davids@openvpn.net>
Acked-by: Steffan Karger <steffan@karger.me>
Message-Id: <1482350454-27280-4-git-send-email-davids@openvpn.net>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg13655.html

8 years agodev-tools: Added script for updating copyright years in files
David Sommerseth [Mon, 19 Dec 2016 18:52:12 +0000 (19:52 +0100)] 
dev-tools: Added script for updating copyright years in files

Very simple tool which modifies the Copyright lines in all git checked-in
files with an updated year.  Lines only listing a single year (2016) will
be modified to list a range instead.

Only the Copyright lines owners of specific owners will be modified.  The
script will need to be slightly updated to cover more owners.  See the
UPDATE_COPYRIGHT_LINES line in the script for the currently set owners.

v2 - On-the-fly-commit-update: use vendor/ instead of cmocka and
     add @sophos.com to the list of copyright holders to update

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

8 years agoPreparing OpenVPN v2.4_rc2 release v2.4_rc2
David Sommerseth [Fri, 16 Dec 2016 10:58:51 +0000 (11:58 +0100)] 
Preparing OpenVPN v2.4_rc2 release

Signed-off-by: David Sommerseth <davids@openvpn.net>
8 years agoauth-gen-token: Hardening memory cleanup on auth-token failuers
David Sommerseth [Fri, 16 Dec 2016 10:25:07 +0000 (11:25 +0100)] 
auth-gen-token: Hardening memory cleanup on auth-token failuers

Further improve the memory management when a clients --auth-token
fails the server side token authentication enabled via --auth-gen-token.

v2 - Add ASSERT() if base64 encoding of token fails
v3 - Use proper boolean logic in ASSERT()
v4 - Rebase against The Great Reformatting

Signed-off-by: David Sommerseth <davids@openvpn.net>
Acked-by: Steffan Karger <steffan.karger@fox-it.com>
Message-Id: <1481883907-26413-1-git-send-email-davids@openvpn.net>
URL: http://www.mail-archive.com/search?l=mid&q=1481883907-26413-1-git-send-email-davids@openvpn.net

8 years agoDon't reopen tun if cipher changes
Steffan Karger [Thu, 15 Dec 2016 21:46:06 +0000 (22:46 +0100)] 
Don't reopen tun if cipher changes

When the pulled options change, OpenVPN will attempt to reopen the tun
device.  That might fail if the process has already dropper privileges,
and is not needed unless the tun MTU is changed.  This patch therefore
ignores the cipher value for the digest if a fixed tun-mtu is used.

Additionally, this patch changes the md_ctx_update() call to include the
trailing zero byte of each option, to make sure that parsing "foo,bar"
results in a different hash than "foobar".  (Sorry for not catching that
during the review...)

The unit tests are a bit lame, but it secretly serves as a way to lower
the bar for adding more buffer.c unit tests.

Trac: #761
Signed-off-by: Steffan Karger <steffan@karger.me>
Acked-by: David Sommerseth <davids@openvpn.net>
Message-Id: <1481838366-32335-1-git-send-email-steffan@karger.me>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg13579.html
Signed-off-by: David Sommerseth <davids@openvpn.net>
8 years agoMerge 'reformatting' branch into master
David Sommerseth [Thu, 15 Dec 2016 12:45:06 +0000 (13:45 +0100)] 
Merge 'reformatting' branch into master

This concludes the first phase of The Great Reformatting project.

Reviewed-by: Selva Nair <selva.nair@gmail.com>
Acked-By: Steffan Karger <steffan@karger.me>
Message-Id: <3a78050c-8c18-d54e-fc37-330272de6d44@sf.lists.topphemmelig.net>
URL: http://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg13556.html
Signed-of-by: David Sommerseth <davids@openvpn.net>
8 years agoThe Great Reformatting - first phase reformatting 111/head
David Sommerseth [Wed, 14 Dec 2016 21:33:21 +0000 (22:33 +0100)] 
The Great Reformatting - first phase

This is the first commit of the big reformatting task.  This
is performed by running the ./dev-tools/reformat-all.sh script.

This is based upon the v3 reformat-all.sh/uncrustify.conf version
which is now applied to git master.

Signed-off-by: David Sommerseth <davids@openvpn.net>
8 years agodev-tools: Add reformat-all.sh for code style unification
David Sommerseth [Wed, 14 Dec 2016 21:05:00 +0000 (22:05 +0100)] 
dev-tools: Add reformat-all.sh for code style unification

This script will run all files related to the currently checked out
git branch through uncrustify using a standardized style configuration.

Due to a bug in uncrustify 0.64, it is needed to add a special treatment
to one of the files at the moment.  So this both pre- and post-patched
before/after uncrustify is run.  This is to simply to assure that all
file processing will happen consistently each time.

Also added doc/doxygen/doc_key_generation.h to an ignore list, as
it carries some specific Doxygen formatting we should be careful with.
This file is anyhow not so critical and can be managed manually.

The src/compat/compat-lz4.[ch] files are also not touched, as they
are based on upstream formatting.  This makes it easier to update
to a newer LZ4 version later on and even see what the differences
are.

v2 - Include updated config from CodeStyle wiki page
     Remove line lenght restriction for The Great Reformatting
     Update the script with improvements by krzee

v3 - Update with a fixed config from the CodeStyle wiki page
     Corrected a typo in the commit message (0.63->0.64)
     Minor changes to the reformat script (no pushd/popd,
     some new lines moved around, bash->sh)

Signed-off-by: David Sommerseth <davids@openvpn.net>
Acked-by: Steffan Karger <steffan@karger.me>
Message-Id: <1481749500-8795-1-git-send-email-davids@openvpn.net>
URL: http://www.mail-archive.com/search?l=mid&q=1481749500-8795-1-git-send-email-davids@openvpn.net

8 years agoChanges.rst: Mainatiner update on C99
David Sommerseth [Tue, 13 Dec 2016 12:16:56 +0000 (13:16 +0100)] 
Changes.rst: Mainatiner update on C99

Mention for maintainers that we've moved to build with -std=c99 by
default.  Also document that 32-bit RHEL5 builds will need -std=gnu99
to be buildable.

Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <1481631416-15377-1-git-send-email-davids@openvpn.net>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg13518.html
Signed-off-by: David Sommerseth <davids@openvpn.net>
8 years agoFurther enhance async-push feature description
David Sommerseth [Wed, 14 Dec 2016 12:23:30 +0000 (13:23 +0100)] 
Further enhance async-push feature description

Signed-off-by: David Sommerseth <davids@openvpn.net>
Acked-by: Steffan Karger <steffan.karger@fox-it.com>
Message-Id: <1481718210-15673-1-git-send-email-davids@openvpn.net>
URL: http://www.mail-archive.com/search?l=mid&q=1481718210-15673-1-git-send-email-davids@openvpn.net

8 years agoman: mention that --ecdh-curve does not work on mbed TLS builds
Steffan Karger [Tue, 13 Dec 2016 19:51:12 +0000 (20:51 +0100)] 
man: mention that --ecdh-curve does not work on mbed TLS builds

Not needed either, because mbed TLS automatically selects the curve based
on the certificate.

Trac: #789

Signed-off-by: Steffan Karger <steffan@karger.me>
Acked-by: David Sommerseth <davids@openvpn.net>
Message-Id: <1481658672-5110-1-git-send-email-steffan@karger.me>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg13523.html
Signed-off-by: David Sommerseth <davids@openvpn.net>
8 years agoUnhide a line in man page by fixing a typo
Selva Nair [Tue, 13 Dec 2016 16:11:38 +0000 (11:11 -0500)] 
Unhide a line in man page by fixing a typo

Signed-off-by: Selva Nair <selva.nair@gmail.com>
Acked-by: Steffan Karger <steffan@karger.me>
Message-Id: <1481645498-22043-1-git-send-email-selva.nair@gmail.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg13520.html
Signed-off-by: David Sommerseth <davids@openvpn.net>
8 years agosystemd: Intermediate --chroot fix with the new sd_notify() implementation
David Sommerseth [Wed, 7 Dec 2016 02:51:52 +0000 (03:51 +0100)] 
systemd: Intermediate --chroot fix with the new sd_notify() implementation

Commit c5931897ae8d663e7e introduced support for talking directly
to the systemd service manager about the situation for the OpenVPN
tunnel. This approach makes a lot of sense and is mostly the proper
way to do it.  But it was discovered that it breaks OpenVPN
configurations using --chroot.

The reason sd_notify() calls fails when using chroot() is that
sd_notify() expects to have access to a file as declared in the
$NOTIFY_SOCKET environment variable.  It is the main systemd
instance which is responsible to provide both the environment variable
as well as the socket file sd_nodify() should use.  When --chroot
comes into play, the $NOTIFY_SOCKET file will not be available
for OpenVPN any more.

As things are getting close to the 2.4_rc2 release we will not dare
to bring a too invasive fix.  As well we need some time to discuss
an approrpriate solution.  So this intermediate fix will only
provide a "successful start" message to the systemd service manager
right before chroot() happens.  This will at least resolve the issue
in a safe and non-intrusive way.

Signed-off-by: David Sommerseth <davids@openvpn.net>
Acked-by: Christian Hesse <mail@eworm.de>
Message-Id: <1481079112-22990-1-git-send-email-davids@openvpn.net>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg13416.html

8 years agoChanges: Further improve systemd unit file updates
David Sommerseth [Fri, 9 Dec 2016 19:52:17 +0000 (20:52 +0100)] 
Changes: Further improve systemd unit file updates

There were some reports that the directories mentioned should
have trailing /, to make it clearer they are directories and not
files.  Also rephrased that sentence slightly to be even clearer
in this aspect.

Signed-off-by: David Sommerseth <davids@openvpn.net>
8 years agombedtls: include correct net/net_sockets header according to version
Magnus Kroken [Fri, 9 Dec 2016 09:07:35 +0000 (10:07 +0100)] 
mbedtls: include correct net/net_sockets header according to version

<mbedtls/net.h> is deprecated as of mbedTLS 2.4.0, it is renamed
<mbedtls/net_sockets.h>. OpenVPN will fail to build with
mbedTLS 2.4.0 with MBEDTLS_DEPRECATED_REMOVED defined.

Check MBEDTLS_VERSION_NUMBER, and include net.h for < 2.4.0 and
net_sockets.h for >= 2.4.0.

Signed-off-by: Magnus Kroken <mkroken@gmail.com>
Acked-by: Steffan Karger <steffan.karger@fox-it.com>
Message-Id: <1481274455-657-1-git-send-email-mkroken@gmail.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg13451.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
8 years agoDeprecate --no-iv
Steffan Karger [Wed, 7 Dec 2016 19:20:47 +0000 (20:20 +0100)] 
Deprecate --no-iv

This fixes the bug of supporting --no-iv (since we're only accepting
bugfixes in the current release phase ;) ).

The --no-iv function decreases security if used (CBC *requires*
unpredictable IVs, other modes don't allow --no-iv at all), and even
marginally decreases other user's security by adding unwanted
complexity to our code.

Let's get rid of this.

Signed-off-by: Steffan Karger <steffan@karger.me>
Acked-by: Gert Doering <gert@greenie.muc.de>
Acked-by: Arne Schwabe <arne@rfc2549.org>
Message-Id: <1481138447-6292-1-git-send-email-steffan@karger.me>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg13430.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
8 years agoFix (and cleanup) crypto flags in combination with NCP
Steffan Karger [Wed, 7 Dec 2016 18:01:24 +0000 (19:01 +0100)] 
Fix (and cleanup) crypto flags in combination with NCP

tls_session_update_crypto_params() did not properly set crypto_flags_or,
but instead set crypto_flags_and twice if a OFB/CFB mode was selected.

Also, the crypto flags in ks->crypto_options.flags were set before
tls_session_update_crypto_params() was called, causing those to not be
adjusted.  To fix this, set the crypto flags in
tls_session_generate_data_channel_keys() instead of key_state_init().

While touching that code, remove the to _or and _and variables, which are
not needed at all.

Finally, refuse to accept --no-iv if NCP is enabled  (we might otherwise
negotiate invalid combinations and ASSERT out later, and using --no-iv is
a bad idea anyway).

Trac: #784

Signed-off-by: Steffan Karger <steffan@karger.me>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <1481133684-5325-1-git-send-email-steffan@karger.me>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg13428.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
8 years agoRefactor setting close-on-exec for socket FDs
Gert Doering [Tue, 6 Dec 2016 12:26:02 +0000 (13:26 +0100)] 
Refactor setting close-on-exec for socket FDs

The existing code can leak socket FDs to the "--up" script, which is
not desired.  Brought up by Alberto Gonzalez Iniesta, based on debian
bug 367716.

Since different sockets get create at different times, just moving the
set_cloexec() to link_socket_init_phase1() is not good enough - so move
the call into create_socket_<family>(), so we will catch ALL socket
creations, no matter when or under which conditions they will be
created (SOCKS proxy socket, listening socket, ...).

--inetd gets an extra fd_cloexec() call, as socket FD is inherited.

URL: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=367716

v2: remove set_cloexec() calls from manage.c

v3: add set_cloexec() calls to accept()ed TCP/unix child sockets

Signed-off-by: Gert Doering <gert@greenie.muc.de>
Acked-by: Arne Schwabe <arne@rfc2549.org>
Message-Id: <1481027162-12165-1-git-send-email-gert@greenie.muc.de>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg13405.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
8 years agoAdd "async push" feature to Changes.rst
Lev Stipakov [Wed, 7 Dec 2016 09:56:57 +0000 (11:56 +0200)] 
Add "async push" feature to Changes.rst

[DS: slightly enhanced the --enable-async-push remark to make it
     even more clear it is a build time configuration]

Acked-by: David Sommerseth <davids@openvpn.net>
Message-Id: <1481104617-3675-1-git-send-email-lstipakov@gmail.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg13420.html
Signed-off-by: David Sommerseth <davids@openvpn.net>
8 years agoArm inotify only in server mode
Lev Stipakov [Tue, 6 Dec 2016 23:45:51 +0000 (01:45 +0200)] 
Arm inotify only in server mode

Async-push is a server side feature and inotify_fd is
initialized in server mode.

Trac: #786
Signed-off-by: Lev Stipakov <lstipakov@gmail.com>
Acked-by: David Sommerseth <davids@openvpn.net>
Message-Id: <1481067951-28917-1-git-send-email-lstipakov@gmail.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg13415.html
Signed-off-by: David Sommerseth <davids@openvpn.net>
8 years agoFix wrong configure.ac parsing of --enable-async-push
David Sommerseth [Tue, 6 Dec 2016 22:10:51 +0000 (23:10 +0100)] 
Fix wrong configure.ac parsing of --enable-async-push

AC_ARG_ENABLE() was used wrong, which led enable_async_push to
always be set, regardless if --enable-async-push or --disable-async-push
was used.

Also spotted the exact same patch when writing this commit message as
GitHub PR#70.

Trac: #786
Signed-off-by: David Sommerseth <davids@openvpn.net>
Acked-by: Lev Stipakov <lstipakov@gmail.com>
Message-Id: <1481062251-18349-1-git-send-email-davids@openvpn.net>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg13411.html

8 years agoCorrectly state the default dhcp server address in man page
Selva Nair [Fri, 2 Dec 2016 19:42:09 +0000 (14:42 -0500)] 
Correctly state the default dhcp server address in man page

Also correct the default ifconfig-pool end in docs and comments

Signed-off-by: Selva Nair <selva.nair@gmail.com>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <1480707729-19578-1-git-send-email-selva.nair@gmail.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg13387.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
8 years agoPreparing OpenVPN v2.4_rc1 release v2.4_rc1
David Sommerseth [Thu, 1 Dec 2016 23:09:00 +0000 (00:09 +0100)] 
Preparing OpenVPN v2.4_rc1 release

Signed-off-by: David Sommerseth <davids@openvpn.net>
8 years agoRefuse to daemonize when running from systemd
Christian Hesse [Thu, 1 Dec 2016 21:31:04 +0000 (22:31 +0100)] 
Refuse to daemonize when running from systemd

We start with systemd Type=notify, so refuse to daemonize. This does not
affect starting openvpn from script or command line.

v2: Update commit message about script and command line.

Signed-off-by: Christian Hesse <mail@eworm.de>
Tested-By: Richard Bonhomme <fragmentux@gmail.com>
Acked-by: David Sommerseth <davids@openvpn.net>
Message-Id: <20161201213104.5667-2-list@eworm.de>
URL: http://www.mail-archive.com/search?l=mid&q=20161201213104.5667-2-list@eworm.de
Signed-off-by: David Sommerseth <davids@openvpn.net>
8 years agoUse systemd service manager notification
Christian Hesse [Thu, 1 Dec 2016 21:31:03 +0000 (22:31 +0100)] 
Use systemd service manager notification

Notify systemd service manager when our initialization sequence
completed. This helps ordering services as dependencies can rely on vpn
being available.

v2: Add curly brackets (and indention) to block the else-part, msg()
    call was non-conditional before.

v3: Move systemd header include from init.h to init.c.

Signed-off-by: Christian Hesse <mail@eworm.de>
Tested-By: Richard Bonhomme <fragmentux@gmail.com>
Acked-by: David Sommerseth <davids@openvpn.net>
Message-Id: <20161201213104.5667-1-list@eworm.de>
URL: http://www.mail-archive.com/search?l=mid&q=20161201213104.5667-1-list@eworm.de
Signed-off-by: David Sommerseth <davids@openvpn.net>
8 years agoMention that OpenVPN 2.4 requires Windows Vista or higher
Samuli Seppänen [Thu, 1 Dec 2016 14:03:05 +0000 (16:03 +0200)] 
Mention that OpenVPN 2.4 requires Windows Vista or higher

Trac: #610

Signed-off-by: Samuli Seppänen <samuli@openvpn.net>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <1480600985-25074-1-git-send-email-samuli@openvpn.net>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg13357.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
8 years agoreload CRL only if file was modified
Antonio Quartulli [Thu, 1 Dec 2016 10:41:45 +0000 (18:41 +0800)] 
reload CRL only if file was modified

In order to prevent annoying delays upon client connection,
reload the CRL file only if it was modified since the last
reload operation.
If not, keep on using the already stored CRL.

This change will boost client connection time in instances
where the CRL file is quite large (dropping from several
seconds to few milliseconds).

Cc: Steffan Karger <steffan.karger@fox-it.com>
Signed-off-by: Antonio Quartulli <a@unstable.cc>
Acked-by: Steffan Karger <steffan.karger@fox-it.com>
Message-Id: <20161201104145.23821-1-a@unstable.cc>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg13345.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
8 years agoDo not restart dns client service as a part of --register-dns processing
Selva Nair [Wed, 30 Nov 2016 21:51:36 +0000 (16:51 -0500)] 
Do not restart dns client service as a part of --register-dns processing

As reported and discussed on Trac #775, restarting dns service has
unwanted side effects when there are dependent services. And it
appears unnecessary to restart this service to get DNS registered
on Windows.

Resolve by removing two actions from --register-dns:
'net stop dnscache' and 'net start dnscache' run through the service
or directly.

Trac: #775

Signed-off-by: Selva Nair <selva.nair@gmail.com>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <1480542696-7123-1-git-send-email-selva.nair@gmail.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg13331.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
8 years agoForce 'def1' method when --redirect-gateway is done through service
Selva Nair [Wed, 30 Nov 2016 00:39:32 +0000 (19:39 -0500)] 
Force 'def1' method when --redirect-gateway is done through service

The service deletes all added routes when the client process (openvpn)
exits, causing the re-instated default route to disappear.
Fix by rewriting "--redirect-gateway" to "--redirect-gateway def1" when
routes are set using interactive service.

Only the behaviour on Windows with intereactive service is affected.

Trac: #778

Signed-off-by: Selva Nair <selva.nair@gmail.com>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <1480466372-2396-1-git-send-email-selva.nair@gmail.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg13307.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
8 years agoWhen parsing '--setenv opt xx ..' make sure a third parameter is present
Selva Nair [Wed, 30 Nov 2016 01:53:14 +0000 (20:53 -0500)] 
When parsing '--setenv opt xx ..' make sure a third parameter is present

When no parameters are present, set it to "setenv opt" to trigger a
descriptive error message. And, thus get rid of the pesky NULL pointer
dereferencing.

Trac: #779

Signed-off-by: Selva Nair <selva.nair@gmail.com>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <1480470794-6349-1-git-send-email-selva.nair@gmail.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg13311.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
8 years agoIntroduce and use secure_memzero() to erase secrets
Steffan Karger [Mon, 28 Nov 2016 22:14:12 +0000 (23:14 +0100)] 
Introduce and use secure_memzero() to erase secrets

As described in trac #751, and shortly after reported by Zhaomo Yang, of
the University of California, San Diego, we use memset() (often through
the CLEAR() macro) to erase secrets after use.  In some cases however, the
compiler might optimize these calls away.

This patch replaces these memset() calls on secrets by calls to a new
secure_memzero() function, that will not be optimized away.

Since we use CLEAR() a LOT of times, I'm not changing that to use
secure_memzero() to prevent performance impact.  I did annotate the macro
to point people at secure_memzero().

This patch also replaces some CLEAR() or memset() calls with a zero-
initialization using "= { 0 }" if that has the same effect, because that
better captures the intend of that code.

Trac: #751

Signed-off-by: Steffan Karger <steffan.karger@fox-it.com>
Acked-by: Selva Nair <selva.nair@gmail.com>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <1480371252-3880-1-git-send-email-steffan@karger.me>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg13278.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
8 years agoMap restart signals from event loop to SIGTERM during exit-notification wait
Selva Nair [Tue, 29 Nov 2016 02:27:04 +0000 (21:27 -0500)] 
Map restart signals from event loop to SIGTERM during exit-notification wait

Commit 63b3e000c9.. fixed SIGTERM getting lost during exit notification
by ignoring any restart signals triggered during this interval. However,
as reported in Trac 777, this could result in repeated triggering of
restart signals when the event loop cannot continue without restart due
to IO errors or timeout.

Avoid by converting soft SIGUSR1 and SIGHUP signals received during
exit-notify wait period to SIGTERM.

Trac #777

Signed-off-by: Selva Nair <selva.nair@gmail.com>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <1480386424-30876-1-git-send-email-selva.nair@gmail.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg13284.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
8 years agoFix windows path in Changes.rst
Gert Doering [Mon, 28 Nov 2016 19:06:52 +0000 (20:06 +0100)] 
Fix windows path in Changes.rst

Escape backslash characters in windows path names.

Signed-off-by: Gert Doering <gert@greenie.muc.de>
Acked-by: Selva Nair <selva.nair@gmail.com>
Message-Id: <1480360012-9479-1-git-send-email-gert@greenie.muc.de>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg13274.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
8 years agoupdate year in copyright message
Christian Hesse [Mon, 28 Nov 2016 17:08:20 +0000 (18:08 +0100)] 
update year in copyright message

This line has not been touched in a long time... Let's update the
copyright message with recent year.

Signed-off-by: Christian Hesse <mail@eworm.de>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20161128170820.20371-1-list@eworm.de>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg13270.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
8 years agoClean up format_hex_ex()
Steffan Karger [Mon, 28 Nov 2016 14:26:40 +0000 (15:26 +0100)] 
Clean up format_hex_ex()

Fix a potential null-pointer dereference, and make the code a bit more
readable while doing so.

The NULL dereference could not be triggered, because the current code
never called format_hex_ex() with maxouput == 0 and separator == NULL.
But it's nicer to not depend on that.

Our use of int vs size_t for lengths needs some attention too, but I'm
not pulling that into this patch.  Instead I decided to just make the
(previously existing) assumption that INT_MAX <= SIZE_MAX explicit by
adding a static_assert().

Signed-off-by: Steffan Karger <steffan.karger@fox-it.com>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <1480343200-25908-1-git-send-email-steffan.karger@fox-it.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg13259.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
8 years agoUnconditionally enable TLS_AGGREGATE_ACK
Steffan Karger [Mon, 28 Nov 2016 14:53:21 +0000 (15:53 +0100)] 
Unconditionally enable TLS_AGGREGATE_ACK

This define has been enabled by default since 2005, and was not
configurable through ./configure (but just by changing ssl.h).  Let's
get rid of it.

Signed-off-by: Steffan Karger <steffan.karger@fox-it.com>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <1480344801-27855-2-git-send-email-steffan.karger@fox-it.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg13261.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
8 years agotls_process: don't set variable that's never read
Steffan Karger [Mon, 28 Nov 2016 14:53:20 +0000 (15:53 +0100)] 
tls_process: don't set variable that's never read

Found by the clang static analyzer: the state_change variable is set,
but never read afterwards.  This code has been like this since 2005,
makes sense without setting state_change to true, and has worked fine
for the past 11 years.

Signed-off-by: Steffan Karger <steffan.karger@fox-it.com>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <1480344801-27855-1-git-send-email-steffan.karger@fox-it.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg13260.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
8 years agoPreparing OpenVPN v2.4_beta2 release v2.4_beta2
David Sommerseth [Thu, 24 Nov 2016 14:04:51 +0000 (15:04 +0100)] 
Preparing OpenVPN v2.4_beta2 release

This also adds a few missing details from Changes.rst

Signed-off-by: David Sommerseth <davids@openvpn.net>
8 years agoSet IPv6 DNS servers using interactive service
Selva Nair [Thu, 24 Nov 2016 03:35:27 +0000 (22:35 -0500)] 
Set IPv6 DNS servers using interactive service

- Any existing addresses are deleted before adding
- On close_tun all addresses are deleted (only if any were added)

Signed-off-by: Selva Nair <selva.nair@gmail.com>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <1479958527-29491-1-git-send-email-selva.nair@gmail.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg13222.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
8 years agoRefactor data channel key generation API
Steffan Karger [Wed, 23 Nov 2016 20:02:05 +0000 (21:02 +0100)] 
Refactor data channel key generation API

Originally for "poor man's NCP", I introduced a simpler API for generating
data channel keys.  That refactoring is no longer needed for that patch,
but I believe still worth a patch on it's own.

This patch should not change any functionality.

Signed-off-by: Steffan Karger <steffan@karger.me>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <1479931325-25919-2-git-send-email-steffan@karger.me>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg13216.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
8 years agoPoor man's NCP for non-NCP peers
Steffan Karger [Wed, 23 Nov 2016 21:21:44 +0000 (22:21 +0100)] 
Poor man's NCP for non-NCP peers

Allows non-NCP peers (<= 2.3, or 2.4+ with --ncp-disable) to specify a
--cipher that is different from the one in our config, as long as the new
cipher value is allowed (i.e. in --ncp-ciphers at our side).

This works both client-to-server and server-to-client.  I.e. a 2.4 client
with "cipher BF-CBC" and "ncp-ciphers AES-256-GCM:AES-256-CBC" can connect
to both a 2.3 server with "cipher BF-CBC" as well as a server with
"cipher AES-256-CBC" in its config.  The other way around, a 2.3 client
with either "cipher BF-CBC" or "cipher AES-256-CBC" can connect to a 2.4
server with e.g. "cipher BF-CBC" and "ncp-ciphers AES-256-GCM:AES-256-CBC"
in its config.

This patch was inspired by Gert's "Poor man's NCP for 2.3 clients" patch,
but takes a different approach to avoid the need for server-side scripts
or client-side 'setenv UV_*' tricks.

Signed-off-by: Steffan Karger <steffan@karger.me>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <1479936104-4045-1-git-send-email-steffan@karger.me>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg13218.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
8 years agoDocument the --auth-token option
David Sommerseth [Sat, 17 Sep 2016 13:20:15 +0000 (16:20 +0300)] 
Document the --auth-token option

This isn't an option to be used directly in any configuration files,
but to be used via --client-connect scripts or --plugin making use of
OPENVPN_PLUGIN_CLIENT_CONNECT or OPENVPN_PLUGIN_CLIENT_CONNECT_V2.

 [v2 - Added lacking .B styling of options
     - Clarified the token life time ]

Signed-off-by: David Sommerseth <davids@openvpn.net>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <1474118415-14666-1-git-send-email-davids@openvpn.net>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg12506.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
8 years agogenerate_key_expansion: make assumption explicit, use C99 features
Steffan Karger [Tue, 22 Nov 2016 20:09:26 +0000 (21:09 +0100)] 
generate_key_expansion: make assumption explicit, use C99 features

This function potentially allocates memory, and can therefor not be run
again on an initialized key_ctx_bi.  Make this explicit by adding an error
if someone tries do to this anyway.

While touching the function, cleanup it up a bit to make up for the added
lines of code.

Signed-off-by: Steffan Karger <steffan@karger.me>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <1479845366-15774-1-git-send-email-steffan@karger.me>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg13202.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
8 years agoChange cmocka remote to use https in stead of git protocol
Steffan Karger [Tue, 22 Nov 2016 20:12:08 +0000 (21:12 +0100)] 
Change cmocka remote to use https in stead of git protocol

Allows to clone the cmocka submodule from networks where 'anything but
web and mail' is firewalled.

Signed-off-by: Steffan Karger <steffan.karger@fox-it.com>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <1479845528-16068-1-git-send-email-steffan@karger.me>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg13203.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
8 years ago--tls-crypt fixes
Steffan Karger [Tue, 22 Nov 2016 20:41:26 +0000 (21:41 +0100)] 
--tls-crypt fixes

* Check return value of buf_init()  (found by coverity)

* Use the TLS frame to determine the buffer size, as is done for the
  reliability buffers used for tls-auth.  (We previously incorrectly used
  the TLS *plaintext* buffer size, which is bigger for typical setups
  with tun-mtu <= 1500.  Using the frame to calculate the size saves some
  bytes for typical setups, and doesn't break setups with big tun-mtu.)

* More carefully handle errors in tls_crypt_wrap() - just drop the packet
  instead of ASSERT()ing out (should not happen in the first place, but
  this is a bit more friendly if it happens somehow anyway).

Signed-off-by: Steffan Karger <steffan@karger.me>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <1479847286-17518-1-git-send-email-steffan@karger.me>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg13204.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>