]> git.ipfire.org Git - thirdparty/openvpn.git/log
thirdparty/openvpn.git
6 years agoFallback to password authentication when auth-token fails
Arne Schwabe [Wed, 10 Oct 2018 14:30:51 +0000 (16:30 +0200)] 
Fallback to password authentication when auth-token fails

Under some circumstances, the auth-token stored by a client may not
be valid anymore.

For example, if the server is restarted, the client will try to
reconnect and resend the old token during authentication. Unfortunately
this attempt will fail, because the server does not keep track of tokens
used during previous runs.

With the current behaviour, depending on how auth-retry was configured,
the client will either just quit, prompt the user for username and password
as the original values are overwritten by the token, or endelessly fail
authentication by sending the old token over and over.

This patch changes the behaviour of the client so that, upon failed
authentication using a token, it will drop the token, perform a soft
restart (USR1) and attempt re-authenticating with the original password
provided by the user if auth-nocache was not specified.

Patch V2: properly formatted commit message, fix openvpn3 detection

Patch V3: remove all server changes, include only minimal non
intrusive client changes that only improve error recovery but don't
change overall behaviour.

Patch V4: forget add push.c to git index, now also included

Patch V5: is fixing overlong lines and one minor style problem.

Signed-off-by: Arne Schwabe <arne@rfc2549.org>
Acked-by: Antonio Quartulli <antonio@openvpn.net>
Message-Id: <20181010143051.27163-1-arne@rfc2549.org>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg17718.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
6 years agoAdds support for setting the default IPv6 gateway for routes using the route-ipv6...
James Bekkema [Mon, 23 Jul 2018 03:28:31 +0000 (13:28 +1000)] 
Adds support for setting the default IPv6 gateway for routes using the route-ipv6-gateway option.

Acked-by: Arne Schwabe <arne@rfc2549.org>
Message-Id: <777939F9-A753-4A66-B40E-1346AFD588DE@sparklabs.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg17290.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
6 years agoImplement block-ipv6
Arne Schwabe [Mon, 3 Dec 2018 16:48:18 +0000 (17:48 +0100)] 
Implement block-ipv6

This can be used to redirect all IPv6 traffic to the tun interface,
effectively black holing the IPv6 traffic. Without ICMPv6 error
messages this will result in timeouts when the server does not send
error codes.  block-ipv6 allows client side only blocking on all
platforms that OpenVPN supports IPv6. On Android it is only way to do
sensible IPv6 blocking on Android < 5.0 and broken devices (Samsung).

PATCH V6:
- Rebase on master and run uncrustify on the patch

PATCH V5:
- Fix even more style issues by Antonio
- Remove check for dev == tun as this also works for tap

PATCH V4:
- Fix more style issues reported by Antonio
- Clarify parts of the patch in comments and manpage

PATCH V3:
- Fix style iusses reported by Antonio and accidentily commited parts
- merge udp_checksum and ipv6_checkusm into common ip_checksum method
- Use fake ff80::7 address when no other address is configured.
- Make block-ipv6 also work for server  by replying block-ipv6 to all
  ipv6 traffic send to the server

Note for the server the process_ip happens before the ipv6 route
lookup so every ipv6 packet, regardless of its source address is
replyied to with a no route to host packet.

Signed-off-by: Arne Schwabe <arne@rfc2549.org>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20181203164818.15756-1-arne@rfc2549.org>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg17977.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
6 years agoAdd tls-crypt-v2 to the list of supported inline options
Arne Schwabe [Tue, 4 Dec 2018 16:05:02 +0000 (17:05 +0100)] 
Add tls-crypt-v2 to the list of supported inline options

Signed-off-by: Arne Schwabe <arne@rfc2549.org>
Acked-by: Steffan Karger <steffan.karger@fox-it.com>
Message-Id: <20181204160502.1089-1-arne@rfc2549.org>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg17980.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
6 years agoRemove deprecated --compat-x509-names and --no-name-remapping
Steffan Karger [Wed, 24 Oct 2018 10:12:05 +0000 (12:12 +0200)] 
Remove deprecated --compat-x509-names and --no-name-remapping

As promised, remove these options for OpenVPN 2.5.

If a user still uses these, print an error that the user should update it's
configuration. Just printing a warning would cause much more confusing
errors, somewhere in middle of a failed connection attempt because the
(non-compat) names no longer match the expected names.

Signed-off-by: Steffan Karger <steffan.karger@fox-it.com>
Acked-by: Arne Schwabe <arne@rfc2549.org>
Message-Id: <1540375925-6111-1-git-send-email-steffan.karger@fox-it.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg17804.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
6 years agotls-crypt-v2: fix client reconnect bug
Steffan Karger [Wed, 31 Oct 2018 13:07:16 +0000 (14:07 +0100)] 
tls-crypt-v2: fix client reconnect bug

As reported by tincantech on the openvpn-devel IRC channel, a tls-crypt-v2
client could be caused to trigger an assert in tls_crypt_wrap() because the
client key might not be correctly initialized after a reconnect attempt.

This was caused by code that was written before the connection-block
tls-auth/tls-crypt logic was integrated (57d6f103), rebased on that change,
but not sufficiently changed to be compatible with the new logic.

This commit fixes that bug.

Note that I also moved the violating hunk of code to the same function
where the tls-auth and tls-crypt (v1) keys are initialized. Once moved
there, it is immediately clear that v2 didn't follow the same (new) logic.

Signed-off-by: Steffan Karger <steffan.karger@fox-it.com>
Tested-by: Richard Bonhomme <tincanteksup@gmail.com>
Acked-by: Antonio Quartulli <antonio@openvpn.net>
Message-Id: <1540991236-4016-1-git-send-email-steffan.karger@fox-it.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg17866.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
6 years agotls-crypt-v2: clarify --tls-crypt-v2-genkey man page section
Steffan Karger [Wed, 31 Oct 2018 10:22:57 +0000 (11:22 +0100)] 
tls-crypt-v2: clarify --tls-crypt-v2-genkey man page section

As kitsune1 mentioned in IRC, this section should explain that
"--tls-crypt-v2-genkey client" requires the user to supply the server
key using "--tls-crypt-v2".

Signed-off-by: Steffan Karger <steffan.karger@fox-it.com>
Acked-by: Antonio Quartulli <antonio@openvpn.net>
Message-Id: <1540981377-22752-1-git-send-email-steffan.karger@fox-it.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg17865.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
6 years agotls-crypt: properly cast time_t to uint64_t
Antonio Quartulli [Wed, 31 Oct 2018 16:01:24 +0000 (00:01 +0800)] 
tls-crypt: properly cast time_t to uint64_t

The exact type of time_t is platform dependent and therefore
can't be assumed to be uint64_t all the time.

For example, on 32bit platforms, where time_t is defined as long
(32bit), the compiler will generate the following warning, due
to the arithmetic used in the macro:

tls_crypt.c:745:29: warning: shift count >= width of type
[-Wshift-count-overflow]

Force time_t to be parsed as uint64_t.

Reported-by: Arne Schwabe <arne@rfc2549.org>
Signed-off-by: Antonio Quartulli <a@unstable.cc>
Acked-by: Arne Schwabe <arne@rfc2549.org>
Message-Id: <20181031160124.26972-1-a@unstable.cc>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg17868.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
6 years agoCorrect error message for --tls-crypt-v2-genkey client
tincanteksup [Tue, 30 Oct 2018 23:20:32 +0000 (23:20 +0000)] 
Correct error message for --tls-crypt-v2-genkey client

Signed-off-by: Richard Bonhomme <tincanteksup@gmail.com>
Acked-by: Steffan Karger <steffan.karger@fox-it.com>
Message-Id: <87a06f64-26df-d1f2-3039-08f8addfaa3b@gmail.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg17862.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
6 years agoDeclare Windows version of openvpn_execve() before use
Selva Nair [Thu, 25 Oct 2018 03:05:16 +0000 (23:05 -0400)] 
Declare Windows version of openvpn_execve() before use

commit bf97c00f7dba441b504881f38e40afcbb610a39f moved
the generic openvpn_execve() to run_command.c and made it static.
But the Windows version is still in win32.c and is called from
run_command.c

Fix by declaring the function in win32.h

Signed-off-by: Selva Nair <selva.nair@gmail.com>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <1540436716-5725-1-git-send-email-selva.nair@gmail.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg17825.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
6 years agotls-crypt-v2: add script hook to verify metadata
Steffan Karger [Mon, 22 Oct 2018 11:45:15 +0000 (13:45 +0200)] 
tls-crypt-v2: add script hook to verify metadata

To allow rejecting incoming connections very early in the handshake,
add a --tls-crypt-v2-verify option that allows administators to
run an external command to verify the metadata from the client key.
See doc/tls-crypt-v2.txt for more details.

Because of the extra dependencies, this requires adding a mock
parse_line() to the tls-crypt unit tests.  Also, this turns tls_wrap_free
into a static inline function, so that we don't need to compile in ssl.c
(and all of it's dependencies) with the unit tests.

Signed-off-by: Antonio Quartulli <antonio@openvpn.net>
Signed-off-by: Steffan Karger <steffan.karger@fox-it.com>
Acked-by: Antonio Quartulli <antonio@openvpn.net>
Message-Id: <1540208715-14044-6-git-send-email-steffan.karger@fox-it.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg17789.html
Signed-off-by: David Sommerseth <davids@openvpn.net>
6 years agotls-crypt-v2: implement tls-crypt-v2 handshake
Steffan Karger [Mon, 22 Oct 2018 11:45:14 +0000 (13:45 +0200)] 
tls-crypt-v2: implement tls-crypt-v2 handshake

This makes clients send-and-use, and servers receive-unwrap-and-use
tls-crypt-v2 client keys, which completes the on-the-wire work.

Signed-off-by: Steffan Karger <steffan.karger@fox-it.com>
Acked-by: Antonio Quartulli <antonio@openvpn.net>
Message-Id: <1540208715-14044-5-git-send-email-steffan.karger@fox-it.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg17787.html
Signed-off-by: David Sommerseth <davids@openvpn.net>
6 years agotls-crypt-v2: add P_CONTROL_HARD_RESET_CLIENT_V3 opcode
Steffan Karger [Mon, 22 Oct 2018 11:45:13 +0000 (13:45 +0200)] 
tls-crypt-v2: add P_CONTROL_HARD_RESET_CLIENT_V3 opcode

Not used yet, but prepare for sending and receiving tls-crypt-v2 handshake
messages.

Signed-off-by: Steffan Karger <steffan.karger@fox-it.com>
Acked-by: Antonio Quartulli <antonio@openvpn.net>
Message-Id: <1540208715-14044-4-git-send-email-steffan.karger@fox-it.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg17790.html
Signed-off-by: David Sommerseth <davids@openvpn.net>
6 years agotls-crypt-v2: add unwrap_client_key
Steffan Karger [Mon, 22 Oct 2018 11:45:12 +0000 (13:45 +0200)] 
tls-crypt-v2: add unwrap_client_key

Add helper functions to unwrap tls-crypt-v2 client keys.

Signed-off-by: Steffan Karger <steffan.karger@fox-it.com>
Acked-by: Antonio Quartulli <antonio@openvpn.net>
Message-Id: <1540208715-14044-3-git-send-email-steffan.karger@fox-it.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg17791.html
Signed-off-by: David Sommerseth <davids@openvpn.net>
6 years agotls-crypt-v2: generate tls-crypt-v2 keys
Steffan Karger [Mon, 22 Oct 2018 11:45:11 +0000 (13:45 +0200)] 
tls-crypt-v2: generate tls-crypt-v2 keys

As a first step towards a full tls-crypt-v2 implementation, add
functionality to generate tls-crypt-v2 client and server keys.

Signed-off-by: Steffan Karger <steffan.karger@fox-it.com>
Acked-by: Antonio Quartulli <antonio@openvpn.net>
Message-Id: <1540208715-14044-2-git-send-email-steffan.karger@fox-it.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg17792.html
Signed-off-by: David Sommerseth <davids@openvpn.net>
6 years agotls-crypt-v2: add specification to doc/
Steffan Karger [Mon, 22 Oct 2018 11:45:10 +0000 (13:45 +0200)] 
tls-crypt-v2: add specification to doc/

This is a preliminary description of tls-crypt-v2.  It should give a good
impression about the reasoning and design behind tls-crypt-v2, but might
need some polishing and updating.

Signed-off-by: Steffan Karger <steffan.karger@fox-it.com>
Acked-by: Antonio Quartulli <antonio@openvpn.net>
Message-Id: <1540208715-14044-1-git-send-email-steffan.karger@fox-it.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg17788.html
Signed-off-by: David Sommerseth <davids@openvpn.net>
6 years agoAdd message explaining early TLS client hello failure
Arne Schwabe [Wed, 26 Sep 2018 12:01:59 +0000 (14:01 +0200)] 
Add message explaining early TLS client hello failure

In my tests an OpenSSL 1.1.1 server does not accept TLS 1.0 only clients
anymore. Unfortunately, Debian 8 still has OpenVPN 2.3.4, which is
TLS 1.0 only without setting tls-version-min.

We currently log only
OpenSSL: error:14209102:SSL
routines:tls_early_post_process_client_hello:unsupported protocol
which indicates the right technical error but is not very helpful to a
person without deep knowledge in SSL/TLS and OpenVPN's TLS version
history.

This commit adds a hopefully helpful message and also tells users how
to fix the old Debian 8 clients. The error message will be displayed on
the server side only.

Note that connecting with an OpenSSL 1.1.1 client to a TLS 1.0 only
server works fine.

This behaviour is also not specific to OpenVPN. Using an openssl s_client
with the -tls1 option against an openssl s_server exhibits the same
behaviour.

Patch V2: fixed message grammar, use tls-version-min 1.0 and clarify
2.3.6 and older to be actually between 2.3.2 and 2.3.6

Signed-off-by: Arne Schwabe <arne@rfc2549.org>
Acked-by: Steffan Karger <steffan.karger@fox-it.com>
Message-Id: <20180926120159.19874-1-arne@rfc2549.org>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg17491.html
Signed-off-by: David Sommerseth <davids@openvpn.net>
6 years agoWrap openvpn_swprintf into Windows define
Lev Stipakov [Tue, 23 Oct 2018 14:51:28 +0000 (17:51 +0300)] 
Wrap openvpn_swprintf into Windows define

Commit 43a5a4f3b4e411419639c195fee8a76495fdc88e added
vswprintf() call which turned to me missing in OpenBSD 4.9.

Since that call is inside openvpn_swprintf() function which
is only used by Windows, wrap that function info #ifdef _WIN32.

Signed-off-by: Lev Stipakov <lev@openvpn.net>
Acked-by: Antonio Quartulli <antonio@openvpn.net>
Acked-by: Selva Nair <selva.nair@gmail.com>
Message-Id: <1540306288-23847-1-git-send-email-lstipakov@gmail.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg17799.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
6 years agoIntroduce openvpn_swprintf() with nul termination guarantee
Lev Stipakov [Mon, 22 Oct 2018 10:19:31 +0000 (13:19 +0300)] 
Introduce openvpn_swprintf() with nul termination guarantee

Every call to swprintf is followed by line which adds nul terminator. This
patch
introduces openvpn_swprintf() which guarantees nul termination for size >
0.

Same approach as for snprintf / openvpn_snprintf.

Signed-off-by: Lev Stipakov <lev@openvpn.net>
Acked-by: Selva Nair <selva.nair@gmail.com>
Message-Id: <1540203571-17646-1-git-send-email-lstipakov@gmail.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg17786.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
6 years agoifconfig-ipv6(-push): allow using hostnames
Antonio Quartulli [Sun, 3 Dec 2017 04:14:26 +0000 (12:14 +0800)] 
ifconfig-ipv6(-push): allow using hostnames

Similarly to ifconfig(-push), its IPv6 counterpart is now able to
accept hostnames as well instead of IP addresses in numeric form.

Basically this means that the user is now allowed to specify
something like this:

ifconfig-ipv6-push my.hostname.cx/64

This is exactly the same behaviour that we already have with
ifconfig(-push).

The generic code introduced in this patch will be later used to
implement the /bits parsing support for IPv4 addresses.

Trac: #808
Signed-off-by: Antonio Quartulli <a@unstable.cc>
Acked-by: Selva Nair <selva.nair@gmail.com>
Message-Id: <20171203041426.25316-1-a@unstable.cc>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg15969.html
Signed-off-by: David Sommerseth <davids@openvpn.net>
6 years agobuffer_list_aggregate_separator(): simplify code
Steffan Karger [Fri, 29 Dec 2017 09:54:31 +0000 (10:54 +0100)] 
buffer_list_aggregate_separator(): simplify code

Clean up the function by slightly simplifying the logic.

Mostly whitespace changes, so best reviewed using 'git diff -w'.

Signed-off-by: Steffan Karger <steffan.karger@fox-it.com>
Acked-by: Antonio Quartulli <a@unstable.cc>
Message-Id: <1514541271-19597-1-git-send-email-steffan.karger@fox-it.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg16105.html
Signed-off-by: David Sommerseth <davids@openvpn.net>
6 years agoRefuse mbed TLS external key with non RSA certificates
Arne Schwabe [Mon, 8 Oct 2018 21:41:23 +0000 (23:41 +0200)] 
Refuse mbed TLS external key with non RSA certificates

The current API that we use (mbedtls_pk_setup_rsa_alt) only allows
using RSA keys with the external API. Using an EC, mbed TLS and external
key in OpenVPN will fail very late with a rather obscure error message.

Instead fail early and provide a clear message that only RSA keys are
supported.

Signed-off-by: Arne Schwabe <arne@rfc2549.org>
Acked-by: Steffan Karger <steffan@karger.me>
Message-Id: <20181008214123.10819-1-arne@rfc2549.org>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg17671.html
Signed-off-by: David Sommerseth <davids@openvpn.net>
6 years agobuffer_list: add functions documentation
Antonio Quartulli [Wed, 10 Oct 2018 08:37:31 +0000 (16:37 +0800)] 
buffer_list: add functions documentation

bufferlist_* functions have no documentation whatsoever and the name is
not always enough to fully understand what the function is doing.
For this reason and for the sake of having better documented code, add
function doc in buffer.h.

Signed-off-by: Antonio Quartulli <a@unstable.cc>
Acked-by: Steffan Karger <steffan@karger.me>
Message-Id: <20181010083731.31132-1-a@unstable.cc>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg17701.html
Signed-off-by: David Sommerseth <davids@openvpn.net>
6 years agoUse right function to set TLS1.3 restrictions in show-tls
Arne Schwabe [Thu, 11 Oct 2018 22:06:39 +0000 (00:06 +0200)] 
Use right function to set TLS1.3 restrictions in show-tls

The last version of the patch used the TLS1.2 version
tls_ctx_restrict_ciphers to set the restrictions for both
TLS 1.3 and TLS1.2 instead of using tls_ctx_restrict_ciphers_tls13
for TLS1.3.

Also fix minor style problem while I am touching the function
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20181011220639.7316-1-arne@rfc2549.org>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg17755.html

Signed-off-by: Gert Doering <gert@greenie.muc.de>
6 years agoAdd better support for showing TLS 1.3 ciphersuites in --show-tls
Arne Schwabe [Wed, 10 Oct 2018 15:36:24 +0000 (17:36 +0200)] 
Add better support for showing TLS 1.3 ciphersuites in --show-tls

--show-tls shows mixed TLS 1.3 and TLS 1.2 ciphers.  The listed ciphers
are only valid in either --tls-cipher or --tls-ciphersuites, but it's
not clear which is which. This is confusing and not really helpful.

This patch modifies show-tls to show separate lists for TLS 1.2 and
TLS 1.3.

Signed-off-by: Arne Schwabe <arne@rfc2549.org>
Acked-by: Steffan Karger <steffan.karger@fox-it.com>
Message-Id: <20181010153624.27957-1-arne@rfc2549.org>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg17723.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
6 years agooptions.c: fix broken unary minus usage
Lev Stipakov [Thu, 11 Oct 2018 11:51:42 +0000 (14:51 +0300)] 
options.c: fix broken unary minus usage

In Visual Studio when unary minus is applied to unsigned,
result is still unsigned. This means that when we use result
as function formal parameter, we pass incorrect value.

Fix by introducing frame_remove_from_extra_frame(),
which makes code semantically more clear and eliminates
the need in negative value and cast.

Since GCC didn't complain (and users too :), it probably performed
cast to signed automatically.

Signed-off-by: Lev Stipakov <lev@openvpn.net>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <1539258702-15427-1-git-send-email-lstipakov@gmail.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg17739.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
6 years agoFix mbedtls unit tests
Steffan Karger [Wed, 10 Oct 2018 06:44:43 +0000 (08:44 +0200)] 
Fix mbedtls unit tests

Commit 674b166 ("Fix build warnings related to get_random()") broke the
unit tests for mbedtls, because <mbedtls/cipher.h> was now included via
platform.c -> crypto.h -> crypto_backend.h, but the crypto cflags were
not included for that unit tests.

Since we got rid of --disable-crypto, we can now fix this by simply always
including the CRYPTO_CFLAGS in the TEST_CFLAGS (and the CRYPTO_LIBS in the
TEST_LDFLAGS). This should not only fix this occurrence, but also prevent
similar problems in the future.

Signed-off-by: Steffan Karger <steffan.karger@fox-it.com>
Acked-by: Arne Schwabe <arne@rfc2549.org>
Message-Id: <1539153883-15789-1-git-send-email-steffan.karger@fox-it.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg17687.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
6 years agombedtls: don't print unsupported ciphers in insecure cipher list
Steffan Karger [Thu, 11 Oct 2018 07:20:00 +0000 (09:20 +0200)] 
mbedtls: don't print unsupported ciphers in insecure cipher list

Commit 447997dd refactored the --show-ciphers code, but introduced a bug
in mbedtls builds where non-AEAD/CBC cipher were printed too.  Those are
however unsupported (as openvpn will tell you when you try to use them).

This fixes that bug.

Signed-off-by: Steffan Karger <steffan.karger@fox-it.com>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <1539242400-27614-1-git-send-email-steffan.karger@fox-it.com>
URL: https://sourceforge.net/p/openvpn/mailman/message/36438012/
Signed-off-by: Gert Doering <gert@greenie.muc.de>
6 years agoList ChaCha20-Poly1305 as stream cipher
Steffan Karger [Tue, 9 Oct 2018 20:43:15 +0000 (22:43 +0200)] 
List ChaCha20-Poly1305 as stream cipher

As Antonio pointed out, "8-bit block cipher" is a bit funny. So teach
print_cipher() to print such cipher as "stream cipher".

Because I didn't want to write the same code twice, I decided to merge the
two print_cipher() implementations into one shared function. That should
make it easier to keep both backends consistent.

Signed-off-by: Steffan Karger <steffan@karger.me>
Acked-by: Antonio Quartulli <antonio@openvpn.net>
Message-Id: <20181009204315.8262-1-steffan@karger.me>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg17682.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
6 years agoAdd support for tls-ciphersuites for TLS 1.3
Arne Schwabe [Sun, 7 Oct 2018 21:55:39 +0000 (23:55 +0200)] 
Add support for tls-ciphersuites for TLS 1.3

OpenSSL 1.1.1 introduces a separate list for TLS 1.3 ciphers. As these
interfaces are meant to be user facing or not exposed at all and we
expose the tls-cipher interface, we should also expose tls-cipherlist.

Combining both settings into tls-cipher would add a lot of glue logic
that needs to be maintained and is error prone. On top of that, users
should not set either settings unless absolutely required.

OpenSSL's own s_client/s_server also expose both settings and I believe
most other software will too:

 -cipher val         Specify TLSv1.2 and below cipher list to be used
 -ciphersuites val   Specify TLSv1.3 ciphersuites to be used

For mbed TLS only the future can tell if we will see a combined or also
two separate lists.
Acked-by: Steffan Karger <steffan.karger@fox-it.com>
Message-Id: <20181007215539.32761-1-arne@rfc2549.org>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg17626.html

Signed-off-by: Gert Doering <gert@greenie.muc.de>
6 years agoRemove MANAGMENT_EXTERNAL_KEY, MANAGMENT_IN_EXTRA, ENABLE_CLIENT_CR
Arne Schwabe [Wed, 10 Oct 2018 14:25:27 +0000 (16:25 +0200)] 
Remove MANAGMENT_EXTERNAL_KEY, MANAGMENT_IN_EXTRA, ENABLE_CLIENT_CR

These defines are always defined when management is enabled.

We still have --disable-management as configure option, so we need
to replace these with ENABLE_MANAGEMENT in some cases.

PATCH v3: Rebase directly on master

Signed-off-by: Arne Schwabe <arne@rfc2549.org>
Acked-by: Steffan Karger <steffan.karger@fox-it.com>
Message-Id: <20181010142527.27025-1-arne@rfc2549.org>
URL: https://www.mail-archive.com/search?l=mid&q=20181010142527.27025-1-arne@rfc2549.org
Signed-off-by: Gert Doering <gert@greenie.muc.de>
6 years agointeractive.c: fix usage of potentially uninitialized variable
Lev Stipakov [Mon, 8 Oct 2018 18:12:58 +0000 (21:12 +0300)] 
interactive.c: fix usage of potentially uninitialized variable

In function netsh_dns_cmd() it is possible to jump on a label and
call free() on uninitialized pointer. Move pointer initialization
above jump.

To fix a few warnings which are treated as errors with SDL enabled,
initialize pointers with NULL.

Signed-off-by: Lev Stipakov <lev@openvpn.net>
Acked-by: Selva Nair <selva.nair@gmail.com>
Message-Id: <1539022378-24485-1-git-send-email-lstipakov@gmail.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg17663.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
6 years agoRemove AUTO_USERID feature
Arne Schwabe [Mon, 8 Oct 2018 18:16:16 +0000 (20:16 +0200)] 
Remove AUTO_USERID feature

There is no user facing way to enable this feature and way that feature
works (username build from MAC of primary net device) is questionable.

It also does not compile anymore.
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20181008181618.8976-2-arne@rfc2549.org>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg17664.html

Signed-off-by: Gert Doering <gert@greenie.muc.de>
6 years agobuild: Fix another compile warning in console_systemd.c
David Sommerseth [Mon, 8 Oct 2018 18:00:17 +0000 (21:00 +0300)] 
build: Fix another compile warning in console_systemd.c

console_systemd.c: In function ?get_console_input_systemd?:
console_systemd.c:75:5: warning: implicit declaration of function
?openvpn_popen? [-Wimplicit-function-declaration]
     if ((std_out = openvpn_popen(&argv, NULL)) < 0)

Signed-off-by: David Sommerseth <davids@openvpn.net>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20181008180017.31413-1-davids@openvpn.net>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg17660.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
6 years agobuild: Fix build warnings related to get_random()
David Sommerseth [Mon, 8 Oct 2018 16:56:48 +0000 (19:56 +0300)] 
build: Fix build warnings related to get_random()

This fixes this compile warning:

    platform.c: In function ?platform_create_temp_file?:
    platform.c:355:31: warning: implicit declaration of function
?get_random? [-Wimplicit-function-declaration]
                                   prefix, (unsigned long) get_random(),

Signed-off-by: David Sommerseth <davids@openvpn.net>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20181008165648.27504-1-davids@openvpn.net>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg17652.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
6 years agoman: correct a --redirection-gateway option flag
Samy Mahmoudi [Sun, 7 Oct 2018 22:35:47 +0000 (00:35 +0200)] 
man: correct a --redirection-gateway option flag

Replace "servers" with "peers" in the description
of the --redirection-gateway option flag local.
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20181007223544.GA2246@t520.my.lan>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg17630.html

Signed-off-by: Gert Doering <gert@greenie.muc.de>
6 years agomsvc: Unify Unicode/MultiByte string setting across all cfg|plat
Simon Rozman [Mon, 8 Oct 2018 09:45:59 +0000 (11:45 +0200)] 
msvc: Unify Unicode/MultiByte string setting across all cfg|plat

The openvpnserv.vcxproj source code is Windows API Unicode compliant
with only Debug|x64 set to Unicode, while other cfg|plat pairs were set
to MultiByte.
Acked-by: Lev Stipakov <lstipakov@gmail.com>
Message-Id: <20181008094600.10164-1-simon@rozman.si>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg17633.html

Signed-off-by: Gert Doering <gert@greenie.muc.de>
6 years agoAdd support for CHACHA20-POLY1305 in the data channel
Steffan Karger [Sun, 7 Oct 2018 22:30:34 +0000 (00:30 +0200)] 
Add support for CHACHA20-POLY1305 in the data channel

We explicitly only supported GCM as a valid AEAD mode, change that to also
allow ChaCha20-Poly1305 as an AEAD cipher.  That works nicely with our new
(GCM) data channel format, because is has the same 96-bit IV.

Note that we need some tricks to not treat the cipher as insecure, because
we used to only look at the block size of a cipher to determine if find a
cipher insecure.  But ChaCha20-Poly1305 is a stream cipher, which
essentially
has a 'block size' of 1 byte and is reported as such.  So, special-case
this
cipher to be in the list of secure ciphers.

Signed-off-by: Steffan Karger <steffan@karger.me>
Acked-by: Antonio Quartulli <antonio@openvpn.net>
Message-Id: <20181007223035.21179-1-steffan@karger.me>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg17629.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
6 years agocrypto.h: remove unused function declaration
Lev Stipakov [Mon, 8 Oct 2018 14:19:26 +0000 (17:19 +0300)] 
crypto.h: remove unused function declaration

This removes declaration of function which has no definition and usage.

Signed-off-by: Lev Stipakov <lev@openvpn.net>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <1539008366-19656-1-git-send-email-lstipakov@gmail.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg17644.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
6 years agomsvc: Move common project settings to reusable property sheets
Simon Rozman [Mon, 8 Oct 2018 09:46:00 +0000 (11:46 +0200)] 
msvc: Move common project settings to reusable property sheets

The Visual Studio 2017 project files were refactored by migrating all
repeating common settings into three property sheets: Debug.props,
Release.props and the existing PropertySheet.props.
This simplifies configuration management while providing uniformity
across projects, configurations and platforms.
Acked-by: Lev Stipakov <lstipakov@gmail.com>
Message-Id: <20181008094600.10164-2-simon@rozman.si>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg17634.html

Signed-off-by: Gert Doering <gert@greenie.muc.de>
6 years agoReference msvc-generate from compat to assure correct build order
Simon Rozman [Mon, 8 Oct 2018 10:03:23 +0000 (12:03 +0200)] 
Reference msvc-generate from compat to assure correct build order

Single-process builds start building compat project first and they fail,
since the referenced config-msvc-version.h is not available yet. Multi-
process rebuilds also tends to fail if the compat project is built
faster than msvc-generate is able to produce the required output files.

Adding a reference to msvc-generate project assures correct build order.
Acked-by: Lev Stipakov <lstipakov@gmail.com>
Message-Id: <20181008100323.11308-1-simon@rozman.si>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg17635.html

Signed-off-by: Gert Doering <gert@greenie.muc.de>
6 years agoDon't print OCC warnings about 'key-method', 'keydir' and 'tls-auth'
Steffan Karger [Sun, 7 Oct 2018 17:52:15 +0000 (19:52 +0200)] 
Don't print OCC warnings about 'key-method', 'keydir' and 'tls-auth'

Like 'proto', a mismatch in key-method, keydir or tls-auth would fail
before we ever get to the point where we can print this warning.

This prepares for removing these from the occ string later on, but also
prepares for tls-crypt-v2, which allows a server to support tls-auth and
tls-crypt-v2 connections in parallel. Such a server will send 'keydir'
and 'tls-auth' in the occ string. This change removes the spurious
warnings about that in the client log.

Signed-off-by: Steffan Karger <steffan.karger@fox-it.com>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20181007175215.25009-1-steffan@karger.me>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg17618.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
6 years agoSimplify --genkey option syntax
Steffan Karger [Fri, 5 Oct 2018 15:00:32 +0000 (17:00 +0200)] 
Simplify --genkey option syntax

Instead of requiring users to do "--genkey --secret new.key", allow
them to just do "--genkey new.key".  This has hit me often enough that I
decided to write a patch for it.  Also, the upcoming tls-crypt-v2-genkey
uses a similar syntax and Antonio suggested we should make them consistent.

The documentation is updated to no longer mention the old syntax, but it is
still supported so people who are used to the old syntax can still use it.

Signed-off-by: Steffan Karger <steffan@karger.me>
Acked-by: Antonio Quartulli <antonio@openvpn.net>
Message-Id: <20181005150032.16541-1-steffan@karger.me>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg17574.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
6 years agoopenvpnserv: clarify return values type
Lev Stipakov [Wed, 3 Oct 2018 17:21:21 +0000 (20:21 +0300)] 
openvpnserv: clarify return values type

Functions openvpn_vsntprintf and openvpn_sntprintf return
values of type int, but in reality it is always 0 or 1 (and -1 for
snrptinf), which can be represented as boolean.

To make code clearer, change return type to BOOL. Also
use stdbool.h header instead of bool definition macros in automatic.c.

Signed-off-by: Lev Stipakov <lev@openvpn.net>
Acked-by: Selva Nair <selva.nair@gmail.com>
Message-Id: <1538587281-3209-1-git-send-email-lstipakov@gmail.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg17532.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
6 years agoFix use-after-free in tls_ctx_use_management_external_key
Steffan Karger [Sun, 7 Oct 2018 10:00:32 +0000 (12:00 +0200)] 
Fix use-after-free in tls_ctx_use_management_external_key

Commit 98bfeeb4 changed our openssl backend implementation of
tls_ctx_use_management_external_key() to no longer use
tls_ctx_load_cert_file_and_copy(), but still free'd 'cert'. Which it no
longer should do. Credits go to Arne for spotting the issue (even though
it was missed during the review).

The offending commit is only recently applied to the master branch, so was
never part of a OpenVPN release. For that reason I did not do full impact
analysis.

Signed-off-by: Steffan Karger <steffan@karger.me>
Acked-by: Arne Schwabe <arne@rfc2549.org>
Message-Id: <20181007100032.17060-1-steffan@karger.me>
URL: https://www.mail-archive.com/search?l=mid&q=20181007100032.17060-1-steffan@karger.me
Signed-off-by: Gert Doering <gert@greenie.muc.de>
6 years agoSigned/unsigned warnings of MSVC resolved
Simon Rozman [Fri, 13 Apr 2018 12:47:56 +0000 (14:47 +0200)] 
Signed/unsigned warnings of MSVC resolved

This patch fixes the signed/unsigned comparison warnings discovered when
compiling openvpnserv using MSVC.

Wherever possible, it changes iterator and/or size variables to a more
appropriate type, or uses type-casting when it is safe to do so.
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20180413124756.5756-1-simon@rozman.si>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg16756.html

Signed-off-by: Gert Doering <gert@greenie.muc.de>
6 years agoChange quoted to angled form when #including external .h files
Simon Rozman [Fri, 13 Apr 2018 15:55:17 +0000 (17:55 +0200)] 
Change quoted to angled form when #including external .h files

Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20180413155517.895-1-simon@rozman.si>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg16760.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
6 years agoensure function declarations are compiled with their definitions
Antonio Quartulli [Sat, 11 Nov 2017 16:18:36 +0000 (00:18 +0800)] 
ensure function declarations are compiled with their definitions

Function prototypes should be included when compiling their
definitions so that it is clear to compilers and static
analyzers that they are not static.

This means that several declarations have to be moved to the
related header files which in turn have to be included by the
source files implementing them.

Generally speaking this also improves the coding style and
makes this code more consistent with the rest that already
follows this rule.

Cc: Steffan Karger <steffan@karger.me>
Signed-off-by: Antonio Quartulli <antonio@openvpn.net>
Acked-by: Steffan Karger <steffan.karger@fox-it.com>
Message-Id: <20171111161836.23356-3-a@unstable.cc>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg15820.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
6 years agomerge *-inline.h files with their main header
Antonio Quartulli [Sun, 12 Nov 2017 08:48:30 +0000 (16:48 +0800)] 
merge *-inline.h files with their main header

*-inline.h files are not very useful anymore.
In the attempt of cleaning up the code some more,
merge them into their main header files.

At the same time, move functions from forward.h
to forward.c, when they are used only in the latter.

No functional change is part of this patch.

Cc: Steffan Karger <steffan@karger.me>
Signed-off-by: Antonio Quartulli <a@unstable.cc>
Acked-by: Steffan Karger <steffan.karger@fox-it.com>
Message-Id: <20171112084830.22912-1-a@unstable.cc>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg15838.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
6 years agopf: restyle pf_c2c/addr_test() to make them 'struct context' agnostic
Antonio Quartulli [Sat, 11 Nov 2017 16:18:34 +0000 (00:18 +0800)] 
pf: restyle pf_c2c/addr_test() to make them 'struct context' agnostic

In the attempt of getting rid of any pf-inline.h file, we need
to make sure that inline functions do not trigger any circular
include dependency.

For this reason, avoid pf_c2c/addr_test() to be 'struct context'
aware, so that pf-inline.h does not need to rely on the content
of openvpn.h.

Cc: Steffan Karger <steffan@karger.me>
Signed-off-by: Antonio Quartulli <a@unstable.cc>
Acked-by: Steffan Karger <steffan.karger@fox-it.com>
Message-Id: <20171111161836.23356-1-a@unstable.cc>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg15822.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
6 years agoFactor out convert_tls_list_to_openssl method
Arne Schwabe [Sat, 6 Oct 2018 08:06:15 +0000 (10:06 +0200)] 
Factor out convert_tls_list_to_openssl method

This makes the tls_ctx_restrict_ciphers function more readable and
clean ups the code a bit more.

Signed-off-by: Arne Schwabe <arne@rfc2549.org>
Acked-by: Steffan Karger <steffan.karger@fox-it.com>
Message-Id: <20181006080617.18136-1-arne@rfc2549.org>
URL: https://www.mail-archive.com/search?l=mid&q=20181006080617.18136-1-arne@rfc2549.org
Signed-off-by: Gert Doering <gert@greenie.muc.de>
6 years agoinit.c: refine functions names and description
Lev Stipakov [Sat, 6 Oct 2018 09:30:19 +0000 (12:30 +0300)] 
init.c: refine functions names and description

This patch provides better naming and description
for functions which deal with backup/restore NCP-negotiable
options.

Signed-off-by: Lev Stipakov <lev@openvpn.net>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <1538818219-18141-1-git-send-email-lstipakov@gmail.com>
URL: https://www.mail-archive.com/search?l=mid&q=1538818219-18141-1-git-send-email-lstipakov@gmail.com
Signed-off-by: Gert Doering <gert@greenie.muc.de>
6 years agoSkip error about ioctl(SIOCGIFCONF) failed on Android
Arne Schwabe [Fri, 5 Oct 2018 13:16:32 +0000 (15:16 +0200)] 
Skip error about ioctl(SIOCGIFCONF) failed on Android

Patch: V2 Do not use C99 style comments

Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20181005131632.32515-1-arne@rfc2549.org>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg17565.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
6 years agoRefactor sending commands to interactive service
Selva Nair [Tue, 2 Oct 2018 20:01:14 +0000 (16:01 -0400)] 
Refactor sending commands to interactive service

Move writing the message buffer to the interactive service pipe and
reading acknowledgement to a function.

A minor bug in open_tun where the ack data could be read even after
a communication error is fixed.

Signed-off-by: Selva Nair <selva.nair@gmail.com>
Acked-by: Lev Stipakov <lstipakov@gmail.com>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <1538510474-27602-3-git-send-email-selva.nair@gmail.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg17519.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
6 years agoEnable dhcp on tap adapter using interactive service
Selva Nair [Tue, 2 Oct 2018 20:01:13 +0000 (16:01 -0400)] 
Enable dhcp on tap adapter using interactive service

Currently, if dhcp on the TAP interface is disabled, OpenVPN
on Windows tries to enable it using netsh but that succeeds only when
run with admin privileges.

When interactive service is available, delegate this task to the
service.

Trac: #1111
Tested on Windows 7

Signed-off-by: Selva Nair <selva.nair@gmail.com>
Acked-by: Lev Stipakov <lstipakov@gmail.com>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <1538510474-27602-2-git-send-email-selva.nair@gmail.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg17517.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
6 years agotravis: add OpenSSL 1.1 Windows build
Steffan Karger [Fri, 5 Oct 2018 12:39:38 +0000 (14:39 +0200)] 
travis: add OpenSSL 1.1 Windows build

So we catch both compilation errors against OpenSSL 1.0 and 1.1 on Windows.

Signed-off-by: Steffan Karger <steffan@karger.me>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20181005123938.25649-1-steffan@karger.me>
URL: https://www.mail-archive.com/search?l=mid&q=20181005123938.25649-1-steffan@karger.me
Signed-off-by: Gert Doering <gert@greenie.muc.de>
6 years agoMove get system directory to a separate function
Selva Nair [Tue, 2 Oct 2018 20:01:12 +0000 (16:01 -0400)] 
Move get system directory to a separate function

Only refactoring to reduce code-duplication, no functional changes.

Signed-off-by: Selva Nair <selva.nair@gmail.com>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <1538510474-27602-1-git-send-email-selva.nair@gmail.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg17518.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
6 years agoAdd OpenSSL compat definition for RSA_meth_set_sign
Arne Schwabe [Fri, 5 Oct 2018 12:23:30 +0000 (14:23 +0200)] 
Add OpenSSL compat definition for RSA_meth_set_sign

Commit 6b495dc4c5cfc118091ddc9c19330b3c9e3e3dff introduced
RSA_meth_set_sign, which is OpenSSL 1.1.0 and newer. Add a compatibility
definition.
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20181005122330.31431-1-arne@rfc2549.org>
URL: https://www.mail-archive.com/search?l=mid&q=20181005122330.31431-1-arne@rfc2549.org

Signed-off-by: Gert Doering <gert@greenie.muc.de>
6 years agoPass the hash without the DigestInfo header to NCryptSignHash()
Selva Nair [Thu, 26 Apr 2018 14:24:24 +0000 (10:24 -0400)] 
Pass the hash without the DigestInfo header to NCryptSignHash()

In case of TLS 1.2 signatures, the callback rsa_priv_enc() gets
the hash with the DigestInfo prepended. Signing this using
NCryptSignHash() with hash algorithm id set to NULL works in most cases.
But when using some hardware tokens, the data gets interpreted as the pre
TLS 1.2 MD5+SHA1 hash and is silently truncated to 36 bytes.
Avoid this by passing the raw hash to NCryptSignHash() and let it
add the DigestInfo.

To get the raw hash we set the RSA_sign() method in the rsa_method
structure. This callback bypasses rsa_priv_enc() and gets called with
the hash type and the hash.

Fixes Trac #1050
Acked-by: Steffan Karger <steffan.karger@fox-it.com>
Message-Id: <1524752664-27946-1-git-send-email-selva.nair@gmail.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg16840.html

Signed-off-by: Gert Doering <gert@greenie.muc.de>
6 years agoRefactor NCP-negotiable options handling
Lev Stipakov [Thu, 20 Sep 2018 13:12:34 +0000 (16:12 +0300)] 
Refactor NCP-negotiable options handling

NCP negotiation can alter options. On reconnect
client sends possibly altered options while server
expects original values. This leads to warnings
in log and, if server uses --opt-verify, breaks
reconnect.

Fix by decouple setting/unsetting NCP options from
the state of TLS context. At startup (and once per sighup)
we load original values to c->c1, which persists over
sigusr1 (restart). When tearing tunnel down we restore
(possibly altered) options back to original values.

Trac: #1105

Signed-off-by: Lev Stipakov <lev@openvpn.net>
Acked-by: Steffan Karger <steffan.karger@fox-it.com>
Message-Id: <1537449154-26879-1-git-send-email-lstipakov@gmail.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg17477.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
6 years agowin: support for Visual Studio 2017
Lev Stipakov [Fri, 28 Sep 2018 13:26:49 +0000 (16:26 +0300)] 
win: support for Visual Studio 2017

This patch enables building openvpn with Visual Studio 2017.

It is advised to use openvpn-build/msvs/build.bat which
also downloads and build required dependencies.

Changes made:

 - updated path to Visual Studio toolchain
 - updated platform toolset
 - added missing libraries
 - added x64 configurations
 - enabled AEAD ciphers to make NCP work
 - enabled unicode support
 - updated source files in project settings
 - fix includes
 - restored variable which was erroneously removed
 - added properties file which sets required env variables
  (required to build with IDE)
 - etc

Signed-off-by: Lev Stipakov <lev@openvpn.net>
Acked-by: Simon Rozman <simon@rozman.si>
Message-Id: <1538141209-32330-1-git-send-email-lstipakov@gmail.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg17499.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
6 years agoFix memory leak in SSL_CTX_use_certificate
Steffan Karger [Wed, 26 Sep 2018 19:27:06 +0000 (21:27 +0200)] 
Fix memory leak in SSL_CTX_use_certificate

Commit 98bfeeb4 introduced a memory leak in SSL_CTX_use_certificate by
removing the "if(x509) { ... }" bit while not changing the
"else if(x) {}" right after to an "if(x) {}".

Signed-off-by: Steffan Karger <steffan@karger.me>
Acked-by: Arne Schwabe <arne@rfc2549.org>
Message-Id: <20180926192706.29460-1-steffan@karger.me>
Signed-off-by: Gert Doering <gert@greenie.muc.de>
6 years agombedtls: remove dependency on mbedtls pkcs11 module
Steffan Karger [Fri, 14 Sep 2018 09:14:19 +0000 (11:14 +0200)] 
mbedtls: remove dependency on mbedtls pkcs11 module

Instead of using mbedtls's pkcs11 module, reuse the code we already have
for management-external-key to also do pkcs11 signatures.  As far as mbed
is concerned, we simply provide an external signature.

This has the following advantages:
 * We no longer need mbed TLS to be compiled with the pkcs11 modules
   enabled (which is not enabled by default).  This makes it easier to use
   a system/distribution-provided mbed shared library.
 * We no longer have a dependency on pkcs11-helper through mbed TLS.  So if
   we want to migrate to some other pkcs11 lib (see e.g. trac #491, #538
   and #549 for reason why), this will be easier.

While touching this code, switch from M_FATAL to M_WARN and proper error
handling.  This improves the error reporting, and helps prevent potential
future DoS attacks if someone starts using these functions on peer input.

Signed-off-by: Steffan Karger <steffan.karger@fox-it.com>
Acked-by: Arne Schwabe <arne@rfc2549.org>
Message-Id: <1536916459-25900-3-git-send-email-steffan.karger@fox-it.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg17463.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
6 years agombedtls: make external signing code generic
Steffan Karger [Fri, 14 Sep 2018 09:14:18 +0000 (11:14 +0200)] 
mbedtls: make external signing code generic

This prepares for reusing this code from the mbedtls pkcs11 implementation.
The change itself should not have any functional impact.

Signed-off-by: Steffan Karger <steffan.karger@fox-it.com>
Acked-by: Arne Schwabe <arne@rfc2549.org>
Message-Id: <1536916459-25900-2-git-send-email-steffan.karger@fox-it.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg17465.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
6 years agoDo not load certificate from tls_ctx_use_external_private_key()
Steffan Karger [Fri, 14 Sep 2018 09:14:17 +0000 (11:14 +0200)] 
Do not load certificate from tls_ctx_use_external_private_key()

The cert and key loading logic surrounding management-external-key and
management-external cert was somewhat intertwined.  Untangle these to
prepare for making the external key code more reusable.

The best part is that this even reduces the number of lines of code.

Signed-off-by: Steffan Karger <steffan.karger@fox-it.com>
Acked-by: Arne Schwabe <arne@rfc2549.org>
Message-Id: <1536916459-25900-1-git-send-email-steffan.karger@fox-it.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg17464.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
6 years agoProperly free tuntap struct on android when emulating persist-tun
Arne Schwabe [Wed, 12 Sep 2018 11:07:01 +0000 (13:07 +0200)] 
Properly free tuntap struct on android when emulating persist-tun

Trac-Ticket: #851
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20180912110701.31609-1-arne@rfc2549.org>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg17460.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
6 years agoRemove unused void_ptr_hash_function and void_ptr_compare_function
Steffan Karger [Wed, 19 Sep 2018 16:20:09 +0000 (18:20 +0200)] 
Remove unused void_ptr_hash_function and void_ptr_compare_function

Both functions are never used, so let's get rid of them.

Signed-off-by: Steffan Karger <steffan.karger@fox-it.com>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <1537374009-11133-1-git-send-email-steffan.karger@fox-it.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg17473.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
6 years agosystemd: extend CapabilityBoundingSet for auth_pam
Christian Ehrhardt [Wed, 29 Aug 2018 14:27:14 +0000 (16:27 +0200)] 
systemd: extend CapabilityBoundingSet for auth_pam

Auth_pam will require audit writes or the connection will be rejected
as the plugin fails to initialize like:
  openvpn[1111]: sudo: unable to send audit message
  openvpn[1111]: sudo: pam_open_session: System error
  openvpn[1111]: sudo: policy plugin failed session initialization

See links from https://community.openvpn.net/openvpn/ticket/918 for
more.

auth_pam is a common use case and capabilties for it should be allowed
by the .service file.

Fixes: #918
Signed-off-by: Christian Ehrhardt <christian.ehrhardt@canonical.com>
Acked-by: David Sommerseth <davids@openvpn.net>
Message-Id: <20180829142715.417-2-christian.ehrhardt@canonical.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg17432.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
6 years agoFix memory leak after sighup
Steffan Karger [Wed, 29 Aug 2018 13:49:43 +0000 (15:49 +0200)] 
Fix memory leak after sighup

The c.es env_set is (re)allocated for each "sighup loop iteration", while
it was free'd only once at process shutdown.  Move the env_set_destroy()
call to match the same level as the env_set_create() call to fix that.

Signed-off-by: Steffan Karger <steffan.karger@fox-it.com>
Acked-by: Arne Schwabe <arne@rfc2549.org>
Message-Id: <1535550583-21825-1-git-send-email-steffan.karger@fox-it.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg17429.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
6 years agombedtls: print warning if random personalisation fails
Steffan Karger [Wed, 29 Aug 2018 12:04:46 +0000 (14:04 +0200)] 
mbedtls: print warning if random personalisation fails

... instead of when it doesn't fail.  Looks like 'someone' mixed up the
mbedtls return style (0 means success) with the openvpn internal return
style (true means success).

Signed-off-by: Steffan Karger <steffan.karger@fox-it.com>
Acked-by: Antonio Quartulli <antonio@openvpn.net>
Message-Id: <1535544286-29638-1-git-send-email-steffan.karger@fox-it.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg17428.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
6 years agoClarify and expand management interface documentation
Jonathan K. Bullard [Wed, 8 Aug 2018 11:35:37 +0000 (11:35 +0000)] 
Clarify and expand management interface documentation

Clarify and expand the documentation for the management interface:

* Add examples of static and dynamic challenge/response sequences in
the "COMMAND -- password and username" section.

* Expand the "Challenge/Response" section with more detail.

* Use "management interface client" throughout (instead of "management
client", which was used in several places previously).

* Clarify when both a username and password are needed, not just a
username or a password.

* Clarify that an exit with a fatal error for a dynamic C/R will occur
only if "--auth-retry none" (the default) is in effect.

* Fix a typo. ("posesses" => "possesses").

Signed-off-by: Jonathan K. Bullard <jkbullard@gmail.com>
Acked-by: Selva Nair <selva.nair@gmail.com>
Message-Id: <nEV9l80I3peitTd26qmQFpeoaQbEO-IR74B1gOvCLv-IfvQKjNfL9UnZq1aWr20480nGcbkSnhA-mSGEI5kG7JBMsGpNbNf2FExV3CSzRf4=@protonmail.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg17390.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
6 years agoFix subnet topology on NetBSD.
Adam Ciarciński [Thu, 2 Aug 2018 14:17:56 +0000 (16:17 +0200)] 
Fix subnet topology on NetBSD.

Signed-off-by: Adam Ciarcin?ski <adam@netbsd.org>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <8110ED8B-4084-4D47-87E2-7B1C14041268@netbsd.org>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg17399.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
6 years agoIntroduce buffer_write_file()
Steffan Karger [Mon, 6 Aug 2018 08:02:33 +0000 (10:02 +0200)] 
Introduce buffer_write_file()

Rewrite buf_write_string_file to buffer_write_file, which is simpler to
use and can deal with not-null-terminated strings.  Mostly implemented so
this can be easily reused for tls-crypt-v2 (client) key files.

Signed-off-by: Steffan Karger <steffan.karger@fox-it.com>
Acked-by: Antonio Quartulli <antonio@openvpn.net>
Tested-by: Antonio Quartulli <antonio@openvpn.net>
Message-Id: <1533542553-7383-1-git-send-email-steffan.karger@fox-it.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg17371.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
6 years agoAccept empty password and/or response in auth-pam plugin
Selva Nair [Wed, 8 Aug 2018 02:44:31 +0000 (22:44 -0400)] 
Accept empty password and/or response in auth-pam plugin

In the auth-pam plugin correctly parse the static challenge string
even when password or challenge response is empty.

Whether an empty user input is an error is determined by the PAM
conversation function depending on whether the PAM module queries
for it or not.

Signed-off-by: Selva Nair <selva.nair@gmail.com>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <1533696271-21799-2-git-send-email-selva.nair@gmail.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg17382.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
6 years agoBump version of openvpn plugin argument structs to 5
Selva Nair [Wed, 8 Aug 2018 02:44:30 +0000 (22:44 -0400)] 
Bump version of openvpn plugin argument structs to 5

This was missed in commit 6690769f78bbfb889fef2a54088d979896c87d51
that exported base64_encode and base64_decode() functions.

Also check the version is >= 5 in auth-pam plugin to ensure
that the base64_decode function pointer can be referenced.

Signed-off-by: Selva Nair <selva.nair@gmail.com>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <1533696271-21799-1-git-send-email-selva.nair@gmail.com>
URL: https://www.mail-archive.com/search?l=mid&q=1533696271-21799-1-git-send-email-selva.nair@gmail.com
Signed-off-by: Gert Doering <gert@greenie.muc.de>
6 years agoParse static challenge response in auth-pam plugin
Selva Nair [Wed, 25 Jul 2018 02:34:53 +0000 (22:34 -0400)] 
Parse static challenge response in auth-pam plugin

If static challenge is in use, the password passed to the plugin by openvpn
is of the form "SCRV1:base64-pass:base64-response". Parse this string to
separate it into password and response and use them to respond to queries
in the pam conversation function.

On the plugin parameters line the substitution keyword for the static
challenge response is "OTP". For example, for pam config named "test" that
prompts for "user", "password" and "pin", use

plugin openvpn-auth-pam.so "test user USERNAME password PASSWORD pin OTP"

Signed-off-by: Selva Nair <selva.nair@gmail.com>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <1532486093-24793-1-git-send-email-selva.nair@gmail.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg17307.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
7 years agoplugin: Export base64 encode and decode functions
David Sommerseth [Fri, 5 May 2017 21:46:23 +0000 (23:46 +0200)] 
plugin: Export base64 encode and decode functions

This patch builds on the "Export secure_memzero() to plug-ins" patch and
adds export of openvpn_base64_encode() and openvpn_base64_decode()

This also ships with a very simple plug-in which demonstrates how to use
the new exported functions.

Signed-off-by: David Sommerseth <davids@openvpn.net>
Acked-by: Selva Nair <selva.nair@gmail.com>
Message-Id: <20170505214624.11675-1-davids@openvpn.net>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg14558.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
7 years agoResolves small IV_GUI_VER typo in the documentation.
James Bekkema [Mon, 23 Jul 2018 01:56:58 +0000 (11:56 +1000)] 
Resolves small IV_GUI_VER typo in the documentation.

Acked-by: Arne Schwabe <arne@rfc2549.org>
Message-Id: <429EB687-EB2D-4C67-B3EA-0A3BECA640B1@sparklabs.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg17288.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
7 years agoCorrect the declaration of handle in 'struct openvpn_plugin_args_open_return'
Selva Nair [Tue, 21 Nov 2017 01:43:25 +0000 (20:43 -0500)] 
Correct the declaration of handle in 'struct openvpn_plugin_args_open_return'

- This is an opaque pointer so the change should not affect
  existing plugins. But it makes the code consistent and clears up
  the documentation as the handle pointer is treated as of type
  "openvpn_plugin_handle_t" in the rest of the code.

Signed-off-by: Selva Nair <selva.nair@gmail.com>
Acked-by: Antonio Quartulli <antonio@openvpn.net>
Message-Id: <1511228605-23207-1-git-send-email-selva.nair@gmail.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg15908.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
7 years agomake tls-auth and tls-crypt per-connection-block options
Antonio Quartulli [Sat, 7 Jul 2018 09:04:21 +0000 (17:04 +0800)] 
make tls-auth and tls-crypt per-connection-block options

Different VPN servers may use different tls-auth/crypt keys.
For this reason it is convenient to make tls-auth/crypt
per-connection-block options so that the user is allowed to
specify one key per remote.

If no tls-auth/crypt option is specified in a given connection
block, the global settings, if any, are used.

Trac: #720
Cc: Steffan Karger <steffan@karger.me>
Signed-off-by: Antonio Quartulli <a@unstable.cc>
Acked-by: Steffan Karger <steffan.karger@fox-it.com>
Message-Id: <20180707090421.25953-2-a@unstable.cc>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg17226.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
7 years agocrypto: always reload tls-auth/crypt key contexts
Antonio Quartulli [Sun, 8 Jul 2018 02:45:17 +0000 (10:45 +0800)] 
crypto: always reload tls-auth/crypt key contexts

In preparation to having tls-auth/crypt keys per connection
block, it is important to ensure that such material is always
reloaded upon SIGUSR1, no matter if `persist-key` was specified
or not.

This is required because when moving from one remote to the
other the key may change and thus the key context needs to
be refreshed.

To ensure that the `persist-key` logic will still work
as expected, the tls-auth/crypt key is pre-loaded so that
the keyfile is not required at runtime.

Trac: #720
Cc: Steffan Karger <steffan@karger.me>
Signed-off-by: Antonio Quartulli <a@unstable.cc>
Acked-by: Steffan Karger <steffan.karger@fox-it.com>
Message-Id: <20180708024517.27108-1-a@unstable.cc>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg17237.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
7 years agoAdd crypto_pem_{encode,decode}()
Steffan Karger [Sun, 22 Jul 2018 10:06:45 +0000 (12:06 +0200)] 
Add crypto_pem_{encode,decode}()

Needed for tls-crypt-v2, but isolated enough to be reviewed as a separate
patch.

The encode API allocates memory, because it fits our typical gc-oriented
code pattern and the caller does not have to do multiple calls or
calculations to determine the required destination buffer size.

The decode API does not allocate memory, because the required destination
buffer is always smaller than the input buffer (so is easy to manage by
the caller) and does not force the caller to use the heap.

Signed-off-by: Steffan Karger <steffan.karger@fox-it.com>
Acked-by: Antonio Quartulli <antonio@openvpn.net>
Message-Id: <20180722100645.5813-1-steffan@karger.me>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg17284.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
7 years agoRemove unneeded newline in debug message in reliable.c
Gert van Dijk [Wed, 18 Jul 2018 14:27:53 +0000 (16:27 +0200)] 
Remove unneeded newline in debug message in reliable.c

Signed-off-by: Steffan Karger <steffan.karger@fox-it.com>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <1531924073-29243-4-git-send-email-steffan.karger@fox-it.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg17262.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
7 years agoMake second parameter to reliable_send_purge() const
Gert van Dijk [Wed, 18 Jul 2018 14:27:52 +0000 (16:27 +0200)] 
Make second parameter to reliable_send_purge() const

Signed-off-by: Steffan Karger <steffan.karger@fox-it.com>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <1531924073-29243-3-git-send-email-steffan.karger@fox-it.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg17261.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
7 years agoMinor reliability layer documentation fixes
Gert van Dijk [Wed, 18 Jul 2018 14:27:51 +0000 (16:27 +0200)] 
Minor reliability layer documentation fixes

Signed-off-by: Steffan Karger <steffan.karger@fox-it.com>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <1531924073-29243-2-git-send-email-steffan.karger@fox-it.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg17260.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
7 years agosocket: make stream_buf_* functions static
Antonio Quartulli [Thu, 12 Jul 2018 01:29:55 +0000 (09:29 +0800)] 
socket: make stream_buf_* functions static

stream_buf_init(), stream_buf_close() and stream_buf_added()
are only used within socket.c, therefore there is noneed to
have them declared in socket.h.

Make them static and remove useless declarations.
This change reuired adding function prototypes in socket.c to
avoid useless code re-ordering.

Signed-off-by: Antonio Quartulli <a@unstable.cc>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20180712012955.24050-1-a@unstable.cc>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg17246.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
7 years agoPrint lzo_init() return code in case of errors
Gert Doering [Fri, 13 Jul 2018 08:19:51 +0000 (10:19 +0200)] 
Print lzo_init() return code in case of errors

This can help pinpointing what exactly went wrong in case of
init failures (library version mismatch, memory issues, ...)

Signed-off-by: Gert Doering <gert@greenie.muc.de>
Acked-by: Arne Schwabe <arne@rfc2549.org>
Message-Id: <20180713081951.31174-1-gert@greenie.muc.de>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg17248.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
7 years agoMove execve/run_script helper functions to run_command.c
Steffan Karger [Wed, 4 Jul 2018 17:53:57 +0000 (19:53 +0200)] 
Move execve/run_script helper functions to run_command.c

To avoid having to include misc.c - which is a dependency mess - in the
tls-crypt unit tests, move the command execution helper functions to a new
run_command.c module.

While at it, abstract away the script_security global variable.

Signed-off-by: Steffan Karger <steffan.karger@fox-it.com>
Acked-by: Antonio Quartulli <antonio@openvpn.net>
Message-Id: <20180704175404.22371-2-steffan@karger.me>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg17212.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
7 years agoMove file-related functions from misc.c to platform.c
Steffan Karger [Wed, 4 Jul 2018 17:53:56 +0000 (19:53 +0200)] 
Move file-related functions from misc.c to platform.c

To avoid having to include misc.c - which is a dependency mess - in the
tls-crypt unit tests, move file-handing related functions to platform.c
(which is where other file-related functions already reside).

Note that platform_create_temp_file() needs random.  To avoid including
misc.c in other tests that use platform.c, add a mock get_random().

(Almost every test includes platform.c, because buffer.c depends on it.
That smells like it needs cleanup too, but not in this patch set.)

Signed-off-by: Steffan Karger <steffan.karger@fox-it.com>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20180704175404.22371-1-steffan@karger.me>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg17208.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
7 years agoAdd MTU to Android IFCONFIG6 control command
Arne Schwabe [Tue, 3 Jul 2018 16:17:51 +0000 (18:17 +0200)] 
Add MTU to Android IFCONFIG6 control command

Since OpenVPN nows supports IPv6 only connections, OpenVPN for Android
cannot longer rely on IFCONFIG to send the MTU. Add sending the MTU to
IFCONFIG6 too.
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20180703161751.7680-1-arne@rfc2549.org>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg17186.html

Signed-off-by: Gert Doering <gert@greenie.muc.de>
7 years agoExtend push-remove to also handle 'ifconfig'.
Gert Doering [Sun, 1 Jul 2018 19:59:38 +0000 (21:59 +0200)] 
Extend push-remove to also handle 'ifconfig'.

Push-remove (introduced in commit 970312f1850) did not handle "ifconfig"
yet, as both "ifconfig" and "ifconfig-ipv6" are handled differently from
all other pushed options.  Since there was no valid use-case to not-push
"ifconfig" (no support on the client side for running IPv6-only) this
was not an issue so far - but with the recent commits to enable ipv6-only
operation it can be a desirable feature.

The implementation is similar to "push-remove ifconfig-ipv6" - namely,
flagging via a new context option (c->options.push_ifconfig_ipv4_blocked)
and then not creating the push statement in "send_push_reply()".

While not truly elegant, it's much less invasive than the alternatives
(storing the list of "push-remove" statements somewhere and then checking
in push_option_ex())

Trac: #1072

Signed-off-by: Gert Doering <gert@greenie.muc.de>
Acked-by: Antonio Quartulli <antonio@openvpn.net>
Message-Id: <20180701195938.2541-1-gert@greenie.muc.de>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg17169.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
7 years agoopenssl: add missing #include statements
Steffan Karger [Sun, 26 Nov 2017 15:49:12 +0000 (16:49 +0100)] 
openssl: add missing #include statements

Compiling our current master against OpenSSL 1.1 with
-DOPENSSL_API_COMPAT=0x10100000L screams bloody murder.  This patch fixes
the errors caused by missing includes.  Previous openssl versions would
usually include 'the rest of the world', but they're fixing that.  So we
should no longer rely on it.

(And sneaking in alphabetic ordering of the includes while touching them.)

Signed-off-by: Steffan Karger <steffan@karger.me>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20171126154912.13283-1-steffan@karger.me>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg15936.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
7 years agoopenssl: don't use deprecated SSLEAY/SSLeay symbols
Steffan Karger [Sun, 26 Nov 2017 15:04:00 +0000 (16:04 +0100)] 
openssl: don't use deprecated SSLEAY/SSLeay symbols

Compiling our current master against OpenSSL 1.1 with
-DOPENSSL_API_COMPAT=0x10100000L screams bloody murder.  This patch fixes
the errors about the deprecated SSLEAY/SSLeay symbols and defines.

Signed-off-by: Steffan Karger <steffan@karger.me>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20171126150401.28565-1-steffan@karger.me>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg15934.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
7 years agoAdd %d, %u and %lu tests to test_argv unit tests.
Gert Doering [Sat, 23 Jun 2018 19:15:38 +0000 (21:15 +0200)] 
Add %d, %u and %lu tests to test_argv unit tests.

Some basic integer tests to verify signed, unsigned and
long unsigned (1L) printing.

Signed-off-by: Gert Doering <gert@greenie.muc.de>
Acked-by: Selva Nair <selva.nair@gmail.com>
Message-Id: <20180623191538.29317-1-gert@greenie.muc.de>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg17131.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
7 years agowindows: properly configure TAP driver when no IPv4 is configured
Antonio Quartulli [Sat, 23 Jun 2018 18:31:08 +0000 (02:31 +0800)] 
windows: properly configure TAP driver when no IPv4 is configured

This patch ensures that the TAP driver on a windows host is still
configured, even though no IPv4 has been provided.

In this case the TAP driver ioctl will be invoked with a fake
0.0.0.0/0.0.0.0 IPv4 which will simply start the interface and
get it to a working state.

Trac: #208
Signed-off-by: Antonio Quartulli <antonio@openvpn.net>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20180623183108.18684-1-a@unstable.cc>
URL: https://www.mail-archive.com/search?l=mid&q=20180623183108.18684-1-a@unstable.cc
Signed-off-by: Gert Doering <gert@greenie.muc.de>
7 years agoadd support for %lu in argv_printf and prevent ASSERT
Antonio Quartulli [Sat, 23 Jun 2018 02:11:47 +0000 (10:11 +0800)] 
add support for %lu in argv_printf and prevent ASSERT

%lu is not supported by our tiny argv_printf implementation, therefore
it will trigger an ASSERT() when parsing it at route.c:1638.

Add support for '%lu' in argv_print() and prevent the ASSERT from being
triggered.

Signed-off-by: Antonio Quartulli <a@unstable.cc>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20180623021147.22792-1-a@unstable.cc>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg17115.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
7 years agotravis-ci: cleanup, refactor, upgrade ssl libraries
Ilya Shipitsin [Sun, 27 May 2018 19:00:57 +0000 (00:00 +0500)] 
travis-ci: cleanup, refactor, upgrade ssl libraries

Both "compiler" and "exclude" are redundant, so remove them.
Add openssl-1.0.1u to build matrix. Enable explicit apt update
(it was disabled by default in travis-ci).

Signed-off-by: Ilya Shipitsin <chipitsine@gmail.com>
--
v2: Add openssl-1.0.1u to build matrix (thanks to Steffan Karger),
Add explicit apt-get update (it was disabled by default in travis-ci)
Acked-by: Steffan Karger <steffan.karger@fox-it.com>
Message-Id: <20180527190057.3488-1-chipitsine@gmail.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg16898.html

Signed-off-by: Gert Doering <gert@greenie.muc.de>
7 years agotun: ensure interface can be configured with IPv6 only
Antonio Quartulli [Mon, 18 Jun 2018 07:47:33 +0000 (15:47 +0800)] 
tun: ensure interface can be configured with IPv6 only

This change ensures that an interface is properly brought
up and down even when only IPv6 settings are configured/pushed.

At the same time, some code restyling took place to ensure the new
generic logic is easier to read. Both do_ifconfig() and close_tun()
(Linux only) functions have been rearranged by splitting the logic
into a v4 and a v6 specific part. Each part has then been moved
into an idependent helper that can be invoked as
needed.

This makes the code easier to read and more "symmetric" with
respect to the two address families.

Trac: #208
Signed-off-by: Antonio Quartulli <antonio@openvpn.net>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20180618074733.19773-1-a@unstable.cc>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg17064.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
7 years agotun: get rid of tt->did_ifconfig member
Antonio Quartulli [Wed, 13 Jun 2018 12:28:24 +0000 (20:28 +0800)] 
tun: get rid of tt->did_ifconfig member

tt->did_ifconfig is currently only read by the Linux platform, but
it is currently uselessly set also by every other system.

The Linux platform does not actually even need this member and can
directly rely on tt->did_ifconfig_setup.

For the reasons above, remove the tt->did_ifconfig at all and use
tt->did_ifconfig_setup where needed (close_tun() on Linux).

Signed-off-by: Antonio Quartulli <antonio@openvpn.net>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20180613122824.4207-4-a@unstable.cc>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg17046.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
7 years agotun: always pass a valid tt pointer
Antonio Quartulli [Wed, 13 Jun 2018 12:28:23 +0000 (20:28 +0800)] 
tun: always pass a valid tt pointer

This patch is a small "logic restyle" which basically moves the
check for "tt != NULL" outside of the various close_tun()
implementations and replaces it with an ASSERT.

This way the check is done only once and the function can rely
on the assumption that "tt" is always valid.

This change is mainly to improve the code style inside close_tun()
implementations by removing one level of indentation.

No functional change is present.

Signed-off-by: Antonio Quartulli <antonio@openvpn.net>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20180613122824.4207-3-a@unstable.cc>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg17045.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>