]> git.ipfire.org Git - thirdparty/openvpn.git/log
thirdparty/openvpn.git
5 years agoRemove key-method 1
Arne Schwabe [Tue, 21 Jul 2020 10:01:28 +0000 (12:01 +0200)] 
Remove key-method 1

Key-method 1 is only needed to talk to pre OpenVPN 2.0 clients.

Patch V2: Fix style. Make V1 op codes illegal, remove all code handling
          v1 op codes and give a good warning message if we encounter
          them in the legal op codes pre-check.

Patch V3: Add a bit more comments in the existing methods.

Signed-off-by: Arne Schwabe <arne@rfc2549.org>
Acked-by: David Sommerseth <davids@openvpn.net>
Message-Id: <20200721100128.9850-1-arne@rfc2549.org>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg20516.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
5 years agoRemove --client-cert-not-required
David Sommerseth [Mon, 20 Jul 2020 11:30:10 +0000 (13:30 +0200)] 
Remove --client-cert-not-required

This removes support for the --client-cert-not-required option.  To
avoid starting a server with this option just ignored, which would make
it impossible for existing clients to connect it will exit with
instructions to replace this option with --verify-client-cert none.

Signed-off-by: David Sommerseth <davids@openvpn.net>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20200720113010.10450-1-davids@openvpn.net>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg20502.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
5 years agoRemove --ifconfig-pool-linear
David Sommerseth [Mon, 20 Jul 2020 11:51:56 +0000 (13:51 +0200)] 
Remove --ifconfig-pool-linear

This option has been deprecated since OpenVPN 2.1 and it has been
highlighted in the documentation and log files since OpenVPN 2.4.4.

Signed-off-by: David Sommerseth <davids@openvpn.net>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20200720115156.13322-1-davids@openvpn.net>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg20504.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
5 years agoRequire AEAD support in the crypto library
Arne Schwabe [Mon, 20 Jul 2020 12:17:04 +0000 (14:17 +0200)] 
Require AEAD support in the crypto library

All supported crypto libraries have AEAD support and with our
ncp/de facto default cipher AES-256-GCM we do not want to support
the obscure corner case of a library with disabled AEAD.

Signed-off-by: Arne Schwabe <arne@rfc2549.org>
Patch V2: Remove three instances of (harmless) #ifdef Steffan spotted
          that can be removed now too.
Acked-by: Steffan Karger <steffan.karger@foxcrypto.com>
Message-Id: <20200720121704.20333-1-arne@rfc2549.org>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg20506.html

Signed-off-by: Gert Doering <gert@greenie.muc.de>
5 years agoDrop support for OpenSSL 1.0.1
Arne Schwabe [Fri, 17 Jul 2020 13:47:32 +0000 (15:47 +0200)] 
Drop support for OpenSSL 1.0.1

OpenSSL 1.0.1 was supported until 2016-12-31. Rhel6/Centos6 still
use this version but considering that RHEL7 and RHEL8 are already
out, these versions can also stay with OpenVPN 2.4.

All the supported Debian based distributions also come with at
least 1.0.2.

We (accidently) unconditionally compiled some key exporter code on
OpenSSL 1.0.2+ without problems. So always compile the whole
key exporter feature for OpenSSL.

This also allows the tls groups commit to be applied without
adding ifdefs to disable that functionality on OpenSSL 1.0.1

Signed-off-by: Arne Schwabe <arne@rfc2549.org>
Acked-by: Steffan Karger <steffan.karger@foxcrypto.com>
Message-Id: <20200717134739.21168-2-arne@rfc2549.org>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg20441.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
5 years agotravis: Fix make distcheck failure
David Sommerseth [Mon, 20 Jul 2020 10:38:22 +0000 (12:38 +0200)] 
travis: Fix make distcheck failure

Since commit f500c49c8e0, the man page and html documentation need to be
generated when building out of the git repository, as both openvpn.8 and
openvpn.8.html will be shipped pregenerated inside the tarball generated
by 'make dist'.

Travis was lacking the python-docutils package, which made the
'make distcheck' build test fail.

Signed-off-by: David Sommerseth <davids@openvpn.net>
Acked-by: Arne Schwabe <arne@rfc2549.org>
Message-Id: <20200720103822.26088-1-davids@openvpn.net>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg20497.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
5 years agoclient-connect: Implement deferred connect support for plugin API v2
Arne Schwabe [Sun, 19 Jul 2020 17:34:36 +0000 (19:34 +0200)] 
client-connect: Implement deferred connect support for plugin API v2

The V2 API is simpler than the V1 API since there is no passing of
data via files. This also means that with the current API the V2 API
cannot support async notify via files. Adding a file just for async
notify seems very hacky and when needed we should implement a better
option when async is needed for the plugin V2 API.

Signed-off-by: Arne Schwabe <arne@rfc2549.org>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20200719173436.16431-5-arne@rfc2549.org>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg20480.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
5 years agoSeparate handling of non-deferred return values for client-connect-scripts.
Gert Doering [Mon, 20 Jul 2020 07:08:02 +0000 (09:08 +0200)] 
Separate handling of non-deferred return values for client-connect-scripts.

(Only) on "CC_RET_SUCCESS", run multi_client_connect_post().

On "CC_RET_FAILURE", add missing log line, do not call ..._post().

Signed-off-by: Gert Doering <gert@greenie.muc.de>
Acked-by: Arne Schwabe <arne@rfc2549.org>
Message-Id: <20200720070802.18819-1-gert@greenie.muc.de>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg20488.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
5 years agoclient-connect: Add deferred support to the client-connect v1 plugin handler
Fabian Knittel [Sun, 19 Jul 2020 17:34:35 +0000 (19:34 +0200)] 
client-connect: Add deferred support to the client-connect v1 plugin handler

Uses the infrastructure provided and used in the previous patch to provide
deferral support to the v1 client-connect plugin handler as well.

Signed-off-by: Fabian Knittel <fabian.knittel@lettink.de>
PATCH V3: Modify the API to also (optionally) call the plugin on a deferred
call (CLIENT_CONNECT_DEFER).

This allows the plugin authors to be more flexible and make the V1 API more
similar to the CLIENT_CONNECT_V2 API.

Signed-off-by: Arne Schwabe <arne@rfc2549.org>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20200719173436.16431-4-arne@rfc2549.org>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg20483.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
5 years agoclient-connect: Use inotify for the deferred client-connect status file
Arne Schwabe [Sun, 19 Jul 2020 17:34:34 +0000 (19:34 +0200)] 
client-connect: Use inotify for the deferred client-connect status file

As we never do client-connect and authentication at the same time
it is safe to reuse the existing fields for client-connect return
status file

Signed-off-by: Arne Schwabe <arne@rfc2549.org>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20200719173436.16431-3-arne@rfc2549.org>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg20481.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
5 years agoclient-connect: Add deferred support to the client-connect script handler
Fabian Knittel [Sun, 19 Jul 2020 17:34:33 +0000 (19:34 +0200)] 
client-connect: Add deferred support to the client-connect script handler

This patch introduces the concept of a return value file for the
client-connect handlers (this is very similar to the auth value file
used during deferred authentication).  The file name is stored in the
client_connect_state struct.

In addition, the patch also moves the storage of the client config file
name into struct client_connect_state.

Both changes are used by the client-connect script handler to support
deferred client-connection handling.  The deferred return value file
(deferred_ret_file) is passed to the script via the environment.

If the script succeeds and writes the value for deferral (2) into the
deferred_ret_file, the handler knows to indicate deferral.  Later on,
the deferred handler checks whether the value of the deferred_ret_file
has been updated to success or failure.

Signed-off-by: Fabian Knittel <fabian.knittel@lettink.de>
Signed-off-by: Arne Schwabe <arne@rfc2549.org>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20200719173436.16431-2-arne@rfc2549.org>
URL: https://www.mail-archive.com/search?l=mid&q=20200719173436.16431-2-arne@rfc2549.org
Signed-off-by: Gert Doering <gert@greenie.muc.de>
5 years agoRemove CAS_PARTIAL state
Arne Schwabe [Sun, 19 Jul 2020 17:34:32 +0000 (19:34 +0200)] 
Remove CAS_PARTIAL state

This state is used to handle a corner case when multiple connect
handlers are active and one of them fails. Unfortunately, this state
complicates the state machine a bit without a good benefit.

Current behaviour:

First/all connect handler(s) fail:

  - client disconnect handler is not called at all

At least one connect handler succeeds but a subsequent handler fails:

  - client disconect is called when we actually
    disconnect the client (a few seconds later, max tls timeout)

All connect handlers suceed:

  - client disconect is called when we actually
    disconnect the client

This patches changes the behaviour in the second to immediately
call disconnect_handler in this case.

This simplifies the logic that already caused a bug and the
behaviour change is very little and affects only a pretty
exotic corner case.

Signed-off-by: Arne Schwabe <arne@rfc2549.org>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20200719173436.16431-1-arne@rfc2549.org>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg20482.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
5 years agodoc/man: Do not install man *.rst files
David Sommerseth [Sun, 19 Jul 2020 11:48:53 +0000 (13:48 +0200)] 
doc/man: Do not install man *.rst files

When the man page got split up into several .rst files, these files got
listed into dist_doc_DATA=.  This variable will both distribute (package
in the source tarball) and install these files into /usr/share/doc.
This was not intended, and it duplicates the content and makes the doc
dir quite messy.

By moving these files to dist_noinst_DATA= instead, these files are
still distributed but not installed via 'make install'.

Signed-off-by: David Sommerseth <davids@openvpn.net>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20200719114853.24168-1-davids@openvpn.net>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg20476.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
5 years agoRemove --no-iv
David Sommerseth [Fri, 17 Jul 2020 17:15:44 +0000 (19:15 +0200)] 
Remove --no-iv

This finializes the depreacation started in OpenVPN 2.4, where --no-iv
was made into a NOOP option.

Signed-off-by: David Sommerseth <davids@openvpn.net>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20200717171544.21632-1-davids@openvpn.net>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg20460.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
5 years agooptions: don't leak inline'd key material in logfile
Antonio Quartulli [Fri, 17 Jul 2020 21:28:20 +0000 (23:28 +0200)] 
options: don't leak inline'd key material in logfile

With the conversion of the introduction of a bool variable to signal
when a certain string is a filename or the actual (inline'd) key
material, the SHOW_STR() macro is now leaking the inline'd material to
the log file.

This happens because SHOW_STR will just print the content of the passed
argument without any check. With the new logic this should not happen
anymore.

A new macro SHOW_STR_INLINE() is therefore introduced which will check
the appropriate bool member before deciding to print the actual string
content or not.

Trac: #1304
Reported-by: Richard Bonhomme <tincanteksup@gmail.com>
Signed-off-by: Antonio Quartulli <a@unstable.cc>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20200717212820.8998-1-a@unstable.cc>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg20472.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
5 years agoMerge Makefile.am's AUTOMAKE_OPTIONS into configure.ac's AM_INIT_AUTOMAKE.
Matthias Andree [Fri, 17 Jul 2020 17:19:18 +0000 (19:19 +0200)] 
Merge Makefile.am's AUTOMAKE_OPTIONS into configure.ac's AM_INIT_AUTOMAKE.

Else one location overwrites options from the other.

Signed-off-by: Matthias Andree <matthias.andree@gmx.de>
Acked-by: David Sommerseth <davids@openvpn.net>
Message-Id: <20200717171918.230727-1-matthias.andree@gmx.de>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg20462.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
5 years agoclient-connect: Add CC_RET_DEFERRED and cope with deferred client-connect
Arne Schwabe [Thu, 16 Jul 2020 13:43:10 +0000 (15:43 +0200)] 
client-connect: Add CC_RET_DEFERRED and cope with deferred client-connect

This patch moves the state, that was previously tracked within the
multi_connection_established() function, into struct client_connect_state.
The multi_connection_established() function can now be exited and
re-entered as many times as necessary - without losing the client-connect
handling state.

The patch also adds the new return value CC_RET_DEFERRED which indicates
that the handler couldn't complete immediately, and needs to be called
later.  At that point multi_connection_established() will exit without
indicating completion.

Each client-connect handler now has an additional argument: "deferred",
to signal "additional call(s) while in deferred state".  The first call
to a handler always sets "deferred = false".  If that call returns
CC_RET_DEFERRED, the next call to the handler will be "deferred = true".

For some handlers (mda, ccd) this can never happen, so we ASSERT()
on !deferred.  If that ever triggers, something is wrong in our data
structures and we should better abort.

Signed-off-by: Fabian Knittel <fabian.knittel@lettink.de>
Patch V3: Use a static struct in multi_instance instead of using
          malloc/free and use two states (deferred with and without
          result) instead of one to eliminate the counter that was
          only tested for > 0.

Patch V5: Use new states in context_auth instead of the extra state
          that the patch series previously used.

Patch V6: Restructure code to make it a bit more readable, rebase on
          master.

Patch V7: move deferred bool into client connect handler calls, switch
          to switch case

Signed-off-by: Arne Schwabe <arne@rfc2549.org>
Acked-by: Antonio Quartulli <antonio@openvpn.net>
Message-Id: <20200716134315.17742-1-arne@rfc2549.org>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg20395.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
5 years agodoc/man: Add misssing renegotiation.rst to Makefile.am
David Sommerseth [Fri, 17 Jul 2020 11:01:36 +0000 (13:01 +0200)] 
doc/man: Add misssing renegotiation.rst to Makefile.am

This file did not get added to Makefile.am by a mistake during the
man-page overhaul, and the issue this causes is not easily spotted.

If a consumer of a tarball (created with 'make dist' from the git
tree) tries runs 'make clean' and 'make dist' plus have
python-docutils installed from such a tarball, it will explode and
complain about this missing file.

Signed-off-by: David Sommerseth <davids@openvpn.net>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20200717110136.11579-1-davids@openvpn.net>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg20431.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
5 years agodoc/man: Documentation for --bind-dev / VRFs on Linux
David Sommerseth [Fri, 17 Jul 2020 10:54:53 +0000 (12:54 +0200)] 
doc/man: Documentation for --bind-dev / VRFs on Linux

Signed-off-by: Maximilian Wilhelm <max@sdn.clinic>
Signed-off-by: David Sommerseth <davids@openvpn.net>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20200717105453.10718-1-davids@openvpn.net>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg20429.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
5 years agodoc/man: Update --txqueuelen default setting (Now OS default)
Richard Bonhomme [Thu, 16 Jul 2020 22:53:37 +0000 (00:53 +0200)] 
doc/man: Update --txqueuelen default setting (Now OS default)

Signed-off-by: Richard Bonhomme <tincanteksup@gmail.com>
Signed-off-by: David Sommerseth <davids@openvpn.net>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20200716225338.611-8-davids@openvpn.net>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg20415.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
5 years agodoc/man: Adopt compression documentation
David Sommerseth [Thu, 16 Jul 2020 22:53:36 +0000 (00:53 +0200)] 
doc/man: Adopt compression documentation

Commit c67e93b25208be2 updated the man page in reagrds to new
compression options and improving existing compression options.  This
adopts those changes into the .rst format.

Signed-off-by: David Sommerseth <davids@openvpn.net>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20200716225338.611-7-davids@openvpn.net>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg20414.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
5 years agodoc/man: Mark compression options as deprecated
David Sommerseth [Thu, 16 Jul 2020 22:53:35 +0000 (00:53 +0200)] 
doc/man: Mark compression options as deprecated

Due to the VORACLE attack vector, compression in general is deprecated.
Make this clear in the man page.

Also remove an incorrect statement claiming --compress lzo is compatible
with --comp-lzo.  It is not, as --compress lzo uses a different
compression framing than --comp-lzo.

Signed-off-by: David Sommerseth <davids@openvpn.net>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20200716225338.611-6-davids@openvpn.net>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg20417.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
5 years agodoc/man: convert openvpn.8 to split-up .rst files
David Sommerseth [Thu, 16 Jul 2020 22:53:31 +0000 (00:53 +0200)] 
doc/man: convert openvpn.8 to split-up .rst files

To avoid keeping around a full-size openvpn.rst file which is never
needed but will take space in the repo forever, patches 01...04
of the big documentation overhaul projects were squashed togehter,
keeping the individual commit logs and URL references below.

Signed-off-by: Gert Doering <gert@greenie.muc.de>
* This is a combination of 4 commits.
* This is the 1st commit message:

doc/man: Add an .rst formatted version of the man page

This is the first step to move away from a manually editing g/nroff
encoded man page.

Some modifications was needed to ensure formatting was consistent and
rendered reasonably okay in GitHub and that the generated man page
(using rst2man) is looking as a proper man page.  Unsupported options
has also been moved into its own section.  HTML rendering directly
using rst2html has also been used to validate the conversion.

The rst2man and rst2html utilities comes from the python-docutils
project: https://docutils.sourceforge.io/

Signed-off-by: David Sommerseth <davids@openvpn.net>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20200716225338.611-2-davids@openvpn.net>
URL: https://sourceforge.net/p/openvpn/mailman/message/37063370/
Signed-off-by: Gert Doering <gert@greenie.muc.de>
* This is the commit message #2:

doc/man: Replace old man page with generated man page

The doc/openvpn.8 and doc/openvpn.8.html files are now being removed
from the git tree, as it will be generated from the doc/openvpn.8.rst
file using python-docutils.

An additional dist-hook is added so these files are generated
automatically when source tarballs are generated for releases.  This
means users compiling directly from the source tarball will not need
python-docutils installed.

Signed-off-by: David Sommerseth <davids@openvpn.net>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20200716225338.611-3-davids@openvpn.net>
URL: https://sourceforge.net/p/openvpn/mailman/message/37063373/
Signed-off-by: Gert Doering <gert@greenie.muc.de>
* This is the commit message #3:

doc/man: Split up and reorganize main man page

The openvpn.8.rst file is quite long and hard to edit, as it covers
several hundred options.  Some options were even documented multiple
places.  The example has also received some attention, cleaning up
old and outdated infomration.

In this commit the main man page is split up into multiple sections
and options are sorted into each of the corresponding section.
Inside each category, each option is for now sorted alphabetically.
The main openvpn.8.rst file is currently kept unchanged and will be
handled in the next commit.

Many language improvements contributed by Richard Bonhomme has also
been incorproated.

Signed-off-by: David Sommerseth <davids@openvpn.net>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20200716225338.611-4-davids@openvpn.net>
URL: https://sourceforge.net/p/openvpn/mailman/message/37063376/
Signed-off-by: Gert Doering <gert@greenie.muc.de>
* This is the commit message #4:

doc/man: Complete openvpn.8.rst splitting

This rebuilds the openvpn.8.rst content by using the text which was
split out in the previous commit by using RST ..include statements.

Signed-off-by: David Sommerseth <davids@openvpn.net>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20200716225338.611-5-davids@openvpn.net>
URL: https://sourceforge.net/p/openvpn/mailman/message/37063377/
Signed-off-by: Gert Doering <gert@greenie.muc.de>
5 years agoAdd deferred authentication support to plugin-auth-pam
Gert Doering [Wed, 15 Jul 2020 09:01:05 +0000 (11:01 +0200)] 
Add deferred authentication support to plugin-auth-pam

If OpenVPN signals deferred authentication support (by setting
the internal environment variables "auth_control_file" and
"deferred_auth_pam"), do not wait for PAM stack to finish.  Instead,
the privileged PAM process returns RESPONSE_DEFER via the control
socket, which gets turned into OPENVPN_PLUGIN_FUNC_DEFERRED towards
openvpn.

The PAM process will then fork() and handle all the PAM auth in
the new process, signalling success/failure back by means of the
auth_control_file (forking twice, to simplify wait() handling).

With the extra fork(), multiple deferred authentications can run at
the same time - otherwise the first one would block the next auth
call (because the child would not be ready again to read from the
control socket).

Lightly tested on Linux.

Signed-off-by: Gert Doering <gert@greenie.muc.de>
--
v2:
  - only do deferred auth if "deferred_auth_pam" is set (env)
  - put deferred auth logic into do_deferred_pam_auth()
  - line-wrap lines where needed
  - close "background end" of socketpair in deferred auth process
  - remove leftover /* plugin_log() */ lines from initial testing
  - tested over a few hundred "15s delayed" authentication cycles

v3:
  - uncrustify new code
  - do not abort background process if do_deferred_pam_auth() fails
    (this can only happen if fork() fails, which is assumed to be
    temporary, or if something is wrong with the socketpair which we
    should notice on the next read()) --> change do_deferred_pam_auth()
    to "void"
  - add documentation to README.auth-pam and Changes.rst
Acked-by: Selva Nair <selva.nair@gmail.com>
Message-Id: <20200715090105.22296-1-gert@greenie.muc.de>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg20361.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
5 years agoreformat multi_client_generate_tls_keys according to uncrustify
Arne Schwabe [Wed, 15 Jul 2020 14:14:25 +0000 (16:14 +0200)] 
reformat multi_client_generate_tls_keys according to uncrustify

The refactor accidently used a wrong code style template and
ended up using 2 instead of 4 as indent.

Signed-off-by: Arne Schwabe <arne@rfc2549.org>
Acked-by: Antonio Quartulli <a@unstable.cc>
Message-Id: <20200715141425.26293-1-arne@rfc2549.org>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg20371.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
5 years agoclient-connect: Move adding inotify watch into its own function
Arne Schwabe [Sat, 11 Jul 2020 09:36:51 +0000 (11:36 +0200)] 
client-connect: Move adding inotify watch into its own function

This makes the code a more readable and also prepares reusing
the function for client-connect return files

Signed-off-by: Arne Schwabe <arne@rfc2549.org>
Acked-by: Antonio Quartulli <a@unstable.cc>
Message-Id: <20200711093655.23686-10-arne@rfc2549.org>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg20284.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
5 years agoclient-connect: Change cas_context from int to enum
Arne Schwabe [Sat, 11 Jul 2020 09:36:48 +0000 (11:36 +0200)] 
client-connect: Change cas_context from int to enum

This deviates from Fabian's original patch that relied on the now
removed connection_established bool as pointer being NULL or non NULL as
implicit third state and making connection_established as a substate of
(cas_context == CAS_PENDING)

Signed-off-by: Arne Schwabe <arne@rfc2549.org>
Patch V5: extend cas_context with two new states instead adding an
          extra mini state machine.

Signed-off-by: Arne Schwabe <arne@rfc2549.org>
Acked-by: Antonio Quartulli <a@unstable.cc>
Message-Id: <20200711093655.23686-7-arne@rfc2549.org>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg20292.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
5 years agoclient-connect: Refactor client-connect handling to calling a bunch of hooks in a...
Fabian Knittel [Sat, 11 Jul 2020 09:36:47 +0000 (11:36 +0200)] 
client-connect: Refactor client-connect handling to calling a bunch of hooks in a loop

This patch changes the calling of the client-connect functions into an
array of hooks and a block of code that calls them in a loop.

Signed-off-by: Fabian Knittel <fabian.knittel@lettink.de>
Signed-off-by: Arne Schwabe <arne@rfc2549.org>
Patch V5: Rebase on master.

Signed-off-by: Arne Schwabe <arne@rfc2549.org>
Acked-by: Antonio Quartulli <a@unstable.cc>
Message-Id: <20200711093655.23686-6-arne@rfc2549.org>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg20293.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
5 years agoclient-connect: Refactor to use return values instead of modifying a passed-in flag
Fabian Knittel [Sat, 11 Jul 2020 09:36:46 +0000 (11:36 +0200)] 
client-connect: Refactor to use return values instead of modifying a passed-in flag

This patch changes the way the client-connect helper functions communicate
with the main function.  Instead of updating cc_succeeded and cc_succeeded_count,
they now return either CC_RET_SUCCEEDED, CC_RET_FAILED or CC_RET_SKIPPED.

In addition, the client-connect helpers are now called in completely
identical ways.  This is in preparation of handling the helpers as simple
call-backs.

Signed-off-by: Fabian Knittel <fabian.knittel@lettink.de>
Patch V5: Minor style fixes

Signed-off-by: Arne Schwabe <arne@rfc2549.org>
Acked-by: Antonio Quartulli <a@unstable.cc>
Message-Id: <20200711093655.23686-5-arne@rfc2549.org>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg20286.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
5 years agoclient-connect: Move multi_client_connect_setenv into early_setup
Fabian Knittel [Sat, 11 Jul 2020 09:36:45 +0000 (11:36 +0200)] 
client-connect: Move multi_client_connect_setenv into early_setup

This patch moves multi_client_connect_setenv into
multi_client_connect_early_setup and makes sure that every client-connect
handling function updates the virtual address selection.

Background: This unifies how the client-connect handling functions work.

Signed-off-by: Fabian Knittel <fabian.knittel@lettink.de>
Signed-off-by: Arne Schwabe <arne@rfc2549.org>
Patch V5: Rebase on master

Signed-off-by: Arne Schwabe <arne@rfc2549.org>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20200711093655.23686-4-arne@rfc2549.org>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg20288.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
5 years agoclient-connect: Refactor multi_client_connect_source_ccd
Fabian Knittel [Sat, 11 Jul 2020 09:36:44 +0000 (11:36 +0200)] 
client-connect: Refactor multi_client_connect_source_ccd

Refactor multi_client_connect_source_ccd(), so that
options_server_import() (or the success path in general) is only
entered in one place within the function.

Signed-off-by: Fabian Knittel <fabian.knittel@lettink.de>
Patch V5: Simplify the logic even further to make it more easy to
understand.

Signed-off-by: Arne Schwabe <arne@rfc2549.org>
Acked-by: Antonio Quartulli <antonio@openvpn.net>
Message-Id: <20200711093655.23686-3-arne@rfc2549.org>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg20287.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
5 years agoAdded support for DHCP option 119 (dns search suffix list) for Windows.
Jan Just Keijser [Tue, 14 Jul 2020 09:39:10 +0000 (11:39 +0200)] 
Added support for DHCP option 119 (dns search suffix list) for Windows.

As of Windows 10 1809 Windows finally supports this so it makes sense
to add support to OpenVPN as well.

Multiple options can be specified at the same time, with one search
domain per line (in the config, or pushed from server):

  dhcp-option DOMAIN-SEARCH my.company.domain
  dhcp-option DOMAIN-SEARCH some.example.domain

OpenVPN will (on windows) concatenate them all together into a single
"option 119" for the tapv9 DHCP server.  Max length is 254 in total.

DNS label compression is not used - it's complicated, and Windows does
not need it.  See RFC 3397 for more details.

This only works with the tun/tap driver, not with wintun.

On non-windows platforms, these settings are exported in the environment
towards --up scripts (or to the management interface), and need to be
picked up there.

Signed-off-by: Jan Just Keijser <jan.just.keijser@gmail.com>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <c404dd17-e0db-ce61-0d79-864a5736f2d0@nikhef.nl>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg20349.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
5 years agoclient-connect: Split multi_connection_established into separate functions
Fabian Knittel [Sat, 11 Jul 2020 09:36:43 +0000 (11:36 +0200)] 
client-connect: Split multi_connection_established into separate functions

This patch splits up the multi_connection_established() function.  Each new
helper function does a specific job.  Functions that do a similar job
receive a similar calling interface.

The patch tries not to reindent code, so that the real changes are as
clearly visible as possible.  (A follow-up patch will only do indentation
changes.)

Signed-off-by: Fabian Knittel <fabian.knittel@lettink.de>
PATCH v3: Since the code has changed enough from the time the original
patch to the current master, the splitting has been redone from the
current code.  Also some style and minor code changes have been added
doing this patch.  This and the big reformatting done before eliminates
the follow up patch with only indentation changes.

The original patch already replaced some instances of
option_permission_mask with CLIENT_CONNECT_OPT_MASK. The V3 version does
this more consistently.

Patch v4: Move config -> mi->cc_config into its own commit

Patch v5: Clean up some minor issues, add one missing check on
temporary file deletion, rebase on latest master.

Signed-off-by: Arne Schwabe <arne@rfc2549.org>
Acked-by: Antonio Quartulli <antonio@openvpn.net>
Message-Id: <20200711093655.23686-2-arne@rfc2549.org>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg20289.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
5 years agoHandle connecting clients without NCP or OCC without crashing.
Gert Doering [Mon, 13 Jul 2020 09:32:52 +0000 (11:32 +0200)] 
Handle connecting clients without NCP or OCC without crashing.

ssl_ncp.c:ncp_get_best_cipher() would crash if a client connects without
NCP (or with a NCP cipher list that does not contain the first NCP cipher
in the server list) due to a NULL pointer strcmp().

Work around / fix by just assigning an empty string to remote_cipher here
("not NULL but will never match either").

Add new warning message in multi.c for the "we do not know what the
client can do" case (no NCP and non-helpful OCC), rewrapped the existing
message to keep line lenght limit.

Signed-off-by: Gert Doering <gert@greenie.muc.de>
Acked-by: Arne Schwabe <arne@rfc2549.org>
Message-Id: <20200713093252.30916-1-gert@greenie.muc.de>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg20309.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
5 years agoAllow changing fallback cipher from ccd files/client-connect
Arne Schwabe [Sat, 11 Jul 2020 09:36:42 +0000 (11:36 +0200)] 
Allow changing fallback cipher from ccd files/client-connect

This allows to control the fallback cipher that is used when the
client/server do have any common cipher on a per client basis.

The patch is similar to Steffan's

  [PATCH v4] Allow changing cipher from a ccd file.

Steffan's old patch also moves the cipher negotiation to
multi_established_connection() which I independently discovered and
implemented in commit 5e78bf66fa9 (Extract process_incoming_push_reply
from process_incoming_push_msg)

Signed-off-by: Arne Schwabe <arne@rfc2549.org>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20200711093655.23686-1-arne@rfc2549.org>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg20281.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
5 years agoCleanup: Remove special case code for old poor man's NCP.
Arne Schwabe [Thu, 9 Jul 2020 10:16:01 +0000 (12:16 +0200)] 
Cleanup: Remove special case code for old poor man's NCP.

Ever since the NCPv2 the ncp_get_best_cipher uses the global
options->ncp_enabled option and ignore the tls_session->ncp_enabled
option.

The server side's poor man's NCP is implemented as seeing the list
of supported ciphers from the peer as just one cipher so this special
handling for poor man's NCP of the older NCP here is not needed anymore.

Theoretically we can now get rid of tls_session->ncp_enabled but doing
so requires more refactoring since options is not available in the
methods that still use it. And when we remove ncp-disable the variable
will be removed anyway.

This commit moves the data channel key generation for the corner case of a
client not supporting NCP but having the same cipher as the server to
the same function that also generates data channel keys for NCP and
poort man's NCP.

This has an unintended side effect of changing the calculated frame
size for this special case. The old path did call
tls_session_update_crypto_params.
To avoid this change in behaviour, this patch adds a hacky
workaround for this.

A proper solution for this needs still be found but this allows the patch
set to be merged.

Document the remaining usage of tls_poor_mans_ncp better.

Signed-off-by: Arne Schwabe <arne@rfc2549.org>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20200709101603.11941-6-arne@rfc2549.org>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg20251.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
5 years agoGenerate data channel keys after connect options have been parsed
Arne Schwabe [Thu, 9 Jul 2020 10:16:00 +0000 (12:16 +0200)] 
Generate data channel keys after connect options have been parsed

The simplify the control flow, it makes more sense to generate the
data keys when all the prerequisites for generating the data channel
keys (ncp cipher selection etc) are met instead of delaying it to the
next incoming PUSH_REQUEST message.

This also eliminates the need for the hack introduced by commit
3b06b57d9 to generate the data channel keys on the async file close
event.

Signed-off-by: Arne Schwabe <arne@rfc2549.org>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20200709101603.11941-5-arne@rfc2549.org>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg20253.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
5 years agoMove protocol option negotiation from push_prepare to new function
Arne Schwabe [Thu, 9 Jul 2020 10:15:59 +0000 (12:15 +0200)] 
Move protocol option negotiation from push_prepare to new function

This clean ups the code and removes the surprising side effects
of preparing a push reply to also select protocol options.

We also remember if we have seen a push request without async
push. This improves reaction time if deferred auth is involved
like managment interface deferred auth.  The other benefit is
removing a number of ifdefs.

NOTE: this patch breaks asynchronous authentication (via plugins
and possibly also via management interface).  The next commit will
fix this.  This is understood and hereby documented, but the two
individual commits are much cleaner without trying to fix it here
or squash both together.

Signed-off-by: Arne Schwabe <arne@rfc2549.org>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20200709101603.11941-4-arne@rfc2549.org>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg20255.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
5 years agoCode cleanup: remove superflous variable
Arne Schwabe [Thu, 9 Jul 2020 10:16:03 +0000 (12:16 +0200)] 
Code cleanup: remove superflous variable

Signed-off-by: Arne Schwabe <arne@rfc2549.org>
Acked-by: Antonio Quartulli <antonio@openvpn.net>
Message-Id: <20200709101603.11941-8-arne@rfc2549.org>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg20252.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
5 years agoRemoved unused definition
Arne Schwabe [Thu, 9 Jul 2020 10:16:02 +0000 (12:16 +0200)] 
Removed unused definition

Signed-off-by: Arne Schwabe <arne@rfc2549.org>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20200709101603.11941-7-arne@rfc2549.org>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg20256.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
5 years agoExtract process_incoming_push_reply from process_incoming_push_msg
Arne Schwabe [Thu, 9 Jul 2020 10:15:58 +0000 (12:15 +0200)] 
Extract process_incoming_push_reply from process_incoming_push_msg

This is a small refactoring to make both function more readable. It also
eliminates the ret variable in process_incoming_push_msg that now serves
no purpose anymore.

Signed-off-by: Arne Schwabe <arne@rfc2549.org>
Acked-by: Antonio Quartulli <antonio@openvpn.net>
Message-Id: <20200709101603.11941-3-arne@rfc2549.org>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg20254.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
5 years agoMake key_state->authenticated more state machine like
Arne Schwabe [Thu, 9 Jul 2020 10:15:57 +0000 (12:15 +0200)] 
Make key_state->authenticated more state machine like

This order the states from unauthenticated to authenticated and also
changes the comparison for KS_AUTH_FALSE from != to >

It also add comments and documents part using the state machine
better.

Remove a now obsolete comment and two obsolete ifdefs. While
keeping the ifdef in ssl_verify would save a few bytes of code,
this is too minor to justify keeping the ifdef

Signed-off-by: Arne Schwabe <arne@rfc2549.org>
Acked-by: Antonio Quartulli <antonio@openvpn.net>
Message-Id: <20200709101603.11941-2-arne@rfc2549.org>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg20258.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
5 years agoDeprecate ncp-disable and add improved ncp to Changes.rst
Arne Schwabe [Thu, 9 Jul 2020 10:15:56 +0000 (12:15 +0200)] 
Deprecate ncp-disable and add improved ncp to Changes.rst

Signed-off-by: Arne Schwabe <arne@rfc2549.org>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20200709101603.11941-1-arne@rfc2549.org>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg20257.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
5 years agoMake openvpn --version exit with exit code 0
Steffan Karger [Tue, 7 Jul 2020 14:26:21 +0000 (16:26 +0200)] 
Make openvpn --version exit with exit code 0

For some reason, openvpn --version has since the beginning of time
returned exit code 1. A quick sample among common unix utilities confirms
that the rest of the world agrees with me that 0 makes more sense. Let's
make openvpn --version exit with exit code 0 too.

Signed-off-by: Steffan Karger <steffan.karger@foxcrypto.com>
Acked-by: Antonio Quartulli <antonio@openvpn.net>
Message-Id: <E1jsoYQ-0007AZ-BF@sfs-ml-1.v29.lw.sourceforge.com>
URL: https://www.mail-archive.com/search?l=mid&q=E1jsoYQ-0007AZ-BF@sfs-ml-1.v29.lw.sourceforge.com
Signed-off-by: Gert Doering <gert@greenie.muc.de>
5 years agoSimplify multi_connection_established.
Arne Schwabe [Tue, 7 Jul 2020 12:16:13 +0000 (14:16 +0200)] 
Simplify multi_connection_established.

Instead of having the whole function as

        if (x) { func }

do

        if (!x) return;
        func

Due to the whitespace changes in the function body this patch looks
very strange. Ignoring whitespace makes the diff look sane.

Signed-off-by: Arne Schwabe <arne@rfc2549.org>
Acked-by: Antonio Quartulli <antonio@openvpn.net>
Message-Id: <20200707121615.15736-3-arne@rfc2549.org>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg20231.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
5 years agoRemove --writepid file on program exit.
Gert Doering [Tue, 7 Jul 2020 08:42:20 +0000 (10:42 +0200)] 
Remove --writepid file on program exit.

For whatever reason, we never removed the pid file on program exit.

Not only this is unclean, but it also makes testing for "I want this
test case to FAIL" in t_client.sh more annoying to code for "is the
OpenVPN process still around?"...

Do not unlink the file if chroot() is active (might be outside the
chroot arena - testing for realpath etc. is left for someone else).

v2: make this work on M_FATAL exit, by unlinking from openvpn_exit() in
error.h - this requires moving write_pid() to init.c so module hierarchy
is maintained and introducing a static variable to save the PID file
name (otherwise it is no longer available when the top level GC is gone).

Signed-off-by: Gert Doering <gert@greenie.muc.de>
Acked-by: Antonio Quartulli <antonio@openvpn.net>
Message-Id: <20200707084220.45753-1-gert@greenie.muc.de>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg20224.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
5 years agomerge key_state->authenticated and key_state->auth_deferred
Arne Schwabe [Mon, 6 Jul 2020 16:35:16 +0000 (18:35 +0200)] 
merge key_state->authenticated and key_state->auth_deferred

Both are tightly coupled often both are checked at the same time.
Merging them into one state makes the code simpler and also brings
us closer in the direction of a state machine

Signed-off-by: Arne Schwabe <arne@rfc2549.org>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20200706163516.11390-2-arne@rfc2549.org>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg20216.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
5 years agoUnified success messages for setting mtu
Christopher Schenk [Tue, 30 Jun 2020 09:54:44 +0000 (11:54 +0200)] 
Unified success messages for setting mtu

that makes sense. I updated the patch.

Christopher
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20200630095443.7188-1-cschenk@mail.uni-paderborn.de>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg20171.html

Signed-off-by: Gert Doering <gert@greenie.muc.de>
5 years agotap.c: fix adapter renaming
Lev Stipakov [Fri, 3 Jul 2020 19:20:29 +0000 (22:20 +0300)] 
tap.c: fix adapter renaming

Turns out that renaming adapter by setting registry key doesn't
really work - while new adapter name is shown in control panel
etc, when one tries to change adapter properties (like set DNS)
with netsh call - it fails:

Fri Mar 13 09:05:36 2020 us=569311 Setting IPv4 dns servers
on 'OpenVPN Wintun' (if_index = 14) using service
Fri Mar 13 09:05:37 2020 us=118028 TUN: adding IPv4 dns failed
using service: Funktio ei kelpaa.   [status=1 if_name=OpenVPN Wintun]

This renames adapter with netsh command, like:

    netsh interface set interface
          name="Local Area Connection 2" newname="OpenVPN Wintun"

Above functionality is used by tapctl.exe and openvpnsica.dll
(during installation).

Signed-off-by: Lev Stipakov <lev@openvpn.net>
Acked-by: Simon Rozman <simon@rozman.si>
Message-Id: <20200703192029.306-1-lstipakov@gmail.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg20207.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
5 years agot_client.sh: correctly report all failed instances in summary
Gert Doering [Fri, 26 Jun 2020 08:27:43 +0000 (10:27 +0200)] 
t_client.sh: correctly report all failed instances in summary

t_client.sh reports a summary at the end:

  Test sets succeeded: none.
  Test sets failed: 1 2 3 4 5.

for tests that are skipped due to the pre-test ping check ("vpn target
IP must not ping before VPN ist started") the script forgot to add
the instance number to the summary line.  Fixed.

Signed-off-by: Gert Doering <gert@greenie.muc.de>
Acked-by: Antonio Quartulli <antonio@openvpn.net>
Message-Id: <20200626082743.15397-1-gert@greenie.muc.de>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg20130.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
5 years agoRemove did_open_context, defined and connection_established_flag
Arne Schwabe [Fri, 3 Jul 2020 09:55:06 +0000 (11:55 +0200)] 
Remove did_open_context, defined and connection_established_flag

multi_instance->defined is not used anywhere.

did_open_context is always set to true when a context is created in
multi_create_instance, so checking it for true is always true.

context_auth is also always set to CAS_PENDING in multi_create_instance.

connection_established_flag is only set to true if context_auth
is changed from CAS_PENDING to one another state, so we can also check
for cas_context != CAS_PENDING.

Signed-off-by: Arne Schwabe <arne@rfc2549.org>
Acked-by: Antonio Quartulli <antonio@openvpn.net>
Message-Id: <20200703095506.28559-1-arne@rfc2549.org>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg20200.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
5 years agoRemove push_reply_deferred variable
Arne Schwabe [Thu, 2 Jul 2020 12:52:24 +0000 (14:52 +0200)] 
Remove push_reply_deferred variable

The variable has no useful function (anymore?).

There is only one place where this variable was checked

    else if (!c->c2.push_reply_deferred && c->c2.context_auth ==
CAS_SUCCEEDED)

This condition also depends on context_auth == CAS_SUCCEEDED but the only
code path that sets context_auth = CAS_SUCCEEDED also sets
push_reply_deferred = false;

Signed-off-by: Arne Schwabe <arne@rfc2549.org>
Acked-by: Lev Stipakov <lstipakov@gmail.com>
Message-Id: <20200702125224.13516-1-arne@rfc2549.org>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg20186.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
5 years agoFix 'engine' unit test on FreeBSD (specifically 'not GNU make')
Gert Doering [Mon, 29 Jun 2020 17:51:09 +0000 (19:51 +0200)] 
Fix 'engine' unit test on FreeBSD (specifically 'not GNU make')

The rules to generate $(builddir)/openssl.cnf from $(srcdir)/openssl.cnf.in
only worked for GNU Make.  BSD make needs the rules more explicit, and
the target must not have a directory specification (fixes commit
542c69c37).

Signed-off-by: Gert Doering <gert@greenie.muc.de>
Acked-by: James Bottomley <James.Bottomley@HansenPartnership.com>
Message-Id: <20200629175109.94276-1-gert@greenie.muc.de>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg20159.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
5 years agomulti.c: use mi->cc_config instead of config variable
Antonio Quartulli [Wed, 1 Jul 2020 14:05:17 +0000 (16:05 +0200)] 
multi.c: use mi->cc_config instead of config variable

Commit ("Remove parameter config from multi_client_connect_mda") has
removed the config variable in favour of mi->cc_config, however one
occurence was not changed.

Fix it now by properly using mi->cc_config.

Signed-off-by: Antonio Quartulli <a@unstable.cc>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20200701140517.11176-1-a@unstable.cc>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg20180.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
5 years agoRemove parameter config from multi_client_connect_mda
Arne Schwabe [Wed, 1 Jul 2020 12:22:39 +0000 (14:22 +0200)] 
Remove parameter config from multi_client_connect_mda

config is always used as mi->cc_config and we pass mi,
so directly use mi->cc_config

Signed-off-by: Arne Schwabe <arne@rfc2549.org>
Acked-by: Antonio Quartulli <antonio@openvpn.net>
Message-Id: <20200701122239.6924-1-arne@rfc2549.org>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg20177.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
5 years agoLog a note if someone wants to set a MTU below 1280 on IPv6
Christopher Schenk [Mon, 29 Jun 2020 19:09:30 +0000 (21:09 +0200)] 
Log a note if someone wants to set a MTU below 1280 on IPv6

Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20200629190930.1360-2-cschenk@mail.uni-paderborn.de>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg20161.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
5 years agoLinux: do not change --txqueuelen OS default if not configured.
Gert Doering [Mon, 29 Jun 2020 18:04:05 +0000 (20:04 +0200)] 
Linux: do not change --txqueuelen OS default if not configured.

Remove default setting of "set txqueuelen to 100".  This default dates
back to the "pre git" times (before 2005) and might have been beneficial
back then - nowadays, the Linux default is 500, and thus reducing(!)
txqueuelen by-default can cause TX packet drops on the tun interface,
and that's bad for throughput.

This is a similar change to commit f0b64e5dc (remove setting of the
socket send/receive buffers by default) - similar vintage of the
existing code, similar motivation.

Note: buffer length can be checked with "ip link show" (qlen NNN)

See also:
  https://ivanvari.com/solving-openvpn-poor-throughput-and-packet-loss/

Signed-off-by: Gert Doering <gert@greenie.muc.de>
Acked-by: Arne Schwabe <arne@rfc2549.org>
Message-Id: <20200629180405.17671-1-gert@greenie.muc.de>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg20160.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
5 years agoAdd --bind-dev option.
Maximilian Wilhelm [Mon, 29 Jun 2020 10:49:07 +0000 (12:49 +0200)] 
Add --bind-dev option.

This options allows the user to specify a network interface or VRF
device the OpenVPN process should use when making a connection or
binding to an address.

This is done by setting the SO_BINDTODEVICE option to the corresponding
socket (on Linux).  SO_BINDTODEVICE forces all packets sent on that socket
to go out via the specified interface, and only packets coming in on
that interface are received by OpenVPN.

When used in a VRF context on Linux [0], you can also specify the name
of the VRF ("--bind-dev external_vrf"), which will put the OpenVPN
"network side" into this VRF.  This allows making connections using a
non-default VRF and having the tun/tap interface in the default VRF.

Thanks to David Ahern (Cumulus Networks) for insights on this.

[0] https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/Documentation/networking/vrf.txt

Signed-off-by: Maximilian Wilhelm <max@sdn.clinic>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <1593427748-29801-2-git-send-email-max@rfc2324.org>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg20156.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
5 years agoAdd c1ff8f247f91c88a2df5502eeedf42857f9a6831 (engine, pool, SSO) to .git-blame-ignore...
Gert Doering [Fri, 26 Jun 2020 13:03:20 +0000 (15:03 +0200)] 
Add c1ff8f247f91c88a2df5502eeedf42857f9a6831 (engine, pool, SSO) to .git-blame-ignore-revs

Signed-off-by: Gert Doering <gert@greenie.muc.de>
5 years agoReformat files using uncrustify
Arne Schwabe [Fri, 26 Jun 2020 12:53:32 +0000 (14:53 +0200)] 
Reformat files using uncrustify

Some of the commits, especially engine have not strictly used uncrustify
clean code. Rerun uncrustify to make them compliant again.
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20200626125332.15385-1-arne@rfc2549.org>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg20142.html

Signed-off-by: Gert Doering <gert@greenie.muc.de>
5 years agoMake compression asymmetric by default and add warnings
Arne Schwabe [Fri, 26 Jun 2020 11:05:54 +0000 (13:05 +0200)] 
Make compression asymmetric by default and add warnings

This commit introduces the allow-compression option that allow
changing the new default to the previous default or to a stricter
version.

Warning for comp-lzo/compress are not generated in the post option check
(options_postprocess_mutate) since these warnings should also be shown
on pushed options. Moving the showing the warning showing for
allow-compression to options_postprocess_mutate will complicate the
option handling without giving any other benefit.

Patch V2: fix spelling and grammer (thanks tincantech), also fix
   uncompressiable to incompressible in three other instances in the
   source code

Patch V3: fix overlong lines. Do not allow compression to be pushed

Patch V4: rename COMP_F_NO_ASYM to COMP_F_ALLOW_COMPRESS, fix style.
          The logic of warnings etc in options.c has not been changed
          since adding all the code to mutate_options would a lot more
          and more complicated code and after discussion we decided that
          it is okay as is.

Patch V5: Reword warnings, rebase on master

Signed-off-by: Arne Schwabe <arne@rfc2549.org>
Acked-by: Lev Stipakov <lstipakov@gmail.com>
Message-Id: <20200626110554.3690-1-arne@rfc2549.org>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg20138.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
5 years agomsvc: fix various level2 warnings
Lev Stipakov [Fri, 26 Jun 2020 10:10:50 +0000 (13:10 +0300)] 
msvc: fix various level2 warnings

Also set warnings level to level2 and
enable "treat warnings as errors" flag.

Signed-off-by: Lev Stipakov <lev@openvpn.net>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20200626101050.442-1-lstipakov@gmail.com>
URL: https://www.mail-archive.com/search?l=mid&q=20200626101050.442-1-lstipakov@gmail.com
Signed-off-by: Gert Doering <gert@greenie.muc.de>
5 years agoengine-key tests: make check_engine_keys.sh work with --enable-small
James Bottomley [Tue, 23 Jun 2020 23:02:34 +0000 (16:02 -0700)] 
engine-key tests: make check_engine_keys.sh work with --enable-small

--enable-small eliminates one of the openssl errors the test is
looking for, so alter the grep also to account for the message in this
version.  Additionally output log.txt on failure so any test platform
gives an easy clue about what went wrong.

Signed-off-by: James Bottomley <James.Bottomley@HansenPartnership.com>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <1592953354.2103.3.camel@HansenPartnership.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg20102.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
5 years agoFix make distcheck for new engine key unit test
James Bottomley [Tue, 23 Jun 2020 13:05:31 +0000 (06:05 -0700)] 
Fix make distcheck for new engine key unit test

Add config precursor and script to extra dist and make sure
built and test leftover files are cleaned up afterwards.

Signed-off-by: James Bottomley <James.Bottomley@HansenPartnership.com>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <1592917531.4768.4.camel@HansenPartnership.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg20088.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
5 years agoAdd unit tests for engine keys
James Bottomley [Mon, 22 Jun 2020 23:23:19 +0000 (16:23 -0700)] 
Add unit tests for engine keys

Testing engines is problematic, so one of the prerequisites built for
the tests is a simple openssl engine that reads a non-standard PEM
guarded key.  The test is simply can we run a client/server
configuration with the usual sample key replaced by an engine key.
The trivial engine prints out some operations and we check for these
in the log to make sure the engine was used to load the key and that
it correctly got the password.

Signed-off-by: James Bottomley <James.Bottomley@HansenPartnership.com>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20200622232319.8143-2-James.Bottomley@HansenPartnership.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg20075.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
5 years agoConvert plugin/auth-pam.c from stderr logging to plugin_log().
Gert Doering [Sat, 20 Jun 2020 14:39:40 +0000 (16:39 +0200)] 
Convert plugin/auth-pam.c from stderr logging to plugin_log().

More recent OpenVPN APIs pass a function pointer for a logging function
(plugin_log()) to plugins.  Using this will make the plugin logs appear
wherever openvpn logs to - file, syslog, stderr.

This patch converts plugin/auth-pam.c "fairly mechanically" to use this
new API.  Real errors are logged with PLOG_ERR or PLOG_ERR|PLOG_ERRNO,
while debug info is logged with PLOG_NOTE (subject to the already-existing
debug level handling inside plugin/auth-pam, via "setenv verb <n>").

Signed-off-by: Gert Doering <gert@greenie.muc.de>
Acked-by: Selva Nair <selva.nair@gmail.com>
Message-Id: <20200620143940.11704-1-gert@greenie.muc.de>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg20037.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
5 years agoAdd unit test for cipher name translations
Arne Schwabe [Fri, 5 Jun 2020 11:25:19 +0000 (13:25 +0200)] 
Add unit test for cipher name translations

The unit test duplicates some part of the test for
the ncp-cipher list but that is not a bad thing.

Signed-off-by: Arne Schwabe <arne@rfc2549.org>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20200605112519.22714-3-arne@rfc2549.org>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg19968.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
5 years agoDepreciation warning for --topology net30 on servers with IPv4 pools.
Gert Doering [Sat, 20 Jun 2020 18:05:32 +0000 (20:05 +0200)] 
Depreciation warning for --topology net30 on servers with IPv4 pools.

IPv4 pool handling needs lots of extra code to deal with "topology net30",
so we want to remove that combination in a future release.

Warn people about this in 2.5 so nobody is hit by this as a surprise.

Client- and ifconfig-support for net30 will stay, as "just net30" is not
what brings maintenance effort here (totally removing all options except
"topology subnet" would be beneficial but is a bit too radical today)

Trac: #1288

Signed-off-by: Gert Doering <gert@greenie.muc.de>
Acked-by: Arne Schwabe <arne@rfc2549.org>
Message-Id: <20200620180532.15738-1-gert@greenie.muc.de>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg20041.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
5 years agoChange timestamps in file-based logging to ISO 8601 time format.
Gert Doering [Sat, 20 Jun 2020 17:23:03 +0000 (19:23 +0200)] 
Change timestamps in file-based logging to ISO 8601 time format.

Replace existing ctime() output which is hard to sort and compare
with ISO 8601 / RFC 3399 "YYYY-MM-DD hh:mm:dd" format for file-based
logging (stderr or --log file).

RFC 3399 5.6 permits use of a space for full-date-full-time separation,
which is used to enhance readability.

Sylog or --machine-readable-output are not affected.

Trac: #719

Signed-off-by: Gert Doering <gert@greenie.muc.de>
Acked-by: Arne Schwabe <arne@rfc2549.org>
Message-Id: <20200620172303.15010-1-gert@greenie.muc.de>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg20040.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
5 years agoImplement forwarding client CR_RESPONSE messages to management
Arne Schwabe [Tue, 19 May 2020 22:00:04 +0000 (00:00 +0200)] 
Implement forwarding client CR_RESPONSE messages to management

When signalling the client that it should do Challenge response
without reconnecting (IV_SSO=crtext/INFOPRE=CR_TEXT), the server
needs forward the response via the management console.

Signed-off-by: Arne Schwabe <arne@rfc2549.org>
Acked-by: David Sommerseth <davids@openvpn.net>
Message-Id: <20200519220004.25136-6-arne@rfc2549.org>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg19910.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
5 years agoImplement sending AUTH_PENDING challenges to clients
Arne Schwabe [Tue, 19 May 2020 22:00:03 +0000 (00:00 +0200)] 
Implement sending AUTH_PENDING challenges to clients

This implements sending AUTH_PENDING and INFO_PRE messages to clients
that indicate that the clients should be continue authentication with
a second factor. This can currently be out of band (openurl) or a normal
challenge/response two like TOTP (CR_TEXT).

Unfortunately this patch spend so much time in review in openvpn2 that
the corosponding IV_SSO commit in openvpn3 (34a3f264) already made its
way to released products so changing this right now is difficult.

https://github.com/OpenVPN/openvpn3/commit/34a3f264f56bd050d9b26d2e7163f88a
f9a559e2

Signed-off-by: Arne Schwabe <arne@rfc2549.org>
Acked-by: David Sommerseth <davids@openvpn.net>
Message-Id: <20200519220004.25136-5-arne@rfc2549.org>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg19909.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
5 years agoImplement sending response to challenge via CR_RESPONSE
Arne Schwabe [Tue, 19 May 2020 22:00:02 +0000 (00:00 +0200)] 
Implement sending response to challenge via CR_RESPONSE

When a client announces its support to support text based
challenge/response via IV_SSO=crtext,the client needs to also
be able to reply to that response.

This adds the "cr-response" management function to be able to
do this. The answer should be base64 encoded.

Signed-off-by: Arne Schwabe <arne@rfc2549.org>
Acked-by: David Sommerseth <davids@openvpn.net>
Message-Id: <20200519220004.25136-4-arne@rfc2549.org>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg19907.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
5 years agoImplement support for signalling IV_SSO to server
Arne Schwabe [Tue, 19 May 2020 22:00:01 +0000 (00:00 +0200)] 
Implement support for signalling IV_SSO to server

Signed-off-by: Arne Schwabe <arne@rfc2549.org>
Acked-by: David Sommerseth <davids@openvpn.net>
Message-Id: <20200519220004.25136-3-arne@rfc2549.org>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg19908.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
5 years agoImplement parsing and sending INFO and INFO_PRE control messages
Arne Schwabe [Tue, 19 May 2020 22:00:00 +0000 (00:00 +0200)] 
Implement parsing and sending INFO and INFO_PRE control messages

OpenVPN 3 implements these messages to send information during the
authentication to the UI, implement these message also in OpenVPN 2.x

Signed-off-by: Arne Schwabe <arne@rfc2549.org>
Acked-by: David Sommerseth <davids@openvpn.net>
Message-Id: <20200519220004.25136-2-arne@rfc2549.org>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg19912.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
5 years agoMake cipher_kt_get also accept OpenVPN config cipher name
Arne Schwabe [Fri, 5 Jun 2020 11:25:18 +0000 (13:25 +0200)] 
Make cipher_kt_get also accept OpenVPN config cipher name

Basically calls to cipher_kt_get were calling
translate_cipher_name_from_openvpn. The only two exception were the
(broken) unit test and tls-crypt that uses cipher_kt_get("AES-256-CTR")

Signed-off-by: Arne Schwabe <arne@rfc2549.org>
Acked-by: Steffan Karger <steffan@karger.me>
Message-Id: <20200605112519.22714-2-arne@rfc2549.org>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg19969.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
5 years agoMake cipher_kt_name always return normalised cipher name
Arne Schwabe [Fri, 5 Jun 2020 11:25:17 +0000 (13:25 +0200)] 
Make cipher_kt_name always return normalised cipher name

The mbed TLS variant of the call already returned the normalised
name while the OpenSSL variant did not. On top of that, all calls but
one to cipher_kt_name were translate_cipher_name_to_openvpn. This commit
moves the call of translate_cipher_name_to_openvpn into cipher_kt_name
or avoids calling it twice in the case of mbed TLS.

The one case that did not translate_cipher_name_to_openvpn is an
internal ssl_openssl.c method that should call EVP_CIPHER_name anyway.

Also simplify cipher_name_cmp function that is only used by
openvpn --show-ciphers with the modified cipher_kt_name
function.

Signed-off-by: Arne Schwabe <arne@rfc2549.org>
Acked-by: Steffan Karger <steffan@karger.me>
Message-Id: <20200605112519.22714-1-arne@rfc2549.org>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg19970.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
5 years agoSet the correct mtu on windows based systems
Christopher Schenk [Tue, 21 Apr 2020 15:46:12 +0000 (17:46 +0200)] 
Set the correct mtu on windows based systems

Signed-off-by: Christopher Schenk <cschenk@mail.uni-paderborn.de>
Acked-by: Selva Nair <selva.nair@gmail.com>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20200421154612.14140-1-cschenk@mail.uni-paderborn.de>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg19803.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
5 years agoAdd .git-blame-ignore-revs with reformat commits
Arne Schwabe [Thu, 4 Jun 2020 23:53:38 +0000 (01:53 +0200)] 
Add .git-blame-ignore-revs with reformat commits

This allows git blame to ignore reformatting changes and instead
to show the previous commit that changed the line.

To avoid manually building the list of commits this commit
adds a file with a list of reformatting commits. I might have
missed a few but this should be a good start. To use the file
use:

   git blame --ignore-revs-file=.git-blame-ignore-revs file

or to automatically always use the file

   git config blame.ignoreRevsFile .git-blame-ignore-revs

Naming the file .git-blame-ignore-revs is a convention.

Some more details in this random blog post:

https://www.moxio.com/blog/43/ignoring-bulk-change-commits-with-git-blame

Patch V2: Remove merge commit of the great formatting, add small
          reminder how to use the feature at the top of the file

Signed-off-by: Arne Schwabe <arne@rfc2549.org>
Acked-by: David Sommerseth <davids@openvpn.net>
Message-Id: <20200604235338.11728-1-arne@rfc2549.org>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg19967.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
5 years agomulti: skip IPv4 logic in multi_select_virtual_addr() if no pool is configured
Antonio Quartulli [Wed, 10 Jun 2020 08:45:49 +0000 (10:45 +0200)] 
multi: skip IPv4 logic in multi_select_virtual_addr() if no pool is configured

When no IPv4 pool is configured (but we have an IPv6 pool
only), the multi_select_virtual_addr() function will spit
a warning when allocating an address for a new client.
This happens because the code will check for some IPv4
bits and will see that they are missing.

However, these bits are not really important, because in
this use case we don't want to configure any IPv4 address
at all.

For this reason it is safe to wrap this entire logic in
an if-block that just does not execute when no IPv4 pool
is configured.

This avoids the warning and will also avoid any other
hidden side effect.

Reported-by: Gert Doering <gert@greenie.muc.de>
Signed-off-by: Antonio Quartulli <a@unstable.cc>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20200610084549.4028-1-a@unstable.cc>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg20012.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
5 years agopool: remove useless 'options.h' include
Antonio Quartulli [Wed, 10 Jun 2020 09:01:00 +0000 (11:01 +0200)] 
pool: remove useless 'options.h' include

Commit 6a8cd033 ("pool: add support for ifconfig-pool-persist with IPv6
only") has accidentally introduced an include for 'options.h', which
revealed to not be useful at all. Remove it.

Reported-by: Gert Doering <gert@greenie.muc.de>
Signed-off-by: Antonio Quartulli <a@unstable.cc>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20200610090100.29738-1-a@unstable.cc>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg20011.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
5 years agoSimplify pool size handling, fix possible array overrun on pool reading.
Gert Doering [Tue, 9 Jun 2020 08:02:29 +0000 (10:02 +0200)] 
Simplify pool size handling, fix possible array overrun on pool reading.

Remove separate ipv4.size and ipv6.size in the pool structure, return
to a single pool_size, which is also the allocated array size.

All calls to ifconfig_pool_size() change to "pool->size" now.

pool->size is set to the size of the active pool, or if both IPv4 and IPv6
are in use, to the smaller size (same underlying logic as in 452113155e7,
but really put it into the size field).

This fixes a SIGSEGV crash if an ifconfig-pool-persist file is loaded
that has IPv6 and no IPv4 (= ipv6 handle is used) and that has more
entries than the IPv4 pool size (comparison was done with ipv6.size,
not with actual pool size), introduced by commit 6a8cd033b18.

While at it, fix pool size calculation for IPv6 pools >= /112
(too many -1), introduced by commit 452113155e7.

Signed-off-by: Gert Doering <gert@greenie.muc.de>
Acked-by: Antonio Quartulli <a@unstable.cc>
Message-Id: <20200609080229.2564-1-gert@greenie.muc.de>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg20006.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
5 years agoipv6-pool: get rid of size constraint
Antonio Quartulli [Mon, 8 Jun 2020 20:16:13 +0000 (22:16 +0200)] 
ipv6-pool: get rid of size constraint

Signed-off-by: Antonio Quartulli <a@unstable.cc>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20200608201613.23750-1-a@unstable.cc>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg20005.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
5 years agooptions: enable IPv4 redirection logic only if really required
Antonio Quartulli [Mon, 8 Jun 2020 15:32:39 +0000 (17:32 +0200)] 
options: enable IPv4 redirection logic only if really required

If no IPv4 redirection flag is set, do not enable the IPv4
redirection logic at all so that it won't bother adding any
useless IPv4 route.

Trac: #208
Signed-off-by: Antonio Quartulli <antonio@openvpn.net>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20200608153239.2260-1-a@unstable.cc>
URL: https://www.mail-archive.com/search?l=mid&q=20200608153239.2260-1-a@unstable.cc
Signed-off-by: Gert Doering <gert@greenie.muc.de>
5 years agocrypto_openssl: add include for openssl/conf.h
James Bottomley [Sun, 7 Jun 2020 22:10:58 +0000 (15:10 -0700)] 
crypto_openssl: add include for openssl/conf.h

Fix build failure on older versions of openssl.

Signed-off-by: James Bottomley <James.Bottomley@HansenPartnership.com>
Acked-by: Arne Schwabe <arne@rfc2549.org>
Message-Id: <1591567858.4011.15.camel@HansenPartnership.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg19996.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
5 years agoroute: warn on IPv4 routes installation when no IPv4 is configured
Antonio Quartulli [Sat, 30 May 2020 00:05:58 +0000 (02:05 +0200)] 
route: warn on IPv4 routes installation when no IPv4 is configured

Same as already happens for IPv6, it is useful for the user to throw a
warning when an IPv4 route is about to be installed and the tun interface
has no IPv4 configured.

The twin message for IPv4 is adapted to have the same format.

The warning is not fatal, becuase the route might actually be external
to the tun interface and therefore it may still work.

At the same time, modify the error message used for a route
installation failure to explicitly mention "IPv4" since this it is
used in the IPv4 code path only.

Trac: #208
Signed-off-by: Antonio Quartulli <antonio@openvpn.net>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20200530000600.1680-6-a@unstable.cc>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg19946.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
5 years agopool: add support for ifconfig-pool-persist with IPv6 only
Antonio Quartulli [Sat, 6 Jun 2020 21:16:24 +0000 (23:16 +0200)] 
pool: add support for ifconfig-pool-persist with IPv6 only

Without altering the pool logic, this patch enables using
a persistent IP pool also when the server is configured
with IPv6 only.

Trac: #208
Signed-off-by: Antonio Quartulli <antonio@openvpn.net>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20200606211624.10877-1-a@unstable.cc>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg19990.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
5 years agocrypto_openssl: add initialization to pick up local configuration
James Bottomley [Thu, 28 May 2020 22:59:19 +0000 (15:59 -0700)] 
crypto_openssl: add initialization to pick up local configuration

The test programme for the new openssl engine code requires overriding
the system default configuration file to point to the location of the
test engine.  Add an initialization stanza that makes this behaviour
universal, so now anyone running openvpn configured with openssl can
specify their own configuration file with the OPENSSL_CONF environment
variable.

Signed-off-by: James Bottomley <James.Bottomley@HansenPartnership.com>
Acked-by: Arne Schwabe <arne@rfc2549.org>
Message-Id: <20200528225920.6983-3-James.Bottomley@HansenPartnership.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg19936.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
5 years agoopenssl: add engine method for loading the key
James Bottomley [Thu, 28 May 2020 22:59:18 +0000 (15:59 -0700)] 
openssl: add engine method for loading the key

As well as doing crypto acceleration, engines can also be used to load
key files.  If the engine is set, and the private key loading fails
for bio methods, this patch makes openvpn try to get the engine to
load the key.  If that succeeds, we end up using an engine based key.
This can be used with the openssl tpm engines to make openvpn use a
TPM wrapped key file.

Signed-off-by: James Bottomley <James.Bottomley@HansenPartnership.com>
Acked-by: Arne Schwabe <arne@rfc2549.org>
Message-Id: <20200528225920.6983-2-James.Bottomley@HansenPartnership.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg19937.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
5 years agoallow usage of --server-ipv6 even when no --server is specified
Antonio Quartulli [Sat, 30 May 2020 00:05:56 +0000 (02:05 +0200)] 
allow usage of --server-ipv6 even when no --server is specified

Until now OpenVPN has not allowed to specify --server-ipv6
if no --server was also set. This constraint comes from the
fact that most of the IPv6 logic (i.e. ifconfig-pool handling)
relied on IPv4 components to be activated and configured as
well.

Now that the IPv6 code path has been made independent from
IPv4, it is finally possible to to relax the constraint
mentioned above and make it possible for the user to have a
configurations with --server-ipv6 only.

Trac: #208
Signed-off-by: Antonio Quartulli <antonio@openvpn.net>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20200530000600.1680-4-a@unstable.cc>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg19949.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
5 years agopool: allow to configure an IPv6-only ifconfig-pool
Antonio Quartulli [Mon, 1 Jun 2020 20:06:24 +0000 (22:06 +0200)] 
pool: allow to configure an IPv6-only ifconfig-pool

With this change a server is allowed to allocate an
IPv6-only pool. This is required to make it capable
of managing an IPv6-only tunnel.

Trac: #208
Signed-off-by: Antonio Quartulli <antonio@openvpn.net>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20200601200624.14765-1-a@unstable.cc>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg19957.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
5 years agoSwitch assertion failure to returning false
Jeremy Evans [Wed, 20 May 2020 18:34:04 +0000 (11:34 -0700)] 
Switch assertion failure to returning false

This assertion failure can be hit in production, which causes the
openvpn server process to stop and all clients to be disconnected.
Bug #1270 has been filed for this issue on Trac by another user
who has experienced the issue, and this patch attempts to address it.

Tracing callers, it appears that some callers check ks->authenticated
before calling, but others do not.  It may be possible to add the check
for the callers that do not check, but this seems to be a simpler
solution.

To give some background, we hit this assertion failure, with the
following log output:

```
Tue May 19 15:57:05 2020 username/73.135.141.11:1194 PUSH: Received
control message: 'PUSH_REQUEST'
Tue May 19 15:57:05 2020 username/73.135.141.11:1194 SENT CONTROL
[username]: 'PUSH_REPLY,redirect-gateway
def1,comp-lzo,persist-key,persist-tun,route-gateway 10.28.47.1,topology
subnet,ping 10,ping-restart 120,ifconfig 10.28.47.38 255.255.255.0,peer-id
89' (status=1)
Tue May 19 15:57:05 2020 username/73.135.141.11:1194 Assertion failed at
/path/to/openvpn-2.4.7/src/openvpn/ssl.c:1944 (ks->authenticated)
Tue May 19 15:57:05 2020 username/73.135.141.11:1194 Exiting due to fatal
error
Tue May 19 15:57:05 2020 username/73.135.141.11:1194 Closing TUN/TAP
interface
```

using the following OpenVPN server configuration:

```
port 1194
proto udp
dev-type tun
ca ca.crt
cert server.crt
key server.key
dh dh.pem
topology subnet
push "redirect-gateway def1"
push "comp-lzo"
push "persist-key"
push "persist-tun"
keepalive 10 120
comp-lzo
user nobody
group nobody
persist-key
persist-tun
cd /home/openvpn/server
chroot /var/empty
daemon
verb 3
crl-verify crl.pem
tls-auth ta.key 0
cipher AES-256-CBC
tls-version-min 1.2
tls-cipher ECDHE-RSA-AES256-GCM-SHA384
ncp-disable
mute-replay-warnings
script-security 3
auth-user-pass-verify "ldap-auth/ldap-auth" via-env
auth-user-pass-optional
```

and the following command line options:

```
--config openvpn.conf --dev tun1 --local 206.131.72.52 \
--log-append openvpn.log --status openvpn-status.log \
--server 10.28.47.0 255.255.255.0
```

The failed assertion is inside the function
`tls_session_generate_data_channel_keys`, which is called 3 other places
in `ssl.c.`:

* `key_method_2_write`: checks for `ks->authenticated` before calling

* `key_method_2_read`: appears to run in client mode but not in server
  mode

* `tls_session_update_crypto_params`: runs in server mode and does not
  check before calling

That leads me to believe the problem caller is
`tls_session_update_crypto_params`. There.s three callers of
`tls_session_update_crypto_params`:.

* `incoming_push_message` (`push.c`): Probably this caller, since the
  server pushes configuration to clients, and the log shows the
  assertion failure right after the push reply.

* `multi_process_file_closed` (`multi.c`): Not this caller.  NCP is
  disabled in config, and async push was not enabled when compiling.

* `do_deferred_options` (`init.c`): Not this caller.  The server
  configuration doesn't pull.

Changing the assertion to returning false appears to be the simplest
fix.  Another approach would be changing callers to check
`ks->authenticated` before calling, either
`tls_session_update_crypto_params` or `incoming_push_message`.

Signed-off-by: Jeremy Evans <code@jeremyevans.net>
Acked-by: Steffan Karger <steffan.karger@foxcrypto.com>
Message-Id: <20200520183404.54822-1-code@jeremyevans.net>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg19914.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
5 years agopool: prevent IPv6 pools to be larger than 2^16 addresses
Antonio Quartulli [Sat, 30 May 2020 00:05:54 +0000 (02:05 +0200)] 
pool: prevent IPv6 pools to be larger than 2^16 addresses

Signed-off-by: Antonio Quartulli <a@unstable.cc>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20200530000600.1680-2-a@unstable.cc>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg19945.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
5 years agoRefuse server mode on Android
Arne Schwabe [Mon, 18 May 2020 15:54:27 +0000 (17:54 +0200)] 
Refuse server mode on Android

After the commit 042429d3 "build: Remove --disable-server from ./configure"
Android needs another way to ensure that OpenVPN is not run in server mode.

Signed-off-by: Arne Schwabe <arne@rfc2549.org>
Acked-by: David Sommerseth <davids@openvpn.net>
Message-Id: <20200518155427.17283-1-arne@rfc2549.org>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg19904.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
5 years agoDo not write extra 0 byte for --gen-key with auth-token/tls-crypt-v2
Arne Schwabe [Thu, 7 May 2020 13:25:34 +0000 (15:25 +0200)] 
Do not write extra 0 byte for --gen-key with auth-token/tls-crypt-v2

Change crypto_pem_encode to not put a nul-terminated terminated
string into the buffer. This was  useful for printf but should
not be written into the file.

Instead do not assume that the buffer is null terminated and
print only the number of bytes in the buffer. Also fix a
similar case in printing static key where the 0 byte was
never added to the buffer

Patch V2: make pem_encode behave more like other similar functions in
OpenVPN
          and do not null terminate.

Patch V3: also make the mbed TLS variant of pem_decode behave like other
          similar functions in OpeNVPN and accept a not null-terminated
          buffer.

Patch V4: The newly introduced unit test
          test_tls_crypt_v2_write_client_key_file_metadata
          was added after the V3 version of the patch and now misses the
          strlen with memcmp replacment that were added to
          test_tls_crypt_v2_write_client_key_file. Also add the
          modifictions to this function.

          Unconditionally allocate buffer in mbed TLS path as
          requested by Steffan.

Signed-off-by: Arne Schwabe <arne@rfc2549.org>
Acked-by: Steffan Karger <steffan.karger@foxcrypto.com>
Message-Id: <20200507132534.6380-1-arne@rfc2549.org>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg19852.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
5 years agoChange client side of t_lpback.sh configs to use inline material.
Gert Doering [Wed, 13 May 2020 14:11:47 +0000 (16:11 +0200)] 
Change client side of t_lpback.sh configs to use inline material.

We have no real test rig for "inline" key material (key, cert, ca,
tls-auth, tls-crypt*) yet.   This change adds the "sample" key set
as inline config to the "loopback-client" config, while keeping
file-based configs for "loopback-server" - that way, testing both
methods of loading keys etc. in one go.

Signed-off-by: Gert Doering <gert@greenie.muc.de>
Acked-by: Antonio Quartulli <antonio@openvpn.net>
Message-Id: <20200513141147.17171-1-gert@greenie.muc.de>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg19883.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
5 years agoPersist management-query-remote and proxy prompts
Selva Nair [Fri, 21 Feb 2020 03:00:28 +0000 (22:00 -0500)] 
Persist management-query-remote and proxy prompts

Currently this prompt is only output once, not re-written to the
management interface when the management client connects. It is thus
not seen by a client that connects after the prompt is output or one that
disconnects and reconnects. This leads to a deadlock: the daemon waiting
for the "remote" command from the client, the latter not aware of it.

Resolve by adding the ">REMOTE" and ">PROXY" prompt to
man.persist.special_state_msg as done for other persisted prompts such
as ">PASSWORD"

Signed-off-by: Selva Nair <selva.nair@gmail.com>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <1582254028-7763-1-git-send-email-selva.nair@gmail.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg19497.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
5 years agoFix session id and initial timestamp not being preserved
Arne Schwabe [Tue, 12 May 2020 12:43:44 +0000 (14:43 +0200)] 
Fix session id and initial timestamp not being preserved

In the initial state of checking whether an auth-token has been
validated, the check check if multi->auth_token is already set and
only then sets the value. This defeats the purpose and lead to always
a new auth-token with new session id and lifetime being generated when
the server restarts or the client reconnect to another server.

Patch V2: Only set multi->auth_token when NULL to avoid leaking
          memory. Improve comments and documentation of auth-token.

Signed-off-by: Arne Schwabe <arne@rfc2549.org>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20200512124344.15929-1-arne@rfc2549.org>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg19878.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
5 years agoDocument reneweal mechanic of auth-token in manual
Arne Schwabe [Thu, 26 Mar 2020 17:23:32 +0000 (18:23 +0100)] 
Document reneweal mechanic of auth-token in manual

Our man page was missing the information that the life time of the
auth-token also depends on the reneg-sec

Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20200326172332.2356-3-arne@rfc2549.org>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg19620.html

Signed-off-by: Gert Doering <gert@greenie.muc.de>
5 years agoFix session id in env missing first byte
Arne Schwabe [Thu, 26 Mar 2020 17:23:31 +0000 (18:23 +0100)] 
Fix session id in env missing first byte

sizeof for a constant string return the size including the null byte.
For copying the session id this meant that we do not copy the first
byte. This made the session id reported to the external authenticator
one byte shorter than it was intended to be.

Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20200326172332.2356-2-arne@rfc2549.org>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg19622.html

Signed-off-by: Gert Doering <gert@greenie.muc.de>
5 years agoget rid of INLINE_FILE_TAG constant
Antonio Quartulli [Fri, 8 May 2020 21:23:56 +0000 (23:23 +0200)] 
get rid of INLINE_FILE_TAG constant

Now that the whole inline logic has been converted to using bool flags,
the INLINE_FILE_TAG constant is not useful anymore.

Get rid of the constant as it's now unused and to prevent any future
developer from mistakenly use it again.

Signed-off-by: Antonio Quartulli <a@unstable.cc>
Acked-by: David Sommerseth <davids@openvpn.net>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20200508212356.18522-1-a@unstable.cc>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg19863.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>