]> www.infradead.org Git - users/dwmw2/openconnect.git/log
users/dwmw2/openconnect.git
4 years agohandle rejecting either IPCP or IP6CP, as long as ≥1 wanted network protocol gets...
Daniel Lenski [Wed, 20 May 2020 02:30:56 +0000 (19:30 -0700)]
handle rejecting either IPCP or IP6CP, as long as ≥1 wanted network protocol gets be configured

More testing with pppd...

Signed-off-by: Daniel Lenski <dlenski@gmail.com>
4 years agologging direction fix
Daniel Lenski [Wed, 20 May 2020 02:18:29 +0000 (19:18 -0700)]
logging direction fix

Signed-off-by: Daniel Lenski <dlenski@gmail.com>
4 years agoremove vestigial copy/pasted bits from F5/Fortinet
Daniel Lenski [Wed, 20 May 2020 01:46:15 +0000 (18:46 -0700)]
remove vestigial copy/pasted bits from F5/Fortinet

Signed-off-by: Daniel Lenski <dlenski@gmail.com>
4 years agouse check_address_sanity for F5 too
Daniel Lenski [Wed, 20 May 2020 01:45:51 +0000 (18:45 -0700)]
use check_address_sanity for F5 too

Signed-off-by: Daniel Lenski <dlenski@gmail.com>
4 years agoMerge branch 'check_address_sanity' into f5
Daniel Lenski [Wed, 20 May 2020 01:41:38 +0000 (18:41 -0700)]
Merge branch 'check_address_sanity' into f5

4 years agoopenconnect_make_cstp_connection should always set ssl_times.last_tx on successful...
Daniel Lenski [Fri, 26 Apr 2019 01:32:43 +0000 (20:32 -0500)]
openconnect_make_cstp_connection should always set ssl_times.last_tx on successful connection

As suggested by David Woodhouse (https://gitlab.com/openconnect/openconnect/merge_requests/35#note_163190180)

Signed-off-by: Daniel Lenski <dlenski@gmail.com>
4 years agoadd comment on openconnect__inet_aton(), which is not 100% compatible with "real...
Daniel Lenski [Thu, 25 Apr 2019 16:29:06 +0000 (11:29 -0500)]
add comment on openconnect__inet_aton(), which is not 100% compatible with "real" inet_aton()

Signed-off-by: Daniel Lenski <dlenski@gmail.com>
4 years agofactor out check_address_sanity() from gpst.c and cstp.c, and use it in oncp.c and...
Daniel Lenski [Wed, 22 May 2019 20:14:03 +0000 (13:14 -0700)]
factor out check_address_sanity() from gpst.c and cstp.c, and use it in oncp.c and pulse.c as well

Suggested by David Woodhouse: https://gitlab.com/openconnect/openconnect/merge_requests/35#note_169620281

Signed-off-by: Daniel Lenski <dlenski@gmail.com>
4 years agogpst.c should also return -EPERM when server changes IP address, not -EINVAL
Daniel Lenski [Wed, 22 May 2019 18:55:59 +0000 (11:55 -0700)]
gpst.c should also return -EPERM when server changes IP address, not -EINVAL

(see previous commit by David Woodhouse, 24df3311ab42f062dbf1aeb7f3432dd45426e9cf, which did this for cstp.c)

Signed-off-by: Daniel Lenski <dlenski@gmail.com>
4 years agoProtocols should try explicitly request the same IP addresses on reconnect, since...
Daniel Lenski [Thu, 21 Dec 2017 06:56:58 +0000 (22:56 -0800)]
Protocols should try explicitly request the same IP addresses on reconnect, since they will abort if new addresses are sent by the server.

* GlobalProtect:
  - Supported and used by official clients (POST /ssl-vpn/getconfig.esp with preferred-ip form field).
  - GlobalProtect servers often give different IP addresses on reconnect if this mechanism is *not* used,
    so this mechanism is necessary.
  - Same mechanism appears to exist for IPv6 (preferred-ipv6) and was added to OpenConnect in
    d6db0ec03394234d41fbec7ffc794ceeb486a8f0, even though IPv6 support is not yet complete.
* AnyConnect:
  - Not (yet) supported by ocserv
  - It appears that *some* AnyConnect server will try to provide the IP address provided in the X-CSTP-Address
    *request* header along with the CONNECT request, but other servers appear not to
  - This patch reproduces the behavior of GPST: attempt to request same IPv4 and IPv6 addresses on reconnect,
    via CONNECT headers.
* Juniper:
  - There does not appear to be any way to provide this using the Juniper NC protocol.
  - No known reports of Juniper servers giving out different IP address on reconnect.

Signed-off-by: Daniel Lenski <dlenski@gmail.com>
4 years agopppd regularly drops initial HDLC flag sequence, and we missed two bytes in Van Jacob...
Daniel Lenski [Tue, 19 May 2020 23:23:31 +0000 (16:23 -0700)]
pppd regularly drops initial HDLC flag sequence, and we missed two bytes in Van Jacobson compression format

Signed-off-by: Daniel Lenski <dlenski@gmail.com>
4 years agoadd 'nullppp' protocol for testing
Daniel Lenski [Tue, 19 May 2020 21:36:48 +0000 (14:36 -0700)]
add 'nullppp' protocol for testing

Use `socat` to set up a PTY connected to a TLS socket (listening only on the local interface):

    socat -s -d -d \
      PTY,raw,b9600 \
      OPENSSL-LISTEN:5556,cert=tests/certs/server-cert.pem,key=tests/certs/server-key.pem,verify=0,so-bindtodevice=lo
    [ N PTY is /dev/pts/X ]

Connect the PTY to `pppd` (requires root):

    # Add 'sync' to disable HDLC framing
    sudo pppd /dev/pts/X 10.0.0.1:10.0.0.101 noauth debug dump logfd 2 local nodetach passive persist ms-dns 1.1.1.1 ms-wins 5.5.5.5 +ipv6

Connect OpenConnect to the TLS socket, and watch it negotiate LCP/IPCP/IP6CP with its peer, and reject CCP:

    # Add noipv4,noipv6 to cookie to try those
    ./openconnect --protocol=nullppp --cookie hdlc --servercert=d66b507ae074d03b02eafca40d35f87dd81049d3 --dump localhost:5556

Signed-off-by: Daniel Lenski <dlenski@gmail.com>
4 years agofix crash when we receive unknown protocol before agreeing on MRU/MTU
Daniel Lenski [Tue, 19 May 2020 21:51:33 +0000 (14:51 -0700)]
fix crash when we receive unknown protocol before agreeing on MRU/MTU

Signed-off-by: Daniel Lenski <dlenski@gmail.com>
4 years agopervasive PPP protocol pretty-printing
Daniel Lenski [Tue, 19 May 2020 21:26:16 +0000 (14:26 -0700)]
pervasive PPP protocol pretty-printing

Signed-off-by: Daniel Lenski <dlenski@gmail.com>
4 years agoadd standard-based PPP framing (RFC1661, RFC1662) as reference points
Daniel Lenski [Tue, 19 May 2020 17:54:22 +0000 (10:54 -0700)]
add standard-based PPP framing (RFC1661, RFC1662) as reference points

- PPP_ENCAP_RFC1661: Plain PPP. “Synchronous” in the ’90s-era language,
  because the start and end of the frame are known from external means.

  In modern instances, this is because they arrive in a complete packet with
  a known length from its lower-level encapsulation. (TLS or DTLS records in
  our expected use cases.)

  This is what `pppd sync` does.

- PPP_ENCAP_RFC1662: “PPP in HDLC-like framing.”

  This is what `pppd` without `sync` does.

At some point, we will be able to add automated testing of our PPP
implementation's ability to communicate with `pppd`.

Signed-off-by: Daniel Lenski <dlenski@gmail.com>
4 years agoFix Signed-off-by CI check
David Woodhouse [Mon, 18 May 2020 18:18:30 +0000 (19:18 +0100)]
Fix Signed-off-by CI check

Signed-off-by: David Woodhouse <dwmw2@infradead.org>
4 years agochange delay_tunnel → delay_tunnel_reason, use for DTLS MTU detection and GPST ESP...
Daniel Lenski [Mon, 18 May 2020 05:46:28 +0000 (22:46 -0700)]
change delay_tunnel → delay_tunnel_reason, use for DTLS MTU detection and GPST ESP connection delays as well

As suggested here: https://gitlab.com/openconnect/openconnect/-/commit/55ffb457010974c05096a78ac917692b7fac664b#note_343873848

There's no clear rationale for using with Pulse/oNCP ESP setup (yet):
- We don't do any MTU detection
- Unlike GPST, we can start sending and receiving packets via the TLS tunnel
  immediately, while attempting to connect ESP as well.

Signed-off-by: Daniel Lenski <dlenski@gmail.com>
4 years agouse IPv6 interface identifier to build link-local address if we don't have a global one
Daniel Lenski [Mon, 18 May 2020 01:28:19 +0000 (18:28 -0700)]
use IPv6 interface identifier to build link-local address if we don't have a global one

Per RFC5072 (https://tools.ietf.org/html/rfc5072), that's what we're supposed to do with it.

See https://gitlab.com/openconnect/openconnect/-/commit/9f387fb21a0243da667521c2f2bca780bab3757c#note_343872233

Signed-off-by: Daniel Lenski <dlenski@gmail.com>
4 years agohard-code browser UA into test-fortinet-login.py
Daniel Lenski [Sun, 17 May 2020 23:37:33 +0000 (16:37 -0700)]
hard-code browser UA into test-fortinet-login.py

See https://gitlab.com/openconnect/openconnect/-/issues/142#note_343854311

Signed-off-by: Daniel Lenski <dlenski@gmail.com>
4 years agoNeed to handle case where rejected protocol was sent as only 1 byte
Daniel Lenski [Sun, 17 May 2020 23:27:52 +0000 (16:27 -0700)]
Need to handle case where rejected protocol was sent as only 1 byte

… as well as the admittedly-unlikely case where the rejected protocol is
larger than peer's MRU (which we've already accepted as our MTU).

Signed-off-by: Daniel Lenski <dlenski@gmail.com>
4 years agoppp: Reject unknown protocols
Andreas Gnau [Sun, 17 May 2020 17:46:09 +0000 (19:46 +0200)]
ppp: Reject unknown protocols

NX won't send any IPCP requests until CCP negotiation is completed.
Since we don't want to implement compression for now (or ever), reject
unknown protocols with an LCP Protocol-Reject (cf. RFC 1661, ch. 5.7).

Signed-off-by: Andreas Gnau <rondom@rondom.de>
4 years agomake delay_tunnel consistent with delay_close
Daniel Lenski [Sun, 17 May 2020 19:46:43 +0000 (12:46 -0700)]
make delay_tunnel consistent with delay_close

1. Decrement counter on each mainloop iteration. Protocol needs to keep setting it to get more mainloop iterations before tunnel setup / close.
2. Value ≥2 causes us to set did_work=1, resulting in no delay before we call mainloop again. Protocol should only set this if it needs to SEND something in order to move things along.
3. Value =1 causes us to set did_work=0, resulting in a delay before we call mainloop again. Protocol should only set this if it needs to RECEIVE something in order to move things along.

Also fix values of NCP_TERM_ACK_{SENT,RECEIVED}.

Signed-off-by: Daniel Lenski <dlenski@gmail.com>
4 years agoattempt to coax server to accept a larger MRU by nak-offering our MTU if it's greater...
Daniel Lenski [Sun, 17 May 2020 20:02:31 +0000 (13:02 -0700)]
attempt to coax server to accept a larger MRU by nak-offering our MTU if it's greater than the server's MRU

We only attempt this once before giving up.

Tested on F5, and this works: we nak-offer a larger MRU, and the server
responds with a new CONFACK requesting the same value.

The F5 server often offers erroneously low MRU values, too small for IPv6
(minimum MTU of 1280), and is consistently strict about not accepting
incoming IP packets which are even 1 byte larger than its MRU, so this is
useful. 🍺

Signed-off-by: Daniel Lenski <dlenski@gmail.com>
4 years agohandle CONFNAK of our magic number by trying a new one
Daniel Lenski [Sun, 17 May 2020 06:11:20 +0000 (23:11 -0700)]
handle CONFNAK of our magic number by trying a new one

(Also, prevent translators from killing me.)

Signed-off-by: Daniel Lenski <dlenski@gmail.com>
4 years agodon't solicit DNS/NBNS servers unless we have neither
Daniel Lenski [Sun, 17 May 2020 06:03:48 +0000 (23:03 -0700)]
don't solicit DNS/NBNS servers unless we have neither

Saves a CONFREQ/CONFNAK-offer round-trip

Signed-off-by: Daniel Lenski <dlenski@gmail.com>
4 years agohandle state transition after sending config packets as well, and prevent race condit...
Daniel Lenski [Sun, 17 May 2020 06:01:49 +0000 (23:01 -0700)]
handle state transition after sending config packets as well, and prevent race conditions on reconnection after dead peer torture testing

Signed-off-by: Daniel Lenski <dlenski@gmail.com>
4 years agofix too-early fallthrough from OPENED to NETWORK state
Daniel Lenski [Sun, 17 May 2020 07:04:12 +0000 (00:04 -0700)]
fix too-early fallthrough from OPENED to NETWORK state

Signed-off-by: Daniel Lenski <dlenski@gmail.com>
4 years agoallegedly universal MTU calculator: use for GPST and PPP
Daniel Lenski [Sat, 16 May 2020 22:51:46 +0000 (15:51 -0700)]
allegedly universal MTU calculator: use for GPST and PPP

Signed-off-by: Daniel Lenski <dlenski@gmail.com>
4 years agoadd delay_close and use it for clean PPP termination on cancel, pause, or server...
Daniel Lenski [Sun, 17 May 2020 02:31:22 +0000 (19:31 -0700)]
add delay_close and use it for clean PPP termination on cancel, pause, or server-sent termination

Whatever delay_close is set to decrements on each mainloop iteration, and
if delay_close == 1, we don't set work_done.

This allows us to set delay_close = 2 for the case where we need to send a termination request
immediately, and then wait briefly for an acknowledgment.

Signed-off-by: Daniel Lenski <dlenski@gmail.com>
4 years agorestore PPP state transition fallthroughs
Daniel Lenski [Sun, 17 May 2020 00:12:22 +0000 (17:12 -0700)]
restore PPP state transition fallthroughs

otherwise we won't actually “go first” in terms of sending our config requests

Signed-off-by: Daniel Lenski <dlenski@gmail.com>
4 years agowe should still try to cleanly close the session if tun device creation fails
Daniel Lenski [Sun, 17 May 2020 00:09:24 +0000 (17:09 -0700)]
we should still try to cleanly close the session if tun device creation fails

Signed-off-by: Daniel Lenski <dlenski@gmail.com>
4 years agoadd delay_tunnel flag to delay tunnel creation
Daniel Lenski [Sun, 17 May 2020 00:06:10 +0000 (17:06 -0700)]
add delay_tunnel flag to delay tunnel creation

Signed-off-by: Daniel Lenski <dlenski@gmail.com>
4 years agovalgrind: fix f5 mem leaks
Daniel Lenski [Sun, 17 May 2020 00:50:15 +0000 (17:50 -0700)]
valgrind: fix f5 mem leaks

Signed-off-by: Daniel Lenski <dlenski@gmail.com>
4 years agouse ACK/NAK request mechanism to request IPv4 address, (IPv4) DNS/NBNS addresses...
Daniel Lenski [Sat, 16 May 2020 01:03:45 +0000 (18:03 -0700)]
use ACK/NAK request mechanism to request IPv4 address, (IPv4) DNS/NBNS addresses, and IPv6 interface identifiers

The idea is that if we CONFREQ an all-zero value for one of these.
PPP server/peer is supposed to:

- CONFNAK with a value filled in, which we then re-CONFREQ to confirm.
- CONFREJ if it can't supply a value (e.g. NBNS servers because it's
  not 1994 and we're not using Windows for Workgroups 3.11).

Tested with F5, by overriding ppp->solicit_peerns=7, ppp->out_peer_addr.s_addr=0,
ppp->out_ipv6_int_ident=0 in openconnect_ppp_new (even though F5 in fact sends these
addresses in the XML config prior to PPP tunnel).

The CONFREQ/CONFNAK/re-CONFREQ exchange is inefficient, requiring three rounds trips
(request and reject, partial re-request and nak, confirming request and ack), but it
works:

    Sending PPP IPCP Configure-Request packet (id 1, 34 bytes total)
    > 0000:  f5 00 00 1e 80 21 01 01  00 1c 03 06 00 00 00 00  |.....!..........|
    > 0010:  81 06 00 00 00 00 82 06  00 00 00 00 83 06 00 00  |................|
    > 0020:  00 00                                             |..|

    ...

    Received proto 0x8021/id 1 Configure-Reject from server
    Server rejected IPCP request for NBNS[1] server
    Server rejected IPCP request for DNS[1] server
    Server rejected IPCP request for NBNS[0] server

    ...

    Sending our proto 0x8021/id 2 config request to server
    < 0000:  f5 00 00 10 80 57 02 01  00 0e 01 0a e0 a7 1c fb  |.....W..........|
    < 0010:  9e 55 00 00                                       |.U..|
    Sending PPP IPCP Configure-Request packet (id 2, 22 bytes total)
    > 0000:  f5 00 00 12 80 21 01 02  00 10 03 06 00 00 00 00  |.....!..........|
    > 0010:  81 06 00 00 00 00                                 |......|
    No work to do; sleeping for 3000 ms...
    < 0000:  f5 00 00 12 80 21 03 02  00 10 03 06 0a 00 00 17  |.....!..........|
    < 0010:  81 06 5a 9b 5c d1                                 |..Z.\.|
    Received proto 0x8021/id 2 Configure-Nak from server
    Server nak-offered IPv4 address: 10.0.0.23
    Server nak-offered IPCP request for DNS[0] server: 90.155.92.209

    ...

    Sending our proto 0x8021/id 3 config request to server
    Sending PPP IPCP Configure-Request packet (id 3, 16 bytes total)
    > 0000:  f5 00 00 0c 80 21 01 03  00 0a 03 06 0a 00 00 17  |.....!..........|
    No work to do; sleeping for 3000 ms...
    < 0000:  f5 00 00 0c 80 21 02 03  00 0a 03 06 0a 00 00 17  |.....!..........|
    Received proto 0x8021/id 3 Configure-Ack from server
    PPP state transition from OPENED to NETWORK
    Current PPP state: NETWORK (encap F5):
        in: asyncmap=0x00000000, lcp_opts=384, lcp_magic=0x04eb81f9, peer=1.1.1.1
       out: asyncmap=0x00000000, lcp_opts=422, lcp_magic=0x70ac508f, peer=10.0.0.23, solicit_peerns=0

The purpose of the IPv6 interface identifier negotiation is unclear, but the F5
server does not accept a zero value, using CONFNAK to offer a new one.

Signed-off-by: Daniel Lenski <dlenski@gmail.com>
4 years agofriendlier logging of outgoing PPP packets
Daniel Lenski [Sat, 16 May 2020 00:57:45 +0000 (17:57 -0700)]
friendlier logging of outgoing PPP packets

Signed-off-by: Daniel Lenski <dlenski@gmail.com>
4 years agocreate vpninfo->ppp in-place
Daniel Lenski [Sat, 16 May 2020 00:54:41 +0000 (17:54 -0700)]
create vpninfo->ppp in-place

Signed-off-by: Daniel Lenski <dlenski@gmail.com>
4 years agofix logging of unknown TLV lengths, and copy-paste mistake
Daniel Lenski [Sat, 16 May 2020 00:54:41 +0000 (17:54 -0700)]
fix logging of unknown TLV lengths, and copy-paste mistake

Signed-off-by: Daniel Lenski <dlenski@gmail.com>
4 years agoadd secure_cookie protocol field to suppress other protocols' cookies from --dump...
Daniel Lenski [Fri, 6 Mar 2020 21:52:18 +0000 (13:52 -0800)]
add secure_cookie protocol field to suppress other protocols' cookies from --dump-http-traffic as well

Signed-off-by: Daniel Lenski <dlenski@gmail.com>
4 years agothanks Coverity
Daniel Lenski [Fri, 15 May 2020 21:41:33 +0000 (14:41 -0700)]
thanks Coverity

Signed-off-by: Daniel Lenski <dlenski@gmail.com>
4 years agoMerge branch 'add_set_cookie' of gitlab.com:randymoss/openconnect
David Woodhouse [Fri, 15 May 2020 16:06:31 +0000 (17:06 +0100)]
Merge branch 'add_set_cookie' of gitlab.com:randymoss/openconnect

4 years agoAdd `openconnect_set_cookie` function to library and jni
Randy Moss [Fri, 15 May 2020 16:04:53 +0000 (16:04 +0000)]
Add `openconnect_set_cookie` function to library and jni
Signed-off-by: Randy Moss <kasaxet794@homedepinst.com>
4 years agoAdd missing files to tarball for win32 build
Justin Kendrick [Thu, 14 May 2020 21:56:25 +0000 (16:56 -0500)]
Add missing files to tarball for win32 build

Fixes building from distribution tarball on win32/mingw.

Makefile.am: Include win32-ipicmp.h and openconnect.ico in tarball

Signed-off-by: Justin Kendrick <justin@kendrick.tech>
4 years agosuppress warnings
Daniel Lenski [Fri, 15 May 2020 15:34:03 +0000 (08:34 -0700)]
suppress warnings

Signed-off-by: Daniel Lenski <dlenski@gmail.com>
4 years agoCheck for Signed-off-by: in CI
David Woodhouse [Fri, 15 May 2020 13:00:39 +0000 (14:00 +0100)]
Check for Signed-off-by: in CI

Signed-off-by: David Woodhouse <dwmw2@infradead.org>
4 years agoRun Coverity only in openconnect/openconnect repo
David Woodhouse [Fri, 15 May 2020 12:33:56 +0000 (13:33 +0100)]
Run Coverity only in openconnect/openconnect repo

It won't work in someone else's master branch if they've forked the repo.

Signed-off-by: David Woodhouse <dwmw2@infradead.org>
4 years agoUpdate packages documentation
David Woodhouse [Fri, 15 May 2020 10:32:14 +0000 (11:32 +0100)]
Update packages documentation

Signed-off-by: David Woodhouse <dwmw2@infradead.org>
4 years agoRemove Fedora updates-testing packages now pushed to stable
David Woodhouse [Fri, 15 May 2020 09:34:31 +0000 (10:34 +0100)]
Remove Fedora updates-testing packages now pushed to stable

Signed-off-by: David Woodhouse <dwmw2@infradead.org>
4 years agoWork around SoftHSM lockup in CI
David Woodhouse [Fri, 15 May 2020 09:31:27 +0000 (10:31 +0100)]
Work around SoftHSM lockup in CI

Signed-off-by: David Woodhouse <dwmw2@infradead.org>
4 years agoIsn't this great?
Daniel Lenski [Fri, 15 May 2020 02:19:50 +0000 (19:19 -0700)]
Isn't this great?

Signed-off-by: Daniel Lenski <dlenski@gmail.com>
4 years agoattempted support for concatenated packets
Daniel Lenski [Fri, 15 May 2020 01:48:55 +0000 (18:48 -0700)]
attempted support for concatenated packets

Plus add comments about what each variable points to and when, during packet parsing.

Tested with F5 HDLC and non-HDLC. Doesn't complain about leftover bytes, or short/incomplete packets, but NOT YET
actually tested with concatenated packets.

Signed-off-by: Daniel Lenski <dlenski@gmail.com>
4 years agomove checking of config packet length to handle_config_packet
Daniel Lenski [Fri, 15 May 2020 01:44:43 +0000 (18:44 -0700)]
move checking of config packet length to handle_config_packet

Signed-off-by: Daniel Lenski <dlenski@gmail.com>
4 years agocan't determine encap-header location until after HDLC'ing
Daniel Lenski [Thu, 14 May 2020 23:38:33 +0000 (16:38 -0700)]
can't determine encap-header location until after HDLC'ing

Tested with F5 HDLC and non-HLDC

Signed-off-by: Daniel Lenski <dlenski@gmail.com>
4 years agofactor out redundancy in HDLC de-encapsulation
Daniel Lenski [Thu, 14 May 2020 22:15:46 +0000 (15:15 -0700)]
factor out redundancy in HDLC de-encapsulation

Tested with F5 HDLC and non-HDLC

Signed-off-by: Daniel Lenski <dlenski@gmail.com>
4 years agoremove redundancy in HDLC encapsulation
Daniel Lenski [Thu, 14 May 2020 21:42:36 +0000 (14:42 -0700)]
remove redundancy in HDLC encapsulation

Tested with F5 HDLC and non-HDLC

Signed-off-by: Daniel Lenski <dlenski@gmail.com>
4 years agofactor out add_ppp_header
Daniel Lenski [Thu, 14 May 2020 22:14:57 +0000 (15:14 -0700)]
factor out add_ppp_header

Tested with F5 HDLC and non-HDLC

Signed-off-by: Daniel Lenski <dlenski@gmail.com>
4 years agofix HDLC packet logging buffer overflow
Daniel Lenski [Thu, 14 May 2020 21:30:41 +0000 (14:30 -0700)]
fix HDLC packet logging buffer overflow

Signed-off-by: Daniel Lenski <dlenski@gmail.com>
4 years agon != ppp.hlen for HDLC (will only work by coincidence if PPP header is uncompressed...
Daniel Lenski [Thu, 14 May 2020 21:41:19 +0000 (14:41 -0700)]
n != ppp.hlen for HDLC (will only work by coincidence if PPP header is uncompressed/4 bytes)

See https://gitlab.com/openconnect/openconnect/-/commit/c060e713f7aba546ccc3a1e729dd6e2e21e0e43b#note_342889873

Signed-off-by: Daniel Lenski <dlenski@gmail.com>
4 years agocheck pre-un-HDLC packet length for NX
Daniel Lenski [Thu, 14 May 2020 22:52:41 +0000 (15:52 -0700)]
check pre-un-HDLC packet length for NX

Signed-off-by: Daniel Lenski <dlenski@gmail.com>
4 years agofix a couple off-by-encap_len bits of NX
Daniel Lenski [Thu, 14 May 2020 21:26:58 +0000 (14:26 -0700)]
fix a couple off-by-encap_len bits of NX

Signed-off-by: Daniel Lenski <dlenski@gmail.com>
4 years agoFix COPR release builds for mingw-openconnect
David Woodhouse [Thu, 14 May 2020 18:51:07 +0000 (19:51 +0100)]
Fix COPR release builds for mingw-openconnect

For release builds, the tarball contents still don't have the default
name; we need to explicitly state that it's openconnect-%{version}

Signed-off-by: David Woodhouse <dwmw2@infradead.org>
4 years agoMerge branch 'nx' of https://gitlab.com/Rondom/openconnect into f5
David Woodhouse [Thu, 14 May 2020 16:33:06 +0000 (17:33 +0100)]
Merge branch 'nx' of https://gitlab.com/Rondom/openconnect into f5

4 years agoMerge branch 'master' of git.infradead.org:public_git/openconnect into f5
David Woodhouse [Thu, 14 May 2020 16:31:30 +0000 (17:31 +0100)]
Merge branch 'master' of git.infradead.org:public_git/openconnect into f5

4 years agoAdd initial SonicWall NetExtender support
Andreas Gnau [Mon, 11 May 2020 19:20:58 +0000 (21:20 +0200)]
Add initial SonicWall NetExtender support

LCP works, no error handling yet.

Signed-off-by: Andreas Gnau <rondom@rondom.de>
4 years agoTag version 8.10 v8.10
David Woodhouse [Thu, 14 May 2020 15:46:24 +0000 (16:46 +0100)]
Tag version 8.10

Signed-off-by: David Woodhouse <dwmw2@infradead.org>
4 years agoUpdate changelog
David Woodhouse [Thu, 14 May 2020 15:27:43 +0000 (16:27 +0100)]
Update changelog

Signed-off-by: David Woodhouse <dwmw2@infradead.org>
4 years agoMerge branch 'bug721570' of gitlab.com:floppym/openconnect
David Woodhouse [Thu, 14 May 2020 15:09:14 +0000 (16:09 +0100)]
Merge branch 'bug721570' of gitlab.com:floppym/openconnect

4 years agoBump Android API level to 23 to allow it to run on Android 10
David Woodhouse [Thu, 14 May 2020 13:28:21 +0000 (14:28 +0100)]
Bump Android API level to 23 to allow it to run on Android 10

Nobody cares about older API versions, which would only be needed
to support Android versions older than 6.0.

cf. https://gitlab.com/openconnect/openconnect/-/merge_requests/92

Signed-off-by: David Woodhouse <dwmw2@infradead.org>
4 years agoUpdate Android dependencies
David Woodhouse [Thu, 14 May 2020 11:56:46 +0000 (12:56 +0100)]
Update Android dependencies

Update GnuTLS, libxml2, nettle, gmp and lz4

Based on a patch from Severus <huynhok.uit@gmail.com>

Signed-off-by: David Woodhouse <dwmw2@infradead.org>
4 years agoMerge branch 'Juniper_frmNextToken_submit_button' of gitlab.com:openconnect/openconnect
David Woodhouse [Thu, 14 May 2020 11:18:41 +0000 (12:18 +0100)]
Merge branch 'Juniper_frmNextToken_submit_button' of gitlab.com:openconnect/openconnect

4 years agoMerge branch 'GP_stop_asking_to_report_unexpected_arg19=4' of gitlab.com:openconnect...
David Woodhouse [Thu, 14 May 2020 11:09:31 +0000 (12:09 +0100)]
Merge branch 'GP_stop_asking_to_report_unexpected_arg19=4' of gitlab.com:openconnect/openconnect

4 years agoMerge branch 'do_not_strip_newlines_in_CSD_response' of gitlab.com:dlenski/openconnect
David Woodhouse [Thu, 14 May 2020 10:50:07 +0000 (11:50 +0100)]
Merge branch 'do_not_strip_newlines_in_CSD_response' of gitlab.com:dlenski/openconnect

4 years agoTidy up PPP strings
David Woodhouse [Thu, 14 May 2020 10:27:21 +0000 (11:27 +0100)]
Tidy up PPP strings

Signed-off-by: David Woodhouse <dwmw2@infradead.org>
4 years agoparse real Fortinet config
Daniel Lenski [Thu, 14 May 2020 03:41:00 +0000 (20:41 -0700)]
parse real Fortinet config

Based on these two real examples (https://forum.fortinet.com/tm.aspx?m=170415 and https://forum.fortinet.com/tm.aspx?m=105123).

Tested with sample XML in comments.

Signed-off-by: Daniel Lenski <dlenski@gmail.com>
4 years agoadd test-fortinet-login.py
Daniel Lenski [Wed, 13 May 2020 21:29:41 +0000 (14:29 -0700)]
add test-fortinet-login.py

Often easier to prototype HTTPS-based authentication flows in Python, since
they're so fiddly and arbitary.  So I copied `test-f5-login.py` to
`test-fortinet-login.py`.  Currently only handles basic
username-and-password auth, no 2FA:

```
usage: test-fortinet-login.py [-h] [-v] [-u USERNAME] [-p PASSWORD] [-r REALM]
                              [-c CERT] [--key KEY] [--no-verify]
                              endpoint [extra [extra ...]]

positional arguments:
  endpoint              Fortinet server (or complete URL, e.g.
                        https://forti.vpn.com/remote/login)
  extra                 Extra field to pass to include in the login query
                        string (e.g. "foo=bar")

optional arguments:
  -h, --help            show this help message and exit
  -v, --verbose
  --no-verify           Ignore invalid server certificate

Login credentials:
  -u USERNAME, --username USERNAME
                        Username (will prompt if unspecified)
  -p PASSWORD, --password PASSWORD
                        Password (will prompt if unspecified)
  -r REALM, --realm REALM
                        Realm (empty if unspecified)
  -c CERT, --cert CERT  PEM file containing client certificate (and optionally
                        private key)
  --key KEY             PEM file containing client private key (if not
                        included in same file as certificate)
```

Signed-off-by: Daniel Lenski <dlenski@gmail.com>
4 years agoBasic ConfRej handling
David Woodhouse [Wed, 13 May 2020 21:21:29 +0000 (22:21 +0100)]
Basic ConfRej handling

Signed-off-by: David Woodhouse <dwmw2@infradead.org>
4 years agoMerge branch 'f5' of gitlab.com:openconnect/openconnect
David Woodhouse [Wed, 13 May 2020 18:25:40 +0000 (19:25 +0100)]
Merge branch 'f5' of gitlab.com:openconnect/openconnect

4 years agoUse LCP protocol code values for feature bitmask
David Woodhouse [Wed, 13 May 2020 18:25:09 +0000 (19:25 +0100)]
Use LCP protocol code values for feature bitmask

In preparation for handling ConfRej

Signed-off-by: David Woodhouse <dwmw2@infradead.org>
4 years agosecond time's a charm?
Daniel Lenski [Wed, 13 May 2020 18:07:43 +0000 (11:07 -0700)]
second time's a charm?

Signed-off-by: Daniel Lenski <dlenski@gmail.com>
4 years agoFewer magic numbers for NCP opts
David Woodhouse [Wed, 13 May 2020 18:07:22 +0000 (19:07 +0100)]
Fewer magic numbers for NCP opts

Signed-off-by: David Woodhouse <dwmw2@infradead.org>
4 years agoMake encap_names[] compile again
David Woodhouse [Wed, 13 May 2020 17:53:27 +0000 (18:53 +0100)]
Make encap_names[] compile again

Signed-off-by: David Woodhouse <dwmw2@infradead.org>
4 years agoMerge branch 'master' of git.infradead.org:public_git/openconnect
David Woodhouse [Wed, 13 May 2020 17:50:26 +0000 (18:50 +0100)]
Merge branch 'master' of git.infradead.org:public_git/openconnect

4 years agofix encap_names for Fortinet HDLC
Daniel Lenski [Wed, 13 May 2020 17:15:46 +0000 (10:15 -0700)]
fix encap_names for Fortinet HDLC

Signed-off-by: Daniel Lenski <dlenski@gmail.com>
4 years agoUse do_https_request()
David Woodhouse [Wed, 13 May 2020 15:44:54 +0000 (16:44 +0100)]
Use do_https_request()

That's a lot simpler than open-coding it.

Signed-off-by: David Woodhouse <dwmw2@infradead.org>
4 years agoFix fortinet_bye() path
David Woodhouse [Wed, 13 May 2020 15:24:44 +0000 (16:24 +0100)]
Fix fortinet_bye() path

Signed-off-by: David Woodhouse <dwmw2@infradead.org>
4 years agocombine comments from heretofore missing ppp.h
Daniel Lenski [Wed, 13 May 2020 14:28:28 +0000 (07:28 -0700)]
combine comments from heretofore missing ppp.h

Signed-off-by: Daniel Lenski <dlenski@gmail.com>
4 years agosave four bytes in HDLC malloc
Daniel Lenski [Wed, 13 May 2020 07:05:55 +0000 (00:05 -0700)]
save four bytes in HDLC malloc

Signed-off-by: Daniel Lenski <dlenski@gmail.com>
4 years agoAdd basic attempt at Fortinet support
David Woodhouse [Wed, 13 May 2020 13:58:56 +0000 (14:58 +0100)]
Add basic attempt at Fortinet support

Signed-off-by: David Woodhouse <dwmw2@infradead.org>
4 years agoUse ID from struct ncp
David Woodhouse [Wed, 13 May 2020 13:32:41 +0000 (14:32 +0100)]
Use ID from struct ncp

Signed-off-by: David Woodhouse <dwmw2@infradead.org>
4 years agoMake proto strings static
David Woodhouse [Wed, 13 May 2020 10:24:07 +0000 (11:24 +0100)]
Make proto strings static

Signed-off-by: David Woodhouse <dwmw2@infradead.org>
4 years agoAdd missing ppp.h
David Woodhouse [Wed, 13 May 2020 09:45:44 +0000 (10:45 +0100)]
Add missing ppp.h

Signed-off-by: David Woodhouse <dwmw2@infradead.org>
4 years agouse HDLC_OUT macro
Daniel Lenski [Wed, 13 May 2020 06:38:51 +0000 (23:38 -0700)]
use HDLC_OUT macro

Signed-off-by: Daniel Lenski <dlenski@gmail.com>
4 years agocheck for PPP state transitions before/after each packet received
Daniel Lenski [Wed, 13 May 2020 06:13:17 +0000 (23:13 -0700)]
check for PPP state transitions before/after each packet received

Signed-off-by: Daniel Lenski <dlenski@gmail.com>
4 years agomove PPP #defines and structs to ppp.h
Daniel Lenski [Tue, 12 May 2020 22:26:23 +0000 (15:26 -0700)]
move PPP #defines and structs to ppp.h

Signed-off-by: Daniel Lenski <dlenski@gmail.com>
4 years agounused label
Daniel Lenski [Tue, 12 May 2020 22:29:57 +0000 (15:29 -0700)]
unused label

Signed-off-by: Daniel Lenski <dlenski@gmail.com>
4 years agoHandle ConfRej for anything that needs it.
David Woodhouse [Tue, 12 May 2020 21:27:24 +0000 (22:27 +0100)]
Handle ConfRej for anything that needs it.

If get a ConfReq with anything we don't want or understand — and that
includes bloody VJ header compression, since I'm not completely batshit
insane — send a ConfRej.

Do this by building up the options to be rejected in an oc_text_buf as
we go, then rejecting that set if it's non-empty once we get to the end.

Signed-off-by: David Woodhouse <dwmw2@infradead.org>
4 years agoFix un-HDLC corner cases
Daniel Lenski [Tue, 12 May 2020 21:12:25 +0000 (14:12 -0700)]
Fix un-HDLC corner cases

1) The initial 0x7e is optional, the final 0x7e is not (was reversed).
2) Dangling escape can occur even when we haven't run out of buffer. 0x7d 0x7e is an invalid sequence.

While not breaking…

3) 0x7d can be the “target” of an escape (0x7d 0x7d → 0x5d)
4) 0x5d as the “target” of an escape (0x7d 0x5d → 0x7d) doesn't indicate a new escape

Signed-off-by: Daniel Lenski <dlenski@gmail.com>
4 years agoget rid of a bunch of casts
Daniel Lenski [Wed, 13 May 2020 05:20:24 +0000 (22:20 -0700)]
get rid of a bunch of casts

Signed-off-by: Daniel Lenski <dlenski@gmail.com>
4 years agostop asking users to report unexpected GP login argument arg[20]="unknown"
Daniel Lenski [Fri, 1 May 2020 18:49:25 +0000 (11:49 -0700)]
stop asking users to report unexpected GP login argument arg[20]="unknown"

We don't know what this one means, but newer GP servers always send it and it's basically uninteresting.

Signed-off-by: Daniel Lenski <dlenski@gmail.com>
4 years agoAdd FCS support
David Woodhouse [Tue, 12 May 2020 19:41:06 +0000 (20:41 +0100)]
Add FCS support

Signed-off-by: David Woodhouse <dwmw2@infradead.org>
4 years agonope, F5 HDLC isn't emitting junk… I'm just failing to unescape the FCS
Daniel Lenski [Tue, 12 May 2020 20:15:37 +0000 (13:15 -0700)]
nope, F5 HDLC isn't emitting junk… I'm just failing to unescape the FCS

Signed-off-by: Daniel Lenski <dlenski@gmail.com>