]> git.ipfire.org Git - thirdparty/openvpn.git/log
thirdparty/openvpn.git
9 years agointeractive service v3
Heiko Hund [Tue, 26 Jan 2016 19:11:48 +0000 (20:11 +0100)] 
interactive service v3

v1: Heiko Hund
 - Message-ID: <2215306.x9ci9DhAZ9@de-gn-40970>
 - extend openvpn service to provide "automatic service" and "interactive
   service" (which is used by GUI and OpenVPN to run openvpn non-privileged
   and still be able to install routes and configure IPv6 addresses)
 - add --msg-channel <n> option to openvpn to tell it which pipe to use
   to talk to the interactive service (used in tun.c for ifconfig + ARP
   flush, and route.c for routing)
 - add openvpn-msg.h with message definitions for talking to interactive
   service
 - routing in openvpn uses message-pipe automatically if --msg-channel <n>
   is configured, no other option needed
 - today, the integration in route.c and tun.c is windows-only, but could
   be adapted to other platforms

v2: Steffan Karger
 - Message-ID: <548D9046.5000600@karger.me>
 - include "openvpn-msg.h" not "include/openvpn-msg.h"
 - add $(top_srcdir)/include to openvpnsrv build for out-of-tree builds

v3: Gert Doering, rebasing and integrating review feedback
 - rebased to 417fe4a72c
 - r->metric_defined is now r->flags & RT_METRIC_DEFINED (c3ef2d2333fb)
 - move "openvpn-msg.h" include inside #ifdef WIN32 (windows-only right now)
 - hide "msg_channel" extra option inside tt->tuntap_options, so we do not
   need an extra argument to all the add/del_route...() functions
 - do_route_ipv6_service(): use r->adapter index (if set) for RGI6 routes

Signed-off-by: Heiko Hund <heiko.hund@sophos.com>
Signed-off-by: Gert Doering <gert@greenie.muc.de>
Acked-by: Selva Nair <selva.nair@gmail.com> (Service changes)
Acked-by: Arne Schwabe <arne@rfc2549.org> (OpenVPN changes)
Message-Id: <1453835508-26119-1-git-send-email-gert@greenie.muc.de>
URL: http://article.gmane.org/gmane.network.openvpn.devel/11027
Signed-off-by: Gert Doering <gert@greenie.muc.de>
9 years agoFix undefined signed shift overflow
Michael McConville [Tue, 2 Feb 2016 19:11:22 +0000 (14:11 -0500)] 
Fix undefined signed shift overflow

Originally discussed here:

https://github.com/OpenVPN/openvpn/pull/42

Thanks for your time,
Michael

Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20160202191122.GE1675@thinkpad.swarthmore.edu>
URL: http://article.gmane.org/gmane.network.openvpn.devel/11050

Signed-off-by: Gert Doering <gert@greenie.muc.de>
9 years agoconfigure.ac: fix polarssl autodetection
Steffan Karger [Mon, 18 Jan 2016 20:49:40 +0000 (21:49 +0100)] 
configure.ac: fix polarssl autodetection

A missing , in the previous configure.ac patch caused the autodetection to
fail.  While fixing that, I noticed I can simplify the check by using the
documented ${ac_cv_search_function} cache variable instead of the nested
AC_SEARCH_LIBS.

Signed-off-by: Steffan Karger <steffan@karger.me>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <1453150181-21453-1-git-send-email-steffan@karger.me>
URL: http://article.gmane.org/gmane.network.openvpn.devel/11010
Signed-off-by: Gert Doering <gert@greenie.muc.de>
9 years agoconfigure.ac: simplify crypto library configuration
Steffan Karger [Sun, 10 Jan 2016 14:37:19 +0000 (15:37 +0100)] 
configure.ac: simplify crypto library configuration

This reworks the crypto library configuration, to make it both simpler to
understand and more usable:

 * Only check for OpenSSL when building against OpenSSL (and similar for
   PolarSSL/mbed TLS).
 * Bail out early if a problem with the library is detected.
 * Set CRYPTO_{LIBS,FLAGS} immediately after the crypto library checks,
   removing the need for an extra switch-case later on.
 * We no longer support building openvpn with crypto but without ssl, so
   we can also simplify the logic in configure.ac accordingly.

As a 'side effect' (this actually triggered me), this fixes a bug that
would cause a user-specified OPENSSL_{CRYPTO,SSL}_LIBS to be overwritten
by AC_CHECK_LIB if there are openssl headers available in the PATH.

Signed-off-by: Steffan Karger <steffan@karger.me>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <1452436639-16838-1-git-send-email-steffan@karger.me>
URL: http://article.gmane.org/gmane.network.openvpn.devel/10978
Signed-off-by: Gert Doering <gert@greenie.muc.de>
9 years agoClarify --block-outside-dns documentation
ValdikSS [Sat, 16 Jan 2016 14:05:26 +0000 (17:05 +0300)] 
Clarify --block-outside-dns documentation

Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <1452953126-6283-1-git-send-email-iam@valdikss.org.ru>
URL: http://article.gmane.org/gmane.network.openvpn.devel/11001

Signed-off-by: Gert Doering <gert@greenie.muc.de>
9 years agoClarify mssfix documentation
ValdikSS [Sat, 9 Jan 2016 15:53:45 +0000 (18:53 +0300)] 
Clarify mssfix documentation

Acked-by: Jan Just Keijser <janjust@nikhef.nl>
Message-Id: <1452354825-5096-1-git-send-email-iam@valdikss.org.ru>
URL: http://article.gmane.org/gmane.network.openvpn.devel/10969

Signed-off-by: Gert Doering <gert@greenie.muc.de>
9 years agoFix build with libressl
Niels Ole Salscheider [Sun, 10 Jan 2016 13:44:35 +0000 (14:44 +0100)] 
Fix build with libressl

Signed-off-by: Niels Ole Salscheider <niels_ole@salscheider-online.de>
Acked-by: Steffan Karger <steffan.karger@fox-it.com>
Message-Id: <1452433475-16779-1-git-send-email-niels_ole@salscheider-online.de>
URL: http://article.gmane.org/gmane.network.openvpn.devel/10975
Signed-off-by: Gert Doering <gert@greenie.muc.de>
9 years agosocks.c: fix check on get_user_pass() return value(s)
Steffan Karger [Wed, 13 Jan 2016 16:09:08 +0000 (17:09 +0100)] 
socks.c: fix check on get_user_pass() return value(s)

My compiler rightfully complains that the checks on creds.username and
creds.password always evaluate to true, so remove those checks.

Judging from the code, they were meant to check the returned values by
get_user_pass().  So instead of these non-functioning checks, just check
the return value of get_user_pass().

Signed-off-by: Steffan Karger <steffan@karger.me>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <1452701348-9577-1-git-send-email-steffan@karger.me>
URL: http://article.gmane.org/gmane.network.openvpn.devel/10993
Signed-off-by: Gert Doering <gert@greenie.muc.de>
9 years agoIgnore stamp-h2 we generate during build process
Arne Schwabe [Thu, 10 Dec 2015 12:37:15 +0000 (13:37 +0100)] 
Ignore stamp-h2 we generate during build process

Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <1449751035-10757-1-git-send-email-arne@rfc2549.org>
URL: http://article.gmane.org/gmane.network.openvpn.devel/10721

Signed-off-by: Gert Doering <gert@greenie.muc.de>
9 years agopolarssl: remove now redundant 128-bit blowfish key override
Steffan Karger [Thu, 7 Jan 2016 20:24:33 +0000 (21:24 +0100)] 
polarssl: remove now redundant 128-bit blowfish key override

As of 1.3.0, polarssl/mbedtls now by default uses a 128 bit key for the
blowfish cipher (as opposed to the 32-bit (!) default they had previously).
Since we require polar 1.3+, we no longer need this fixup code.

Signed-off-by: Steffan Karger <steffan@karger.me>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <1452198273-26493-1-git-send-email-steffan@karger.me>
URL: http://article.gmane.org/gmane.network.openvpn.devel/10956
Signed-off-by: Gert Doering <gert@greenie.muc.de>
9 years agopolarssl: use wrappers to access md_info_t member functions
Steffan Karger [Thu, 7 Jan 2016 20:22:12 +0000 (21:22 +0100)] 
polarssl: use wrappers to access md_info_t member functions

The md_info_t will become an opaque struct in mbed TLS 2.x, start using
the wrapper function in preparation to a future upgrade to 2.x.

Signed-off-by: Steffan Karger <steffan@karger.me>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <1452198132-25560-1-git-send-email-steffan@karger.me>
URL: http://article.gmane.org/gmane.network.openvpn.devel/10955
Signed-off-by: Gert Doering <gert@greenie.muc.de>
9 years agoUpdate manpage: OpenSSL might also need /dev/urandom inside chroot
Steffan Karger [Thu, 7 Jan 2016 19:52:44 +0000 (20:52 +0100)] 
Update manpage: OpenSSL might also need /dev/urandom inside chroot

As reported in trac ticket #646, OpenSSL might also need /dev/urandom to
be available in the chroot.  This depends on OS, OS version and ssl library
configuration.  Update the manpage to better explain this.

Signed-off-by: Steffan Karger <steffan@karger.me>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <1452196364-18786-1-git-send-email-steffan@karger.me>
URL: http://article.gmane.org/gmane.network.openvpn.devel/10954
Signed-off-by: Gert Doering <gert@greenie.muc.de>
9 years agopolarssl: optimize polar_ok() for non-errors
Steffan Karger [Thu, 7 Jan 2016 09:15:16 +0000 (10:15 +0100)] 
polarssl: optimize polar_ok() for non-errors

Adding polar_ok() was a good plan for improving error reporting, but also
added two function calls (one to polar_log_func_line() and one to
polar_log_err()) for each function call wrapped with polar_ok().
Especially in the critical path, this is a waste of time.

To avoid this overhead, add a simple static inline wrapper to reduce it to
a single branch.

v2 - use a static inline wrapper to prevent evaluating 'errval' twice in
     the macro.

Signed-off-by: Steffan Karger <steffan.karger@fox-it.com>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <1452158116-17363-1-git-send-email-steffan.karger@fox-it.com>
URL: http://article.gmane.org/gmane.network.openvpn.devel/10949
Signed-off-by: Gert Doering <gert@greenie.muc.de>
9 years agopolarssl: actually use polarssl debug logging
Steffan Karger [Wed, 6 Jan 2016 20:59:03 +0000 (21:59 +0100)] 
polarssl: actually use polarssl debug logging

We had the machinery in place, but did not actually use it because nothing
will be logged untill the debug threshold is increased.

This commit makes --verb 8 result is level 2 polar logging (which is
verbose, and --verb 9 result in level 3 polar logging (which is very
verbose).  There are higher levels, but those are extremely verbose.

Signed-off-by: Steffan Karger <steffan@karger.me>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <1452113943-30684-1-git-send-email-steffan@karger.me>
URL: http://article.gmane.org/gmane.network.openvpn.devel/10945
Signed-off-by: Gert Doering <gert@greenie.muc.de>
9 years agoFix assert when comp is called with unknown algorithm, always call comp init method
Arne Schwabe [Tue, 5 Jan 2016 14:56:01 +0000 (15:56 +0100)] 
Fix assert when comp is called with unknown algorithm, always call comp init method

Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <1452005761-5503-1-git-send-email-arne@rfc2549.org>
URL: http://article.gmane.org/gmane.network.openvpn.devel/10939

Signed-off-by: Gert Doering <gert@greenie.muc.de>
9 years agoImplement the compression V2 data format for stub and lz4.
Arne Schwabe [Sun, 3 Jan 2016 17:27:46 +0000 (18:27 +0100)] 
Implement the compression V2 data format for stub and lz4.

Patch V2: Fix minor issues found by Steffan
Patch V3: split wire codes and compression flags
Patch V4: Fix further issues reported by Gert
Patch V5: really fix the issues that should be fixed in v2
Patch V6: fix more minor things

It has been tested against v3 server and again itself. From James Mail:

 Compression V2

   I have observed that compression in many cases, even when
   enabled, often does not produce packet size reduction
   because much of the packet data typically generated by web
   sessions is already compressed.  Further, the single byte that
   precedes the packet and indicates whether or not compression
   occurred has the unfortunate side effect of misaligning the IP
   packet in cases where compression did not occur.  To remedy this,
   I propose a Compression V2 header that is optimized for the
   case where compression does not occur.

   a. No compression occurred and first byte of IP/Ethernet packet
      is NOT 0x50 (0 bytes of overhead and maintains alignment):

        [ uncompressed IP/Ethernet packet ]

   b. No compression occurred and first byte of IP/Ethernet packet
      is 0x50 (2 bytes of overhead but unlikely since no known
      IP packet can begin with 0x50):

        [ 0x50 ] [ 0x00 ] [ uncompressed IP/Ethernet packet ]

   c. Compression occurred (2 bytes of overhead):

        [ 0x50 ] [ compression Alg ID ] [ compressed IP/Ethernet packet ]

      Compression Alg ID is one-byte algorithm identifier
      for LZ4 (0x1), LZO (0x2), or Snappy (0x3).

   This approach has several beneficial effects:

   1. In the common case where compression does not occur, no
      compression op is required, therefore there is zero overhead.

   2. When compression does not occur, the IP/Ethernet packet
      alignment is retained.

   3. This technique does not require any byte swapping with
      the tail of the packet which can potentially incur an
      expensive cache miss.

Acked-by: Steffan Karger <steffan.karger@fox-it.com>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <1451842066-13475-1-git-send-email-arne@rfc2549.org>
URL: http://article.gmane.org/gmane.network.openvpn.devel/10925

Signed-off-by: Gert Doering <gert@greenie.muc.de>
9 years agoFix regression in setups without a client certificate
Steffan Karger [Sun, 3 Jan 2016 09:47:56 +0000 (10:47 +0100)] 
Fix regression in setups without a client certificate

This fixes a null-pointer dereference in tls_ctx_cert_time(), which will
occur on clients that do not use a client certificate (ie that only have
auth-user-pass in the config, but no key and cert).  This bug was
introduced by commit 091edd8e on the master branch, and commit dfd940bb
on the release/2.3 branch.

This bug was found by chipitsine and reported in trac ticket #644.

While touching this function, I also made this function conform to the
openvpn coding style.

v2 - fix memory leak in builds using pre-1.0.2 openssl

Signed-off-by: Steffan Karger <steffan@karger.me>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <1451814476-32574-1-git-send-email-steffan@karger.me>
URL: http://article.gmane.org/gmane.network.openvpn.devel/10921
Signed-off-by: Gert Doering <gert@greenie.muc.de>
9 years agoDetecting and logging Windows versions
Lev Stipakov [Tue, 29 Dec 2015 21:02:37 +0000 (23:02 +0200)] 
Detecting and logging Windows versions

Also send it with peer-info as IV_PLAT_VER.

Signed-off-by: Lev Stipakov <lstipakov@gmail.com>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <1451422957-23951-1-git-send-email-lstipakov@gmail.com>
URL: http://article.gmane.org/gmane.network.openvpn.devel/10904
Signed-off-by: Gert Doering <gert@greenie.muc.de>
9 years agoMake certificate expiry warning patch (091edd8e299686) work on OpenSSL 1.0.1 and...
Jan Just Keijser [Sat, 26 Dec 2015 09:15:04 +0000 (10:15 +0100)] 
Make certificate expiry warning patch (091edd8e299686) work on OpenSSL 1.0.1 and earlier.

Integrating feedback from Steffan Karger, tested by Gert Doering on
FreeBSD 7.4 / OpenSSL 0.9.8.

Signed-off-by: Gert Doering <gert@greenie.muc.de>
Acked-by: Steffan Karger <steffan.karger@fox-it.com>
Message-Id: <20151226091900.GU24952@greenie.muc.de>
URL: http://article.gmane.org/gmane.network.openvpn.devel/10881

9 years agoUse bob.example.com and alice.example.com to improve clarity of documentation
Phillip Smith [Tue, 22 Dec 2015 00:12:26 +0000 (11:12 +1100)] 
Use bob.example.com and alice.example.com to improve clarity of documentation

This patch uses generic "bob.example.com" and "alice.example.com"
hostnames to replace the current "may" and "june" examples. Generic
names chosen rather than other names like "server"/"client" or
"head-office"/"remote-office" etc which may create other unintended
or implicit meanings to the reader.

The example.com domain is set aside defined by IANA for use as
documentation examples. Refer to: http://www.iana.org/domains/reserved
Using this well-known domain makes comprehension of documentation easier.
This patch incorporates feedback from Gert Doering and Selva Nair.

Signed-off-by: Phillip Smith <fukawi2@gmail.com>
Acked-by: Steffan Karger <steffan.karger@fox-it.com>
Message-Id: <1450743146-9050-1-git-send-email-fukawi2@gmail.com>
URL: http://article.gmane.org/gmane.network.openvpn.devel/10875
Signed-off-by: Gert Doering <gert@greenie.muc.de>
9 years agocleanup: get rid of httpdigest.c type warnings
Steffan Karger [Sun, 20 Dec 2015 21:27:48 +0000 (22:27 +0100)] 
cleanup: get rid of httpdigest.c type warnings

When I compile with --enable-strict, I only want to see warnings that are
relevant.  So, change httpdigest.c to make the casts explicit.

This commit should not change behaviour.

v2: as discussed on #openvpn-devel, make colon a const uint8_t *, instead
    of uint8_t.
v3: as further discussed on #openvpn-devel, don't use a 'colon' var, but
    just add casts.

Signed-off-by: Steffan Karger <steffan@karger.me>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <1450646868-15346-1-git-send-email-steffan@karger.me>
URL: http://article.gmane.org/gmane.network.openvpn.devel/10871
Signed-off-by: Gert Doering <gert@greenie.muc.de>
9 years agoMake assert_failed() print the failed condition
Steffan Karger [Sun, 20 Dec 2015 10:44:09 +0000 (11:44 +0100)] 
Make assert_failed() print the failed condition

Easy change to make logging output more useful.

v2: don't print the failed condition if ENABLE_SMALL is defined.

Signed-off-by: Steffan Karger <steffan@karger.me>
Acked-by: Arne Schwabe <arne@rfc2549.org>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <1450608249-9947-1-git-send-email-steffan@karger.me>
URL: http://article.gmane.org/gmane.network.openvpn.devel/10862
Signed-off-by: Gert Doering <gert@greenie.muc.de>
9 years agoDisable certificate notBefore/notAfter sanity check on OpenSSL < 1.0.2
Steffan Karger [Mon, 14 Dec 2015 22:14:45 +0000 (23:14 +0100)] 
Disable certificate notBefore/notAfter sanity check on OpenSSL < 1.0.2

The SSL_CTX_get0_certificate() function I used in 091edd8e is available in
OpenSSL 1.0.2+ only.  Older versions seem to not have a useful alternative.
The remaining option would then be to create a cache for our parsed
certificate, but that would mean adding more struct members and code for
the select group of people that do use an up-to-date openvpn, but do not
update their openssl.  I don't think that's worth it.  So just disable the
code for older openssl versions.

Signed-off-by: Steffan Karger <steffan@karger.me>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <1450131285-30182-1-git-send-email-steffan@karger.me>
URL: http://article.gmane.org/gmane.network.openvpn.devel/10802
Signed-off-by: Gert Doering <gert@greenie.muc.de>
9 years agoWarn user if their certificate has expired
Steffan Karger [Mon, 14 Dec 2015 20:09:18 +0000 (21:09 +0100)] 
Warn user if their certificate has expired

Previously, client certificate expiry warnings would only visible in the
server log, and server certificate expiry warnings in the client log.
Both after a (failed) connection attempt.  This patch adds a warning to
log when a users own certificate has expired (or is not yet valid) to ease
problem diagnosis / error reporting.

Note that this is just a warning, since on some systems (notably embedded
devices) there might be no correct time available.

Signed-off-by: Steffan Karger <steffan@karger.me>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <1450123758-31641-1-git-send-email-steffan@karger.me>
URL: http://article.gmane.org/gmane.network.openvpn.devel/10794
Signed-off-by: Gert Doering <gert@greenie.muc.de>
9 years agoPass adapter index to up/down scripts
Lev Stipakov [Sat, 12 Dec 2015 12:34:20 +0000 (14:34 +0200)] 
Pass adapter index to up/down scripts

Trac #637

Signed-off-by: Lev Stipakov <lstipakov@gmail.com>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <1449923660-27363-1-git-send-email-lstipakov@gmail.com>
URL: http://article.gmane.org/gmane.network.openvpn.devel/10762
Signed-off-by: Gert Doering <gert@greenie.muc.de>
9 years agoAdd Windows DNS Leak fix using WFP ('block-outside-dns')
ValdikSS [Thu, 10 Dec 2015 20:51:55 +0000 (23:51 +0300)] 
Add Windows DNS Leak fix using WFP ('block-outside-dns')

This option blocks all out-of-tunnel communication on TCP/UDP port 53
(except for OpenVPN itself), preventing DNS Leaks on Windows 8.1 and 10.

This is the same patch as dd628d2e0d786e4 in release/2.3, except that it
is always compiled (on WIN32) here - we already require compilation for
Vista+ in master (-> 2.4).

Reviewed-by: Selva Nair <selva.nair@gmail.com>
Reviewed-by: Lev Stipakov <lstipakov@gmail.com>
Reviewed-by: James Yonan <james@openvpn.net>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <1449780715-4027-1-git-send-email-iam@valdikss.org.ru>
URL: http://article.gmane.org/gmane.network.openvpn.devel/10744

Signed-off-by: Gert Doering <gert@greenie.muc.de>
9 years agoUse adapter index for add/delete_route_ipv6
Lev Stipakov [Fri, 11 Dec 2015 22:37:52 +0000 (00:37 +0200)] 
Use adapter index for add/delete_route_ipv6

Trac #637

Signed-off-by: Lev Stipakov <lstipakov@gmail.com>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <1449873472-14954-1-git-send-email-lstipakov@gmail.com>
URL: http://article.gmane.org/gmane.network.openvpn.devel/10759
Signed-off-by: Gert Doering <gert@greenie.muc.de>
9 years agoDetect config lines that are too long and give a warning/error
Arne Schwabe [Thu, 10 Dec 2015 12:37:10 +0000 (13:37 +0100)] 
Detect config lines that are too long and give a warning/error

Trac #631

Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <1449751030-10703-1-git-send-email-arne@rfc2549.org>
URL: http://article.gmane.org/gmane.network.openvpn.devel/10723

Signed-off-by: Gert Doering <gert@greenie.muc.de>
9 years agoFix isatty() check for good.
Gert Doering [Wed, 9 Dec 2015 20:03:55 +0000 (21:03 +0100)] 
Fix isatty() check for good.

Commit 079e5b9c13 introduced a check to see if we --daemon'ized before
trying to ask for a password (which would then fail with a non-intuitive
error), breaking querying systemd under certain conditions.

Move check from get_user_pass_cr() to get_console_input() and make it
"full featured" by not only checking isatty() for stdin/stderr but also
trying to open /dev/tty in case we still have a controlling tty - which
is what getpass() does under the hood, so if either of this works, we're
fine.

Trac #618 and #630

Signed-off-by: Gert Doering <gert@greenie.muc.de>
Acked-by: Selva Nair <selva.nair@gmail.com>
Message-Id: <1449691435-5928-1-git-send-email-gert@greenie.muc.de>
URL: http://article.gmane.org/gmane.network.openvpn.devel/10709

9 years agoAlso remove second instance of enable-password-save in the man page
Arne Schwabe [Sun, 29 Nov 2015 19:38:21 +0000 (20:38 +0100)] 
Also remove second instance of enable-password-save in the man page

Acked-by: Selva Nair <selva.nair@gmail.com>
Message-Id: <1448825901-12294-1-git-send-email-arne@rfc2549.org>
URL: http://article.gmane.org/gmane.network.openvpn.devel/10671

Signed-off-by: Gert Doering <gert@greenie.muc.de>
9 years agoReflect enable-password-save change in documentation
Arne Schwabe [Sun, 29 Nov 2015 18:52:24 +0000 (19:52 +0100)] 
Reflect enable-password-save change in documentation

Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <1448823144-1497-1-git-send-email-arne@rfc2549.org>
URL: http://article.gmane.org/gmane.network.openvpn.devel/10665

Signed-off-by: Gert Doering <gert@greenie.muc.de>
9 years agoRemove --enable-password-save option
Arne Schwabe [Sun, 29 Nov 2015 14:55:59 +0000 (15:55 +0100)] 
Remove --enable-password-save option

This options is enabled in virtually all distributions and gives no real
security benefit.
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <1448808959-10565-1-git-send-email-arne@rfc2549.org>
URL: http://article.gmane.org/gmane.network.openvpn.devel/10661

Signed-off-by: Gert Doering <gert@greenie.muc.de>
9 years agoput virtual IPv6 addresses into env
Heiko Hund [Wed, 25 Nov 2015 16:46:49 +0000 (17:46 +0100)] 
put virtual IPv6 addresses into env

Add missing environment variables for IPv6 virtual addresses:

  * ifconfig_pool_local_ip6
  * ifconfig_pool_remote_ip6
  * ifconfig_pool_ip6_netbits

Signed-off-by: Heiko Hund <heiko.hund@sophos.com>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <1448470009-5243-1-git-send-email-heiko.hund@sophos.com>
URL: http://article.gmane.org/gmane.network.openvpn.devel/10613
Signed-off-by: Gert Doering <gert@greenie.muc.de>
9 years agoUnbreak read username password from management
Selva Nair [Fri, 27 Nov 2015 02:20:53 +0000 (21:20 -0500)] 
Unbreak read username password from management

Commit 6e9373c846.. introduced a bug by which auth-user-pass
or need-ok input falls back to read-from-stdin after successfully
reading from management or console. Fix by treating stdin as the last
option for input.

Signed-off-by: Selva Nair <selva.nair@gmail.com>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <1448590853-26862-1-git-send-email-selva.nair@gmail.com>
URL: http://article.gmane.org/gmane.network.openvpn.devel/10630
Signed-off-by: Gert Doering <gert@greenie.muc.de>
9 years agoSupport duplicate x509 field values in environment
Steffan Karger [Sun, 29 Nov 2015 09:39:24 +0000 (10:39 +0100)] 
Support duplicate x509 field values in environment

As reported in trac #387, an x509 DN can contain duplicate fields.
Previously, we would overwrite any previous field value with a new one if
we would process a second same-name field.  Now, instead, append _$N,
starting at N=1 to the name for each consequent field to export all fields
to the enviroment.

v2 - make better use of const qualifiers in env_set_get(), and use strcpy()
     instead of memcpy() in setenv_str_incr()

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: <CAA1AbxLoZpanyqfpJuroMeOj_M=gU5JB+pqZqRxYqaiNP754-g@mail.gmail.com>
URL: http://article.gmane.org/gmane.network.openvpn.devel/10654
Signed-off-by: Gert Doering <gert@greenie.muc.de>
9 years agoFix openssl builds with custom-built library: specify most-dependent first
Steffan Karger [Sat, 28 Nov 2015 22:48:01 +0000 (23:48 +0100)] 
Fix openssl builds with custom-built library: specify most-dependent first

Libraries should be specified from left-to-right as most-dependent to
least-dependent.  Thus, -lssl comes first, then -lcrypto.

(This does not fail when pkg-config finds your libraries for you, since
we tell it '-lssl needs -lcrypto' and we then end up with
"-lcrypto -lssl -lcrypto", which is not pretty but does work.)

Signed-off-by: Steffan Karger <steffan@karger.me>
Acked-by: Arne Schwabe <arne@rfc2549.org>
Message-Id: <1448750881-10767-1-git-send-email-steffan@karger.me>
URL: http://article.gmane.org/gmane.network.openvpn.devel/10649
Signed-off-by: Gert Doering <gert@greenie.muc.de>
9 years agoUn-break compilation on *BSD
Gert Doering [Sat, 28 Nov 2015 19:58:37 +0000 (20:58 +0100)] 
Un-break compilation on *BSD

Commit 2191c47165 introduced code to handle IP address query on
multihoming hosts for IP_PKTINFO-supporting OSes, but all the BSDs
need the "#elsif IP_RECVDSTADDR" variant... add code equivalent
to what we have in socket.c/print_link_socket_actual_ex()

Tested on FreeBSD 9.3/sparc64

Signed-off-by: Gert Doering <gert@greenie.muc.de>
Acked-by: Arne Schwabe <arne@rfc2549.org>
Message-Id: <1448740717-60914-1-git-send-email-gert@greenie.muc.de>
URL: http://article.gmane.org/gmane.network.openvpn.devel/10648

9 years agoextend management interface command "state"
Heiko Hund [Wed, 25 Nov 2015 12:57:00 +0000 (13:57 +0100)] 
extend management interface command "state"

Currently the state command shows only the tun/tap IPv4 address. The
IPv4 address of the remote peer is also displayed. In case you connect
via IPv6 it just shows the first 4 bytes of the address in IPv4 notation.

This patch extends the state command, so it handles IPv6 addresses.
In addition it also displays the local address and the both port numbers
of the connection, e.g.

1447250958,CONNECTED,SUCCESS,10.0.0.2,fd00::1,1193,fd00::2,6492,fdff::1002

Signed-off-by: Heiko Hund <heiko.hund@sophos.com>
Acked-by: Arne Schwabe <arne@rfc2549.org>
Message-Id: <1448456220-2042-1-git-send-email-heiko.hund@sophos.com>
URL: http://article.gmane.org/gmane.network.openvpn.devel/10603
Signed-off-by: Gert Doering <gert@greenie.muc.de>
9 years agoFix rand_bytes return value checking
Steffan Karger [Sat, 28 Nov 2015 10:38:25 +0000 (11:38 +0100)] 
Fix rand_bytes return value checking

This patch is in response to an off-list report by Sebastian Krahmer of
the SuSE security team.  Sebastian noticed we do not check the return
value of rand_bytes() in prng_bytes(), which we really should.

Failing to check the return value occurs if no prng is used (i.e. in
static key mode, or when explicitly disabled using --prng none).
prng_bytes() is used for generating IVs, session IDs and filenames.

The impact of failing to check the return value seems very limited:

Not generating random file names or session IDs could cause collisions in
(temporary) file names and/or session IDs.  These in turn could cause
availability issues, but would not result in a breach in confidentiality
and/or integrity.

Our CBC mode protocol uses a packet id (timestamp + packet counter in
static key mode, or just the packet counter in TLS mode) at the start of
each packet (by default, but can be disabled using --no-iv and
--no-replay). Because the timestamp and packet counter are not
controllable by an attacker, it is not clear how predictable or even
repeating IVs could be used to mount an attack.  (Note that the fact that
*I* can't find or come up with an attack is not a very strong argument,
this remains somewhat worrisome.)

CFB and OFB modes are not affected, because they do not rely on the prng
for IVS.

Finally, RAND_bytes() actually failing is quite unlikely, as that would
result in all sorts of other problems we should have heard about.

Of course, we still really should fix this, so this patch adds return
value checking of rand_bytes() inside prng_bytes().  The ASSERT() might be
a bit crude, so a follow-up patch that adds a return value to prng_bytes()
and proper return value checking probably makes sense.  But at least this
is a quick and simple fix for the issue at hand.

Signed-off-by: Steffan Karger <steffan@karger.me>
Acked-by: Arne Schwabe <arne@rfc2549.org>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <1448707105-10753-2-git-send-email-steffan@karger.me>
URL: http://article.gmane.org/gmane.network.openvpn.devel/10636
Signed-off-by: Gert Doering <gert@greenie.muc.de>
9 years agoopenssl: properly check return value of RAND_bytes()
Steffan Karger [Sat, 28 Nov 2015 10:38:24 +0000 (11:38 +0100)] 
openssl: properly check return value of RAND_bytes()

This patch is in response to an off-list report by Sebastian Krahmer of
the SuSE security team.  Sebastian noticed we do not check the return
value of RAND_bytes() correctly.

The RAND_bytes() man page first says "RAND_bytes() returns 1 on success,
0 otherwise.", but then a bit later "Both functions return -1 if they are
not supported by the current RAND method.".  This second case was not
covered by our return value checking.

Note that if RAND_bytes() would return -1, it would *always* return -1 and
fail to generate random.

Also note that if RAND_bytes() would return -1, it would do so too in the
openssl internal ssl funtions.  The openssl internal function do check the
return value properly, and connection setup would fail all together.  If
that would be at least somewhat common, we would have received a *lot* of
bug reports.  In other words, the error affects static key setups only,
and seems highly unlikely to occur in actual setups.

Only builds using OpenSSL as the crypto backend are affected.

This patch:
1. Changes the behaviour of rand_bytes() in openssl builds to match what
   the doxygen claims (and polarssl builds already do).
2. Adds error reporting for RAND_bytes() failures.

Signed-off-by: Steffan Karger <steffan@karger.me>
Acked-by: Arne Schwabe <arne@rfc2549.org>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <1448707105-10753-1-git-send-email-steffan@karger.me>
URL: http://article.gmane.org/gmane.network.openvpn.devel/10637
Signed-off-by: Gert Doering <gert@greenie.muc.de>
9 years agoAvoid partial authentication state when using --disabled in CCD configs
David Sommerseth [Wed, 11 Nov 2015 13:01:39 +0000 (14:01 +0100)] 
Avoid partial authentication state when using --disabled in CCD configs

If an openvpn server is configured with --client-config-dir and a client
configuration file contains 'disabled', it is supposed to tell the client
it is not authorized to use the service.

This patch will ensure that the internal state in this scenario is a
complete CAS_FAILED state, and not CAS_PARTIAL if other authorization
steps passed.

Trac: #521
Tested-by: Eric Crist <ecrist@secure-computing.net>
Signed-off-by: David Sommerseth <davids@redhat.com>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <1447246899-22769-1-git-send-email-openvpn@sf.lists.topphemmelig.net>
URL: http://article.gmane.org/gmane.network.openvpn.devel/10486
Signed-off-by: Gert Doering <gert@greenie.muc.de>
9 years agoremove unused gc_arena in FreeBSD close_tun()
Gert Doering [Tue, 24 Nov 2015 13:09:10 +0000 (14:09 +0100)] 
remove unused gc_arena in FreeBSD close_tun()

not used, and a small mem leak on every tunnel close...

Signed-off-by: Gert Doering <gert@greenie.muc.de>
Acked-by: Steffan Karger <steffan.karger@fox-it.com>
Message-Id: <1448370550-23897-1-git-send-email-gert@greenie.muc.de>
URL: http://article.gmane.org/gmane.network.openvpn.devel/10581

9 years agoremove nonsense const specifier in nonfatal() return value
Steffan Karger [Tue, 24 Nov 2015 14:00:35 +0000 (15:00 +0100)] 
remove nonsense const specifier in nonfatal() return value

Return values are rvalues, and can not be changed anyway.  Adding const
does not make sense here at all.  (What was I thinking...?)

Signed-off-by: Steffan Karger <steffan.karger@fox-it.com>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <1448373635-21649-1-git-send-email-steffan.karger@fox-it.com>
URL: http://article.gmane.org/gmane.network.openvpn.devel/10583
Signed-off-by: Gert Doering <gert@greenie.muc.de>
9 years agoFix memory leak in add_option() by simplifying get_ipv6_addr
Steffan Karger [Mon, 23 Nov 2015 20:58:55 +0000 (21:58 +0100)] 
Fix memory leak in add_option() by simplifying get_ipv6_addr

If get_ipv6_addr() would fail *after* allocating memory for ipv6_local,
add_option() would fail to free that memory.

The fix here is to remove the allocation from get_ipv6_addr(), and create
a separate function for the strip-and-allocate, such that failures are
easier to handle.

v2 - remove free(options->ifconfig_ipv6_local), since that is now handled
     by a garbage collector.

Memory leak found by coverity (in 2011!).

Signed-off-by: Steffan Karger <steffan@karger.me>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <1448312335-25908-1-git-send-email-steffan@karger.me>
URL: http://article.gmane.org/gmane.network.openvpn.devel/10573
Signed-off-by: Gert Doering <gert@greenie.muc.de>
(cherry picked from commit 7e618994f3112ff4b29b9f08d087fb558636a6af)

9 years agoFix FreeBSD-specific mishandling of gc arena pointer in create_arbitrary_remote()
Gert Doering [Tue, 10 Nov 2015 21:17:03 +0000 (22:17 +0100)] 
Fix FreeBSD-specific mishandling of gc arena pointer in create_arbitrary_remote()

... and while at it, fix warning about losing "const" qualifier on
return.

Signed-off-by: Gert Doering <gert@greenie.muc.de>
Acked-by: Steffan Karger <steffan.karger@fox-it.com>
Message-Id: <1447190223-8065-1-git-send-email-gert@greenie.muc.de>
URL: http://article.gmane.org/gmane.network.openvpn.devel/10478

9 years agoFix info.af == AF_UNSPEC case for server with --mtu-disc
Gert Doering [Mon, 23 Nov 2015 19:47:42 +0000 (20:47 +0100)] 
Fix info.af == AF_UNSPEC case for server with --mtu-disc

Commit 2bed089d31a12c2 introduced "AF_UNSPEC" sockets when we do not know
the actual address family yet - for the "bind local" case, getaddrinfo()
will tell us what to do, but that information never made it into
sock->info.af - so, make it.  Otherwise, trying to call --mtu-disc
on an OpenVPN server will cause a M_FATAL error in set_mtu_discovery())

Signed-off-by: Gert Doering <gert@greenie.muc.de>
Acked-by: Christian Pellegrin <chripell@google.com>
Message-ID: <20151121200637.GD24952@greenie.muc.de>
URL: http://article.gmane.org/gmane.network.openvpn.devel/10547

9 years agopolarssl: require >= 1.3.8
Steffan Karger [Mon, 23 Nov 2015 10:26:24 +0000 (11:26 +0100)] 
polarssl: require >= 1.3.8

Since commit 67a67e39, we use API calls that were introduced in polarssl
1.3.8.  Update the configure check to reflect that.

Signed-off-by: Steffan Karger <steffan.karger@fox-it.com>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <1448274384-22953-1-git-send-email-steffan.karger@fox-it.com>
URL: http://article.gmane.org/gmane.network.openvpn.devel/10563
Signed-off-by: Gert Doering <gert@greenie.muc.de>
9 years agoNotify clients about server's exit/restart
Lev Stipakov [Tue, 17 Nov 2015 09:33:47 +0000 (11:33 +0200)] 
Notify clients about server's exit/restart

When server exits / restarts (gets SIGUSR1, SIGTERM, SIGHUP, SIGINT) and
explicit-exit-notify is set, server sends RESTART control channel
command to all clients and reschedules received signal in 2 secs.

When client receives RESTART command, it either reconnects to the same
server or advances to the new one, depends on parameter comes with
RESTART command - behavior is controlled by explicit-exit-notify in the
server config.

v4:
- Rebase on top of master
- Remove #ifdef ENABLE_OCC around
connection_entry->explicit_exit_notification
since it is also used outside of OCC context
- Update usage message

v3:
- Use control channel "RESTART" command instead of new OCC code to
notify clients
- Configure on the server side (by value of explicit-exit-notify) if
client should reconnect to the same server or advance to the next one
- Fix compilation when OCC is disabled (--enable-small)
- Update man page

v2:
- Take into use explicit-exit-notify on the server side
- OCC_SHUTTING_DOWN renamed to OCC_SERVER_EXIT
- Code prettifying

Signed-off-by: Lev Stipakov <lstipakov@gmail.com>
Acked-by: Arne Schwabe <arne@rfc2549.org>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <1447752827-16720-1-git-send-email-lstipakov@gmail.com>
URL: http://article.gmane.org/gmane.network.openvpn.devel/10515
Signed-off-by: Gert Doering <gert@greenie.muc.de>
9 years agoHandle ctrl-C and ctrl-break events on Windows
Selva Nair [Tue, 17 Nov 2015 02:48:09 +0000 (21:48 -0500)] 
Handle ctrl-C and ctrl-break events on Windows

v2 changes
 - cleaner, hopefully easier to get a code review :)
 - handles both console mode and service mode
-- >8 --

Handle ctrl-C or ctrl-Break sent to the console as a SIGTERM.
Depending on the console mode, windows delivers ctrl-C as a
keyboard input or as a signal. We handle both cases. This allows
graceful termination of openvpn from programs such as nssm.
Works in both console mode and service mode.

Signed-off-by: Selva Nair <selva.nair@gmail.com>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <1447728489-14991-1-git-send-email-selva.nair@gmail.com>
URL: http://article.gmane.org/gmane.network.openvpn.devel/10513
Signed-off-by: Gert Doering <gert@greenie.muc.de>
9 years agopolarssl: don't use deprecated functions anymore
Steffan Karger [Sat, 21 Nov 2015 11:41:00 +0000 (12:41 +0100)] 
polarssl: don't use deprecated functions anymore

A number of functions were deprecated in polarssl 1.3.11.  Stop using
these, and use their alternatives instead.

This enables (and also almost forces) us to move the pkcs11 and external
key logic from the per-connection setup (key_state_ssl_init()) to the
per-instance setup (tls_ctx_use_{pkcs11,external_private_key}()).

Note that tls_ctx_use_external_private_key() is now placed right below
external_pkcs1_sign() and external_key_len(), instead of right above,
because it now needs to be aware of those static functions.

Tested with:
 * PEM key files
 * pkcs11
 * management-external-key

Signed-off-by: Steffan Karger <steffan@karger.me>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <1448106060-19469-1-git-send-email-steffan@karger.me>
URL: http://article.gmane.org/gmane.network.openvpn.devel/10544
Signed-off-by: Gert Doering <gert@greenie.muc.de>
9 years agoAdjust server-ipv6 documentation
Christos Trochalakis [Thu, 19 Nov 2015 12:47:23 +0000 (14:47 +0200)] 
Adjust server-ipv6 documentation

ifconfig-ipv6-pool starts at 0x1000 and not 0x10000 since v2.3
c55e9562: Implement IPv6 interface config with non-/64 prefix lengths

Signed-off-by: Christos Trochalakis <yatiohi@ideopolis.gr>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20151119124723.GA10830@luke.ws.skroutz.gr>
URL: http://article.gmane.org/gmane.network.openvpn.devel/10537
Signed-off-by: Gert Doering <gert@greenie.muc.de>
9 years agopolarssl: also allocate PKCS#11 certificate object on demand
Steffan Karger [Sat, 21 Nov 2015 10:22:04 +0000 (11:22 +0100)] 
polarssl: also allocate PKCS#11 certificate object on demand

Commit 444a93ea changed certificate allocation to be postponed until
actual usage to fix --client-cert-not-required / --verify-client-cert
for PolarSSL builds.  However, I forgot to allocate when using pkcs11
(because that code does not use the tls_ctx_load_cert_file() function).

And while we're at it, use ALLOC_OBJ_CLEAR() instead of malloc + manual
check.

Signed-off-by: Steffan Karger <steffan@karger.me>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <1448101324-20310-1-git-send-email-steffan@karger.me>
URL: http://article.gmane.org/gmane.network.openvpn.devel/10543
Signed-off-by: Gert Doering <gert@greenie.muc.de>
9 years agoSupport for username-only auth file.
Michal Ludvig [Sun, 11 Oct 2015 08:44:20 +0000 (10:44 +0200)] 
Support for username-only auth file.

Make OpenVPN read the username from the auth file
parameter of --auth-user-pass and prompt for a
password if it's not in the file.

Rationale: Prior to this change OpenVPN either
required both username and password present in the
auth file or prompted for both on the console.
Unlike passwords usernames usually don't change and
can therefore be "hardcoded" in the config.

Signed-off-by: Michal Ludvig <mludvig@logix.net.nz>
Reviewed and updated to current master.

Signed-off-by: Adriaan de Jong <dejong@fox-it.com>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <1444553060-15946-1-git-send-email-dejong@fox-it.com>
URL: http://article.gmane.org/gmane.network.openvpn.devel/10255

9 years agoDo not hard-code windows systemroot in env_block
Selva Nair [Fri, 13 Nov 2015 02:41:27 +0000 (21:41 -0500)] 
Do not hard-code windows systemroot in env_block

FWIW, fixes trac #500

Signed-off-by: Selva Nair <selva.nair@gmail.com>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <1447382487-26031-1-git-send-email-selva.nair@gmail.com>
URL: http://article.gmane.org/gmane.network.openvpn.devel/10492
Signed-off-by: Gert Doering <gert@greenie.muc.de>
9 years agoUse adapter index instead of name for windows IPv6 interface config
Lev Stipakov [Wed, 11 Nov 2015 11:48:07 +0000 (13:48 +0200)] 
Use adapter index instead of name for windows IPv6 interface config

Some windows machines get weird issues with netsh when using
adapter name on "netsh.exe interface ipv6 set address" command.

Changed logic to get adapter index and use it instead of adapter
name for netsh set address command.

v2:
 * Remove netsh call which uses adapter name. After thoughtful testing
   turns out that "adapter name" code branch is never used.

v3:
 * Use interface=<idx> syntax.
 * Add forward declaration of get_adapter_index_flexible to get
   rid of warning.
 * NOTE: temp variable is needed because argv_printf() does not
   handle combined strings like "interface=%lu" today

Signed-off-by: Olli Mannisto <olmannisto@gmail.com>
Signed-off-by: Lev Stipakov <lstipakov@gmail.com>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <1447242487-30243-1-git-send-email-lstipakov@gmail.com>
URL: http://article.gmane.org/gmane.network.openvpn.devel/10484
Signed-off-by: Gert Doering <gert@greenie.muc.de>
9 years agoAdd macro to ensure we exit on fatal errors
Steffan Karger [Thu, 5 Nov 2015 21:03:01 +0000 (22:03 +0100)] 
Add macro to ensure we exit on fatal errors

Also prevents false positives in static analysis tools.

(Note that the current x_msg() code does properly exit, this is just a way
to make it trivial to see we will not return from msg() on fatal errors,
even for static analysis tools.)

Signed-off-by: Steffan Karger <steffan@karger.me>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <1446757381-27863-1-git-send-email-steffan@karger.me>
URL: http://article.gmane.org/gmane.network.openvpn.devel/10440
Signed-off-by: Gert Doering <gert@greenie.muc.de>
9 years agoFix (potential) memory leak in init_route_list()
Steffan Karger [Fri, 6 Nov 2015 07:42:39 +0000 (08:42 +0100)] 
Fix (potential) memory leak in init_route_list()

init_route() can allocate memory in netlist, but fail in many more ways
than just fail to allocate.  Thus, always check and clean up netlist if
needed, instead of just when init_route() succeeds.

This fix is for master only.  The release/2.3 branch cleans up netlist
immediately, and needs a different patch for a similar problem.

Found using coverity.

v2: initialize netlist to NULL

Signed-off-by: Steffan Karger <steffan@karger.me>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <1446795759-3288-1-git-send-email-steffan@karger.me>
URL: http://article.gmane.org/gmane.network.openvpn.devel/10443
Signed-off-by: Gert Doering <gert@greenie.muc.de>
9 years agopolarssl: add --verify-client-cert optional support
Steffan Karger [Thu, 15 Oct 2015 22:43:15 +0000 (00:43 +0200)] 
polarssl: add --verify-client-cert optional support

This adds support for the --verify-client-cert optional option in PolarSSL
builds, as was earlier added for OpenSSL builds by Jan-Just Keijser.

This patch also adds an additional sanity check that this option may only
be used in combination with some other authentication method, and changes
the warning message about this option to be displayed only once on startup,
instead of for each connecting client.

Signed-off-by: Steffan Karger <steffan@karger.me>
Acked-by: Jan Just Keijser <janjust@nikhef.nl>
Message-Id: <1444948995-18720-3-git-send-email-steffan@karger.me>
URL: http://article.gmane.org/gmane.network.openvpn.devel/10288
Signed-off-by: Gert Doering <gert@greenie.muc.de>
9 years agoAuthor: Jan Just Keijser <janjust@nikhef.nl>
Jan Just Keijser [Fri, 9 Oct 2015 09:39:19 +0000 (11:39 +0200)] 
Author: Jan Just Keijser <janjust@nikhef.nl>

Add extended client certificate verification support.

Replace --client-cert-not-required with a more flexible option,
that allows for no, optional or mandatory client certificate
verification.

Signed-off-by: Jan Just Keijser <janjust@nikhef.nl>
Acked-by: Steffan Karger <steffan.karger@fox-it.com>
Message-Id: <1444383559-15788-1-git-send-email-janjust@nikhef.nl>
URL: http://article.gmane.org/gmane.network.openvpn.devel/10213
Signed-off-by: Gert Doering <gert@greenie.muc.de>
9 years agoFix termination when windows suspends/sleeps
Selva Nair [Wed, 4 Nov 2015 18:59:38 +0000 (13:59 -0500)] 
Fix termination when windows suspends/sleeps

When TUN/TAP I/O operation is aborted, restart with a SIGHUP instead of
terminate. The abort error from TAP is often triggered by system suspend
which is fully recoverable on resume. Catastrophic events will get caught
later during the restart.  This solves the abnormal termination during
suspend/resume.

Signed-off-by: Selva Nair <selva.nair@gmail.com>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <1446663578-14471-1-git-send-email-selva.nair@gmail.com>
URL: http://article.gmane.org/gmane.network.openvpn.devel/10438
Signed-off-by: Gert Doering <gert@greenie.muc.de>
9 years agopolarssl: fix --client-cert-not-required
Steffan Karger [Thu, 15 Oct 2015 22:43:14 +0000 (00:43 +0200)] 
polarssl: fix --client-cert-not-required

PolarSSL 1.3 determines whether to use a client key/cert based on the
private key and/or certificate structs being allocated or not.  We
previously would always allocate the structs in
tls_ctx_{client,server}_new(), which made polarssl clients without a
client key/cert (can also be mgmt-external-key or pkcs11) fail to connect.

Note that this bug is not present in OpenVPN 2.3, because PolarSSL 1.2
does not contain the 'pk' abtraction layer and therefore behaves slightly
different.

Signed-off-by: Steffan Karger <steffan@karger.me>
Acked-by: Arne Schwabe <arne@rfc2549.org>
Message-Id: <1444948995-18720-2-git-send-email-steffan@karger.me>
URL: http://article.gmane.org/gmane.network.openvpn.devel/10287
Signed-off-by: Gert Doering <gert@greenie.muc.de>
9 years agoReplace variable length array with malloc
Lev Stipakov [Wed, 21 Oct 2015 07:13:26 +0000 (10:13 +0300)] 
Replace variable length array with malloc

Commit
https://github.com/OpenVPN/openvpn/commit/685e486e8b8f70c25f09590c24762ff73
4f94a51
introduced a variable length array. Although C99 supports that, MSVS 2013
still requires
size of array to be compiler time constant. As a fix, use malloc/free.

v2:
 Replace OPENSSL_malloc with gc_malloc

Signed-off-by: Lev Stipakov <lstipakov@gmail.com>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <1445411606-13369-1-git-send-email-lstipakov@gmail.com>
URL: http://article.gmane.org/gmane.network.openvpn.devel/10344
Signed-off-by: Gert Doering <gert@greenie.muc.de>
9 years agoopenssl: remove usage of OPENSSL_malloc() from show_available_curves
Steffan Karger [Tue, 20 Oct 2015 22:39:04 +0000 (00:39 +0200)] 
openssl: remove usage of OPENSSL_malloc() from show_available_curves

There is no need to use OPENSSL_malloc(), so use our own functions that
automatically check for NULL and remove the now redundant NULL check.

Signed-off-by: Steffan Karger <steffan@karger.me>
Acked-by: Lev Stipakov <lstipakov@gmail.com>
Message-Id: <1445380744-21086-1-git-send-email-steffan@karger.me>
URL: http://article.gmane.org/gmane.network.openvpn.devel/10339
Signed-off-by: Gert Doering <gert@greenie.muc.de>
9 years agoFix memory leak in auth-pam plugin
Steffan Karger [Tue, 20 Oct 2015 22:38:26 +0000 (00:38 +0200)] 
Fix memory leak in auth-pam plugin

As it says on the tin.  aresp would not be free'd nor returned by
my_conv() on errors.  Note that we never reach this code if allocation
of aresp failed.

Found with the Clang static analyzer.

Signed-off-by: Steffan Karger <steffan@karger.me>
Acked-by: Lev Stipakov <lstipakov@gmail.com>
Message-Id: <1445380706-20864-1-git-send-email-steffan@karger.me>
URL: http://article.gmane.org/gmane.network.openvpn.devel/10338
Signed-off-by: Gert Doering <gert@greenie.muc.de>
9 years agoGenerate openvpn-plugin.h for MSVC build
Lev Stipakov [Thu, 22 Oct 2015 07:51:22 +0000 (10:51 +0300)] 
Generate openvpn-plugin.h for MSVC build

openvpn-plugin.h was not generated for MSVC build since it has been
removed from sources and made generated by configure script.

This fix generates it for MSVC build and substitutes macroses like
@OPENVPN_VERSION_MAJOR@ with actual values.

Signed-off-by: Lev Stipakov <lstipakov@gmail.com>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <1445500282-23129-1-git-send-email-lstipakov@gmail.com>
URL: http://article.gmane.org/gmane.network.openvpn.devel/10360
Signed-off-by: Gert Doering <gert@greenie.muc.de>
9 years agohardening: add insurance to exit on a failed ASSERT()
Steffan Karger [Wed, 21 Oct 2015 08:08:06 +0000 (10:08 +0200)] 
hardening: add insurance to exit on a failed ASSERT()

The code behind our ASSERT() macro is pretty complex.  Although it seems
to be correct, make it trivially clear we will never return from a failed
assert by adding an _exit(1) call.  As was suggested by Sebastian Krahmer
of the SuSE security team.

To make sure they that tools like clang static analyzer and coverity
understand that assert_failed() will not return, add an
__attribute__((__noreturn__)) annotation.

v2: use __attribute__ instead of inline to convince static analysers.

Signed-off-by: Steffan Karger <steffan@karger.me>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <1445414886-11052-1-git-send-email-steffan@karger.me>
URL: http://article.gmane.org/gmane.network.openvpn.devel/10349
Signed-off-by: Gert Doering <gert@greenie.muc.de>
9 years agoStart Changes.rst that lists changes in 2.4.0
Arne Schwabe [Thu, 15 Oct 2015 14:44:58 +0000 (16:44 +0200)] 
Start Changes.rst that lists changes in 2.4.0

This list is proably incomplete but should give a good starting point

Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <1444920298-5972-1-git-send-email-arne@rfc2549.org>
URL: http://article.gmane.org/gmane.network.openvpn.devel/10283

Signed-off-by: Gert Doering <gert@greenie.muc.de>
9 years agoDo not set the buffer size by default but rely on the operation system default.
Arne Schwabe [Thu, 15 Oct 2015 14:38:38 +0000 (16:38 +0200)] 
Do not set the buffer size by default but rely on the operation system default.

Also remove SOCKET_SND_RCV_BUF_MAX since limiting the buffer to 1000k is
arbitrary and all OSes impose a maximum that can be set anyway.

closes trac ticket #461

V2: SOCKET_SND_RCV_BUF_MAX removal

Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <1444919918-4525-1-git-send-email-arne@rfc2549.org>
URL: http://article.gmane.org/gmane.network.openvpn.devel/10280

Signed-off-by: Gert Doering <gert@greenie.muc.de>
9 years agoFix privilege drop if first connection attempt fails
Lukasz Kutyla [Sat, 17 Oct 2015 19:15:15 +0000 (21:15 +0200)] 
Fix privilege drop if first connection attempt fails

OpenVPN does not drop privileges (UID/GID/chroot) as requested according
to the configuration file and/or passed arguments if the first connection
attempt is not established successfully, this also includes applying
SELinux context.
Signals and restarts are processed after "context.first_time" is set to
"false", which results in omitting entire privilege dropping block in
"do_uid_gid_chroot()" when successful connection is finally made
(everything is initialized correctly and said function is called), since
"context.first_time" is used as block entry condition.

We modify "do_uid_gid_chroot()" in such a way that allows us to drop
privileges even when first connection attempt was unsuccessful.

Signed-off-by: Lukasz Kutyla <movrax-dev@cryptolab.net>
Acked-by: Steffan Karger <steffan.karger@fox-it.com>
Message-Id: <20151018103446.5fed9f97.movrax-dev@cryptolab.net>
URL: http://article.gmane.org/gmane.network.openvpn.devel/10301
Acked-by: Steffan Karger <steffan.karger@fox-it.com>
Message-Id: <20151018103446.5fed9f97.movrax-dev@cryptolab.net
20151018103446.5fed9f97.movrax-dev@cryptolab.net>
URL: http://article.gmane.org/gmane.network.openvpn.devel/10301
Signed-off-by: Gert Doering <gert@greenie.muc.de>
9 years agoRefine float logging
Lev Stipakov [Thu, 15 Oct 2015 11:39:42 +0000 (14:39 +0300)] 
Refine float logging

v2:
 * Bump log level for attack attempt message
 * More clear message for float event

v1:
 * Decrease log level for peer float message

Signed-off-by: Lev Stipakov <lstipakov@gmail.com>
Acked-by: Steffan Karger <steffan.karger@fox-it.com>
Message-Id: 1444909182-11785-1-git-send-email-lstipakov@gmail.com
URL: http://article.gmane.org/gmane.network.openvpn.devel/10276
Signed-off-by: David Sommerseth <davids@redhat.com>
9 years agoFix commit c67acea173dc9ee37220f5b9ff14ede081181992
Arne Schwabe [Wed, 14 Oct 2015 13:05:56 +0000 (15:05 +0200)] 
Fix commit c67acea173dc9ee37220f5b9ff14ede081181992

Move things to the proper place, ensure that line_ptr is actually properly
initialized for *every* line read, not just for the first one

Acked-by: Lev Stipakov <lstipakov@gmail.com>
Message-Id: 1444827956-2169-1-git-send-email-arne@rfc2549.org
URL: http://article.gmane.org/gmane.network.openvpn.devel/10271

Signed-off-by: David Sommerseth <davids@redhat.com>
9 years agoFix compilation with --disable-server
Lev Stipakov [Sun, 11 Oct 2015 10:15:31 +0000 (13:15 +0300)] 
Fix compilation with --disable-server

Add missing #if P2MP_SERVER

Acked-by: David Sommerseth <davids@redhat.com>
Message-Id: <1444558531-18241-1-git-send-email-lstipakov@gmail.com>
URL: http://article.gmane.org/gmane.network.openvpn.devel/10259
Signed-off-by: David Sommerseth <davids@redhat.com>
9 years agoSend push reply right after async auth complete
Lev Stipakov [Sat, 10 Oct 2015 16:04:25 +0000 (19:04 +0300)] 
Send push reply right after async auth complete

v3:
* better comments
* better variable naming
* include sys/inotify.h if HAVE_SYS_INOTIFY_H is defined

v2:
More careful inotify_watchers handling
* Ensure that same multi_instance is added only once
* Ensure that multi_instance is always removed

v1:
This feature speeds up connection establishment in cases when async
authentication result is not ready when first push request arrives. At
the moment server sends push reply only when it receives next push
request, which comes 5 seconds later.

Implementation overview.

Add new configure option ENABLE_ASYNC_PUSH, which can be enabled if
system supports inotify.

Add inotify descriptor to an event loop. Add inotify watch for a
authentication control file. Store mapping between watch descriptor and
multi_instance in a dictionary. When file is closed, inotify fires an
event and we continue with connection establishment - call client-
connect etc and send push reply.

Inotify watch descriptor got automatically deleted after file is closed
or when file is removed. We catch that event and remove it from the
dictionary.

Feature is easily tested with sample "defer" plugin and following settings:

auth-user-pass-optional
setenv test_deferred_auth 3
plugin simple.so

Signed-off-by: Lev Stipakov <lstipakov@gmail.com>
Add doxygen comment
Acked-by: David Sommerseth <davids@redhat.com>
Message-Id: <1444493065-13506-1-git-send-email-lstipakov@gmail.com>
URL: http://article.gmane.org/gmane.network.openvpn.devel/10248
Signed-off-by: David Sommerseth <davids@redhat.com>
9 years agoRemove support for snappy compression.
Gert Doering [Sat, 10 Oct 2015 16:34:49 +0000 (18:34 +0200)] 
Remove support for snappy compression.

LZ4 is using less CPU at similar performance, and it is easier to
build and support for binary installs (as it does not require C++
and a C++ runtime).  Since it was never supported in any formally
released OpenVPN version, just drop it again.

This leaves in the compression opcode for Snappy for documentation
purposes.

trac #617

Signed-off-by: Gert Doering <gert@greenie.muc.de>
Acked-by: Arne Schwabe <arne@rfc2549.org>
Message-Id: <1444494889-28925-1-git-send-email-gert@greenie.muc.de>
URL: http://article.gmane.org/gmane.network.openvpn.devel/10251

9 years agoFix "White space before end tags can break the config parser"
janjust [Sat, 10 Oct 2015 16:12:49 +0000 (18:12 +0200)] 
Fix "White space before end tags can break the config parser"

trac #569

Acked-by: Arne Schwabe <arne@rfc2549.org>
Message-Id: <1444493569-24026-1-git-send-email-janjust@nikhef.nl>
URL: http://article.gmane.org/gmane.network.openvpn.devel/10249

Signed-off-by: Gert Doering <gert@greenie.muc.de>
9 years agoAdd CONTRIBUTING.rst
Samuli Seppänen [Sat, 10 Oct 2015 13:41:14 +0000 (16:41 +0300)] 
Add CONTRIBUTING.rst

Signed-off-by: Samuli Seppänen <samuli@openvpn.net>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <1444484474-6471-1-git-send-email-samuli@openvpn.net>
Signed-off-by: Gert Doering <gert@greenie.muc.de>
9 years agoUpdate expiry date in management event loop
Thomas Veerman [Wed, 22 Jan 2014 08:27:29 +0000 (09:27 +0100)] 
Update expiry date in management event loop

When there are events from the management console with an interval shorter
than 1 second, the event loop never stops as it keeps resetting event_wait.

Acked-by: Arne Schwabe <arne@rfc2549.org>
Message-Id: <etPan.52df80ec.2901d82.13bb7@Bert-3.local>
URL: http://article.gmane.org/gmane.network.openvpn.devel/8253

Signed-off-by: Gert Doering <gert@greenie.muc.de>
9 years agoFix compilation error with --disable-crypto
Lev Stipakov [Sat, 10 Oct 2015 10:14:29 +0000 (13:14 +0300)] 
Fix compilation error with --disable-crypto

Also disable "ENETUNREACH -> restart" behavior for static key setup.

Acked-by: Arne Schwabe <arne@rfc2549.org>
Message-Id: <1444472069-32036-1-git-send-email-lstipakov@gmail.com>
URL: http://article.gmane.org/gmane.network.openvpn.devel/10231

Signed-off-by: Gert Doering <gert@greenie.muc.de>
9 years agoFix --mtu-disc option with IPv6 transport
Julien Muchembled [Sat, 10 Oct 2015 09:44:51 +0000 (11:44 +0200)] 
Fix --mtu-disc option with IPv6 transport

Socket configuration of MTU discovery was done unconditionally at IP level,
which has no effect for other protocols. This fixes the issue of OpenVPN
sending fragmented tcp6/udp6 packets even when 'mtu-disc yes' option is
passed.

Patch V2 (by Arne Schwabe): Rebase to current master and have
separate #ifdefs for IPv4 an IPv6

Signed-off-by: Julien Muchembled <jm@nexedi.com>
Acked-by: Arne Schwabe <arne@rfc2549.org>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <1444470291-2980-1-git-send-email-arne@rfc2549.org>
URL: http://article.gmane.org/gmane.network.openvpn.devel/10229
Signed-off-by: Gert Doering <gert@greenie.muc.de>
9 years agoFast recovery when host is in unreachable network
Lev Stipakov [Mon, 2 Mar 2015 17:58:31 +0000 (19:58 +0200)] 
Fast recovery when host is in unreachable network

When client connects to the server which is in unreachable network (for
example hostname got resolved into ipv6 address and client has no ipv6),
throw SIGUSR1 and connect to the next server without waiting 60 seconds
for "TLS key negotiation failed".
Acked-by: Arne Schwabe <arne@rfc2549.org>
Message-Id: <1425319111-21291-1-git-send-email-lstipakov@gmail.com>
URL: http://article.gmane.org/gmane.network.openvpn.devel/9498

Signed-off-by: Gert Doering <gert@greenie.muc.de>
9 years agosample-plugin: TLS Keying Material Exporter [RFC-5705] demonstration plug-in
Daniel Kubec [Sat, 4 Apr 2015 22:10:37 +0000 (00:10 +0200)] 
sample-plugin: TLS Keying Material Exporter [RFC-5705] demonstration plug-in

A simple plug-in with a corresponding HTTP server and client which can authenticate
an HTTP user based on the authentication already done via an established OpenVPN
connection

[DS: Renamed the module at commit time from sso to keyingmaterialexporter to
     avoid confusion with other Single-Sign-On solutions.  Updated documentation
     and commits accordingly.  Added --pull to the client config]

Signed-off-by: Daniel Kubec <niel@rtfm.cz>
Signed-off-by: David Sommerseth <davids@redhat.com>
Acked-by: David Sommerseth <davids@redhat.com>
9 years agoAdded document for TLS Keying Material Exporters [RFC-5705]
Daniel Kubec [Thu, 12 Mar 2015 14:25:42 +0000 (15:25 +0100)] 
Added document for TLS Keying Material Exporters [RFC-5705]

[DS: Fixed option prefix from '-' to '--']

Signed-off-by: Daniel Kubec <niel@rtfm.cz>
Signed-off-by: David Sommerseth <davids@redhat.com>
Acked-by: Steffan Karger <steffan.karger@fox-it.com
Acked-by: David Sommerseth <davids@redhat.com>
9 years agoAdded support for TLS Keying Material Exporters [RFC-5705]
Daniel Kubec [Thu, 12 Mar 2015 14:14:20 +0000 (15:14 +0100)] 
Added support for TLS Keying Material Exporters [RFC-5705]

Keying Material Exporter [RFC-5705] allow additional keying material to be
derived from existing TLS channel. This exported keying material can then be
used for a variety of purposes.

[DS: Updated man page to document both upper and lower length boundaries]

Signed-off-by: Daniel Kubec <niel@rtfm.cz>
Signed-off-by: David Sommerseth <davids@redhat.com>
Acked-by: Steffan Karger <steffan.karger@fox-it.com
Acked-by: David Sommerseth <davids@redhat.com>
9 years agoopenssl: be less verbose about cipher translation errors
Steffan Karger [Tue, 6 Oct 2015 18:38:27 +0000 (20:38 +0200)] 
openssl: be less verbose about cipher translation errors

Translation errors are usually not a real problem, since we don't maintain
the complete list of ciphers OpenSSL supports.  So, be less verbose if we
can not find a translation.

Also, add 'translations' for commonly used negated cipher suites to
suppress messages about those completely.

Signed-off-by: Steffan Karger <steffan@karger.me>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <1444156707-14087-1-git-send-email-steffan@karger.me>
URL: http://article.gmane.org/gmane.network.openvpn.devel/10198
Signed-off-by: Gert Doering <gert@greenie.muc.de>
9 years agopolarssl: Improve PolarSSL logging
Steffan Karger [Tue, 6 Oct 2015 16:20:40 +0000 (18:20 +0200)] 
polarssl: Improve PolarSSL logging

Use the new polar_log_err() and polar_ok() functions introduced in the
previous commit to provide more log/debug output for polarssl errors.

Signed-off-by: Steffan Karger <steffan@karger.me>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <1444148440-10564-1-git-send-email-steffan@karger.me>
URL: http://article.gmane.org/gmane.network.openvpn.devel/10197
Signed-off-by: Gert Doering <gert@greenie.muc.de>
9 years agoContinuation of MSVS fixes
Lev Stipakov [Tue, 6 Oct 2015 11:15:13 +0000 (14:15 +0300)] 
Continuation of MSVS fixes

 * Upgrade API level to Vista to implement get_default_gateway_ipv6
 * Define HAVE_INET_NTOP/PTON since Vista has its own implementation of
those

Signed-off-by: Lev Stipakov <lstipakov@gmail.com>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <1444130113-23387-1-git-send-email-lstipakov@gmail.com>
URL: http://article.gmane.org/gmane.network.openvpn.devel/10194
Signed-off-by: Gert Doering <gert@greenie.muc.de>
9 years agopolarssl: add easy logging for PolarSSL errors
Steffan Karger [Sun, 8 Mar 2015 10:20:04 +0000 (11:20 +0100)] 
polarssl: add easy logging for PolarSSL errors

Add the functions polar_log_err(), polar_log_func_line() and a macro
polar_ok(), to easily log human-readable PolarSSL errors from
polarssl-specific code.

This does not provide the full logging interface as msg(), because I
would have to add a lot more of macro-magic to achieve that on the
various supported compilers and platforms, and this suffices too (for
now at least).

Signed-off-by: Steffan Karger <steffan@karger.me>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <1425810005-11893-1-git-send-email-steffan@karger.me>
URL: http://article.gmane.org/gmane.network.openvpn.devel/9528
Signed-off-by: Gert Doering <gert@greenie.muc.de>
9 years agoThis fixes MSVS 2013 compilation.
Lev Stipakov [Fri, 2 Oct 2015 11:46:41 +0000 (14:46 +0300)] 
This fixes MSVS 2013 compilation.

 * Tools version changed to 12
 * Added comp.c/h and compat.c/h to project files
 * Workaround for missing __attribute__ support

Also, as a preparation for MSVS2015, ensured that snprintf is not defined
for that VS version.
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <1443786401-30416-1-git-send-email-lstipakov@gmail.com>
URL: http://article.gmane.org/gmane.network.openvpn.devel/10174

Signed-off-by: Gert Doering <gert@greenie.muc.de>
9 years agoget_default_gateway_ipv6(): Win32 implementation using GetBestRoute2()
Gert Doering [Fri, 11 Sep 2015 15:33:47 +0000 (17:33 +0200)] 
get_default_gateway_ipv6(): Win32 implementation using GetBestRoute2()

To get access to that functionality, bump Windows API level for MinGW
compilation from NTDDI_WINXP/_WIN32_WINNT_WINXP to ..._VISTA, and
shuffle around WIN32 includes a bit in syshead.h

MinGW 32 seems to be broken regarding MIB_TCP_STATE enum, so add typedef
for that - surrounding #ifdefs found by googling do not work yet -> TODO!

Extend add_route_ipv6() and delete_route_ipv6() to handle routes not on
the tap adapter but on ifindex-addressed interfaces ("interface=nn"),
and while at it, fix deletion of IPv6 routes with gateway address.

NOTE: this breaks Windows XP compatibility as GetBestRoute2() is not
available there, so even when not using IPv6, the binary will not run.

(Lightly) tested on Win7/64.

Signed-off-by: Gert Doering <gert@greenie.muc.de>
Lazy-ACK-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <1441985627-14822-11-git-send-email-gert@greenie.muc.de>
URL: http://article.gmane.org/gmane.network.openvpn.devel/10085

9 years agoAdd custom check for inet_pton()/inet_ntop() on MinGW/WIN32
Gert Doering [Tue, 22 Sep 2015 20:31:24 +0000 (22:31 +0200)] 
Add custom check for inet_pton()/inet_ntop() on MinGW/WIN32

More recent MinGW versions have these functions (if compiling at
_VISTA level or higher), but the normal AC_CHECK_FUNCS() check does
not find them because the necessary header file is not #include'd and
the libws2_32 not linked - and our compat functions are incompatible
with the definitions in <ws2tcpip.h>, so compilation fails.

Fix with a custom AC_LINK_IFELSE()/AC_LANG_PROGRAM() construct.

Signed-off-by: Gert Doering <gert@greenie.muc.de>
Tested-by: Heiko Hund <heiko.hund@sophos.com>
Tested-by: Samuli Seppänen <samuli@openvpn.net>
Lazy-ACK-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <1442953884-54602-1-git-send-email-gert@greenie.muc.de>
URL: http://article.gmane.org/gmane.network.openvpn.devel/10165

9 years agoCheck return value of ms_error_text()
Steffan Karger [Mon, 21 Sep 2015 20:04:19 +0000 (22:04 +0200)] 
Check return value of ms_error_text()

ms_error_text() may return NULL, and it is unclear (or, at least
undocumented) whether the OpenSSL ERR code (and our code using the ERR
code) can deal with esd->string being NULL.  So, just to be sure, check
that ms_error_text() succeeded before passing the result to
ERR_load_strings().

Signed-off-by: Steffan Karger <steffan@karger.me>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <561130FC.8090008@karger.me>
URL: http://article.gmane.org/gmane.network.openvpn.devel/10176
Signed-off-by: Gert Doering <gert@greenie.muc.de>
9 years agoReplace strdup() calls for string_alloc() calls
Steffan Karger [Mon, 21 Sep 2015 18:48:33 +0000 (20:48 +0200)] 
Replace strdup() calls for string_alloc() calls

As reported by Bill Parker in trac #600, strdup() return values are not
always correctly checked for failed allocations.  This patch adds missing
checks by using string_alloc(), which performs the required checks.

Signed-off-by: Steffan Karger <steffan@karger.me>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <561130FC.8090008@karger.me>
URL: http://article.gmane.org/gmane.network.openvpn.devel/10176
Signed-off-by: Gert Doering <gert@greenie.muc.de>
9 years agoRepair test_local_addr() on WIN32
Gert Doering [Fri, 25 Sep 2015 06:36:10 +0000 (08:36 +0200)] 
Repair test_local_addr() on WIN32

Intermediate result was stored in a "bool" variable, but the actual
range of results is 0/1/2 - so "2" (TLA_LOCAL) never worked.  Change
to "int".

Diagnosed by "dferbas" in trac #609 (thanks).

Signed-off-by: Gert Doering <gert@greenie.muc.de>
Acked-by: Steffan Karger <steffan.karger@fox-it.com>
Message-Id: <1443162970-38210-1-git-send-email-gert@greenie.muc.de>
URL: http://article.gmane.org/gmane.network.openvpn.devel/10168

9 years agoReplace unaligned 16bit access to TCP MSS value with bytewise access
Gert Doering [Thu, 27 Aug 2015 13:00:02 +0000 (15:00 +0200)] 
Replace unaligned 16bit access to TCP MSS value with bytewise access

TCP options are not always word-aligned, and accessing a 16bit value
at an odd memory address will cause a "bus error" crash on some
architectures, e.g. Linux/Sparc(64)

Trac #497

Signed-off-by: Gert Doering <gert@greenie.muc.de>
Acked-by: Steffan Karger <steffan.karger@fox-it.com>
Message-Id: <1440680402-96548-1-git-send-email-gert@greenie.muc.de>
URL: http://article.gmane.org/gmane.network.openvpn.devel/10056

9 years agoLog serial number of revoked certificate
Boris Lytochkin [Sun, 20 Sep 2015 14:05:22 +0000 (17:05 +0300)] 
Log serial number of revoked certificate

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

So we log certificate serial in case it is revoked.

Sponsored-by: Yandex LLC
Signed-off-by: Boris Lytochkin <lytboris@yandex-team.ru>
Acked-by: Steffan Karger <steffan.karger@fox-it.com>
Message-Id: <55FEBF7E.3010209@yandex-team.ru>
URL: http://article.gmane.org/gmane.network.openvpn.devel/10154

Signed-off-by: Gert Doering <gert@greenie.muc.de>
9 years agoFix IPv6 host routes to LAN gateway on OpenSolaris
Gert Doering [Fri, 11 Sep 2015 15:33:46 +0000 (17:33 +0200)] 
Fix IPv6 host routes to LAN gateway on OpenSolaris

The tun/tap routes need to be set with "metric 0", while this will
prevent routes to LAN gateways from being installed.  So, set metric 0
only if no other interface is requested...

(Note: OpenSolaris can not specify host+interface gateways, so we just
use the GW addresses - it seems to still work for fe80:: addresses,
however it is done internally.  NUD maybe?)

Signed-off-by: Gert Doering <gert@greenie.muc.de>
Acked-by: Arne Schwabe <arne@rfc2549.org>
Message-Id: <1441985627-14822-10-git-send-email-gert@greenie.muc.de>
URL: http://article.gmane.org/gmane.network.openvpn.devel/10092

9 years agoget_default_gateway_ipv6(): *BSD / MacOS / Solaris PF_ROUTE implementation
Gert Doering [Fri, 11 Sep 2015 15:33:45 +0000 (17:33 +0200)] 
get_default_gateway_ipv6(): *BSD / MacOS / Solaris PF_ROUTE implementation

As for IPv4, a common implementation for all (supported) BSD families
and Solaris.  Supporting the latter requires separate implementations
for IPv4 and IPv6, unfortunately, so it's quite a bit of duplicate
code.

Further, extend add_route_ipv6() and delete_route_ipv6() to handle
link-local gateway addresses that require "gateway + interface" in
scoped notation ("fe80::1%em0").

Tested on FreeBSD 7.4/amd64, 9.3/sparc64, 10.0/amd64, NetBSD 5.1/amd64,
OpenBSD 4.9/i386, MacOS X 10.5/32 and 10.10/64 and OpenSolaris 10.11/i386.

Signed-off-by: Gert Doering <gert@greenie.muc.de>
Acked-by: Arne Schwabe <arne@rfc2549.org>
Message-Id: <1441985627-14822-9-git-send-email-gert@greenie.muc.de>
URL: http://article.gmane.org/gmane.network.openvpn.devel/10082

9 years agoImplement '--redirect-gateway ipv6'
Gert Doering [Fri, 11 Sep 2015 15:33:44 +0000 (17:33 +0200)] 
Implement '--redirect-gateway ipv6'

Add "ipv6" and "!ipv4" sub-options to "--redirect-gateway" option.

This is done in the same way as in the OpenVPN 3 code base, so
"--redirect-gateway ipv6" will redirect both IPv4 and IPv6 - if you
want v6-only, use "--redirect-gateway ipv6 !ipv4".

The actual implementation is much simpler than for IPv4 - we just
add a few extra routes to the route_ipv6_option_list and leave it to
init_route_ipv6_list() to figure out whether there is an overlap with
IPv6 transport, and if yes, insert a host route to the VPN server
via the current IPv6 default gateway.

Signed-off-by: Gert Doering <gert@greenie.muc.de>
Acked-by: Arne Schwabe <arne@rfc2549.org>
Message-Id: <1441985627-14822-8-git-send-email-gert@greenie.muc.de>
URL: http://article.gmane.org/gmane.network.openvpn.devel/10086

9 years agoDo not install a host route for the VPN on Android
Arne Schwabe [Thu, 17 Sep 2015 10:23:58 +0000 (12:23 +0200)] 
Do not install a host route for the VPN on Android

Routing loops are avoided using the VPNService API protect API

Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <1442485438-15704-1-git-send-email-arne@rfc2549.org>
URL: http://article.gmane.org/gmane.network.openvpn.devel/10135

Signed-off-by: Gert Doering <gert@greenie.muc.de>
9 years agoImplement handling of overlapping IPv6 routes with IPv6 remote VPN server address
Gert Doering [Fri, 11 Sep 2015 15:33:43 +0000 (17:33 +0200)] 
Implement handling of overlapping IPv6 routes with IPv6 remote VPN server address

- socket.[ch]: add link_socket_current_remote_ipv6() helper to extract
   current address of remote VPN server (if IPv6, NULL otherwise), IPv6
   equivalent to link_socket_current_remote()

- init.c: pass remote VPN server address to init_route_ipv6_list()
   (link_socket_current_remote_ipv6())

- route.h: add route_ipv6_gateway_info to route_ipv6_list, and reorder
   structures so that this actually compiles.  Add iface/adapter_index
   to struct route_ipv6 (for non-tun/tap routes).

- route.[ch]: add "const" to *dest argument to get_default_gateway_ipv6()

- route.c: add route_ipv6_match_host() helper to check whether an IPv6
   address is matched by a given "route_ipv6" IPv6 route)

- route.c: init_route_ipv6_list()
   - call get_default_gateway_ipv6()
   - check to-be-installed IPv6 routes against VPN server address (if IPv6)
   - if an overlap is seen, add a host route for the VPN server address
     via the just-discovered gateway to the list of IPv6 routes to be
     installed (rl6->routes_ipv6)
   - warn if overlap is detected but platform code has not been able to
     discover IPv6 default gateway

- route.c: add_route_ipv6() / delete_route_ipv6(): set "device" to
   "external default gateway interface" (r6->iface) instead of TUN/TAP
   device (if set), which nicely enables arbitrary gateway/interface
   combinations for Linux

- ssl.c: add "IV_RGI6=1" to push-peer-info data to let server know we can
  handle pushed IPv6 routes that overlap with server IPv6 address

- tun.c: when adding/removing on-link routes, CLEAR(r6) first to
  ensure new struct route_ipv6 members are cleared

Tested on Linux with iproute2 and /bin/route, on eth and tun routes.

Signed-off-by: Gert Doering <gert@greenie.muc.de>
Acked-by: Arne Schwabe <arne@rfc2549.org>
Message-Id: <1441985627-14822-7-git-send-email-gert@greenie.muc.de>
URL: http://article.gmane.org/gmane.network.openvpn.devel/10089