]> git.ipfire.org Git - thirdparty/openvpn.git/log
thirdparty/openvpn.git
9 years agoAdd Windows DNS Leak fix using WFP ('block-outside-dns')
ValdikSS [Thu, 10 Dec 2015 20:51:35 +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.

The 2.3 version of this patch is only active if compiling for Vista+
(_WIN32_WINNT >= 0x0600) as XP does not have the necessary includes
and libraries.

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: <1449780695-3879-1-git-send-email-iam@valdikss.org.ru>
URL: http://article.gmane.org/gmane.network.openvpn.devel/10743

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 23:10:30 +0000 (01:10 +0200)] 
Use adapter index for add/delete_route_ipv6

Trac #637

Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <1449875430-15579-1-git-send-email-lstipakov@gmail.com>
URL: http://article.gmane.org/gmane.network.openvpn.devel/10760

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

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

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

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

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

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

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

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

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.

Note: crypto_msg() was changed to msg() for 2.3

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

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

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

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

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

9 years agoClient-side part for server restart notification
Lev Stipakov [Mon, 23 Nov 2015 11:38:13 +0000 (13:38 +0200)] 
Client-side part for server restart notification

When client receives "RESTART,N", it advances to the next remote.

Whole patch (server + client) has been merged to master and will be part
of 2.4.

Signed-off-by: Lev Stipakov <lstipakov@gmail.com>
Acked-by: Arne Schwabe <arne@rfc2549.org>
Message-Id: <1448278693-29322-1-git-send-email-lstipakov@gmail.com>
URL: http://article.gmane.org/gmane.network.openvpn.devel/10564
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>
(cherry picked from commit 87f1be66e88303c51520925f169dc5a8aa58a7f2)

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

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

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

9 years agoFix possible heap overflow on read accessing getaddrinfo() result.
Gert Doering [Tue, 10 Nov 2015 21:58:39 +0000 (22:58 +0100)] 
Fix possible heap overflow on read accessing getaddrinfo() result.

The code always tried to copy-out a "struct sockaddr_in6" even for IPv4
results, which reads more bytes than getaddrinfo() is guaranteed to
allocate.

Now, look at ai->ai_family and only copy "struct sockaddr" for IPv4.

Also, reformat this block of code to comply to coding style.

This is a specific 2.3 bug as the code in master (to be 2.4) has been
completely rewritten to properly handle dual-stack and multiple responses
from getaddrinfo() proper.

Bug found by Daniel Hirche using "gcc -fsanitize=address".  No possible
exploits are known.

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

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

9 years agoFix unintialized variable in plugin_vlog()
Steffan Karger [Sun, 8 Nov 2015 12:04:27 +0000 (13:04 +0100)] 
Fix unintialized variable in plugin_vlog()

Does not seem to be a problem in normal usage, because one of the PLOG_ERR,
PLOG_WARN, PLOG_NOTE or PLOG_DEBUG will be set, and will cause msg_flags
to be initialized.  In the worst case, msg_flags might accidentally
end up having M_FATAL set, causing openvpn to exit.

This was previously fixed in the master branch (5ead2ae0), but was not
backported to release/2.3, probably because that commit fixed other parts
of the code too, and those parts are quite different between master and
release/2.3.

Re-discovered by coverity.

Signed-off-by: Steffan Karger <steffan@karger.me>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <1446984267-3323-1-git-send-email-steffan@karger.me>
URL: http://article.gmane.org/gmane.network.openvpn.devel/10450
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>
(cherry picked from commit ea66a2b5cdb21422139c421b4d3733e1c1c3937e)

9 years agoFix (potential) memory leak in init_route_list()
Steffan Karger [Thu, 5 Nov 2015 22:17:01 +0000 (23:17 +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 release/2.3 only.  The master branch uses a gc to clean
up the netlist, and needs a different patch for a similar problem.

Found using coverity.

Signed-off-by: Steffan Karger <steffan@karger.me>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <1446761821-14013-1-git-send-email-steffan@karger.me>
URL: http://article.gmane.org/gmane.network.openvpn.devel/10442
Signed-off-by: Gert Doering <gert@greenie.muc.de>
9 years agoFix memory leak in auth-pam plugin 36/head
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>
(cherry picked from commit cfc13b38bc6504b9768e4cc43311807d6b074672)

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

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

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

9 years agoFix commit a3160fc1bd7368395745b9cee6e40fb819f5564c
Arne Schwabe [Wed, 14 Oct 2015 13:05:56 +0000 (15:05 +0200)] 
Fix commit a3160fc1bd7368395745b9cee6e40fb819f5564c

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

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

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

9 years agoIncrease control channel packet size for faster handshakes
Steffan Karger [Tue, 30 Jun 2015 19:44:56 +0000 (21:44 +0200)] 
Increase control channel packet size for faster handshakes

Instead of limiting the control channel TCP/UDP packet payload size at
'100 bytes + real control channel overhead' (~140 bytes ethernet payload),
increase the max TCP/UDP payload size to '1250 bytes - calculated overhead'
(~1210 bytes ethernet payload).

Note that this patch does *not* yield an optimal solution, but it is a
simple and rather safe change that will improve connection setup times
significantly.

v2: use the mininum value of --link-mtu and 1250 to give the user a way to
    reduce control packet size if really needed.

trac #545

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

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

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

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

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

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

9 years agoShow extra-certs in current parameters.
Arne Schwabe [Sat, 8 Aug 2015 12:57:36 +0000 (14:57 +0200)] 
Show extra-certs in current parameters.

Closes ticket #591

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

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

10 years agoUn-break --auth-user-pass on windows
Gert Doering [Tue, 4 Aug 2015 12:53:16 +0000 (14:53 +0200)] 
Un-break --auth-user-pass on windows

Commit b131c7b974d9d4d3f0 introduced a check to create a meaningful
warning if we try to read a password after daemon()izing (by checking
whether stdin or stderr is connected to a tty).  For some reason this
breaks on Windows builds if run under GUI control - but since Windows
doesn't have this particular daemon() issue anyway, just #ifndef WIN32
the offending code.

Signed-off-by: Gert Doering <gert@greenie.muc.de>
Acked-by: Steffan Karger <steffan.karger@fox-it.com>
Message-Id: <1438692796-14663-1-git-send-email-gert@greenie.muc.de>
URL: http://article.gmane.org/gmane.network.openvpn.devel/10000
(cherry picked from commit 0ffd744332f51878c4df430ab14aca3126bdfc8a)

10 years agoPreparing for release v2.3.8 (ChangeLog, version.m4) v2.3.8
Gert Doering [Mon, 3 Aug 2015 15:41:53 +0000 (17:41 +0200)] 
Preparing for release v2.3.8 (ChangeLog, version.m4)

Signed-off-by: Gert Doering <gert@greenie.muc.de>
10 years agoFix overflow check in openvpn_decrypt()
Steffan Karger [Wed, 29 Jul 2015 10:30:26 +0000 (12:30 +0200)] 
Fix overflow check in openvpn_decrypt()

Sebastian Krahmer from the SuSE security team reported that the buffer
overflow check in openvpn_decrypt() was too strict according to the
cipher update function contract:

"The amount of data written depends on the block alignment of the
encrypted data: as a result the amount of data written may be anything
from zero bytes to (inl + cipher_block_size - 1) so outl should contain
sufficient room."

This stems from the way CBC mode works, which caches input and 'flushes'
it block-wise to the output buffer.  We do allocate enough space for this
extra block in the output buffer for CBC mode, but not for CFB/OFB modes.

This patch:
 * updates the overflow check to also verify that the extra block required
   according to the function contract is available.
 * uses buf_inc_len() to double-check for overflows during en/decryption.
 * also reserves the extra block for non-CBC cipher modes.

In practice, I could not find a way in which this would fail. The plaintext
is never longer than the ciphertext, and the implementations of CBC/OFB/CBC
for AES and BF in both OpenSSL and PolarSSL/mbed TLS do not use the buffer
beyond the plaintext length when decrypting.  However, some funky OpenSSL
engine I did not check *might* use the buffer space required by the
function contract.  So we should still make sure we have enough room
anyway.

v2 - always ASSERT() on buf_inc_len().  It is a double-check so should
     really not fail, but if it fails there has been a buffer overflow.
     At that point the best thing we can do is assert out. (The primary
     check *is* handled gracefully, and just drops the packet.)

Signed-off-by: Steffan Karger <steffan.karger@fox-it.com>
Acked-by: Arne Schwabe <arne@rfc2549.org>
Message-Id: <1438165826-32762-1-git-send-email-steffan.karger@fox-it.com>
URL: http://article.gmane.org/gmane.network.openvpn.devel/9974
Signed-off-by: Gert Doering <gert@greenie.muc.de>
(cherry picked from commit cc377dec820f9e6e7e72981013eb3857aa6ea5ce)

10 years agoFix commit e473b7c if an inline file happens to have a line break exactly at buffer...
Arne Schwabe [Mon, 27 Jul 2015 15:33:11 +0000 (17:33 +0200)] 
Fix commit e473b7c if an inline file happens to have a line break exactly at buffer limit

The check does only for strlen(line) space and buf_printf will only use at
most space -1 and not print the final character ('\n') in this corner.
Since a missing \n only breaks certificates at the start and end marker,
missing line breaks otherwise do not trigger this error.

Acked-by: Steffan Karger <steffan.karger@fox-it.com>
Message-Id: <1438011191-19389-1-git-send-email-arne@rfc2549.org>
URL: http://article.gmane.org/gmane.network.openvpn.devel/9956

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

10 years agoFix using management interface to get passwords.
Steffan Karger [Wed, 15 Jul 2015 20:13:52 +0000 (22:13 +0200)] 
Fix using management interface to get passwords.

Commits da9b292733e929a2900dc32d37f0424c3d588366 and
315f6fbc7f657a7f1127628bd714f468709d5185 broke the use case where we are
asking password from the management client. The password is always asked
before daemonization. With this fix we avoid this and ask it via management
interface in the same spot as before the mentioned commits. Tested on Linux.

v2: This patch was first submitted by Christian Pellegrin (from Google),
and reworked by Steffan Karger (from the OpenVPN team) to also work for
setups with --management-query-passwords but without --auth-user-pass.

Signed-off-by: Steffan Karger <steffan@karger.me>
Signed-off-by: Christian Pellegrin <chripell@google.com>
Tested-by: Christian Pellegrin <chripell@google.com>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <55A6C46C.5080601@karger.me>
URL: http://article.gmane.org/gmane.network.openvpn.devel/9927
Signed-off-by: Gert Doering <gert@greenie.muc.de>
(cherry picked from commit d4fbe287fc2ddbef05fdfe22adc641859a8a7412)

10 years agoDocument --daemon changes and consequences (--askpass, --auth-nocache).
Gert Doering [Tue, 14 Jul 2015 07:09:54 +0000 (09:09 +0200)] 
Document --daemon changes and consequences (--askpass, --auth-nocache).

Trac #574, #576

Signed-off-by: Gert Doering <gert@greenie.muc.de>
Acked-by: Steffan Karger <steffan.karger@fox-it.com>
Message-Id: <1436857794-29419-1-git-send-email-gert@greenie.muc.de>
URL: http://article.gmane.org/gmane.network.openvpn.devel/9923
(cherry picked from commit b6ec7fbe96f4e200b8962ef6bb572bbb2228133e)

10 years agoFix --askpass not allowing for password input via stdin
James Geboski [Tue, 8 Jan 2013 22:52:57 +0000 (17:52 -0500)] 
Fix --askpass not allowing for password input via stdin

This resolves --askpass treating stdin as a file during the file access
check. In turn, this leads to openvpn failing to start if this option is
set to stdin.

By default, --askpass reads the certificate's password from stdin rather
than a file. Without passing the CHKACC_ACPTSTDIN flag to
check_file_access(), stdin is marked as being a nonexistent file.

Trac #248

Signed-off-by: James Geboski <jgeboski@gmail.com>
Acked-by: Steffan Karger <steffan.karger@fox-it.com>
Message-Id: <55A41225.2020705@karger.me>
URL: http://article.gmane.org/gmane.network.openvpn.devel/9918
Signed-off-by: Gert Doering <gert@greenie.muc.de>
(cherry picked from commit 4e1e3ba1d8582a1e95dd6f9564e97c99784959a7)

10 years agoProduce a meaningful error message if --daemon gets in the way of asking for passwords.
Gert Doering [Mon, 13 Jul 2015 19:10:07 +0000 (21:10 +0200)] 
Produce a meaningful error message if --daemon gets in the way of asking for passwords.

With the --daemon / SSL init reordering in da9b292733, we fail if we
daemonize first and then try to ask for a private key passphrase (or,
for that matter, username+password if --auth-nocache is set) - but
no meaningful error message was printed, instead depending on operating
system and library versions, either we looped around "ssl init failed"
or died with an unspecified "fatal error".

So: check if get_user_pass_cr() is called in a context that needs
"from_stdin", but both stdin and stderr are not connected to a tty
device (which getpass() needs).  In that case, print a meaningful
error message pointing to --askpass, and die.

Trac #574 and #576

Signed-off-by: Gert Doering <gert@greenie.muc.de>
Acked-by: Steffan Karger <steffan.karger@fox-it.com>
Message-Id: <1436814607-16707-1-git-send-email-gert@greenie.muc.de>
URL: http://article.gmane.org/gmane.network.openvpn.devel/9916
(cherry picked from commit 079e5b9c13bf81d7afc6f932b5417d2f08f8e64b)

10 years agofix regression: query password before becoming daemon
Steffan Karger [Thu, 9 Jul 2015 21:35:59 +0000 (23:35 +0200)] 
fix regression: query password before becoming daemon

The init sequence was changed to daemonize before the crypto init to fix
issues on FreeBSD some commits ago.  This introduced a regression where
we would no longer query for passwords before daemonizing, as described
in trac #574 and #576.

This commit restores the correct order, and adds a bit of const
correctness since we're touching this now code anyway.

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

10 years agoMake __func__ work with Visual Studio too
Steffan Karger [Wed, 1 Jul 2015 21:25:56 +0000 (23:25 +0200)] 
Make __func__ work with Visual Studio too

Because even VS2013 is incapable of doing C99.

Signed-off-by: Steffan Karger <steffan@karger.me>
Tested-by: Fish Wang <fish.thss@gmail.com>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <CAA1AbxKrPXnc1+PPH4dQV1OksY_0t3ewqRnqVrjhZL+i2Pbkmw@mail.gmail.com>
URL: http://article.gmane.org/gmane.network.openvpn.devel/9859
Signed-off-by: Gert Doering <gert@greenie.muc.de>
(cherry picked from commit 9884e20810bda737c7708ff587e09cc0bb8475c7)

10 years agoReport missing endtags of inline files as warnings
Arne Schwabe [Mon, 29 Jun 2015 12:46:35 +0000 (14:46 +0200)] 
Report missing endtags of inline files as warnings

(2.3 reports as warning only, 2.4 reports as M_FATAL)

trac #568

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

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

10 years agoDel ipv6 addr on close of linux tun interface
Holger Kummert [Thu, 25 Jun 2015 16:01:20 +0000 (18:01 +0200)] 
Del ipv6 addr on close of linux tun interface

When a linux tun interface is closed (e.g. on disconnect)
an optional ipv6 addr that was previously set is deleted now.
Without this patch a later reconnect could fail with
'Linux ip -6 addr add failed: external program exited with error status: 2'
and openvpn would exit.

This is mainly relevant for persistant tun devices (staying around
after openvpn exits) but can also happen at reconnect.

If addresses are *supposed* to stay around on openvpn exit, run
openvpn with --ifconfig-noexec and configure IPv4/IPv6 addresses
manually before openvpn starts (or using an --up script).

Trac #141

Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <1435248080-12670-1-git-send-email-Holger.Kummert@Sophos.com>
URL: http://article.gmane.org/gmane.network.openvpn.devel/9810

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

10 years agowrite pid file immediately after daemonizing
Steffan Karger [Thu, 18 Jun 2015 22:08:45 +0000 (00:08 +0200)] 
write pid file immediately after daemonizing

Since we split daemonizing from changing directory in commit da9b292
(f025de005d719201a69ad0313d545a1ddd244752 in release/2.3), we can
now simply write the pid file immediately after daemonizing.

This not only fixes the bug reported in trac #563, but also further
simplifies the code.

trac #563

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

10 years agoPreparing for release v2.3.7 (ChangeLog, version.m4) v2.3.7
Gert Doering [Tue, 2 Jun 2015 17:47:34 +0000 (19:47 +0200)] 
Preparing for release v2.3.7 (ChangeLog, version.m4)

Signed-off-by: Gert Doering <gert@greenie.muc.de>
10 years agoFix FreeBSD ifconfig for topology subnet tunnels.
Gert Doering [Sun, 26 Apr 2015 18:03:58 +0000 (20:03 +0200)] 
Fix FreeBSD ifconfig for topology subnet tunnels.

For "topology subnet", we only pretend to have a subnet and keep
using the tun if in point-to-point mode - but for that to fully
work, the "remote" address needs to be different from the "local"
address.  So just arbitrarily construct one from the on-link
subnet - base+1, if "that is not us", base+2, otherwise.

Fix trac #481

See also: https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=194745

Signed-off-by: Gert Doering <gert@greenie.muc.de>
Tested-By: Anton Sayetsky <vsasjason@gmail.com>
Lazy-ACK-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <1430071438-31675-1-git-send-email-gert@greenie.muc.de>
URL: http://article.gmane.org/gmane.network.openvpn.devel/9606
(cherry picked from commit 60fd44e501f2002459a49c6c9bc64370ea26ca87)

10 years agoImprove documentation in --script-security section of the man-page
Samuli Seppänen [Tue, 2 Jun 2015 07:59:42 +0000 (10:59 +0300)] 
Improve documentation in --script-security section of the man-page

Trac: #395

Signed-off-by: Samuli Seppänen <samuli@openvpn.net>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <1433231982-24945-1-git-send-email-samuli@openvpn.net>
URL: http://article.gmane.org/gmane.network.openvpn.devel/9777
Signed-off-by: Gert Doering <gert@greenie.muc.de>
(cherry picked from commit 001384e2952b54089e889edbda3196283b21641d)

10 years agoMove res_init() call to inner openvpn_getaddrinfo() loop
Gert Doering [Sun, 31 May 2015 13:59:09 +0000 (15:59 +0200)] 
Move res_init() call to inner openvpn_getaddrinfo() loop

A non-working nameserver in /etc/resolv.conf could lead to endless
loops inside openvpn_getaddrinfo(), because many systems will only
pick up changes to resolv.conf if res_init() is called again.

To reproduce, run openvpn with --resolv-retry infinite (2.3) or
--resolv-retry "a high number" (master) on a BSD system.  Linux
glibc seems to stat() resolv.conf on calls to getaddrinfo() and
pick up changes automatically.

Trac #523

Signed-off-by: Gert Doering <gert@greenie.muc.de>
Acked-by: Arne Schwabe <arne@rfc2549.org>
Message-Id: <1433080749-6892-1-git-send-email-gert@greenie.muc.de>
URL: http://article.gmane.org/gmane.network.openvpn.devel/9763
(cherry picked from commit 288a819af7d3a6fab9e0b69ae8dbaac74b36307b)

10 years agoFix --redirect-private in --dev tap mode.
Guy Yur [Mon, 1 Jun 2015 19:51:13 +0000 (21:51 +0200)] 
Fix --redirect-private in --dev tap mode.

When specifying redirect-private option and not specifying route-gateway
or ifconfig options, OpenVPN fails to add the route to the remote host
with the following message:

NOTE: unable to redirect default gateway -- VPN gateway parameter
(--route-gateway or --ifconfig) is missing

In redirect_default_route_to_vpn() the check for remote endpoint happens
even though it is not used by redirect-private - make check conditional
on RG_REROUTE_GW (= --redirect-gateway).

Trac #261

Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20150531120327.GE382@greenie.muc.de>
URL: http://article.gmane.org/gmane.network.openvpn.devel/9761
Signed-off-by: Gert Doering <gert@greenie.muc.de>
(cherry picked from commit 1e2b229e5140b784820906feb8446e47c1ecc62e)

10 years agoUse EAI_AGAIN instead of EAI_SYSTEM for openvpn_getaddrinfo().
Gert Doering [Mon, 1 Jun 2015 17:15:14 +0000 (19:15 +0200)] 
Use EAI_AGAIN instead of EAI_SYSTEM for openvpn_getaddrinfo().

Windows has no EAI_SYSTEM (introduced by 5f6c01ea6172ed), but everyone
has EAI_AGAIN - which also fits ("a temporary failure in name resolution").

Trac #276

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

10 years agoUse configure.ac hack to apply serial_test AM option only if supported.
Gert Doering [Mon, 1 Jun 2015 19:04:47 +0000 (21:04 +0200)] 
Use configure.ac hack to apply serial_test AM option only if supported.

Inspired by libguestfs' configure.ac hack - test automake version,
and if 1.12 or newer, use m4 magic to pass "serial_tests" option
to AM_INIT_AUTOMAKE().

https://www.redhat.com/archives/libguestfs/2013-February/msg00102.html

Trac #427

Signed-off-by: Gert Doering <gert@greenie.muc.de>
Acked-by: David Sommerseth <davids@redhat.com>
Message-Id: <1433185487-9724-1-git-send-email-gert@greenie.muc.de>
URL: http://article.gmane.org/gmane.network.openvpn.devel/9769
(cherry picked from commit c615835aa93701c764c23fc2579d97757c1a9970)

10 years agoOn signal reception, return EAI_SYSTEM from openvpn_getaddrinfo().
Gert Doering [Sun, 31 May 2015 20:41:58 +0000 (22:41 +0200)] 
On signal reception, return EAI_SYSTEM from openvpn_getaddrinfo().

A signal (except SIGUSR1) received while waiting for getaddrinfo() is
considered fatal, so openvpn_getaddrinfo() is destroying the returned
information with freeaddrinfo(), but still signalled "success" (0)
to the caller - so if the caller accessed *res before checking
*signal_received, it would access just-free()ed memory, which on some
platforms still worked and on others caused a crash.

Also, ensure that *ai is also NULLed in the caller now.

Trac #276

Signed-off-by: Gert Doering <gert@greenie.muc.de>
Acked-by: Arne Schwabe <arne@rfc2549.org>
Message-Id: <1433104918-9523-1-git-send-email-gert@greenie.muc.de>
URL: http://article.gmane.org/gmane.network.openvpn.devel/9764
(cherry picked from commit 5f6c01ea6172ed1d8ed04e31f9f6c3f8e4696109)

10 years agoRevert "Enforce "serial-tests" behaviour for tests/Makefile"
Gert Doering [Thu, 28 May 2015 09:11:47 +0000 (11:11 +0200)] 
Revert "Enforce "serial-tests" behaviour for tests/Makefile"

This reverts commit c196ea922755bb25f9837080d562ef4d3495999f,
because it breaks "autoreconf -vif" on autoconf versions older
than 1.12 - like, CentOS 6, Debian 7, ...

10 years agoEnforce "serial-tests" behaviour for tests/Makefile
Gert Doering [Wed, 27 May 2015 18:31:38 +0000 (20:31 +0200)] 
Enforce "serial-tests" behaviour for tests/Makefile

Our "make check" testsuite creates quite a bit of output which is
intended to help pinpointing the exact reason for failure - hidden by
default by automake 1.12 and up, which default to "parallel-tests" which
has no benefit for us.  So, just set the automake option to revert to
the old behaviour.

See also: https://www.gnu.org/software/automake/manual/html_node/Serial-Test-Harness.html

Trac #427

Signed-off-by: Gert Doering <gert@greenie.muc.de>
Message-ID: <20150524193011.GK382@greenie.muc.de>
URL: http://article.gmane.org/gmane.network.openvpn.devel/9738
Acked-by: David Sommerseth <openvpn.list@topphemmelig.net>
(cherry picked from commit fc03ca9d13e35c40bdf1c3c676db2adf48c60223)

10 years agoslightly enhance documentation about --cipher
Gert Doering [Tue, 26 May 2015 21:01:03 +0000 (23:01 +0200)] 
slightly enhance documentation about --cipher

point out that this is for "data channel" packets

trac #463

Signed-off-by: Gert Doering <gert@greenie.muc.de>
Acked-by: Steffan Karger <steffan.karger@fox-it.com>
Message-Id: <1432674063-15916-1-git-send-email-gert@greenie.muc.de>
URL: http://article.gmane.org/gmane.network.openvpn.devel/9746
(cherry picked from commit 0fe2498ef9326e301869c9e8a9e622a3996ae579)

10 years agoCall daemon() before initializing crypto library
Steffan Karger [Mon, 27 Apr 2015 14:28:57 +0000 (16:28 +0200)] 
Call daemon() before initializing crypto library

But keep the chdir to / at the place where deamon() was before, to preserve
the current behaviour wrt relative paths in the config.

This should fix the issue reported in trac #480, without changing the
behaviour visible to the end user.

Note that by moving the daemon() call to an earlier stage of the init
process, we no longer have to call platform_mlockall() again, or do a
pkcs11_forkFixup().

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

10 years agoDisallow usage of --server-poll-timeout in --secret key mode.
Gert Doering [Sun, 24 May 2015 13:02:34 +0000 (15:02 +0200)] 
Disallow usage of --server-poll-timeout in --secret key mode.

The internal machinery wants TLS for this to work, so just add this
to the (long) list of options not allowed unless either --tls-client
or --tls-server is active.  For added sanity, add an ASSERT() call
to the place where this combination caused a NULL ptr reference, and
document the restriction.

Fix trac #373

Signed-off-by: Gert Doering <gert@greenie.muc.de>
Acked-by: Steffan Karger <steffan.karger@fox-it.com>
Message-Id: <1432472554-24666-1-git-send-email-gert@greenie.muc.de>
URL: http://article.gmane.org/gmane.network.openvpn.devel/9736
(cherry picked from commit 6478c1f359e6b0ea2046d9e2801830753e53c06a)

10 years agoClarify --capath option in manpage
Steffan Karger [Sun, 24 May 2015 09:45:40 +0000 (11:45 +0200)] 
Clarify --capath option in manpage

Prevent confusion as described in trac #422 by better explaining the
behaviour of --capath, and providing pointers to relevant openssl man
pages.

Attached are patches for the master and release/2.3 branches.  The only
difference is that in the master patch, a line referencing the
requirement for OpenSSL 0.9.7 is removed, since master already requires
OpenSSL >= 0.9.8.

-Steffan

>From 96e564e113cc26adf22e5d4b51d5754858610c3e Mon Sep 17 00:00:00 2001
From: Steffan Karger <steffan@karger.me>
Date: Sun, 24 May 2015 11:20:11 +0200
Subject: [PATCH] Clarify --capath option in manpage

Prevent confusion as described in trac #422 by better explaining the
behaviour of --capath, and providing pointers to relevant openssl man
pages.

Signed-off-by: Steffan Karger <steffan@karger.me>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <55619DC4.2020108@karger.me>
URL: http://article.gmane.org/gmane.network.openvpn.devel/9732
Signed-off-by: Gert Doering <gert@greenie.muc.de>
10 years agoCorrect note about DNS randomization in openvpn.8
Gert Doering [Sat, 23 May 2015 20:47:27 +0000 (22:47 +0200)] 
Correct note about DNS randomization in openvpn.8

Commit 4880739c17b502d00a removed DNS randomization, but this fact
never made it into the man page.

Trac #411

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

10 years agoFix null pointer dereference in options.c
Jonathan K. Bullard [Sat, 23 May 2015 19:33:21 +0000 (15:33 -0400)] 
Fix null pointer dereference in options.c

Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <CAEsd45SHoEtahdVT95a+N-zmjRG4nH3QPxBZoGpnh1pykjSU4A@mail.gmail.com>
URL: http://article.gmane.org/gmane.network.openvpn.devel/9723

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

10 years agoassume res_init() is always there.
Gert Doering [Mon, 27 Apr 2015 19:27:21 +0000 (21:27 +0200)] 
assume res_init() is always there.

Previously, the code tried to find res_init(), and on some systems
got it wrong in configure, silently not-using res_init(), leading
to unexpected failures to re-init the resolver.

We know that all supported OSes (except Windows) have res_init(), so
change the call to "#ifndef WIN32", and adjust configure.ac to just
find the library to link (if any).  With that, failures to find
res_init() are no longer "hidden" but clearly visible at link time.

AC_SEARCH_LIBS() bits inspired by CUPS' cups_network.m4 (GPLv2)

Fix (part of) trac #523

Signed-off-by: Gert Doering <gert@greenie.muc.de>
Lazy-ACK-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <1430162841-5840-1-git-send-email-gert@greenie.muc.de>
URL: http://article.gmane.org/gmane.network.openvpn.devel/9614
(cherry picked from commit 403dc434d245e5df5ae262935aa2e7364547e260)

10 years agoRe-read auth-user-pass file on (re)connect if required
Steffan Karger [Sat, 23 May 2015 13:02:25 +0000 (15:02 +0200)] 
Re-read auth-user-pass file on (re)connect if required

Fixes trac #225 ('--auth-user-pass FILE' and '--auth-nocache' problem).

This patch is based on the changes suggested by ye_olde_iron in the trac
ticket.  Also added a note to the manpage to inform people to use
absolute paths when combining --auth-user-pass file and --auth-nocache.

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

10 years agorepair --dev null breakage caused by db950be85d37
Gert Doering [Sat, 23 May 2015 17:35:05 +0000 (19:35 +0200)] 
repair --dev null breakage caused by db950be85d37

"make check" self-test was broken after commit db950be85d37 due to
do_ifconfig_setenv() not checking whether tt->did_ifconfig_setup
was set (which isn't, for "dev null" type setups)

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

10 years agoinclude ifconfig_ environment variables in --up-restart env set
Jan Just Keijser [Wed, 20 May 2015 02:33:20 +0000 (04:33 +0200)] 
include ifconfig_ environment variables in --up-restart env set

here's my patch for bug #93: missing ifconfig_* env vars after
up-restart. Tested with both IPv4, IPv6, topology subnet and topology net30

Document differences between --up-restart and --up in openvpn.8

See trac #93 and the discussion starting with <555BF270.3090706@nikhef.nl>
on the openvpn-devel mailing list.

fix trac #93

Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <555BF270.3090706@nikhef.nl>
URL: http://article.gmane.org/gmane.network.openvpn.devel/9705
Signed-off-by: Gert Doering <gert@greenie.muc.de>
(cherry picked from commit db950be85d37eab40d8fffe0bc2060059f8a7e10)

10 years agoUpdated manpage for --rport and --lport
Robert Fischer [Mon, 18 May 2015 19:21:09 +0000 (21:21 +0200)] 
Updated manpage for --rport and --lport

[SK: v2, patch taken from trac #127 and updated to current master branch]

Signed-off-by: Robert Fischer <ml-openvpn@trispace.org>
Signed-off-by: Steffan Karger <steffan@karger.me>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <1431976869-4948-1-git-send-email-steffan@karger.me>
URL: http://article.gmane.org/gmane.network.openvpn.devel/9701
Signed-off-by: Gert Doering <gert@greenie.muc.de>
(cherry picked from commit d3eacb2d6ebb8a42506343c54e00c72252d683f8)

10 years agoUse OPENVPN_ETH_P_* so that <netinet/if_ether.h> is unecessary
Felix Janda [Sat, 16 May 2015 13:59:50 +0000 (15:59 +0200)] 
Use OPENVPN_ETH_P_* so that <netinet/if_ether.h> is unecessary

Fixes compilation error on linux with musl libc because of
conflicting ethhdr declarations in <netinet/if_ether.h> and
<linux/if_ether.h> which is included from <linux/if_tun.h>

Signed-off-by: Felix Janda <felix.janda@posteo.de>
Acked-by: Steffan Karger <steffan.karger@fox-it.com>
Message-Id: <20150516134604.GA2302@euler>
URL: http://article.gmane.org/gmane.network.openvpn.devel/9690
Signed-off-by: Gert Doering <gert@greenie.muc.de>
(cherry picked from commit ddb1f20a9ddbb94956c9f7b1115c89543d9b411a)

10 years agoImprove --tls-cipher and --show-tls man page description
Steffan Karger [Tue, 5 May 2015 15:47:37 +0000 (17:47 +0200)] 
Improve --tls-cipher and --show-tls man page description

As reported in trac tickets #304, #358 and #359 (and possibly more), the
usage and interpretation of --tls-cipher (and --show-tls) is tricky.  This
patch extends the man page to explain those a bit better and point out
that --tls-cipher is an expert feature (i.e. easy to get wrong).  Also add
a notice to the --show-tls output, referring to the man page explanation.

Signed-off-by: Steffan Karger <steffan@karger.me>
Acked-by: Arne Schwabe <arne@rfc2549.org>
Message-Id: <1430840857-6123-1-git-send-email-steffan@karger.me>
URL: http://article.gmane.org/gmane.network.openvpn.devel/9651
Signed-off-by: Gert Doering <gert@greenie.muc.de>
(cherry picked from commit 5f66f907cfc57b89110c08e50c7aab228e090911)

Conflicts:
doc/openvpn.8
src/openvpn/ssl_polarssl.c

10 years agoProperly escape dashes on the man-page
Samuli Seppänen [Tue, 5 May 2015 13:29:49 +0000 (16:29 +0300)] 
Properly escape dashes on the man-page

On UTF-8 systems groff interprets unescaped dashes as hyphens and
escaped dashes as minus signs. Unescaped dashes can cause problems
when searching for or copying and pasting options. This patch ensures
that dashes in command-line options are escaped and that everything
else is left unescaped.

Trac: 512
URL: http://thread.gmane.org/gmane.network.openvpn.devel/9569
Signed-off-by: Samuli Seppänen <samuli@openvpn.net>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <1430832589-9150-1-git-send-email-samuli@openvpn.net>
URL: http://article.gmane.org/gmane.network.openvpn.devel/9648
Signed-off-by: Gert Doering <gert@greenie.muc.de>
10 years agoAdd note about file permissions and --crl-verify to manpage.
Gert Doering [Sat, 2 May 2015 19:07:05 +0000 (21:07 +0200)] 
Add note about file permissions and --crl-verify to manpage.

Trac #522

Signed-off-by: Gert Doering <gert@greenie.muc.de>
Acked-by: Steffan Karger <steffan.karger@fox-it.com>
Message-Id: <1430593625-855-1-git-send-email-gert@greenie.muc.de>
URL: http://article.gmane.org/gmane.network.openvpn.devel/9634
(cherry picked from commit d55be0fb8091ff03af1319a27f68401d31ce8571)

10 years agoRemove size limit for files inlined in config
Steffan Karger [Mon, 27 Apr 2015 08:12:22 +0000 (10:12 +0200)] 
Remove size limit for files inlined in config

As described in trac #484, the current inline file size limit of 10000
bytes is becoming an issue for some users.  Since RSA keys and signature
sizes are increasing, we need to adjust our limits.  As #484 reports,
10000 can be too small for PKCS#12 files with 4K RSA keys.  Instead of
postponing this issue by increasing the static limit, dynamically increase
the buffer size while reading. This keeps the memory usage limited but does
allow for larger inlined files.

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

10 years agoexplain effect of --topology subnet on --ifconfig
Gert Doering [Tue, 28 Apr 2015 10:20:19 +0000 (12:20 +0200)] 
explain effect of --topology subnet on --ifconfig

The fact that the second parameter of --ifconfig is no longer
a "remote address" but a "netmask" when using --dev tun and
--topology subnet was not documented clearly enough.

Trac #370

Signed-off-by: Gert Doering <gert@greenie.muc.de>
Acked-by: Steffan Karger <steffan.karger@fox-it.com>
Message-Id: <1430216419-11943-1-git-send-email-gert@greenie.muc.de>
URL: http://article.gmane.org/gmane.network.openvpn.devel/9616
(cherry picked from commit 3a840739e43acc5ea15814be08debb9dbb7ba67c)

10 years agoPrint helpful error message on --mktun/--rmtun if not available.
Gert Doering [Tue, 28 Apr 2015 11:04:23 +0000 (13:04 +0200)] 
Print helpful error message on --mktun/--rmtun if not available.

OpenVPN only supports --mktun/--rmtun to create/destroy persistant
tunnels on Linux.  On BSD OSes, "ifconfig tun0 create" can do the
same job, so we do not actually need to support it - but the previous
error message ("unknown option") wasn't helpful.  So always accept
the option now, and on non-supported systems, direct user to manpage.

Trac #85

Signed-off-by: Gert Doering <gert@greenie.muc.de>
Acked-by: David Sommerseth <dazo@users.sourceforge.net>
Message-Id: <1430219063-12291-1-git-send-email-gert@greenie.muc.de>
URL: http://article.gmane.org/gmane.network.openvpn.devel/9617
(cherry picked from commit 4ad2b65d9deb3197d847d7dcc36715aa5394836f)

10 years agoManual page update for Re-enabled TLS version negotiation.
Matthias Andree [Mon, 30 Mar 2015 19:54:54 +0000 (21:54 +0200)] 
Manual page update for Re-enabled TLS version negotiation.

Signed-off-by: Matthias Andree <matthias.andree@gmx.de>
Acked-by: Steffan Karger <steffan.karger@fox-it.com>
Message-Id: <1427745294-31041-1-git-send-email-matthias.andree@gmx.de>
URL: http://article.gmane.org/gmane.network.openvpn.devel/9562
Signed-off-by: Gert Doering <gert@greenie.muc.de>
10 years agoRe-enable TLS version negotiation by default
Steffan Karger [Tue, 10 Mar 2015 19:26:45 +0000 (20:26 +0100)] 
Re-enable TLS version negotiation by default

Re-enable TLS version negotiation by default, so that users
benefit from the stronger and better crypto of TLSv1.1 and
TLSv1.2, without having to add 'tls-version-min' to their
config files.

We tried this before in 2.3.3, but got various reports of people
no longer being able to connect.  Back then, we did not have a
way for users to control the TLS version.  We now have
--tls-version-min and --tls-version-max, and even automatically
set --tls-version-max to 1.1 if --cryptoapi is used, because
the cryptoapi code is incompatible with TLS 1.2.

To make sure users can fall back to the _exact_ old default
behaviour, not only limit the TLS version to 1.0 if
--tls-version-max 1.0 is set, but also keep using the API calls
TLSv1_{client,server}_method(), instead of the ones that support
negotiation (SSLv23_{client,server}_method()).  (Yes, the naming
is awkward, but 'SSLv23' really means 'enable negotiation' in
OpenSSL-API language.

This patch is for the release/2.3 branch only.

Signed-off-by: Steffan Karger <steffan@karger.me>
Acked-by: Matthias Andree <matthias.andree@gmx.de>
Message-Id: <1426015605-4068-1-git-send-email-steffan@karger.me>
URL: http://article.gmane.org/gmane.network.openvpn.devel/9542
Signed-off-by: Gert Doering <gert@greenie.muc.de>
10 years agoRemove unneeded parameter 'first_time' from possibly_become_daemon()
Steffan Karger [Thu, 26 Mar 2015 00:01:29 +0000 (01:01 +0100)] 
Remove unneeded parameter 'first_time' from possibly_become_daemon()

The static helper function possibly_become_daemon() is called only once,
by do_init_first_time(), which checks 'first_time' to be true before
calling possibly_become_daemon().  This makes the parameter useless.

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

10 years agoFix incorrect use of get_ipv6_addr() for iroute options.
Gert Doering [Sun, 8 Mar 2015 12:56:41 +0000 (13:56 +0100)] 
Fix incorrect use of get_ipv6_addr() for iroute options.

get_ipv6_addr() returns "bool/false", not "int < 0" to signal error.

Signed-off-by: Gert Doering <gert@greenie.muc.de>
Acked-by: Steffan Karger <steffan.karger@fox-it.com>
Message-Id: <1425819401-18465-1-git-send-email-gert@greenie.muc.de>
URL: http://article.gmane.org/gmane.network.openvpn.devel/9532
(cherry picked from commit e8562d5531277ee4dd7c517ef68e87af077ac948)

10 years agoFix mssfix default value in connection_list context
Lev Stipakov [Thu, 5 Mar 2015 20:33:56 +0000 (22:33 +0200)] 
Fix mssfix default value in connection_list context

Due to this bug, mssfix hasn't been assigned to fragment value
and used default value (1450) instead. As a consequence, TCP packets
get fragmented, which causes performance penalty.

Since dual stack patch (commit 23d61c56b9fd218c39ad151b01b7e2d6690e6093)
OpenVPN uses options->connection_list, even for single remote.

This fix assigns mssfix value to fragment value for connection_entry
inside connection_list instead of connection_entry inside options struct
(which does not work for connection_list case).

Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <1425587636-23338-1-git-send-email-lstipakov@gmail.com>
URL: http://article.gmane.org/gmane.network.openvpn.devel/9507

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

10 years agoAllow for CN/username of 64 characters (fixes off-by-one)
Steffan Karger [Thu, 5 Mar 2015 21:37:31 +0000 (22:37 +0100)] 
Allow for CN/username of 64 characters (fixes off-by-one)

This is an alternative patch to fix the issue reported in trac #515 by
Jorge Peixoto. Instead of increasing the TLS_USERNAME_LEN define, do +1 at
the relevant places in the code.

Also see Jorge's original patch and the discussion on the maillinglist:
http://thread.gmane.org/gmane.network.openvpn.devel/9438

Signed-off-by: Steffan Karger <steffan@karger.me>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <54F8CC9B.9040104@karger.me>
URL: http://article.gmane.org/gmane.network.openvpn.devel/9508
Signed-off-by: Gert Doering <gert@greenie.muc.de>
(cherry picked from commit ecd934b1ef83eec58eb2df5d3a98309ca56d5812)

Conflicts:
src/openvpn/ssl_verify.c

10 years agoNew approach to handle peer-id related changes to link-mtu (2.3 version)
Gert Doering [Sun, 8 Feb 2015 10:18:45 +0000 (11:18 +0100)] 
New approach to handle peer-id related changes to link-mtu (2.3 version)

Instead of statically increasing link-mtu by +3, keep the old value for
OCC compatibility with old servers/clients, and only increase link-mtu
if peer-id option is enabled (right now: is pushed by server).

If link-mtu has been set in the config, keep configured value, and log
warning (because the extra overhead has to decrease tun-mtu).

Reserve extra +3 bytes in frame->extra_link.

v2: use frame->extra_link, not frame->extra_buffer (receive path on server)
    introduce frame_add_to_link_mtu() to manipulate frame->link_mtu value
    rework comments to make more clear what is happening

Adaption to 2.3: reserve +8 bytes in frame->extra_buffer - if compression
    is not enabled, the 2.3 code does not reserve space for compression
    overhead (2.4 code does), so the buffer ends up being too small.
    +3 is not sufficient because the buffer handling code also does some
    alignment tricks...

This reverts commit 4ec70ca227370380011d072c09b739135e236183.

Signed-off-by: Gert Doering <gert@greenie.muc.de>
(cherry picked from commit 9e0963c11aa439deb382d7d6bc40b6ade999401c)
Acked-by: Steffan Karger <steffan.karger@fox-it.com>
Message-Id: <1424031695-10218-1-git-send-email-gert@greenie.muc.de>
URL: http://article.gmane.org/gmane.network.openvpn.devel/9458

10 years agoFix frame size calculation for non-CBC modes.
Steffan Karger [Tue, 29 Jul 2014 20:52:24 +0000 (22:52 +0200)] 
Fix frame size calculation for non-CBC modes.

CBC mode is the only mode that OpenVPN supports that needs padding. So,
only include the worst case padding size in the frame size calculation when
using CBC mode.

While doing so, rewrite crypto_adjust_frame_parameters() to be better
readable, and provide debug output (for high debug levels).

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

10 years agoDisable SSL compression
Steffan Karger [Sun, 15 Feb 2015 14:24:26 +0000 (15:24 +0100)] 
Disable SSL compression

As reported in trac #502, SSL compression can cause problems in some corner
cases.  OpenVPN does not need SSL compression, since the control channel is
low bandwidth.  This does not influence the data channel compressen (i.e.
--comp or --comp-lzo).

Even though this has not yet been relevant for OpenVPN (since an attacker
can not easily control contents of control channel messages), SSL
compression has been used in the CRIME and BREACH attacks on TLS.  TLS 1.3
will probably even remove support for compression all together, for
exactly this reason.

Since we don't need it, and SSL compression causes issues, let's just
disable it in OpenSSL builds.  PolarSSL has no run-time flag to disable
compression, but is by default compiled without compression.

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: <1424010266-5910-1-git-send-email-steffan@karger.me>
URL: http://article.gmane.org/gmane.network.openvpn.devel/9453
Signed-off-by: Gert Doering <gert@greenie.muc.de>
(cherry picked from commit 5d5233778868ddd568140c394adfcfc8e3453245)

10 years agoAccount for peer-id in frame size calculation
Steffan Karger [Fri, 23 Jan 2015 19:52:41 +0000 (20:52 +0100)] 
Account for peer-id in frame size calculation

Data channel packet using P_DATA_V2 will use three bytes extra for the
peer-id. This needs to be accounted for, otherwise OpenVPN will throw

  TCP/UDP packet too large on write to [AF_INET]10.1.1.1:1194

warnings.

Signed-off-by: Steffan Karger <steffan@karger.me>
Acked-by: Lev Stipakov <lstipakov@gmail.com>
Message-Id: <1422042761-10014-1-git-send-email-steffan@karger.me>
URL: http://article.gmane.org/gmane.network.openvpn.devel/9418
Signed-off-by: Gert Doering <gert@greenie.muc.de>
(cherry picked from commit f95010ad247a8998e0c39e394236251fca316849)

10 years agoDefault gateway can't be determined on illumos/Solaris platforms
Alexander Pyhalov [Tue, 14 Oct 2014 19:43:21 +0000 (23:43 +0400)] 
Default gateway can't be determined on illumos/Solaris platforms

The logic which is used on BSD is preserved. The only distinction
is that illumos doesn't provide sa_len field in sockaddr structures.
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <1413315802-62359-4-git-send-email-alp@rsu.ru>
URL: http://article.gmane.org/gmane.network.openvpn.devel/9128

Signed-off-by: Gert Doering <gert@greenie.muc.de>
10 years agoSet tls-version-max to 1.1 if cryptoapicert is used
Steffan Karger [Sun, 28 Dec 2014 10:25:13 +0000 (11:25 +0100)] 
Set tls-version-max to 1.1 if cryptoapicert is used

OpenVPN's current cryptoapicert implementation does not support TLS 1.2
(and newer).  Fixing this requires a rewrite of our cryptoapi code to use
Microsofts' "Cryptography API: Next Generation", and several hacks to work
around that API.  As long as we don't fix that, make openvpn automatically
cap the TLS version to 1.1 when using cryptoapi (and tell the user we're
doing so).  This enables the user to use cryptoapi + TLS version
negotiation (upto TLS 1.1) without having to change his configuration.

This patch has been tested on Windows 8.1 for both the master and
release/2.3 branches.

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

10 years agoMake 'provider' option to --show-pkcs11-ids optional where p11-kit is present
David Woodhouse [Thu, 18 Dec 2014 12:25:06 +0000 (12:25 +0000)] 
Make 'provider' option to --show-pkcs11-ids optional where p11-kit is present

Trac: 490
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
Acked-by: Steffan Karger <steffan.karger@fox-it.com>
Message-Id: <1418905506.21260.6.camel@infradead.org>
URL: http://article.gmane.org/gmane.network.openvpn.devel/9355
Signed-off-by: Gert Doering <gert@greenie.muc.de>
10 years agopkcs11: Load p11-kit-proxy.so module by default
David Woodhouse [Thu, 11 Dec 2014 13:03:35 +0000 (13:03 +0000)] 
pkcs11: Load p11-kit-proxy.so module by default

If the user specifies --pkcs11-id or --pkcs-id-management but neglects
to explicitly provide a --pkcs11-provider argument, and if the system
has p11-kit installed, then load the p11-kit proxy module so that the
system-configured tokens are available.

Trac: 490
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
Acked-by: Steffan Karger <steffan.karger@fox-it.com>
Message-Id: <1418303015.31745.78.camel@infradead.org>
URL: http://article.gmane.org/gmane.network.openvpn.devel/9342
Signed-off-by: Gert Doering <gert@greenie.muc.de>
10 years agoplugins, down-root: Code style clean-up
David Sommerseth [Mon, 8 Dec 2014 22:45:51 +0000 (23:45 +0100)] 
plugins, down-root: Code style clean-up

The coding style was somewhat chaotic.  Cleaning it up using the astyle
tool.  The style parameters are coherent to what was agreed upon at the
Munich Hackathon 2014 [1].

     astyle --style=allman --indent=spaces=4 -c

Also included a "Local variables" section which some editors may pick
up automatically.

Signed-off-by: David Sommerseth <davids@redhat.com>
Acked-by: Steffan Karger <steffan.karger@fox-it.com>
Message-Id: <1418078751-3614-1-git-send-email-openvpn.list@topphemmelig.net>
URL: http://article.gmane.org/gmane.network.openvpn.devel/9331
Signed-off-by: Gert Doering <gert@greenie.muc.de>
(cherry picked from commit e2e9a69c1ecc7142cc17d665076795215b6a8e9a)

10 years agosockets: Remove the limitation of --tcp-nodelay to be server-only
David Sommerseth [Tue, 9 Dec 2014 09:52:44 +0000 (10:52 +0100)] 
sockets: Remove the limitation of --tcp-nodelay to be server-only

The assert(0) happening if trying to use --tcp-nodelay in a client
config is really not helpful at all.  When this assert(0) was removed,
another warning appeared that this could only be used in server
configs.  That itself is also quite silly, as clients can choose to
use --socket-flags TCP_NODELAY in the client config instead.  This
behaviour does not help the user in any way.

This patch removes the server-only restriction and rather provides
a more helpful warning when using --tcp-nodelay on the client side.

Trac: 489
Signed-off-by: David Sommerseth <davids@redhat.com>
Acked-by: Arne Schwabe <arne@rfc2549.org>
Message-Id: 1418118764-17846-1-git-send-email-openvpn.list@topphemmelig.net
URL: http://article.gmane.org/gmane.network.openvpn.devel/9334
(cherry picked from commit 706283d3765d1ee62dbd913fbfc191855b92528d)

10 years agoplugin, down-root: Fix compiler warnings
David Sommerseth [Mon, 8 Dec 2014 21:31:15 +0000 (22:31 +0100)] 
plugin, down-root: Fix compiler warnings

Removed a few compiler warnings:
  down-root.c:164:4: warning: implicit declaration of function 'warn'
[-Wimplicit-function-declaration]
  down-root.c:239:5: warning: implicit declaration of function 'err'
[-Wimplicit-function-declaration]
  down-root.c:461:7: warning: unused variable 'i' [-Wunused-variable]
  down-root.c:460:15: warning: unused variable 'p' [-Wunused-variable]

Signed-off-by: David Sommerseth <davids@redhat.com>
Acked-by: Steffan Karger <steffan.karger@fox-it.com>
Message-Id: 1418074541-24987-1-git-send-email-openvpn.list@topphemmelig.net
URL: http://article.gmane.org/gmane.network.openvpn.devel/9327
(cherry picked from commit 7dd51f6f50b17ab91cbb724e2d5e96657fab834a)

10 years agoUpdate doxygen (a bit)
Steffan Karger [Sun, 7 Dec 2014 18:48:15 +0000 (19:48 +0100)] 
Update doxygen (a bit)

This is not a full update, but just updates some data channel-related docs
I came across. Other pages probably need a bit of attention too.

Stuff that was changed:
 * Explain data channel crypto format in crypto.h
 * Add P_DATA_V1 and P_DATA_V2 packet format spec
 * Remove '2.1' from title
 * Update some OpenSSL-specific text

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

10 years agodown-root: Improve error messages
David Sommerseth [Mon, 17 Nov 2014 22:14:20 +0000 (23:14 +0100)] 
down-root: Improve error messages

If down-root fails it will now use warn() to provide some more information
about what went wrong, by retrieving the error message via errno.

Signed-off-by: David Sommerseth <davids@redhat.com>
Acked-by: Steffan Karger <steffan.karger@fox-it.com>
Message-Id: <1416262460-9158-1-git-send-email-openvpn.list@topphemmelig.net>
URL: http://article.gmane.org/gmane.network.openvpn.devel/9247
Signed-off-by: Gert Doering <gert@greenie.muc.de>
(cherry picked from commit b0f2c521303b7bceb6806680363bc4b9d225e5b8)