]> www.infradead.org Git - users/dwmw2/openconnect.git/log
users/dwmw2/openconnect.git
11 years agoandroid: Build ARM with -march=armv7-a
Kevin Cernekee [Thu, 6 Mar 2014 03:25:46 +0000 (19:25 -0800)]
android: Build ARM with -march=armv7-a

This will be required to use the hand-optimized AES implementation in
nettle 2.7.

Signed-off-by: Kevin Cernekee <cernekee@gmail.com>
11 years agocstp: Make cstp_reconnect() static again
Kevin Cernekee [Sun, 23 Feb 2014 02:34:18 +0000 (18:34 -0800)]
cstp: Make cstp_reconnect() static again

This function was originally exported to to support rekeying from dtls.c,
but the DTLS code no longer needs a way to force CSTP reconnections now.

Signed-off-by: Kevin Cernekee <cernekee@gmail.com>
11 years agodtls: Align new-tunnel rekey behavior with Cisco clients
Kevin Cernekee [Sun, 23 Feb 2014 02:21:39 +0000 (18:21 -0800)]
dtls: Align new-tunnel rekey behavior with Cisco clients

Cisco clients do not appear to send a new DTLS master secret; they just
re-handshake every <n> minutes according to the gateway's rekey interval.
Change openconnect so that it only sets the master secret once upon
creation of the library instance, not in cstp_reconnect().  This also
fixes several other issues:

 - Changing the DTLS master secret on sessions that have rekeying disabled
   (because (last_rekey + rekey < time(NULL) + 300) is pretty much always
   true if rekey == 0)

 - Failing to force a DTLS rehandshake after sending a new master secret
   through a CSTP reconnection request, if DTLS uses REKEY_SSL

 - Incorrectly bumping dtls_times.last_rekey on any successful CSTP
   reconnection

Signed-off-by: Kevin Cernekee <cernekee@gmail.com>
11 years agowww: Fix missing space on platforms page
Kevin Cernekee [Mon, 17 Feb 2014 20:17:51 +0000 (12:17 -0800)]
www: Fix missing space on platforms page

Signed-off-by: Kevin Cernekee <cernekee@gmail.com>
11 years agowww: Don't ignore groff errors
Kevin Cernekee [Mon, 17 Feb 2014 20:22:52 +0000 (12:22 -0800)]
www: Don't ignore groff errors

Since most shells disable pipefail by default, errors parsing the man
page into HTML can be silently ignored.  This results in manual.html
showing a header and a footer, but no content.

Signed-off-by: Kevin Cernekee <cernekee@gmail.com>
11 years agoAdd autoconf test for functional groff with UTF-8 xhtml output
David Woodhouse [Fri, 7 Mar 2014 10:45:20 +0000 (10:45 +0000)]
Add autoconf test for functional groff with UTF-8 xhtml output

Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
11 years agoFix 'missing initializer' warning on Solaris/GCC build
David Woodhouse [Fri, 7 Mar 2014 10:31:04 +0000 (10:31 +0000)]
Fix 'missing initializer' warning on Solaris/GCC build

Not entirely sure why I can't reproduce locally even when I explicitly add
-Wmissing-field-initializers.

Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
11 years agoAllow libtoolize to be specified via environment variable
Jay Soffian [Thu, 6 Mar 2014 19:04:34 +0000 (14:04 -0500)]
Allow libtoolize to be specified via environment variable

On OS X, libtoolize is known as glibtoolize. Allow this to be
specified via an environment variable so that autogen.sh need
not be modified to build.

Signed-off-by: Jay Soffian <jaysoffian@gmail.com>
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
11 years agoversion.sh: respect GIT_DIR
Jay Soffian [Thu, 6 Mar 2014 19:02:55 +0000 (14:02 -0500)]
version.sh: respect GIT_DIR

This change allows version.sh to work correctly when checked out
in an external work tree, as for example is done by Homebrew.

Signed-off-by: Jay Soffian <jaysoffian@gmail.com>
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
11 years agoRemove W3C icons from web pages
Mike Miller [Thu, 6 Mar 2014 02:54:21 +0000 (21:54 -0500)]
Remove W3C icons from web pages

Don't embed links to externally hosted icons in local documentation.

Signed-off-by: Mike Miller <mtmiller@ieee.org>
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
11 years agoFix GnuTLS 2.x build
David Woodhouse [Thu, 6 Mar 2014 08:46:39 +0000 (08:46 +0000)]
Fix GnuTLS 2.x build

Commit c7077b96b ("Do not abort when GnuTLS reports unclean shutdown")
introduced a build failure for GnuTLS 2.x which lacks the
GNUTLS_E_PREMATURE_TERMINATION error that we check for. Instead, it
returns GNUTLS_E_UNEXPECTED_PACKET_LENGTH.

Since the offending server turned out not to be an AnyConnect server at
all in the end, gracefully handling the unclean SSL shutdown probably
isn't strictly necessary — although it remains a good idea on general
principles. But it's not *so* important that I'm going to jump through
hoops to do it even for users who are still using GnuTLS 2.x.

So just put the check inside #ifdef GNUTLS_E_PREMATURE_TERMINATION, and
if we later find an *AnyConnect* server which displays this behaviour and
requires us to cope with it, we can find a better solution. Which might
just be to deprecate GnuTLS 2.x entirely... ☺

Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
11 years agoTag version 5.99 v5.99
David Woodhouse [Wed, 5 Mar 2014 11:12:52 +0000 (11:12 +0000)]
Tag version 5.99

Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
11 years agoResync translations with sources
David Woodhouse [Wed, 5 Mar 2014 11:09:43 +0000 (11:09 +0000)]
Resync translations with sources

Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
11 years agoFix 'cast from pointer to integer of different size' warning in Win64 build
David Woodhouse [Mon, 3 Mar 2014 21:41:05 +0000 (21:41 +0000)]
Fix 'cast from pointer to integer of different size' warning in Win64 build

The "long" data type on 64-bit Windows isn't 64-bit, so isn't enough to hold
a pointer. So use intptr_t instead.

This warning was introduced by commit a983aed4 (Do an SSL rehandshake
when the server sends "X-CSTP-Rekey-Method: ssl".)

Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
11 years agoAdvertise the hostname we connect using SNI.
Nikos Mavrogiannopoulos [Wed, 5 Feb 2014 21:46:52 +0000 (22:46 +0100)]
Advertise the hostname we connect using SNI.

This would provide the server with more information on the
connection that can be used to distinguish between different
servers (https and vpn), or even different vpn server configurations.
It is conditionally enabled when compiled with gnutls 3.2.9 or later
where the %COMPAT keyword ensures that the client hello size is
outside the F5 firewall black hole range.

[dwmw2: Make string_is_hostname() accept NULL, cosmetic changes]

Signed-off-by: Nikos Mavrogiannopoulos <nmav@gnutls.org>
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
11 years agoImport translations from GNOME
David Woodhouse [Mon, 3 Mar 2014 20:31:25 +0000 (20:31 +0000)]
Import translations from GNOME

Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
11 years agoUpdate platforms.html information about Windows builds
David Woodhouse [Mon, 3 Mar 2014 19:49:08 +0000 (19:49 +0000)]
Update platforms.html information about Windows builds

Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
11 years agoUpdate translations from Transifex
David Woodhouse [Fri, 21 Feb 2014 01:50:23 +0000 (01:50 +0000)]
Update translations from Transifex

Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
11 years agoResync translations with sources
David Woodhouse [Fri, 21 Feb 2014 01:48:33 +0000 (01:48 +0000)]
Resync translations with sources

Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
11 years agoOnly include non-empty files in LINGUAS
David Woodhouse [Fri, 21 Feb 2014 01:47:16 +0000 (01:47 +0000)]
Only include non-empty files in LINGUAS

Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
11 years agoSort new files imported from Transifex so 'update-po' won't touch them
David Woodhouse [Fri, 21 Feb 2014 01:28:13 +0000 (01:28 +0000)]
Sort new files imported from Transifex so 'update-po' won't touch them

Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
11 years agoAdd update-po target
David Woodhouse [Thu, 20 Feb 2014 23:56:21 +0000 (23:56 +0000)]
Add update-po target

This just updates the local po files to be consistent with the sources,
which should make the commits for other translation imports easier to
parse.

Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
11 years agoDon't lose translations when merging from Transifex
David Woodhouse [Fri, 21 Feb 2014 00:39:27 +0000 (00:39 +0000)]
Don't lose translations when merging from Transifex

Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
11 years agoFix --os=win
Antonio Borneo [Sun, 8 Dec 2013 04:29:32 +0000 (12:29 +0800)]
Fix --os=win

Running OpenConnect with flag "--os=win" we get
        vpninfo->csd_xmltag == "csd"
In fact, in library.c we have:
     85         else if (!strcmp(os, "win"))
     86                 vpninfo->csd_xmltag = "csd";

In current code, the case (vpninfo->csd_xmltag == "csd") is
grabbed by previous "else if()" condition and not evaluated
anymore to extract "stuburl", "starturl" and "waiturl".

Split the "else if" in independent statement.

Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
11 years agoAdd RFC4226 HOTP token support
David Woodhouse [Tue, 18 Feb 2014 16:43:40 +0000 (16:43 +0000)]
Add RFC4226 HOTP token support

This isn't really complete since it doesn't handle the token counter
properly. It relies on being given the token counter along with the
secret key, and there's no way to save the new value when we're done.

We could perhaps add a library function to write the token counter back,
and rely on the library user to manage the file storage containing the
counter.

Or maybe we want to use libpskc and allow the PSKC file to be specified,
then we can update that file directly.

A UI tool might also want to store the PSKC data in something like the
keyring instead of a simple file, so in that case the library should
probably allow for a callback which provides the new PSKC data rather
than unconditionally writing it to a file.

Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
11 years agoIf DTLS rehandshake fails, then reconnect.
Nikos Mavrogiannopoulos [Tue, 18 Feb 2014 08:03:16 +0000 (09:03 +0100)]
If DTLS rehandshake fails, then reconnect.

Signed-off-by: Nikos Mavrogiannopoulos <nmav@gnutls.org>
11 years agoNotify on rekey time when we are not in REKEY_NONE state.
Nikos Mavrogiannopoulos [Tue, 18 Feb 2014 07:13:40 +0000 (08:13 +0100)]
Notify on rekey time when we are not in REKEY_NONE state.

Signed-off-by: Nikos Mavrogiannopoulos <nmav@gnutls.org>
11 years agoRevert "dtls: Set rekey_method correctly if the header is missing"
Nikos Mavrogiannopoulos [Tue, 18 Feb 2014 07:11:24 +0000 (08:11 +0100)]
Revert "dtls: Set rekey_method correctly if the header is missing"

This reverts commit a1e3914fd0f469640a323da63715e8abf764a3a0.

11 years agoPrefer python2 if available
David Woodhouse [Mon, 17 Feb 2014 20:20:28 +0000 (20:20 +0000)]
Prefer python2 if available

Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
11 years agomainloop: Simplify the keepalive functions
Kevin Cernekee [Sat, 15 Feb 2014 19:51:22 +0000 (11:51 -0800)]
mainloop: Simplify the keepalive functions

Moving the "compare values + update timeout" logic into a helper function
lets us delete several duplicated checks and temporary variables.

[dwmw2: Fix up conflicts with commit a983aed4]

Signed-off-by: Kevin Cernekee <cernekee@gmail.com>
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
Conflicts:
mainloop.c

11 years agoMerge branch 'rekey' of git://gitorious.org/openconnect-x/openconnect-x
David Woodhouse [Mon, 17 Feb 2014 15:54:10 +0000 (15:54 +0000)]
Merge branch 'rekey' of git://gitorious.org/openconnect-x/openconnect-x

11 years agoAvoid deprecated AC_OUTPUT syntax
Kevin Cernekee [Sun, 16 Feb 2014 17:47:36 +0000 (09:47 -0800)]
Avoid deprecated AC_OUTPUT syntax

The use of AC_OUTPUT with arguments is deprecated[1], so use
AC_CONFIG_FILES instead.

[1] http://www.gnu.org/software/autoconf/manual/autoconf.html#Obsolete-Macros

Signed-off-by: Kevin Cernekee <cernekee@gmail.com>
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
11 years agodtls: Fix link error on !HAVE_DTLS builds
Kevin Cernekee [Sun, 16 Feb 2014 00:00:25 +0000 (16:00 -0800)]
dtls: Fix link error on !HAVE_DTLS builds

Several internal library functions call dtls_close() to clean up, so just
make it a stub function if this is a non-DTLS build.

Signed-off-by: Kevin Cernekee <cernekee@gmail.com>
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
11 years agoRemoved the new-tunnel reconnection option from DTLS.
Nikos Mavrogiannopoulos [Mon, 17 Feb 2014 13:04:58 +0000 (14:04 +0100)]
Removed the new-tunnel reconnection option from DTLS.

There is no purpose for that option as X-DTLS-Rekey-Method is
only sent by ocserv that doesn't sent this option.

Signed-off-by: Nikos Mavrogiannopoulos <nmav@redhat.com>
11 years agoWhen CSTP rehandshake or reconnection succeeds, reconnect DTLS.
Nikos Mavrogiannopoulos [Mon, 17 Feb 2014 13:02:24 +0000 (14:02 +0100)]
When CSTP rehandshake or reconnection succeeds, reconnect DTLS.

That only occurs when DTLS doesn't have it's owner timer and
mechanism for rehandshake. In that case we replicate the Anyconnect
clients' behavior, by reconnecting DTLS just after the CSTP reconnect.

Signed-off-by: Nikos Mavrogiannopoulos <nmav@redhat.com>
11 years agomainloop: Use consistent logic for rekey timeout check
Kevin Cernekee [Sat, 15 Feb 2014 20:08:35 +0000 (12:08 -0800)]
mainloop: Use consistent logic for rekey timeout check

ka_stalled_action() and keepalive_action() should both use the same test.

Signed-off-by: Kevin Cernekee <cernekee@gmail.com>
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
11 years agoSanity-check CSTP and DTLS rekey times
Kevin Cernekee [Sat, 15 Feb 2014 20:22:11 +0000 (12:22 -0800)]
Sanity-check CSTP and DTLS rekey times

Just set REKEY_NONE if the rekey time is zero or negative, so that we
don't need to test (ka->rekey && ka->rekey_method != REKEY_NONE) in
multiple locations.

Signed-off-by: Kevin Cernekee <cernekee@gmail.com>
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
11 years agodtls: Set rekey_method correctly if the header is missing
Kevin Cernekee [Sat, 15 Feb 2014 19:24:40 +0000 (11:24 -0800)]
dtls: Set rekey_method correctly if the header is missing

ASA gateways do not appear to send the X-DTLS-Rekey-Method: header, so
fall back to the same rekey_method as CSTP rather than assuming
REKEY_NONE.

Signed-off-by: Kevin Cernekee <cernekee@gmail.com>
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
11 years agocstp: Make sure outbound packets are sent over CSTP if DTLS is down
Kevin Cernekee [Sat, 15 Feb 2014 23:09:10 +0000 (15:09 -0800)]
cstp: Make sure outbound packets are sent over CSTP if DTLS is down

As of commit 6a3ad9877 (Kill new_dtls_* variables), it is no longer safe
to assume that (dtls_fd != -1) means that the DTLS connection is able
to pass traffic; it might still be handshaking.  Instead, we should check
vpninfo->dtls_state.

Signed-off-by: Kevin Cernekee <cernekee@gmail.com>
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
11 years agoandroid: Install stripped binaries under $(TRIPLET)/out
Kevin Cernekee [Mon, 10 Feb 2014 00:20:22 +0000 (16:20 -0800)]
android: Install stripped binaries under $(TRIPLET)/out

This is a little more user-friendly than making people dig into .libs/
and copy them out.

Signed-off-by: Kevin Cernekee <cernekee@gmail.com>
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
11 years agoandroid: Use make-standalone-toolchain.sh from NDK
Kevin Cernekee [Sun, 19 Jan 2014 19:45:01 +0000 (11:45 -0800)]
android: Use make-standalone-toolchain.sh from NDK

This helps avoid having to hardcode internal NDK paths in our build
scripts, making them less fragile.  It also lets us use a combined
sysroot for all dependencies, as the local copy of the toolchain is
guaranteed to be writable.  Net result is that packages can generally
just invoke plain $(CC) without --sysroot, -I, or -L flags.

For background info, see "the easy way" in
$(NDK)/docs/STANDALONE-TOOLCHAIN.html

Also, after openconnect is built, the user is left with a new toolchain
containing many helpful libraries.  It can be used to cross-compile other
programs just by setting $PATH and --host= with appropriate values.

The change was successfully compile-tested with the following NDK releases:
8c, 8d, 8e, 9, 9b, 9c.  For each release, ARM/x86/MIPS targets were built
on Linux using both x86 and x86_64 host binaries.  OSX was not tested.

NDK releases <= 8b were also tested, but they showed a large number of
unrelated build failures due to factors like:

 - Shipping a version of binutils that doesn't recognize the "rrx(s)"
instruction in gmp

 - Calling the x86 binary "i686-android-linux-gcc" instead of
"i686-linux-android-gcc"

 - Using binutils (bfd) ld instead of gold for x86, so the final link
hits the same zlib dependency bug that we see on MIPS

 - Lack of support for the android-14 (4.0/ICS) ABI

Signed-off-by: Kevin Cernekee <cernekee@gmail.com>
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
11 years agoandroid: Explicitly disable symbol versioning
Kevin Cernekee [Sun, 9 Feb 2014 05:44:52 +0000 (21:44 -0800)]
android: Explicitly disable symbol versioning

On current Android builds, autotools fails to pass --sysroot to one of
the link commands, causing the test to fail and symbol versioning to be
disabled:

    configure:12875: arm-linux-androideabi-gcc -shared  -fPIC -DPIC conftest.o -v -Wl,-soname -Wl,conftest -o conftest -Wl,-M -Wl,conftest.map
    [...]
    /opt/android-ndk-r9c/toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86_64/bin/../lib/gcc/arm-linux-androideabi/4.8/../../../../arm-linux-androideabi/bin/ld: error: cannot open crtbegin_so.o: No such file or directory
    [...]
    collect2: error: ld returned 1 exit status
    configure:12878: $? = 1
    configure:12885: result: no

This is somewhat fortuitous, because it wouldn't work anyway.
__gmp_binvert_limb_table is accessed from $GMP/mpn/arm/mode1o.asm using
a homebrew PIC implementation.  This causes it to generate a relocation
entry when linked into libopenconnect.so.  The Android ldso (via
soinfo_elf_lookup() in Bionic) only allows global and weak symbols to
match relocation entries, so if __gmp_binvert_limb_table gets marked as a
local symbol by our version script, the program will fail to execute:

    soinfo_link_image(linker.cpp:1673): could not load library
    "libopenconnect.so.3" needed by "./openconnect"; caused by
    soinfo_relocate(linker.cpp:1013): cannot locate symbol
    "__gmp_binvert_limb_table" referenced by "libopenconnect.so.3"...
    CANNOT LINK EXECUTABLE

With no linker script, it remains a global symbol and there is no
problem.  Manually hexediting the library to switch the binding between
STB_LOCAL and STB_GLOBAL confirms that there is an issue with this one
symbol.

When make-standalone-toolchain.sh is used to build the library, the
--sysroot problem disappears because it is set implicitly, so symbol
versioning is enabled and that reveals the relocation problem.  Thus,
symbol versioning needs to be forced off (or libgmp needs to be fixed)
before we can safely use make-standalone-toolchain.sh.

Android bug report:
https://code.google.com/p/android/issues/detail?id=66048

Signed-off-by: Kevin Cernekee <cernekee@gmail.com>
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
11 years agocstp_reconnect: Don't sleep if the user terminated the connection
Kevin Cernekee [Sun, 9 Feb 2014 20:02:12 +0000 (12:02 -0800)]
cstp_reconnect: Don't sleep if the user terminated the connection

If openconnect_make_cstp_connection() fails due to user cancellation,
we don't want cstp_reconnect() to sit around waiting for 10+ seconds.
Instead, return immediately so the mainloop can clean up.

Signed-off-by: Kevin Cernekee <cernekee@gmail.com>
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
11 years agohttp: Don't retry on user cancellation
Kevin Cernekee [Thu, 30 Jan 2014 04:10:50 +0000 (20:10 -0800)]
http: Don't retry on user cancellation

We aren't currently checking to see if do_https_request() failed due to
an actual network error or a user cancellation.  So if the library tries
to connect to an unreachable host, and the user hits Cancel before the
operation times out, we will still try falling back to non-xmlpost mode:

    $ ./openconnect 1.2.3.4
    POST https://1.2.3.4/
    Attempting to connect to server 1.2.3.4:443
    ^CSocket connect cancelled
    Failed to connect to host 1.2.3.4
    Failed to open HTTPS connection to 1.2.3.4
    GET https://1.2.3.4/
    Attempting to connect to server 1.2.3.4:443
    ^CSocket connect cancelled
    Failed to connect to host 1.2.3.4
    Failed to open HTTPS connection to 1.2.3.4
    Failed to obtain WebVPN cookie

Add a new check and return the appropriate error code for "user cancelled"
to openconnect_obtain_cookie().

Signed-off-by: Kevin Cernekee <cernekee@gmail.com>
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
11 years agoAdd liboath version check
Kevin Cernekee [Tue, 4 Feb 2014 03:14:29 +0000 (19:14 -0800)]
Add liboath version check

Versions prior to 1.12.0 are missing oath_base32_decode(), resulting in an
error:

      CC     libopenconnect_la-library.lo
    library.c: In function 'set_oath_mode':
    library.c:475:3: error: implicit declaration of function 'oath_base32_decode' [-Werror=implicit-function-declaration]
    library.c:475:3: warning: nested extern declaration of 'oath_base32_decode' [-Wnested-externs]

Signed-off-by: Kevin Cernekee <cernekee@gmail.com>
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
11 years agoandroid: Add android/ directory to release tarballs
David Woodhouse [Sun, 16 Feb 2014 21:54:27 +0000 (21:54 +0000)]
android: Add android/ directory to release tarballs

Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
11 years agoRemove Java_* wildcard from libopenconnect.map
David Woodhouse [Sun, 16 Feb 2014 21:17:57 +0000 (21:17 +0000)]
Remove Java_* wildcard from libopenconnect.map

The Solaris linker can't cope with wildcards. So include the Java_*
functions explicitly by name, only where needed.

Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
11 years agoDo rehandshake on the DTLS channel as well.
Nikos Mavrogiannopoulos [Sun, 16 Feb 2014 08:44:19 +0000 (09:44 +0100)]
Do rehandshake on the DTLS channel as well.

When we receive "X-DTLS-Rekey-Method: ssl" do a rehandshake
on the DTLS channel as well. Currently this header is only
sent by ocserv, and by using that method we rekey without reconnecting
the DTLS channel.

Signed-off-by: Nikos Mavrogiannopoulos <nmav@gnutls.org>
11 years agoDo an SSL rehandshake when the server sends "X-CSTP-Rekey-Method: ssl".
Nikos Mavrogiannopoulos [Sun, 16 Feb 2014 08:42:44 +0000 (09:42 +0100)]
Do an SSL rehandshake when the server sends "X-CSTP-Rekey-Method: ssl".

Signed-off-by: Nikos Mavrogiannopoulos <nmav@gnutls.org>
11 years agoIncreased DTLS timeout value to 12 seconds.
Nikos Mavrogiannopoulos [Sun, 16 Feb 2014 08:39:59 +0000 (09:39 +0100)]
Increased DTLS timeout value to 12 seconds.

Signed-off-by: Nikos Mavrogiannopoulos <nmav@gnutls.org>
11 years agoInclude <errno.h> in xml.c to fix non-libstoken build
David Woodhouse [Sat, 15 Feb 2014 10:15:00 +0000 (10:15 +0000)]
Include <errno.h> in xml.c to fix non-libstoken build

Pointed out by Nikos Mavrogiannopoulos.

Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
11 years agoAssign Address-IP6 field to netmask instead of address
Jeremy Visser [Fri, 14 Feb 2014 12:32:47 +0000 (23:32 +1100)]
Assign Address-IP6 field to netmask instead of address

The Address-IP6 field combines the address and netmask into one line,
meaning it only makes sense in the netmask field.

Fixes an error rather not dissimilar to the following:

  Error: an inet prefix is expected rather than "<foo>/64/128"

Signed-off-by: Jeremy Visser <jeremy@visser.name>
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
11 years agoDo not abort when GnuTLS reports unclean shutdown
David Woodhouse [Fri, 14 Feb 2014 11:49:34 +0000 (11:49 +0000)]
Do not abort when GnuTLS reports unclean shutdown

Some servers are observed to send an HTTP 1.0 response and then just kill
the socket. This is horrid, but we need to cope. If we get the
GNUTLS_E_PREMATURE_TERMINATION "error" when trying to read an empty
HTTP body, we shouldn't abort the connection attempt. We should just
treat it as EOF.

https://bugs.launchpad.net/bugs/1225276

Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
11 years agoClean up GnuTLS openconnect_SSL_{read,write,gets} functions
David Woodhouse [Fri, 14 Feb 2014 11:48:22 +0000 (11:48 +0000)]
Clean up GnuTLS openconnect_SSL_{read,write,gets} functions

Let's do if(EAGAIN) {...} else {...} rather than doing them backwards.

Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
11 years agoImport translations from GNOME
David Woodhouse [Fri, 14 Feb 2014 01:31:28 +0000 (01:31 +0000)]
Import translations from GNOME

Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
11 years agoUpdate changelog
David Woodhouse [Fri, 14 Feb 2014 01:30:13 +0000 (01:30 +0000)]
Update changelog

Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
11 years agoFix crash with -C option
David Woodhouse [Fri, 14 Feb 2014 01:03:20 +0000 (01:03 +0000)]
Fix crash with -C option

Commit 1df2832e8 ("Fix a few minor memory leaks") turned vpninfo->cookie
into an "owned" script... except for where it comes from argv[]. Freeing
that hurts.

Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
11 years agoFix OpenBSD build
David Woodhouse [Fri, 14 Feb 2014 00:57:50 +0000 (00:57 +0000)]
Fix OpenBSD build

Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
11 years agoSupport IPv6 split tunnelling
Jeremy Visser [Wed, 15 Jan 2014 13:27:14 +0000 (00:27 +1100)]
Support IPv6 split tunnelling

First step is to send the "X-CSTP-Full-IPv6-Capability: true" header,
which causes the ASA to send the extra headers we need to support split
tunnelling.

Instead of receiving these headers (where a default route is implied):

 X-CSTP-Address: 2001:db8:1000:1000::1
 X-CSTP-Netmask: 2001:db8:1000:1000::1/64

Sending the aforementioned "X-CSTP-Full-IPv6-Capability: true" results
in this being received:

 X-CSTP-Address-IP6: 2001:db8:1000:1000::1/64
 X-CSTP-Split-Include-IP6: 2001:db8:1000:1001::/64
 X-CSTP-Split-Include-IP6: 2001:db8:1000:1002::/64

Because the address and netmask are being specified in the same header,
this is the reason for the slight logic change with the
"X-CSTP-Address-IP6" header parsing.

Signed-off-by: Jeremy Visser <jeremy@visser.name>
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
11 years agoAdd openconnect_setup_tun_script() stub for Windows
David Woodhouse [Fri, 14 Feb 2014 00:22:00 +0000 (00:22 +0000)]
Add openconnect_setup_tun_script() stub for Windows

Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
11 years agoMake openconnect_setup_tun_fd() work on Windows
David Woodhouse [Fri, 14 Feb 2014 00:18:12 +0000 (00:18 +0000)]
Make openconnect_setup_tun_fd() work on Windows

And use it for openconnect_setup_tun_device() too, like the non-Windows
version does.

Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
11 years agoClean up search_taps() function
David Woodhouse [Fri, 14 Feb 2014 00:08:24 +0000 (00:08 +0000)]
Clean up search_taps() function

Firstly, make it capable of returning an intptr_t (which will be a HANDLE)
which is generated by the callback function. Or -1 on all errors.

Secondly, add an explicit break after calling the callback, so that we
aren't making assumptions about what a zero result means.

Finally, add an 'all' argument to avoid said break, so that it can still
be used for the '--list-taps' functionality as was originally envisaged.

Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
11 years agoMove Windows interface name matching into search_taps() function
David Woodhouse [Fri, 14 Feb 2014 00:01:02 +0000 (00:01 +0000)]
Move Windows interface name matching into search_taps() function

This simplifies the return value from the callback since there is never
a "ignore this one and try me with the next one" option. It can just return
-1 for failure, or a handle.

Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
11 years agoRemove tun.c from Windows build
David Woodhouse [Thu, 13 Feb 2014 23:55:22 +0000 (23:55 +0000)]
Remove tun.c from Windows build

Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
11 years agoMove openconnect_setup_tun_device() to library.c
David Woodhouse [Thu, 13 Feb 2014 23:54:56 +0000 (23:54 +0000)]
Move openconnect_setup_tun_device() to library.c

Perhaps not the perfect location for it but now tun.c can be entirely
dropped from the Windows build.

Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
11 years agoMove set_tun_mtu() into os_setup_tun()
David Woodhouse [Thu, 13 Feb 2014 23:43:54 +0000 (23:43 +0000)]
Move set_tun_mtu() into os_setup_tun()

There's no real reason for this to be in openconnect_setup_tun_device()
after the vpnc-script is run. That's just a historical artifact because
we *used* to attempt to do IP configuration ourselves if there was no
vpnc-script, and we used to do the MTU setup even if there *was*.

In commit ad9c6573c ("Don't attempt to configure Legacy IP address on
tun device.") it was changed to run the script, then set the MTU anyway
just in case the script didn't get it right. But the MTU could actually
have been set much sooner.

In fact it probably doesn't need to be done at all these days, since
nobody should still be using a vpnc-script that old. But it doesn't hurt.

Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
11 years agoSplit out os_setup_tun() for Windows vs. sane platforms
David Woodhouse [Thu, 13 Feb 2014 23:32:52 +0000 (23:32 +0000)]
Split out os_setup_tun() for Windows vs. sane platforms

Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
11 years agoMove Windows openconnect_setup_tun_fd() to tun-win32.c
David Woodhouse [Thu, 13 Feb 2014 23:28:28 +0000 (23:28 +0000)]
Move Windows openconnect_setup_tun_fd() to tun-win32.c

Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
11 years agoSplit out os_shutdown_tun() for Windows vs. sane platforms
David Woodhouse [Thu, 13 Feb 2014 23:21:29 +0000 (23:21 +0000)]
Split out os_shutdown_tun() for Windows vs. sane platforms

Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
11 years agoMove tun_mainloop() to mainloop.c
David Woodhouse [Thu, 13 Feb 2014 23:18:55 +0000 (23:18 +0000)]
Move tun_mainloop() to mainloop.c

It can't live in tun.c because we're about to stop that being built on
Windows.

Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
11 years agoFactor out os_write_tun() from tun_mainloop()
David Woodhouse [Thu, 13 Feb 2014 23:16:04 +0000 (23:16 +0000)]
Factor out os_write_tun() from tun_mainloop()

Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
11 years agoFactor out os_read_tun() from tun_mainloop()
David Woodhouse [Thu, 13 Feb 2014 22:58:33 +0000 (22:58 +0000)]
Factor out os_read_tun() from tun_mainloop()

Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
11 years agoMove script_config_tun() to script.c
David Woodhouse [Thu, 13 Feb 2014 16:13:06 +0000 (16:13 +0000)]
Move script_config_tun() to script.c

Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
11 years agoMove set_script_env() to script.c
David Woodhouse [Thu, 13 Feb 2014 16:10:09 +0000 (16:10 +0000)]
Move set_script_env() to script.c

Let's move the environment stuff out of the way so that tun.c can be built
for sane platforms only.

Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
11 years agoUpdate build documentation
David Woodhouse [Thu, 13 Feb 2014 15:58:56 +0000 (15:58 +0000)]
Update build documentation

Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
11 years agoUpdate vpnc-script documentation for Windows
David Woodhouse [Thu, 13 Feb 2014 15:48:48 +0000 (15:48 +0000)]
Update vpnc-script documentation for Windows

Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
11 years agoClean up default vpnc-script handling for Windows
David Woodhouse [Thu, 13 Feb 2014 11:01:40 +0000 (11:01 +0000)]
Clean up default vpnc-script handling for Windows

We automatically prepend the current executable's path to the script
name if it's relative, and run it in 'cscript.exe'.

Perhaps it would be nicer if we determined whether the path was relative
or not in autoconf, rather than at runtime.

Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
11 years agoMove vpnc-script handling after platform detection in configure.ac
David Woodhouse [Thu, 13 Feb 2014 00:57:33 +0000 (00:57 +0000)]
Move vpnc-script handling after platform detection in configure.ac

Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
11 years agoPrint error when no TAP interfaces found
David Woodhouse [Thu, 13 Feb 2014 00:06:08 +0000 (00:06 +0000)]
Print error when no TAP interfaces found

Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
11 years agoFix error printing when registry open fails
David Woodhouse [Thu, 13 Feb 2014 00:03:46 +0000 (00:03 +0000)]
Fix error printing when registry open fails

Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
11 years agoPrint a message when ignoring a TAP device due to --interface option
David Woodhouse [Thu, 13 Feb 2014 00:01:12 +0000 (00:01 +0000)]
Print a message when ignoring a TAP device due to --interface option

That would have saved me a while....

Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
11 years agoAvoid building against GnuTLS v3.2.0-v3.2.9 on Windows
David Woodhouse [Wed, 12 Feb 2014 16:34:20 +0000 (16:34 +0000)]
Avoid building against GnuTLS v3.2.0-v3.2.9 on Windows

http://lists.infradead.org/pipermail/openconnect-devel/2014-February/001641.html

Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
11 years agoFix Windows openconnect_passphrase_from_fsid()
David Woodhouse [Wed, 12 Feb 2014 16:13:37 +0000 (16:13 +0000)]
Fix Windows openconnect_passphrase_from_fsid()

It was leaving the key file open, and using OpenFile() was causing warnings
on Win64 so use CreateFile() instead.

Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
11 years agoFix overflow warning in dumb_socketpair() on Win64
David Woodhouse [Wed, 12 Feb 2014 15:56:06 +0000 (15:56 +0000)]
Fix overflow warning in dumb_socketpair() on Win64

The SOCKET type is a pointer, although in practice what's returned really
does look like a file descriptor. It's a low-valued integer such as 0x23
under Wine, 0x54 under Windows 7 in my testing.

The INVALID_SOCKET error return from socket() is defined as (SOCKET)(~0),
or 0xFFFFFFFFFFFFFFFF on Win64. Thus we get errors when assigning it to
an int in the socks[] array. So use -1 here instead.

Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
11 years agoUse intptr_t for intermediate cast to gnutls_transport_ptr_t
David Woodhouse [Wed, 12 Feb 2014 15:53:16 +0000 (15:53 +0000)]
Use intptr_t for intermediate cast to gnutls_transport_ptr_t

In Win64, 'long' is still only 32 bits, and isn't enough to avoid the
"cast to pointer from integer of different size" warning. This kind of
braindamage is why intptr_t exists, so use it.

Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
11 years agoRemove references to Symbian
David Woodhouse [Tue, 11 Feb 2014 22:38:44 +0000 (22:38 +0000)]
Remove references to Symbian

Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
11 years agoRemove obsolete VAR_CVSID variable
David Woodhouse [Tue, 11 Feb 2014 22:29:49 +0000 (22:29 +0000)]
Remove obsolete VAR_CVSID variable

Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
11 years agoMake web pages work in out-of-tree builds
David Woodhouse [Tue, 11 Feb 2014 22:28:53 +0000 (22:28 +0000)]
Make web pages work in out-of-tree builds

Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
11 years agoDistinguish between the different rekey methods.
Nikos Mavrogiannopoulos [Tue, 11 Feb 2014 15:29:06 +0000 (16:29 +0100)]
Distinguish between the different rekey methods.

AnyConnect allows for different rekey methods including new-tunnel
and ssl (rehandshake). Currently only the new-tunnel is implemented
in openconnect.

Signed-off-by: Nikos Mavrogiannopoulos <nmav@redhat.com>
11 years agoFinally add tun handling for Windows
David Woodhouse [Tue, 11 Feb 2014 14:41:04 +0000 (14:41 +0000)]
Finally add tun handling for Windows

Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
11 years agoAdd event handling for Windows
David Woodhouse [Tue, 11 Feb 2014 13:32:20 +0000 (13:32 +0000)]
Add event handling for Windows

Only handles sockets for now, which *can* be done through select(). But
now we can add the tun device handling into the loop...

Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
11 years agoAbstract select() and FD_SET handling
David Woodhouse [Tue, 11 Feb 2014 12:41:51 +0000 (12:41 +0000)]
Abstract select() and FD_SET handling

This should let us make the mainloop work for Windows, where we can't just
select() on the tun device file descriptor. Or indeed *get* a proper file
descriptor for the tun device, AFAICT.

It might also let us use epoll() etc. if we wanted to.

Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
11 years agoFix up comment on GnuTLS dtls_ssl field
David Woodhouse [Tue, 11 Feb 2014 12:16:25 +0000 (12:16 +0000)]
Fix up comment on GnuTLS dtls_ssl field

Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
11 years agoKill new_dtls_* variables
David Woodhouse [Tue, 11 Feb 2014 12:11:58 +0000 (12:11 +0000)]
Kill new_dtls_* variables

We once might have kept the old DTLS stuff around while we made the new
connection. We don't any more; it's just unneeded baggage.

Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
11 years agoIntroduce dtls_state variable to make reconnect handling cleaner
David Woodhouse [Tue, 11 Feb 2014 11:33:28 +0000 (11:33 +0000)]
Introduce dtls_state variable to make reconnect handling cleaner

Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
11 years agoMove DTLS reconnect handling into dtls.c
David Woodhouse [Tue, 11 Feb 2014 10:42:22 +0000 (10:42 +0000)]
Move DTLS reconnect handling into dtls.c

There's no good reason for this to be in mainloop.c

Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
11 years agoRemove Windows-specific pull/push/errno functions for GnuTLS
David Woodhouse [Tue, 11 Feb 2014 09:34:05 +0000 (09:34 +0000)]
Remove Windows-specific pull/push/errno functions for GnuTLS

GnuTLS does all this for itself on Windows; we don't need to provide them.

Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
11 years agoFix setenv() with value==NULL on Windows
David Woodhouse [Tue, 11 Feb 2014 09:28:42 +0000 (09:28 +0000)]
Fix setenv() with value==NULL on Windows

Also comment about putenv() taking a *copy* of the string. That is
Windows-specific behaviour and not POSIX-compliant, so we don't want
anyone thinking it's reasonable to do it elsewhere:

Tested thus, under wine and Windows 7:

int main(void)
{
char foo[]="FOO=bar";
char *bar;

putenv(foo);
printf("FOO is: %s\n", getenv("FOO"));
foo[5] = 'f';
printf("FOO is: %s\n", getenv("FOO"));
putenv("FOO=");
printf("FOO is: %s\n", getenv("FOO"));
}

With the following results:

FOO is: bar
FOO is: bar
FOO is: (null)

Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
11 years agofix bug in run_csd_script()
Antonio Borneo [Sun, 9 Feb 2014 06:16:47 +0000 (14:16 +0800)]
fix bug in run_csd_script()

run_csd_script() uses proxy_write() to write the CSD script
to file.
From commit 433132b90473538fa46fb6934ef8f7b7f36447b5
"Use send() and recv() for proxy communication (for MinGW's benefit)"
proxy_write() replaces write() with send(), incompatible with
run_csd_script().
Got error:
Failed to write temporary CSD script file:
Socket operation on non-socket

Replace proxy_write() with write() directly in run_csd_script().
Run only a simple check that write() really writes all the buffer.

Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
11 years agoFix Windows set_sock_nonblock()
David Woodhouse [Mon, 10 Feb 2014 14:09:49 +0000 (14:09 +0000)]
Fix Windows set_sock_nonblock()

Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>