]> www.infradead.org Git - users/dwmw2/openconnect.git/log
users/dwmw2/openconnect.git
3 years agoRefuse to handle forms without ->auth_id (but do it in the right place, and noisily)
Daniel Lenski [Sat, 20 Nov 2021 21:12:34 +0000 (13:12 -0800)]
Refuse to handle forms without ->auth_id (but do it in the right place, and noisily)

In 0b47ea1882346fdedfcd8a315f51aeb39e13459e ("Refuse to handle forms without
->auth_id"), the process_auth_form_cb for the OpenConnect CLI was modified
to silently reject forms with auth_id unset.

Issues with this:

1. If a form doesn't have its auth_id set, it'll fail *silently*, which
   makes it confusingly difficult to identify the root cause. (See #351.)
2. As that commit message says, GUIs/front-ends need the auth_id to be set,
   but it didn't do anything to enforce it other than for the CLI.

The solution is to reject forms with auth_id unset in process_auth_form()
itself, rather than expecting the front-ends’ callback functions to check
this, and to do so with an error message explaining that this is a bug in
OpenConnect.

Signed-off-by: Daniel Lenski <dlenski@gmail.com>
3 years agoBugfix F5 'plain' login form
Daniel Lenski [Fri, 19 Nov 2021 19:26:59 +0000 (11:26 -0800)]
Bugfix F5 'plain' login form

Fixes #351.

It turns out that the "plain auth form" for F5 has been broken since
0b47ea1882346fdedfcd8a315f51aeb39e13459e.  (This form is used as a stand-in
when the server fails to provide a real HTML login form, and only gives a
JavaScript mess that dynamically creates a form.)

DW probably didn't notice this when making that commit, because
a07bbbcd711c6fc4ef20fd9719e0e5da40f141f9 had previously fixed the other
places where a form with no `auth_id` could be created.

This ensures that the "plain auth form" has its `auth_id` set, and adds test
coverage of this form to `f5-auth-and-config`.

Signed-off-by: Daniel Lenski <dlenski@gmail.com>
3 years agoMerge branch 'repeat' into 'master'
Daniel Lenski [Thu, 18 Nov 2021 05:51:52 +0000 (05:51 +0000)]
Merge branch 'repeat' into 'master'

Remove repeated words from documentation

See merge request openconnect/openconnect!302

3 years agoRemove repeated words from documentation
Dimitri Papadopoulos [Thu, 18 Nov 2021 05:27:40 +0000 (06:27 +0100)]
Remove repeated words from documentation

Signed-off-by: Dimitri Papadopoulos <3350651-DimitriPapadopoulos@users.noreply.gitlab.com>
3 years agoAdd changelog entry
Daniel Lenski [Wed, 13 Oct 2021 04:05:43 +0000 (21:05 -0700)]
Add changelog entry

Signed-off-by: Daniel Lenski <dlenski@gmail.com>
3 years agoJuniper/NC ESP rekey fix
Daniel Lenski [Wed, 13 Oct 2021 01:25:40 +0000 (18:25 -0700)]
Juniper/NC ESP rekey fix

This should fix https://gitlab.com/openconnect/openconnect/-/issues/322.
This was an immensely tricky issue to identify and solve.  Many thanks to
@john508 for his patient logging, testing, and bisecting.

This came down to a subtle combination of 2 problems, described further in
https://gitlab.com/openconnect/openconnect/-/issues/322#note_702122197.

First, a bug:

  The code for Juniper/Pulse 'dontsend' added in
  https://gitlab.com/openconnect/openconnect/-/commit/b4f50f8bd5da7e6ac926ddd5095501edbc204cd0
  caused IPv6 packets to get sent over the Juniper oNCP/TLS channel in a
  completely mangled form, thereby confusing the server and making it not
  respond to subsequent ESP rekey packets sent over the oNCP/TLS channel.

  The fix is to use this code path *only* for the Pulse protocol, not for the
  Juniper protocol. Juniper cannot do ESP-over-IPv6 at all, and cannot send
  tunneled IPv6 packets at all (neither via ESP-over-IPv4, nor via oNCP/TLS).

Second, we introduced a subtle regression against a Juniper server behavior
which we weren't previously aware of:

  Juniper servers apparently don't always resend the IP address in a
  configuration packet, if that configuration packet is for
  rekey/reconnection only.

  To address this, we need to add a special case for Juniper to the
  install_vpn_opts() function, which was added in
  https://gitlab.com/openconnect/openconnect/-/commit/3d845bc9bf62b3e816e0d2fd72970ef33964a191.

Signed-off-by: Daniel Lenski <dlenski@gmail.com>
3 years agoIf oNCP negotiation response is a redirect, cookie is invalid
Daniel Lenski [Wed, 13 Oct 2021 17:32:33 +0000 (10:32 -0700)]
If oNCP negotiation response is a redirect, cookie is invalid

Signed-off-by: Daniel Lenski <dlenski@gmail.com>
3 years agoFix/update comments in fake-*-server.py scripts
Daniel Lenski [Sat, 13 Nov 2021 18:35:36 +0000 (10:35 -0800)]
Fix/update comments in fake-*-server.py scripts

Also adds a stub to make sure that 'fake-juniper-server.py' rejects attempts
to start speaking the Junos/Pulse protocol, rather than the Juniper/oNCP
protocol.

Signed-off-by: Daniel Lenski <dlenski@gmail.com>
3 years agoFix missing protocol flag for Juniper NC
Daniel Lenski [Sun, 14 Nov 2021 17:56:41 +0000 (09:56 -0800)]
Fix missing protocol flag for Juniper NC

Signed-off-by: Daniel Lenski <dlenski@gmail.com>
3 years agoMerge branch 'revert_to_using_TAPWindows_by_default' into 'master'
Daniel Lenski [Sat, 13 Nov 2021 02:19:59 +0000 (02:19 +0000)]
Merge branch 'revert_to_using_TAPWindows_by_default' into 'master'

Switch back to TAP-Windows as default driver on Windows

See merge request openconnect/openconnect!300

3 years agoRe-add TAP-Windows driver to installer, and update docs to reference its inclusion
Daniel Lenski [Fri, 12 Nov 2021 01:16:01 +0000 (17:16 -0800)]
Re-add TAP-Windows driver to installer, and update docs to reference its inclusion

This mostly reverts commit 8c1d2de09829d0930d1a7642b0729cd6cbf5ab67 ("Remove
TAP-Windows driver from installer, and update docs to reference Wintun's
default inclusion").

It appears that Wintun is not fully stable yet for OpenConnect VPN connections.
See #338 for two reports of instability (with #324 as a possible third), including
one where switching to TAP-Windows clearly resolved the issue.

Per https://gitlab.com/openconnect/openconnect/-/issues/338#note_731175712,
we should revert to installing and using TAP-Windows by default until we can figure out why.

OpenConnect will continue to use Wintun if TAP-Windows is unavailable, but will
issue a loud warning to the log.

Signed-off-by: Daniel Lenski <dlenski@gmail.com>
3 years agoAvoid code duplication in www/html.py
Daniel Lenski [Wed, 3 Nov 2021 20:57:10 +0000 (13:57 -0700)]
Avoid code duplication in www/html.py

Ping #342, closes !279.

Signed-off-by: Dimitri Papadopoulos <3350651-DimitriPapadopoulos@users.noreply.gitlab.com>
Signed-off-by: Daniel Lenski <dlenski@gmail.com>
3 years agoMerge branch 'vpn_progress_n' into 'master'
Daniel Lenski [Mon, 1 Nov 2021 23:54:31 +0000 (23:54 +0000)]
Merge branch 'vpn_progress_n' into 'master'

vpn_progress(), vpn_perror() and '\n'

See merge request openconnect/openconnect!287

3 years agoMerge branch 'discourage_use_of_csd-wrapper.sh' into 'master'
Daniel Lenski [Fri, 22 Oct 2021 22:44:59 +0000 (22:44 +0000)]
Merge branch 'discourage_use_of_csd-wrapper.sh' into 'master'

Encourage use of csd-post.sh, and discourage use of csd-wrapper.sh

See merge request openconnect/openconnect!231

3 years agoMerge branch 'python3' into 'master'
Daniel Lenski [Fri, 22 Oct 2021 22:42:22 +0000 (22:42 +0000)]
Merge branch 'python3' into 'master'

These are Python 3 scripts

See merge request openconnect/openconnect!291

3 years agoMerge branch 'Fortinet_HTML_form_based_MFA' into 'master'
Daniel Lenski [Thu, 21 Oct 2021 15:46:05 +0000 (15:46 +0000)]
Merge branch 'Fortinet_HTML_form_based_MFA' into 'master'

Add support for Fortinet's HTML-type multi-factor authentication

Closes #332

See merge request openconnect/openconnect!295

3 years agoTest both tokeninfo- and HTML-based MFA challenges for Fortinet
Daniel Lenski [Thu, 21 Oct 2021 01:11:01 +0000 (18:11 -0700)]
Test both tokeninfo- and HTML-based MFA challenges for Fortinet

Signed-off-by: Daniel Lenski <dlenski@gmail.com>
3 years agoAdd support for Fortinet's HTML-type multi-factor authentication
Daniel Lenski [Thu, 21 Oct 2021 00:48:12 +0000 (17:48 -0700)]
Add support for Fortinet's HTML-type multi-factor authentication

Fortinet is known to support *two* different types of MFA/2FA challenges
(see details in
https://gitlab.com/openconnect/openconnect/-/issues/332#note_709413011):

1. HTTP 200 response to initial login with plain-text body
   (`ret=...,reqid=...,polid=...,...tokeninfo=,chal_msg=...`) containing
   prompt and fields to be parroted back.
2. HTTP 401 response to initial login with HTML body containing a "normal"
   HTML form to be filled out and sent back.

OpenConnect has supported "tokeninfo-type 2FA" (1) since #225 and
426fc3d434ae614b7e10999aff84c52dcffd047a.

This adds support for "HTML-type 2FA" (2), based on the example logs
from #332, and mentions its support in the documentation.

Signed-off-by: Daniel Lenski <dlenski@gmail.com>
3 years agoAdd flag to allow do_http_request() to return the server response body even on error
Daniel Lenski [Thu, 21 Oct 2021 00:40:07 +0000 (17:40 -0700)]
Add flag to allow do_http_request() to return the server response body even on error

Also, rename the argument 'fetch_redirect' to 'flags', and make it a
bitfield with explicit #define'd values.

Signed-off-by: Daniel Lenski <dlenski@gmail.com>
3 years agoUpdate documentation on state of Fortinet reconnects
Daniel Lenski [Wed, 20 Oct 2021 14:14:00 +0000 (07:14 -0700)]
Update documentation on state of Fortinet reconnects

Inadvertently omitted this from !292.

Signed-off-by: Daniel Lenski <dlenski@gmail.com>
3 years agoMerge branch 'refine_Fortinet_reconnect_and_DPD' into 'master'
Daniel Lenski [Wed, 20 Oct 2021 18:42:10 +0000 (18:42 +0000)]
Merge branch 'refine_Fortinet_reconnect_and_DPD' into 'master'

refine Fortinet reconnect and DPD

See merge request openconnect/openconnect!292

3 years agoEnable Fortinet DPD even if server doesn't say that reconnect-after-drop is allowed
Daniel Lenski [Mon, 18 Oct 2021 03:03:23 +0000 (20:03 -0700)]
Enable Fortinet DPD even if server doesn't say that reconnect-after-drop is allowed

Even if we can't automatically reconnect, disabling DPD doesn't seem like a
good idea.  This will just recapitulate the poor behavior of official
Fortinet clients, which don't provide useful signals about dropped
connection.

Instead, let's just tell users explicitly that reconnect probably won't work
in the logging messages.

Signed-off-by: Daniel Lenski <dlenski@gmail.com>
3 years agoDo request "ancient HTML config" in order to distinguish truly-ancient Fortinet serve...
Daniel Lenski [Tue, 31 Aug 2021 01:55:37 +0000 (18:55 -0700)]
Do request "ancient HTML config" in order to distinguish truly-ancient Fortinet servers from some reconnection problems

This should at least partially address #298.

Signed-off-by: Daniel Lenski <dlenski@gmail.com>
3 years agoAttempt to determine whether Fortinet server really supports reconnect-after-drop...
Daniel Lenski [Tue, 31 Aug 2021 01:55:37 +0000 (18:55 -0700)]
Attempt to determine whether Fortinet server really supports reconnect-after-drop (without reauth)

If the server doesn't actually support reconnection, then DPD is probably
useless or counterproductive, and we shouldn't enable it.

See discussion here: https://gitlab.com/openconnect/openconnect/-/issues/297#note_664686767

Signed-off-by: Daniel Lenski <dlenski@gmail.com>
3 years agoAdd links to latest Windows builds to www/packages.html and README.md
Daniel Lenski [Thu, 14 Oct 2021 04:02:45 +0000 (21:02 -0700)]
Add links to latest Windows builds to www/packages.html and README.md

Fixes #286.

Signed-off-by: Daniel Lenski <dlenski@gmail.com>
3 years agoDump initial oNCP negotiation request if --dump-http-traffic is specified
Daniel Lenski [Wed, 25 Aug 2021 20:09:36 +0000 (20:09 +0000)]
Dump initial oNCP negotiation request if --dump-http-traffic is specified

Joachim Kuebart noted the absence of this output in
https://gitlab.com/openconnect/openconnect/-/merge_requests/271#note_654871352

Signed-off-by: Daniel Lenski <dlenski@gmail.com>
3 years agoThese are Python 3 scripts
Dimitri Papadopoulos [Thu, 30 Sep 2021 08:43:00 +0000 (10:43 +0200)]
These are Python 3 scripts

Signed-off-by: Dimitri Papadopoulos <3350651-DimitriPapadopoulos@users.noreply.gitlab.com>
3 years agoResync translations with sources
Dimitri Papadopoulos [Sun, 26 Sep 2021 10:52:13 +0000 (12:52 +0200)]
Resync translations with sources

Signed-off-by: Dimitri Papadopoulos <3350651-DimitriPapadopoulos@users.noreply.gitlab.com>
3 years agoRemove extra '\n' from a vpn_perror() message
Dimitri Papadopoulos [Sun, 26 Sep 2021 10:40:33 +0000 (12:40 +0200)]
Remove extra '\n' from a vpn_perror() message

Signed-off-by: Dimitri Papadopoulos <3350651-DimitriPapadopoulos@users.noreply.gitlab.com>
3 years agoAdd missing '\n' to vpn_progress() messages
Dimitri Papadopoulos [Sun, 26 Sep 2021 10:26:09 +0000 (12:26 +0200)]
Add missing '\n' to vpn_progress() messages

Signed-off-by: Dimitri Papadopoulos <3350651-DimitriPapadopoulos@users.noreply.gitlab.com>
3 years agobugfix openconnect__strchrnul function in compat.c
Daniel Lenski [Sun, 19 Sep 2021 19:56:20 +0000 (12:56 -0700)]
bugfix openconnect__strchrnul function in compat.c

In e6ce815e112415e8a00cf838bcaf9121be3503de, I claimed…

> GNU strchrnul() is trivial to implement

Nevertheless, I got it wrong: there was an off-by-one error in the case
where the sought character is indeed found.

The strchrnul() function is used in protocol-specific code for both GP and
Fortinet. Fixes #318.

Signed-off-by: Daniel Lenski <dlenski@gmail.com>
3 years agoMerge branch 'wintun-0.13' into 'master'
Daniel Lenski [Fri, 24 Sep 2021 23:28:01 +0000 (23:28 +0000)]
Merge branch 'wintun-0.13' into 'master'

Upgrade to Wintun 0.13?

See merge request openconnect/openconnect!264

3 years agoAnnotate vpnc-script-win.js with a header documenting its exact source revision
Daniel Lenski [Fri, 24 Sep 2021 22:50:53 +0000 (22:50 +0000)]
Annotate vpnc-script-win.js with a header documenting its exact source revision

By annotating the vpnc-script-win.js included in the Windows installers
with information about the exact source revision, we will ease reporting
and reduce confusion about problems resulting from interactions between
OpenConnect and vpnc-script.

Example of the header added to vpnc-script-win.js:

    // This script matches the version found at https://gitlab.com/openconnect/vpnc-scripts/-/blob/b749c2cadc2f32e2efffa69302861f9a7d4a4e5f/vpnc-script-win.js
    // Updated on 2021-09-24 by Daniel Lenski <dlenski@gmail.com> ("Ensure that vpnc-script-win.js works even if INTERNAL_IP4_{NETADDR,NETMASK} are unset")
    //

Signed-off-by: Daniel Lenski <dlenski@gmail.com>
3 years agoFix missing newline in Windows error message
Daniel Lenski [Fri, 24 Sep 2021 22:06:27 +0000 (15:06 -0700)]
Fix missing newline in Windows error message

Signed-off-by: Daniel Lenski <dlenski@gmail.com>
3 years agoMerge branch 'deepsource' into 'master'
Daniel Lenski [Fri, 24 Sep 2021 21:07:59 +0000 (21:07 +0000)]
Merge branch 'deepsource' into 'master'

Fix DeepSource alerts

See merge request openconnect/openconnect!284

3 years agoFix DeepSource alert
Dimitri Papadopoulos [Fri, 24 Sep 2021 19:26:52 +0000 (21:26 +0200)]
Fix DeepSource alert

Useless inheritance from `object`

The class is inheriting from `object`, which is implicit under Python 3 ,
hence can be safely removed from bases.

Signed-off-by: Dimitri Papadopoulos <3350651-DimitriPapadopoulos@users.noreply.gitlab.com>
3 years agoFix DeepSource alert
Dimitri Papadopoulos [Fri, 24 Sep 2021 19:01:58 +0000 (21:01 +0200)]
Fix DeepSource alert

Logging is not lazy

The logging statement has the call of the form
logging.(format_string % (format_args...))
For such calls, it is recommended to leave string interpolation to the
logging method itself and be written as
logging.(format_string, format_args...)
so that the program may avoid incurring the cost of the interpolation
in those cases in which no message will be logged. For more details, see
PEP 282.

Signed-off-by: Dimitri Papadopoulos <3350651-DimitriPapadopoulos@users.noreply.gitlab.com>
3 years agoFix DeepSource alert
Dimitri Papadopoulos [Fri, 24 Sep 2021 18:47:08 +0000 (20:47 +0200)]
Fix DeepSource alert

Consider decorating method with `@staticmethod`

Signed-off-by: Dimitri Papadopoulos <3350651-DimitriPapadopoulos@users.noreply.gitlab.com>
3 years agoFix DeepSource alert
Dimitri Papadopoulos [Fri, 24 Sep 2021 18:02:11 +0000 (20:02 +0200)]
Fix DeepSource alert

Function/method with an empty body

Signed-off-by: Dimitri Papadopoulos <3350651-DimitriPapadopoulos@users.noreply.gitlab.com>
3 years agoFix DeepSource alert
Dimitri Papadopoulos [Fri, 24 Sep 2021 17:58:19 +0000 (19:58 +0200)]
Fix DeepSource alert

Dangerous default argument

Do not use a mutable like `list` or `dictionary` as a default value to an
argument. Python’s default arguments are evaluated once when the function
is defined. Using a mutable default argument and mutating it will mutate
that object for all future calls to the function as well.

Signed-off-by: Dimitri Papadopoulos <3350651-DimitriPapadopoulos@users.noreply.gitlab.com>
3 years agoThis is a Python 3 script
Dimitri Papadopoulos [Fri, 24 Sep 2021 17:42:03 +0000 (19:42 +0200)]
This is a Python 3 script

Remove Python2 test, this will at the same time remove a DeepSource
false positive about `reload` being an undefined name.

Signed-off-by: Dimitri Papadopoulos <3350651-DimitriPapadopoulos@users.noreply.gitlab.com>
3 years agoFix DeepSource alert
Dimitri Papadopoulos [Fri, 24 Sep 2021 17:36:22 +0000 (19:36 +0200)]
Fix DeepSource alert

Consider using literal syntax to create the data structure

Using the literal syntax can give minor performance bumps compared to
using function calls to create `dict`, `list` and `tuple`.

This is because here, the name `dict` must be looked up in the global
scope in case it has been rebound. Same goes for the other two types
`list()` and `tuple()`.

Signed-off-by: Dimitri Papadopoulos <3350651-DimitriPapadopoulos@users.noreply.gitlab.com>
3 years agoFix DeepSource alert
Dimitri Papadopoulos [Fri, 24 Sep 2021 17:33:11 +0000 (19:33 +0200)]
Fix DeepSource alert

Built-in function `len` used as condition

Using the `len` function to check if a sequence is empty is not idiomatic
and can be less performant than checking the truthiness of the object.

`len` doesn't know the context in which it is called, so if computing the
length means traversing the entire sequence, it must; it doesn't know
that the result is just being compared to 0. Computing the boolean value
can stop after it sees the first element, regardless of how long the
sequence actually is.

Signed-off-by: Dimitri Papadopoulos <3350651-DimitriPapadopoulos@users.noreply.gitlab.com>
3 years agoFix DeepSource alert
Dimitri Papadopoulos [Fri, 24 Sep 2021 17:29:46 +0000 (19:29 +0200)]
Fix DeepSource alert

Useless `return` detected

Signed-off-by: Dimitri Papadopoulos <3350651-DimitriPapadopoulos@users.noreply.gitlab.com>
3 years agoFix DeepSource alert
Dimitri Papadopoulos [Fri, 24 Sep 2021 17:26:57 +0000 (19:26 +0200)]
Fix DeepSource alert

`print` statement has no effect

Signed-off-by: Dimitri Papadopoulos <3350651-DimitriPapadopoulos@users.noreply.gitlab.com>
3 years agoWintun 0.10.2 (2021-02-16) → 0.13 (2021-08-02)
Dimitri Papadopoulos [Fri, 6 Aug 2021 20:37:05 +0000 (22:37 +0200)]
Wintun 0.10.2 (2021-02-16) → 0.13 (2021-08-02)

Signed-off-by: Dimitri Papadopoulos <3350651-DimitriPapadopoulos@users.noreply.gitlab.com>
3 years agoMerge branch 'wintun_doc_and_naming_tweaks' into 'master'
Daniel Lenski [Thu, 23 Sep 2021 19:53:10 +0000 (19:53 +0000)]
Merge branch 'wintun_doc_and_naming_tweaks' into 'master'

Wintun and related improvements

See merge request openconnect/openconnect!178

3 years agoNuke tabs in Python
Dimitri Papadopoulos [Wed, 22 Sep 2021 20:33:09 +0000 (22:33 +0200)]
Nuke tabs in Python

TAB → 4 × SP

Signed-off-by: Dimitri Papadopoulos <3350651-DimitriPapadopoulos@users.noreply.gitlab.com>
3 years agoLGTM recommendations: Except block handles 'BaseException'
Dimitri Papadopoulos [Wed, 22 Sep 2021 13:55:39 +0000 (15:55 +0200)]
LGTM recommendations: Except block handles 'BaseException'

Except block directly handles BaseException.

Signed-off-by: Dimitri Papadopoulos <3350651-DimitriPapadopoulos@users.noreply.gitlab.com>
3 years agoDocument --force-trojan as available on _WIN32
Dimitri Papadopoulos [Sun, 18 Jul 2021 12:11:57 +0000 (14:11 +0200)]
Document --force-trojan as available on _WIN32

Signed-off-by: Dimitri Papadopoulos <3350651-DimitriPapadopoulos@users.noreply.gitlab.com>
3 years agoMerge branch 'set_VPNPID_for_vpnc_script' into 'master'
Daniel Lenski [Fri, 17 Sep 2021 16:15:05 +0000 (16:15 +0000)]
Merge branch 'set_VPNPID_for_vpnc_script' into 'master'

Provide the vpnc-script with our PID (as $VPNPID)

See merge request openconnect/openconnect!278

3 years agoProvide the vpnc-script with our PID (as $VPNPID)
Daniel Lenski [Thu, 16 Sep 2021 19:51:43 +0000 (12:51 -0700)]
Provide the vpnc-script with our PID (as $VPNPID)

This will enable a vpnc-script to more easily identify which VPN connection
is calling it, in the case of multiple concurrent or "stacked" VPN
connections.

Because OpenConnect (and vpnc) invoke the vpnc-script via an intermediate
shell process, the vpnc-script would otherwise need to determine its
GRANDparent PID, which is an error-prone, and not easily portable, process.
See https://gitlab.com/openconnect/vpnc-scripts/-/issues/28 and
https://gitlab.com/openconnect/vpnc-scripts/-/merge_requests/36 for issues
with the current approaches.

Signed-off-by: Daniel Lenski <dlenski@gmail.com>
3 years agoUpdate changelog to reflect Wintun and vpnc-script-win.js improvements
Daniel Lenski [Fri, 2 Apr 2021 15:53:00 +0000 (08:53 -0700)]
Update changelog to reflect Wintun and vpnc-script-win.js improvements

Signed-off-by: Daniel Lenski <dlenski@gmail.com>
3 years agoTry to delete-and-reclaim IP addresses from down interfaces
Daniel Lenski [Fri, 2 Apr 2021 07:16:59 +0000 (00:16 -0700)]
Try to delete-and-reclaim IP addresses from down interfaces

As mentioned previously, Windows will not allow us to set an IP address on
the tunnel interface (using 'netsh' in vpnc-script-win.js) if that address
is assigned to another interface, *even if* that interface is not currently
up.

In order to figure out if our interface's desired IP address(es) are
assigned to any other interface(s), we have to iterate over the results of
`GetAdaptersAddresses`. This retrieves a list of all IP addresses (both
Legacy and IPv6) by interface, along with up/down status thereof.

If we find another interface that is assigned our desired IP address, but is
not up, we should attempt to unassign/delete/reclaim the address from this
interface. In order to do that, we need to use a completely separate API
(`GetUnicastIpAddressTable`) to get a list of all assigned IP addresses in a
form that can be used to delete them (with `DeleteUnicastIpAddressEntry`).

The simplest way to structure the code to do this is to use two nested
loops:

- The outer loop iterates over the adapters and addresses returned by
  `GetAdaptersAddresses`
- The inner loop — which runs only in the case of a conflicting address —
  iterates over the addresses as returned by `GetUnicastIpAddressTables`.
- Perhaps this could be optimized, but because this runs only once per VPN
  connection, and a typical client system will have <<N=100 adapters and IP
  addresses… it doesn't seem worth it.

NB: I had previously tried avoiding the use of `GetUnicastIpAddressTable`
    altogether by creating a fake/synthetic `MIB_UNICASTIPADDRESS_ROW` with
    most of the fields filled in using information returned by
    `GetAdaptersAddresses`, and passing this directly to
    `DeleteUnicastIpAddressEntry`.  It simply did not work, perhaps due to
    the absence of one or two seemingly-unimportant fields whose values
    couldn't be determined. (See 4acc773c69d8b06da2983fd5fe70cca357822503)

Signed-off-by: Daniel Lenski <dlenski@gmail.com>
3 years agoAdd check_address_conflicts() to tun-win32.c
Daniel Lenski [Fri, 2 Apr 2021 05:57:02 +0000 (22:57 -0700)]
Add check_address_conflicts() to tun-win32.c

If other adapters have conflicting IPv4/IPv6 addresses, vpnc-script-win.js
will fail to configure the tunnel addresses correctly.

For now, check_address_conflicts() only checks and fails; it doesn't try to
delete/reclaim the conflicting addresses.

[ Yay, Windows, for persisting a value we don't need or want persisted, and
  not allowing us to override this with 'netsh interface ipvX set address'.
  This appears to be a limitation of the Windows 'netsh' configuration
  utility. ]

Signed-off-by: Daniel Lenski <dlenski@gmail.com>
3 years agoDon't set Legacy IP address on Windows tunnel interface within OpenConnect itself
Daniel Lenski [Thu, 1 Apr 2021 00:21:41 +0000 (17:21 -0700)]
Don't set Legacy IP address on Windows tunnel interface within OpenConnect itself

The pre-existing Windows routing connection script (vpnc-script-win.js) was
not able to reliably set the Legacy IP address of the tunnel interface, so
we've been setting it in OpenConnect itself since
60d1f092e35f05217f1c96823c4f1b86c7915bbd.

As of https://gitlab.com/openconnect/vpnc-scripts/-/merge_requests/26, we've
got vpnc-script-win.js setting the Legacy IP address correctly, and IPv6 as
well. We should leave this as the script's responsibility for
cross-platform consistency.

Signed-off-by: Daniel Lenski <dlenski@gmail.com>
3 years agoCheck vpnc-script exit status on all platforms including Windows
Daniel Lenski [Wed, 31 Mar 2021 21:48:09 +0000 (14:48 -0700)]
Check vpnc-script exit status on all platforms including Windows

See https://gitlab.com/openconnect/vpnc-scripts/-/merge_requests/26, in
which I modified vpnc-script-win.js to return a usable exit status.

Signed-off-by: Daniel Lenski <dlenski@gmail.com>
3 years agoDistinguish ERROR_ACCESS return value from create_wintun()
Daniel Lenski [Wed, 31 Mar 2021 01:35:45 +0000 (18:35 -0700)]
Distinguish ERROR_ACCESS return value from create_wintun()

The error 'Is the driver installed?' is misleading in this case; the actual
problem is likely that the user isn't running as SYSTEM/Administrator.

Signed-off-by: Daniel Lenski <dlenski@gmail.com>
3 years agoRemove TAP-Windows driver from installer, and update docs to reference Wintun's defau...
Daniel Lenski [Wed, 31 Mar 2021 00:52:19 +0000 (17:52 -0700)]
Remove TAP-Windows driver from installer, and update docs to reference Wintun's default inclusion

Signed-off-by: Daniel Lenski <dlenski@gmail.com>
3 years agoUse hostname as Wintun ifname (if ifname not specified)
Daniel Lenski [Wed, 31 Mar 2021 01:08:00 +0000 (18:08 -0700)]
Use hostname as Wintun ifname (if ifname not specified)

Without this change, OpenConnect will *only* attempt to use the Wintun
driver if `-i InterfaceName`, and will require TAP-Windows driver otherwise.

That seems like a surprising and hard-to-discover behavior.

Instead, we should use the VPN server's hostname as a sane default interface
name with Wintun, and only attempt to use TAP-Windows as a fallback in the
case where Wintun can't be initialized.

Signed-off-by: Daniel Lenski <dlenski@gmail.com>
3 years agoMerge branch 'flake8' into 'master'
Daniel Lenski [Fri, 10 Sep 2021 18:21:07 +0000 (18:21 +0000)]
Merge branch 'flake8' into 'master'

Flake8 errors and warnings

See merge request openconnect/openconnect!277

3 years agoFlake8 errors and warnings
Dimitri Papadopoulos [Thu, 9 Sep 2021 12:44:08 +0000 (14:44 +0200)]
Flake8 errors and warnings

Signed-off-by: Dimitri Papadopoulos <3350651-DimitriPapadopoulos@users.noreply.gitlab.com>
3 years agoMerge branch 'codespell' into 'master'
Dimitri Papadopoulos Orfanos [Tue, 31 Aug 2021 20:01:49 +0000 (20:01 +0000)]
Merge branch 'codespell' into 'master'

Typos caught by codespell

See merge request openconnect/openconnect!275

3 years agoTypos caught by codespell
Dimitri Papadopoulos [Tue, 31 Aug 2021 13:31:04 +0000 (16:31 +0300)]
Typos caught by codespell

More typos caught by the latest version of codespell.

Signed-off-by: Dimitri Papadopoulos <3350651-DimitriPapadopoulos@users.noreply.gitlab.com>
3 years agoMerge branch 'ERR_GET_FUNC_OpenSSL_3.0' into 'master'
Daniel Lenski [Mon, 30 Aug 2021 17:35:27 +0000 (17:35 +0000)]
Merge branch 'ERR_GET_FUNC_OpenSSL_3.0' into 'master'

Build with OpenSSL 3.0 beta 2 Release Candidate

Closes #289

See merge request openconnect/openconnect!269

3 years agoBuild with OpenSSL 3.0 beta 2 Release Candidate
Dimitri Papadopoulos [Mon, 16 Aug 2021 12:43:02 +0000 (15:43 +0300)]
Build with OpenSSL 3.0 beta 2 Release Candidate

I had forgotten this ERR_GET_FUNC() call in my previous patch !262.

Again, removing calls to ERR_GET_FUNC() will not change anything:

PKCS11_F_PKCS11_LOGIN / ERR_LIB_PKCS11

We check the function code is PKCS11_F_PKCS11_LOGIN right after
calling PKCS11_login().

Signed-off-by: Dimitri Papadopoulos <3350651-DimitriPapadopoulos@users.noreply.gitlab.com>
3 years agoMerge branch 'lgtm' into 'master'
Daniel Lenski [Wed, 11 Aug 2021 20:09:04 +0000 (20:09 +0000)]
Merge branch 'lgtm' into 'master'

Fix LGTM alerts in Python code

See merge request openconnect/openconnect!266

3 years agoMerge branch 'ERR_GET_FUNC_OpenSSL_3.0' into 'master'
Daniel Lenski [Wed, 11 Aug 2021 17:29:48 +0000 (17:29 +0000)]
Merge branch 'ERR_GET_FUNC_OpenSSL_3.0' into 'master'

Build with OpenSSL 3.0 beta 2 Release Candidate

Closes #289

See merge request openconnect/openconnect!262

3 years agoOnly remove ERR_GET_FUNC for OpenSSL v3.0 and newer
Daniel Lenski [Wed, 11 Aug 2021 17:12:40 +0000 (17:12 +0000)]
Only remove ERR_GET_FUNC for OpenSSL v3.0 and newer

This function is removed in OpenSSL 3.0 beta 2, per
https://github.com/openssl/openssl/blob/openssl-3.0.0-beta2/CHANGES.md:

> The ERR_GET_FUNC() function was removed. With the loss of
> meaningful function codes, this function can only cause
> problems for calling applications.

It appears that this function may not have had any useful purpose for a long
time (see
https://gitlab.com/openconnect/openconnect/-/merge_requests/262#note_648720006),
but in the absence of clear documentation or testing, we should limit its
remove to OpenSSL 3.0+ to be on the safe side.

Signed-off-by: Daniel Lenski <dlenski@gmail.com>
3 years agoUse more idiomatic super().__init__() in html.py
Daniel Lenski [Tue, 10 Aug 2021 23:31:22 +0000 (23:31 +0000)]
Use more idiomatic super().__init__() in html.py

Signed-off-by: Daniel Lenski <dlenski@gmail.com>
3 years agoMerge branch 'tests_trailing_space' into 'master'
Daniel Lenski [Tue, 10 Aug 2021 23:26:17 +0000 (23:26 +0000)]
Merge branch 'tests_trailing_space' into 'master'

Remove spurious trailing space

See merge request openconnect/openconnect!261

3 years agoLGTM recommendation: Unused local variable
Dimitri Papadopoulos [Sun, 8 Aug 2021 09:12:28 +0000 (11:12 +0200)]
LGTM recommendation: Unused local variable

The value assigned to '...' is never used.

https://lgtm.com/rules/6780086/

Signed-off-by: Dimitri Papadopoulos <3350651-DimitriPapadopoulos@users.noreply.gitlab.com>
3 years agoLGTM error: Missing call to `__init__` during object initialization
Dimitri Papadopoulos [Sat, 7 Aug 2021 21:43:27 +0000 (23:43 +0200)]
LGTM error: Missing call to `__init__` during object initialization

Class docHandler may not be initialized properly as method
ContentHandler.__init__ is not called from its __init__ method.

https://lgtm.com/rules/5990072/

Signed-off-by: Dimitri Papadopoulos <3350651-DimitriPapadopoulos@users.noreply.gitlab.com>
3 years agoLGTM recommendation: Unused import
Dimitri Papadopoulos [Sat, 7 Aug 2021 21:38:09 +0000 (23:38 +0200)]
LGTM recommendation: Unused import

Import of '...' is not used.

https://lgtm.com/rules/6770079/

Signed-off-by: Dimitri Papadopoulos <3350651-DimitriPapadopoulos@users.noreply.gitlab.com>
3 years agoLGTM recommendation: Unused import
Dimitri Papadopoulos [Sat, 7 Aug 2021 21:34:33 +0000 (23:34 +0200)]
LGTM recommendation: Unused import

Import of 'StringIO' is not used.

https://lgtm.com/rules/6770079/

Signed-off-by: Dimitri Papadopoulos <3350651-DimitriPapadopoulos@users.noreply.gitlab.com>
3 years agoLGTM warning: Unnecessary pass
Dimitri Papadopoulos [Sat, 7 Aug 2021 21:32:46 +0000 (23:32 +0200)]
LGTM warning: Unnecessary pass

Unnecessary 'pass' statement.

https://lgtm.com/rules/910088/

Signed-off-by: Dimitri Papadopoulos <3350651-DimitriPapadopoulos@users.noreply.gitlab.com>
3 years agoRemove spurious trailing space
Dimitri Papadopoulos [Sat, 31 Jul 2021 11:19:27 +0000 (13:19 +0200)]
Remove spurious trailing space

Signed-off-by: Dimitri Papadopoulos <3350651-DimitriPapadopoulos@users.noreply.gitlab.com>
3 years agoBuild with OpenSSL 3.0 beta 2 Release Candidate
Dimitri Papadopoulos [Sun, 1 Aug 2021 21:04:42 +0000 (23:04 +0200)]
Build with OpenSSL 3.0 beta 2 Release Candidate

From the OpenSSL 3.0 Migration guide:
The function code part of an OpenSSL error code is no longer relevant
This code is now always set to zero. Related functions are deprecated.

In our case, removing calls to ERR_GET_FUNC() will not change anything:

PKCS12_F_PKCS12_PARSE / PKCS12_R_MAC_VERIFY_FAILURE

The reason code PKCS12_R_MAC_VERIFY_FAILURE is raised in two OpenSSL functions:
* PKCS12_newpass() in p12_npas.c,
* PKCS12_parse() in p12_kiss.c.
In out code, we check the reason code is PKCS12_R_MAC_VERIFY_FAILURE after
calling PKCS12_parse(), so the incriminated function is necessarily
PKCS12_parse(). Verifying the function code is PKCS12_F_PKCS12_PARSE is
redundant.

EVP_F_EVP_DECRYPTFINAL_EX / EVP_R_BAD_DECRYPT

The reason code EVP_R_BAD_DECRYPT is raised in a single OpenSSL function:
* EVP_DecryptFinal_ex() in evp_enc.c
Therefore verifying the function code is EVP_F_EVP_DECRYPTFINAL_EX is
useless, EVP_F_EVP_DECRYPTFINAL_EX is the only possible value.

Signed-off-by: Dimitri Papadopoulos <3350651-DimitriPapadopoulos@users.noreply.gitlab.com>
3 years agoMerge branch 'codespell' into 'master'
David Woodhouse [Sat, 7 Aug 2021 14:58:47 +0000 (14:58 +0000)]
Merge branch 'codespell' into 'master'

Typos caught by codespell

See merge request openconnect/openconnect!265

3 years agoTypos caught by codespell
Dimitri Papadopoulos [Sat, 7 Aug 2021 12:34:11 +0000 (14:34 +0200)]
Typos caught by codespell

Signed-off-by: Dimitri Papadopoulos <3350651-DimitriPapadopoulos@users.noreply.gitlab.com>
3 years agoMerge branch 'ci' into 'master'
Daniel Lenski [Tue, 3 Aug 2021 19:12:57 +0000 (19:12 +0000)]
Merge branch 'ci' into 'master'

Get CI passing again

See merge request openconnect/openconnect!263

3 years agoMark auth-swtpm test as XFAIL on Fedora/OpenSSL and Fedora/OpenSSL/clang
Dimitri Papadopoulos [Sat, 31 Jul 2021 20:01:02 +0000 (22:01 +0200)]
Mark auth-swtpm test as XFAIL on Fedora/OpenSSL and Fedora/OpenSSL/clang

Apparently, verifying that either 'tsstartup' or 'tpm2_startup' is available
is *not* sufficient to make auth-swtpm tests work again. See error log at
https://gitlab.com/openconnect/openconnect/-/issues/287#note_641338923

[Originally by DP. DL added Fedora/OpenSSL/clang as well]

Signed-off-by: Dimitri Papadopoulos <3350651-DimitriPapadopoulos@users.noreply.gitlab.com>
Signed-off-by: Daniel Lenski <dlenski@gmail.com>
3 years agoVerify that TPMv2 startup tools are present in order to enable auth-swtpm tests
Daniel Lenski [Mon, 2 Aug 2021 20:41:29 +0000 (13:41 -0700)]
Verify that TPMv2 startup tools are present in order to enable auth-swtpm tests

Autoconf source now verifies that either 'tpm2_startup' or 'tsstartup' is
found before enabling this test.

See discussion at https://gitlab.com/openconnect/openconnect/-/issues/287#note_640185660.

I also added tpm2-tools (package providing 'tpm2_startup') to the Fedora
build image, in https://gitlab.com/openconnect/build-images/-/commit/35ee4ffb88ba319014c321dc8999e48fce81f130.

Signed-off-by: Daniel Lenski <dlenski@gmail.com>
3 years agoMark sync/no-HDLC PPP tests as XFAIL for all CI images
Daniel Lenski [Mon, 2 Aug 2021 16:58:04 +0000 (09:58 -0700)]
Mark sync/no-HDLC PPP tests as XFAIL for all CI images

See https://gitlab.com/openconnect/openconnect/-/issues/287#note_641198529 for discussions.

Across all CI images, non-HDLC PPP tests are consistently failing (this is
described as "synchronous" framing in the '90s-era terminology of pppd, and
is supported by 'pppd sync').

    FAIL: ppp-over-tls
    ==================
    Testing PPP ...
    [...]
    Starting PPP peer (sync/no-HDLC, IPv4+IPv6, DNS, extraneous VJ and CCP)... started in 0 seconds
    2021/07/31 20:54:18 socat[10622] E waitpid(): child 10625 exited with status 1
    Connecting to it with openconnect --protocol=nullppp... failed (after 0 seconds)
    [...]
    ===== START pppd log =====
    Couldn't set tty to PPP discipline: Invalid argument

The 'pppd sync' support has always appeared to be a fairly marginal part of
pppd capabilities, brittle and not well-tested, and I've run into other
problems with it before (see eaabbb09 for example).

This is frustrating because non-HDLC/pre-framed PPP is the version that is
(and should be!) used in all modern implementations of PPP, including F5 and
Fortinet's implementations.

This patch splits the sync/no-HDLC PPP test into a separate script
(ppp-over-tls-sync), and marks it as XFAIL for all CI runs, so that we can
continue to test it by default when running locally, and to fail on the
other PPP tests (which use async mode aka “HDLC-like” framing).

Signed-off-by: Daniel Lenski <dlenski@gmail.com>
3 years agoUse sysctl to un-disable IPv6 for all CI runs where PPP tests are enabled
Daniel Lenski [Sat, 31 Jul 2021 14:42:12 +0000 (07:42 -0700)]
Use sysctl to un-disable IPv6 for all CI runs where PPP tests are enabled

See https://gitlab.com/openconnect/openconnect/-/issues/287#note_640115686,
and https://gitlab.com/openconnect/vpnc-scripts/-/issues/12#note_547951023
for where this issue was originally discovered (specifically on the Ubuntu
18.04 CI runs).

Signed-off-by: Daniel Lenski <dlenski@gmail.com>
4 years agoAdd HAVE_EPOLL check to fix macOS build failure
Joerg Mayer [Thu, 29 Jul 2021 06:41:00 +0000 (23:41 -0700)]
Add HAVE_EPOLL check to fix macOS build failure

Closes https://gitlab.com/openconnect/openconnect/-/issues/285

Signed-off-by: Daniel Lenski <dlenski@gmail.com>
4 years agoMake all cert rules order-only
David Woodhouse [Wed, 28 Jul 2021 15:52:26 +0000 (16:52 +0100)]
Make all cert rules order-only

For some reason, perhaps a make update or perhaps just higher precision
timestamps causing some files to actually appear as older than others,
the CI has taken to rebuilding all the certs. Don't do that.

Signed-off-by: David Woodhouse <dwmw2@infradead.org>
4 years agoDo not truncate RSA-PSS salt length for small keys
David Woodhouse [Wed, 28 Jul 2021 11:22:07 +0000 (12:22 +0100)]
Do not truncate RSA-PSS salt length for small keys

RFC8446 forbids this, and it looks like it was a bug that it ever worked
against GnuTLS.

 • https://gitlab.com/gnutls/gnutls/-/issues/1258
 • https://github.com/openssl/openssl/issues/16167

Signed-off-by: David Woodhouse <dwmw2@infradead.org>
4 years agoFix selection of TPM2 key gen tools
Sabin Rapan [Wed, 28 Jul 2021 09:51:28 +0000 (12:51 +0300)]
Fix selection of TPM2 key gen tools

The comments on TPM2TSS_GENKEY and CREATE_TPM2_KEY say the former can
only create keys, while the latter can import them too, but we used them
the other way around. This causes the auth-hwtpm test to fail on
machines just with tpm2-tss-engine installed.

Tested on Ubuntu 20.04 with openssl and tpm2-tss.

Signed-off-by: Sabin Rapan <sabin.rapan@gmail.com>
4 years agoFix RSA-PSS padding with SHA384 for TPMv2 keys
David Woodhouse [Tue, 27 Jul 2021 13:47:42 +0000 (14:47 +0100)]
Fix RSA-PSS padding with SHA384 for TPMv2 keys

There seems to be a GnuTLS bug which was breaking SHA384 support. Work
around it by destroying the hash context and making a fresh one.

Signed-off-by: David Woodhouse <dwmw2@infradead.org>
4 years agoMerge branch 'DeviceIoControl_TAP_IOCTL_GET_VERSION' into 'master'
Dimitri Papadopoulos Orfanos [Wed, 21 Jul 2021 19:47:13 +0000 (19:47 +0000)]
Merge branch 'DeviceIoControl_TAP_IOCTL_GET_VERSION' into 'master'

Fix Linux kernel coding style warning

Closes #275

See merge request openconnect/openconnect!253

4 years agoMerge branch 'INITIALISED_STATIC' into 'master'
Dimitri Papadopoulos Orfanos [Wed, 21 Jul 2021 19:44:41 +0000 (19:44 +0000)]
Merge branch 'INITIALISED_STATIC' into 'master'

Fix Linux kernel coding style error

Closes #276

See merge request openconnect/openconnect!250

4 years agoShut static analyser up
Dimitri Papadopoulos [Sun, 18 Jul 2021 11:44:15 +0000 (13:44 +0200)]
Shut static analyser up

Signed-off-by: Dimitri Papadopoulos <3350651-DimitriPapadopoulos@users.noreply.gitlab.com>
4 years agoFix Linux kernel coding style error
Dimitri Papadopoulos [Sat, 17 Jul 2021 10:00:05 +0000 (12:00 +0200)]
Fix Linux kernel coding style error

do not initialise statics to 0
do not initialise statics to NULL

Signed-off-by: Dimitri Papadopoulos <3350651-DimitriPapadopoulos@users.noreply.gitlab.com>
4 years agoFix Linux kernel coding style warning
Dimitri Papadopoulos [Sun, 18 Jul 2021 19:02:11 +0000 (21:02 +0200)]
Fix Linux kernel coding style warning

Fix a single SIZEOF_ADDRESS warning.

While I haven't found official documentation for the TAP_IOCTL_GET_VERSION
control code, clearly the DeviceIoControl() parameters were incorrect,
see other online examples:
https://github.com/juhovh/tapcfg/blob/3d5ef74/src/lib/tapcfg_windows.c#L140-L146
https://github.com/OpenVPN/openvpn/blob/34b4254/src/openvpn/tun.c#L6030-L6032

Signed-off-by: Dimitri Papadopoulos <3350651-DimitriPapadopoulos@users.noreply.gitlab.com>
4 years agoMerge branch 'ooops' into 'master'
Dimitri Papadopoulos Orfanos [Mon, 19 Jul 2021 11:45:00 +0000 (11:45 +0000)]
Merge branch 'ooops' into 'master'

Fix typo from previous merge request

See merge request openconnect/openconnect!254

4 years agoMerge branch 'LINE_CONTINUATIONS' into 'master'
Dimitri Papadopoulos Orfanos [Mon, 19 Jul 2021 11:28:15 +0000 (11:28 +0000)]
Merge branch 'LINE_CONTINUATIONS' into 'master'

Fix Linux kernel coding style warning

See merge request openconnect/openconnect!249

4 years agoFix Linux kernel coding style warning
Dimitri Papadopoulos [Sat, 17 Jul 2021 09:41:35 +0000 (11:41 +0200)]
Fix Linux kernel coding style warning

Avoid unnecessary line continuations

Signed-off-by: Dimitri Papadopoulos <3350651-DimitriPapadopoulos@users.noreply.gitlab.com>
4 years agoFix typo from 275d838
Dimitri Papadopoulos [Mon, 19 Jul 2021 04:30:19 +0000 (06:30 +0200)]
Fix typo from 275d838

Signed-off-by: Dimitri Papadopoulos <3350651-DimitriPapadopoulos@users.noreply.gitlab.com>
4 years agoMerge branch 'SINGLE_STATEMENT_DO_WHILE_MACRO' into 'master'
Dimitri Papadopoulos Orfanos [Mon, 19 Jul 2021 05:06:02 +0000 (05:06 +0000)]
Merge branch 'SINGLE_STATEMENT_DO_WHILE_MACRO' into 'master'

Fix Linux kernel coding style warning

See merge request openconnect/openconnect!248