]> www.infradead.org Git - users/dwmw2/openconnect.git/log
users/dwmw2/openconnect.git
10 years agouse CreateProcess instead of system to run scripts.
Nikos Mavrogiannopoulos [Thu, 21 Aug 2014 15:20:55 +0000 (17:20 +0200)]
use CreateProcess instead of system to run scripts.

That prevents the pop up of terminal windows.

[dwmw2: Use -ETIMEDOUT instead of -ETIME which doesn't seem to be present in
        my Fedora 20 MinGW setup. Do not prepend 'cscript' to vpnc_script
        string now that we invoke it that way unconditionally.]

Signed-off-by: Nikos Mavrogiannopoulos <nmav@redhat.com>
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
10 years agouse recv() and closesocket() on the cmd_fd on windows
Nikos Mavrogiannopoulos [Thu, 21 Aug 2014 14:24:36 +0000 (16:24 +0200)]
use recv() and closesocket() on the cmd_fd on windows

[dwmw2: Reduce #ifdefs by using recv() everywhere, not just on Windows]

Signed-off-by: Nikos Mavrogiannopoulos <nmav@redhat.com>
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
10 years agouse windows types and return codes for socket errors
Nikos Mavrogiannopoulos [Thu, 21 Aug 2014 14:38:33 +0000 (16:38 +0200)]
use windows types and return codes for socket errors

That is, use SOCKET instead of int for cmd_pipe, and return INVALID
socket for cmd_pipe.

Signed-off-by: Nikos Mavrogiannopoulos <nmav@redhat.com>
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
10 years agoImport translations from GNOME
David Woodhouse [Mon, 8 Sep 2014 12:53:34 +0000 (13:53 +0100)]
Import translations from GNOME

Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
10 years agoCheck to avoid calling iconv_close(-1) in openconnect_vpninfo_free
Chad Catlett [Wed, 27 Aug 2014 23:34:23 +0000 (18:34 -0500)]
Check to avoid calling iconv_close(-1) in openconnect_vpninfo_free

Signed-off-by: Chad Catlett <chad@catlett.info>
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
10 years agoUse inet_pton() to provide inet_aton() functionality
David Woodhouse [Fri, 22 Aug 2014 17:15:30 +0000 (12:15 -0500)]
Use inet_pton() to provide inet_aton() functionality

This is cleaner and simpler than the original compat code, and avoids
the strange issues that Nikos was reporting on his Windows 7
installation with inet_addr() not working correctly.

Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
10 years agoFix DeviceIoControl() calls to make NDIS6 TAP-Windows driver happy
David Woodhouse [Thu, 21 Aug 2014 22:08:08 +0000 (17:08 -0500)]
Fix DeviceIoControl() calls to make NDIS6 TAP-Windows driver happy

All calls appear to need both input and output buffers.

Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
10 years agoMerge branch 'hotp-java-v1' of git://github.com/cernekee/openconnect
David Woodhouse [Mon, 18 Aug 2014 01:37:06 +0000 (20:37 -0500)]
Merge branch 'hotp-java-v1' of git://github.com/cernekee/openconnect

10 years agoClean up OpenSSL key loading
David Woodhouse [Sun, 17 Aug 2014 19:57:04 +0000 (14:57 -0500)]
Clean up OpenSSL key loading

Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
10 years agoRemove cert_type field from struct openconnect_info
David Woodhouse [Sun, 17 Aug 2014 19:48:16 +0000 (14:48 -0500)]
Remove cert_type field from struct openconnect_info

We stopped actually using this a long time ago (4.00, June 2012).

Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
10 years agoStop using obsolete vpninfo->cert_type in OpenSSL code
David Woodhouse [Sun, 17 Aug 2014 19:47:20 +0000 (14:47 -0500)]
Stop using obsolete vpninfo->cert_type in OpenSSL code

This wants cleaning up a little but that can come in separate commits.

Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
10 years agoStop using obsolete vpninfo->cert_type in GnuTLS code
David Woodhouse [Sun, 17 Aug 2014 19:47:02 +0000 (14:47 -0500)]
Stop using obsolete vpninfo->cert_type in GnuTLS code

Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
10 years agoUse BIO_CLOSE when importing PEM private key with OpenSSL
David Woodhouse [Sun, 17 Aug 2014 19:46:13 +0000 (14:46 -0500)]
Use BIO_CLOSE when importing PEM private key with OpenSSL

Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
10 years agowww: Add notes on SecurID PIN usage
Kevin Cernekee [Sun, 17 Aug 2014 17:37:07 +0000 (10:37 -0700)]
www: Add notes on SecurID PIN usage

Signed-off-by: Kevin Cernekee <cernekee@gmail.com>
10 years agojni: Fix onTokenLock() invocation from native code
Kevin Cernekee [Sun, 17 Aug 2014 16:51:06 +0000 (09:51 -0700)]
jni: Fix onTokenLock() invocation from native code

Fix the type signature to reflect 0 arguments, and make sure the int
return value propagates back to the library.

Signed-off-by: Kevin Cernekee <cernekee@gmail.com>
10 years agojava: Add constant for OC_TOKEN_MODE_HOTP
Kevin Cernekee [Sun, 17 Aug 2014 16:20:21 +0000 (09:20 -0700)]
java: Add constant for OC_TOKEN_MODE_HOTP

Signed-off-by: Kevin Cernekee <cernekee@gmail.com>
10 years agoResync translations with sources
David Woodhouse [Sat, 16 Aug 2014 22:51:15 +0000 (23:51 +0100)]
Resync translations with sources

Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
10 years agoReread token file in lock_token()
David Woodhouse [Thu, 14 Aug 2014 10:30:48 +0000 (11:30 +0100)]
Reread token file in lock_token()

If someone else has used a HOTP token between the initial invocation of
openconnect and the time the token gets used, we want to use the current
value of the counter not the original value.

Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
10 years agoDisable soft token on failure
David Woodhouse [Thu, 14 Aug 2014 10:30:09 +0000 (11:30 +0100)]
Disable soft token on failure

Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
10 years agoAdd software token documentation
David Woodhouse [Wed, 13 Aug 2014 14:15:12 +0000 (15:15 +0100)]
Add software token documentation

Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
10 years agoMove stoken code to stoken.c
David Woodhouse [Wed, 13 Aug 2014 12:43:52 +0000 (13:43 +0100)]
Move stoken code to stoken.c

Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
10 years agoMove HOTP/TOTP code to oath.c
David Woodhouse [Wed, 13 Aug 2014 12:20:17 +0000 (13:20 +0100)]
Move HOTP/TOTP code to oath.c

Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
10 years agoShift TOTP/HOTP functions in library.c under a single #ifdef HAVE_LIBOATH
David Woodhouse [Wed, 13 Aug 2014 12:05:15 +0000 (13:05 +0100)]
Shift TOTP/HOTP functions in library.c under a single #ifdef HAVE_LIBOATH

Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
10 years agoShift TOTP/HOTP functions in auth.c under a single #ifdef HAVE_LIBOATH
David Woodhouse [Wed, 13 Aug 2014 12:01:14 +0000 (13:01 +0100)]
Shift TOTP/HOTP functions in auth.c under a single #ifdef HAVE_LIBOATH

Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
10 years agoAdd PSKC support
David Woodhouse [Wed, 13 Aug 2014 11:26:01 +0000 (12:26 +0100)]
Add PSKC support

Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
10 years agoAdd token lock/unlock callbacks to Java bindings
David Woodhouse [Tue, 12 Aug 2014 20:31:52 +0000 (21:31 +0100)]
Add token lock/unlock callbacks to Java bindings

Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
10 years agoUpdate changelog
David Woodhouse [Tue, 12 Aug 2014 12:46:36 +0000 (13:46 +0100)]
Update changelog

Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
10 years agoActually lock and unlock/write back HOTP tokens when counter updates
David Woodhouse [Tue, 12 Aug 2014 12:45:08 +0000 (13:45 +0100)]
Actually lock and unlock/write back HOTP tokens when counter updates

This was kind of the point...

Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
10 years agoSupport writing back to token files from openconnect(8) itself
David Woodhouse [Tue, 12 Aug 2014 12:43:26 +0000 (13:43 +0100)]
Support writing back to token files from openconnect(8) itself

This is quite basic; we probably ought to re-read the file and call
openconnect_set_token_mode() again if it's changed, and we ought to
have locking on the file to prevent concurrent updates. But this is a
good start.

Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
10 years agoAdd openconnect_set_token_callbacks() API
David Woodhouse [Tue, 12 Aug 2014 12:36:46 +0000 (13:36 +0100)]
Add openconnect_set_token_callbacks() API

This allows the application to lock the file (or other) storage when
a token is about to be generated, then to unlock it and write the new
counter back to the file when we're done.

This gives us a clean way to use HOTP tokens safely.

Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
10 years agoRemember what form we got the HOTP secret in
David Woodhouse [Tue, 12 Aug 2014 12:33:39 +0000 (13:33 +0100)]
Remember what form we got the HOTP secret in

We'll care about this shortly...

Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
10 years agoAllow HOTP/TOTP secrets to be specified in hex form
David Woodhouse [Tue, 12 Aug 2014 12:28:57 +0000 (13:28 +0100)]
Allow HOTP/TOTP secrets to be specified in hex form

Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
10 years agoAllow whitespace at end of HOTP and TOTP tokens
David Woodhouse [Tue, 12 Aug 2014 12:09:17 +0000 (13:09 +0100)]
Allow whitespace at end of HOTP and TOTP tokens

When we're reading them from a file, in particular, we want to tolerate
having a newline at the end.

Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
10 years agoFor HOTP tokens increment vpninfo->token_time in do_gen_hotp_code()
David Woodhouse [Mon, 11 Aug 2014 21:02:25 +0000 (22:02 +0100)]
For HOTP tokens increment vpninfo->token_time in do_gen_hotp_code()

This allows us to do a lock/increment/unlock cycle in one place.

Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
10 years agoUpdate changelog
David Woodhouse [Mon, 11 Aug 2014 11:36:16 +0000 (12:36 +0100)]
Update changelog

Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
10 years agoBe consistent about spelling of cancel{l,}ed
David Woodhouse [Mon, 11 Aug 2014 10:14:35 +0000 (11:14 +0100)]
Be consistent about spelling of cancel{l,}ed

The source uses 'cancelled', and the en_US file can be 'canceled' if that's
the way they prefer it.

Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
10 years agoConvert all args using GetCommandLineW() on Windows
David Woodhouse [Thu, 7 Aug 2014 23:16:06 +0000 (00:16 +0100)]
Convert all args using GetCommandLineW() on Windows

Checking for ? isn't enough — some characters are 'loosely' translated on
the 8-bit command line judging by https://bugzilla.redhat.com/1124436#c2

Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
10 years agoUpdate translations from GNOME
David Woodhouse [Thu, 7 Aug 2014 16:06:37 +0000 (17:06 +0100)]
Update translations from GNOME

Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
10 years agoMinor SSPI fixes
David Woodhouse [Thu, 7 Aug 2014 15:12:17 +0000 (16:12 +0100)]
Minor SSPI fixes

When using NTLM, the payload sometimes does get encrypted, so preserve it.
And after DecryptMessage() don't free the buffer. It'll have been decrypted
in-place.

Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
10 years agoFix ntlm_auth handling to accept AF in auth reply
David Woodhouse [Tue, 5 Aug 2014 23:50:05 +0000 (00:50 +0100)]
Fix ntlm_auth handling to accept AF in auth reply

This is what it should have been giving all along, if it weren't for
Samba bug #10691. Also report the error better if we do get one.

Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
10 years agoFix endless loop when automatic NTLM auth fails
David Woodhouse [Tue, 5 Aug 2014 23:40:00 +0000 (00:40 +0100)]
Fix endless loop when automatic NTLM auth fails

We never *do* actually fall back from automatic to manual NTLM auth since
our criteria for using each are mutually exclusive. So arguably we could
simplify things somewhat and just set the state to AUTH_FAILED if the SSO
version fails. But let's preserve the option to fall back later, if we do
start prompting for a password on demand.

Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
10 years agoFix SSPI SOCKS auth crash on double-cleanup
David Woodhouse [Tue, 5 Aug 2014 15:33:29 +0000 (16:33 +0100)]
Fix SSPI SOCKS auth crash on double-cleanup

Using the state for this is horrid; we should make it idempotent like
the GSSAPI one is.

Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
10 years agoFix SOCKS SSPI auth to send final token client->server if needed
David Woodhouse [Tue, 5 Aug 2014 14:59:48 +0000 (15:59 +0100)]
Fix SOCKS SSPI auth to send final token client->server if needed

Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
10 years agoFix SOCKS GSSAPI auth to send final token client->server if needed
David Woodhouse [Tue, 5 Aug 2014 14:56:02 +0000 (15:56 +0100)]
Fix SOCKS GSSAPI auth to send final token client->server if needed

Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
11 years agoUpdate translations from GNOME
David Woodhouse [Mon, 4 Aug 2014 11:46:24 +0000 (12:46 +0100)]
Update translations from GNOME

11 years agoSilence iconv() compiler warnings on systems which expect (const char **)
David Woodhouse [Mon, 4 Aug 2014 11:38:44 +0000 (12:38 +0100)]
Silence iconv() compiler warnings on systems which expect (const char **)

Some systems expect the src argument to be const, so just cast it to (void *)
to shut them up.

Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
11 years agoUse O_BINARY for xmlconfig file
David Woodhouse [Mon, 4 Aug 2014 11:25:11 +0000 (12:25 +0100)]
Use O_BINARY for xmlconfig file

Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
11 years agoFix UTF-8 handling of config file name
David Woodhouse [Mon, 4 Aug 2014 11:20:49 +0000 (12:20 +0100)]
Fix UTF-8 handling of config file name

If we're going to convert the filename *from* UTF-8 when opening it, then
we really ought to be convert it *to* UTF-8 first. This would have shown
up if invoking openconnect in a non-UTF-8 locale, with a non-ASCII
filename.

On POSIX systems this whole thing is a no-op, since converting from any
arbitrary 8-bit charset to UTF-8 and back again effectively does nothing.

However, on Windows the convert_arg_to_utf8() function doesn't just work
on the input string; it looks aside with GetCommandLineW() to find the
*original* text on the command line, and uses that instead. So we really
do have to do the double "conversion" — even when it's simply converting to
UTF-8, *immediately* converting back again (in fopen_utf8()), and *never*
using it again.

Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
11 years agoFix NetBSD compile warnings with isspace()
David Woodhouse [Mon, 4 Aug 2014 11:19:36 +0000 (12:19 +0100)]
Fix NetBSD compile warnings with isspace()

As mentioned in the comment in openssl.c, we need to cast the arguments
for ctype functions first to (unsigned char) and then to (int) to make
NedBSD happy.

Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
11 years agoUse openconnect_[f]open_utf8() for xmlconfig, pidfile, config_file
Kevin Cernekee [Sun, 3 Aug 2014 19:36:04 +0000 (12:36 -0700)]
Use openconnect_[f]open_utf8() for xmlconfig, pidfile, config_file

Each option was sanity-tested under Linux.

Signed-off-by: Kevin Cernekee <cernekee@gmail.com>
11 years agossl: Support more read/write modes in openconnect_fopen_utf8()
Kevin Cernekee [Sun, 3 Aug 2014 19:43:48 +0000 (12:43 -0700)]
ssl: Support more read/write modes in openconnect_fopen_utf8()

This adds ASCII "r"/"w" and binary "wb".

Signed-off-by: Kevin Cernekee <cernekee@gmail.com>
11 years agossl: Allow openconnect_open_utf8() to be used with O_CREAT
Kevin Cernekee [Sun, 3 Aug 2014 19:31:05 +0000 (12:31 -0700)]
ssl: Allow openconnect_open_utf8() to be used with O_CREAT

Pass in the optional mode/pmode argument; per the API docs this will be
ignored if O_CREAT is not used.

The _WIN32 version is based on [1] but untested.

[1] http://msdn.microsoft.com/en-us/library/z0kc8e3z.aspx

Signed-off-by: Kevin Cernekee <cernekee@gmail.com>
11 years agoRename and export open_utf8(), fopen_utf8()
Kevin Cernekee [Sun, 3 Aug 2014 19:19:46 +0000 (12:19 -0700)]
Rename and export open_utf8(), fopen_utf8()

Make these functions available to main.c and xml.c.

Signed-off-by: Kevin Cernekee <cernekee@gmail.com>
11 years agoauth: Refactor stoken form handling
Kevin Cernekee [Sat, 2 Aug 2014 21:37:47 +0000 (14:37 -0700)]
auth: Refactor stoken form handling

Split the devid/pass form from the PIN form, to allow the use of new "v3"
tokens from the command line.  On newer libstoken versions, query the
PIN status and token interval time; use this information to figure out
whether to request a PIN for concatenation (ala hard tokens) and whether
to use a 30- or 60-second delta in response to the next tokencode prompt.

Signed-off-by: Kevin Cernekee <cernekee@gmail.com>
11 years agoauth: Rearrange stoken support code
Kevin Cernekee [Sat, 2 Aug 2014 21:36:39 +0000 (14:36 -0700)]
auth: Rearrange stoken support code

Put everything under one giant #ifdef to make it easier to add helper
functions later.  No change to the program logic.

Signed-off-by: Kevin Cernekee <cernekee@gmail.com>
11 years agomain: Allow reading --token-secret from a file
Kevin Cernekee [Sat, 2 Aug 2014 20:09:06 +0000 (13:09 -0700)]
main: Allow reading --token-secret from a file

If the token string starts with '@' or '/', assume it refers to a
filename.  None of the current token backends would recognize a string
starting with '@' or '/'.

The main use cases are:

 - Keeping token secrets from showing up in "ps" output
 - Allowing the use of SecurID SDTID XML files without import/conversion

This accepts "raw" HOTP/TOTP/SecurID tokens, not .stokenrc files.
Therefore it cannot use stoken_import_rcfile().

Signed-off-by: Kevin Cernekee <cernekee@gmail.com>
11 years agomain: Restore tty state if password prompt is aborted
Kevin Cernekee [Sat, 2 Aug 2014 20:20:34 +0000 (13:20 -0700)]
main: Restore tty state if password prompt is aborted

On Linux, hitting ^C on any of the password prompts now leaves ECHO
disabled, so the user needs to run "stty sane".  Restore the correct
settings prior to exiting.

Signed-off-by: Kevin Cernekee <cernekee@gmail.com>
11 years agoxml: Call openconnect_parse_url() on <HostAddress> entries
Kevin Cernekee [Sat, 2 Aug 2014 22:44:45 +0000 (15:44 -0700)]
xml: Call openconnect_parse_url() on <HostAddress> entries

Per the Cisco docs[1] these should just contain a FQDN, not a full URL.
But calling openconnect_parse_url() populates other internal fields, like
protocol and port; the latter is misreported as 0 right now:

    Host "MIT" has address "vpn.mit.edu"
    POST https://vpn.mit.edu:0/
    Attempting to connect to server 18.9.37.5:443

[1] http://www.cisco.com/c/en/us/td/docs/security/vpn_client/anyconnect/anyconnect30/administration/guide/anyconnectadmin30/ac13vpnxmlref.html

Signed-off-by: Kevin Cernekee <cernekee@gmail.com>
11 years agoxml: Trim whitespace from xmlconfig entries
Kevin Cernekee [Sat, 2 Aug 2014 22:27:36 +0000 (15:27 -0700)]
xml: Trim whitespace from xmlconfig entries

The Cisco implementations seem to be more tolerant of extraneous
whitespace in these files; for us, it can break hostname resolution:

    Host "MIT" has address "vpn.mit.edu "
    POST https://vpn.mit.edu :0/
    getaddrinfo failed for host 'vpn.mit.edu ': Name or service not known
    Failed to open HTTPS connection to vpn.mit.edu
    Failed to obtain WebVPN cookie

Signed-off-by: Kevin Cernekee <cernekee@gmail.com>
11 years agoxml: Make a generic function to read a file into a string
Kevin Cernekee [Sat, 2 Aug 2014 19:37:09 +0000 (12:37 -0700)]
xml: Make a generic function to read a file into a string

This replaces load_xml_conf_file(); it can be called by main.c for other
purposes.

Signed-off-by: Kevin Cernekee <cernekee@gmail.com>
11 years agoUpdate GUI page
David Woodhouse [Thu, 31 Jul 2014 22:17:42 +0000 (23:17 +0100)]
Update GUI page

Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
11 years agoRemove stray perror() in convert_str()
David Woodhouse [Thu, 31 Jul 2014 19:50:09 +0000 (20:50 +0100)]
Remove stray perror() in convert_str()

This was for debugging only.

Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
11 years agoWrap ifreq_set_ifname() in #ifndef __sun__ to shut the compiler up there
David Woodhouse [Thu, 31 Jul 2014 19:43:13 +0000 (20:43 +0100)]
Wrap ifreq_set_ifname() in #ifndef __sun__ to shut the compiler up there

Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
11 years agoFix csd_wrapper handling for non-UTF8 locales
David Woodhouse [Thu, 31 Jul 2014 15:45:23 +0000 (16:45 +0100)]
Fix csd_wrapper handling for non-UTF8 locales

Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
11 years agoCheck inputs for invalid UTF-8
David Woodhouse [Thu, 31 Jul 2014 15:42:46 +0000 (16:42 +0100)]
Check inputs for invalid UTF-8

Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
11 years agoMake buf_append_utf16le() suitable for validation-only
David Woodhouse [Thu, 31 Jul 2014 15:34:50 +0000 (16:34 +0100)]
Make buf_append_utf16le() suitable for validation-only

Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
11 years agoFix buf_append_utf16le() error handling harder
David Woodhouse [Thu, 31 Jul 2014 15:29:25 +0000 (16:29 +0100)]
Fix buf_append_utf16le() error handling harder

Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
11 years agoRemove static out_pkt
David Woodhouse [Thu, 31 Jul 2014 15:22:47 +0000 (16:22 +0100)]
Remove static out_pkt

Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
11 years agoFix asprintf() handling in openconnect_passphrase_from_fsid()
David Woodhouse [Thu, 31 Jul 2014 13:32:30 +0000 (14:32 +0100)]
Fix asprintf() handling in openconnect_passphrase_from_fsid()

It returns -1 on error. Not non-zero. We were always returning -ENOMEM but
nobody cared; if this fails they'll just ignore it and let us ask the user
for the passphrase anyway.

Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
11 years agoHandle UTF-8 sslkey in Windows openconnect_passphrase_from_fsid
David Woodhouse [Thu, 31 Jul 2014 13:31:37 +0000 (14:31 +0100)]
Handle UTF-8 sslkey in Windows openconnect_passphrase_from_fsid

Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
11 years agoHandle UTF-8 sslkey in Linux openconnect_passphrase_from_fsid
David Woodhouse [Thu, 31 Jul 2014 13:12:04 +0000 (14:12 +0100)]
Handle UTF-8 sslkey in Linux openconnect_passphrase_from_fsid

Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
11 years agoHandle UTF-8 sslkey in BSD openconnect_passphrase_from_fsid
David Woodhouse [Thu, 31 Jul 2014 13:11:52 +0000 (14:11 +0100)]
Handle UTF-8 sslkey in BSD openconnect_passphrase_from_fsid

Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
11 years agoUpdate changelog
David Woodhouse [Thu, 31 Jul 2014 13:05:32 +0000 (14:05 +0100)]
Update changelog

Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
11 years agoAdd web page about charset handling
David Woodhouse [Thu, 31 Jul 2014 13:01:59 +0000 (14:01 +0100)]
Add web page about charset handling

Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
11 years agoConvert last remaining OpenSSL code to open_utf8()
David Woodhouse [Thu, 31 Jul 2014 12:35:10 +0000 (13:35 +0100)]
Convert last remaining OpenSSL code to open_utf8()

Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
11 years agoConvert cafile to legacy charset for OpenSSL
David Woodhouse [Thu, 31 Jul 2014 12:34:30 +0000 (13:34 +0100)]
Convert cafile to legacy charset for OpenSSL

On Windows this is OK, but legacy UNIX needs the filename to be converted
back to the legacy charset.

Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
11 years agoAvoid SSL_CTX_use_RSAPrivateKey_file() because it doesn't handle UTF-8.
David Woodhouse [Thu, 31 Jul 2014 12:33:02 +0000 (13:33 +0100)]
Avoid SSL_CTX_use_RSAPrivateKey_file() because it doesn't handle UTF-8.

Open the file for ourselves with fopen_utf8() then do it manually.

Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
11 years agoExtend reload_pem_cert() to become load_cert_chain_file()
David Woodhouse [Thu, 31 Jul 2014 12:29:05 +0000 (13:29 +0100)]
Extend reload_pem_cert() to become load_cert_chain_file()

Because SSL_CTX_use_certificate_chain_file() doesn't cope with UTF-8
filenames, and we have a couple of other minor reasons for wanting to
reimplement it anyway (which is why we had reload_pem_cert() in the first
place).

Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
11 years agoFactor out OpenSSL install_extra_certs() from load_pkcs12_certificate()
David Woodhouse [Thu, 31 Jul 2014 12:17:25 +0000 (13:17 +0100)]
Factor out OpenSSL install_extra_certs() from load_pkcs12_certificate()

We'll want to use this again in a moment...

Also fix up the translations, since nobody had translated 'PKCS#12' anyway.

Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
11 years agoConvert vpnc_script to legacy charset (or UTF-16 for Windows)
David Woodhouse [Thu, 31 Jul 2014 12:14:26 +0000 (13:14 +0100)]
Convert vpnc_script to legacy charset (or UTF-16 for Windows)

The script_config_tun() function ends up being *just* different enough
between the two implementations that it's not quite worth trying to
reduce the duplication.

Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
11 years agoConvert $CISCO_BANNER environment variable to legacy charset
David Woodhouse [Thu, 31 Jul 2014 12:14:01 +0000 (13:14 +0100)]
Convert $CISCO_BANNER environment variable to legacy charset

Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
11 years agoConvert vpninfo->ifname to legacy charset for $TUNDEV and configuration
David Woodhouse [Thu, 31 Jul 2014 12:12:38 +0000 (13:12 +0100)]
Convert vpninfo->ifname to legacy charset for $TUNDEV and configuration

Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
11 years agoUse open_utf8() in GnuTLS load_datum()
David Woodhouse [Thu, 31 Jul 2014 12:11:06 +0000 (13:11 +0100)]
Use open_utf8() in GnuTLS load_datum()

This should cover all cert-related files including vpninfo->cafile.

Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
11 years agoAdd open_utf8() and fopen_utf8() functions for opening files
David Woodhouse [Thu, 31 Jul 2014 12:07:27 +0000 (13:07 +0100)]
Add open_utf8() and fopen_utf8() functions for opening files

These will convert to legacy charset as required (or UTF-16 for Windows).

Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
11 years agoAdd openconnect_utf8_to_legacy() helper function for charset conversion
David Woodhouse [Thu, 31 Jul 2014 12:03:58 +0000 (13:03 +0100)]
Add openconnect_utf8_to_legacy() helper function for charset conversion

In some cases, the library itself really is going to have to know about
legacy non-UTF8 locales — when opening files or setting environment
variables, for example.

Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
11 years agoFix some arguments missing dup_config_arg()
David Woodhouse [Thu, 31 Jul 2014 11:42:40 +0000 (12:42 +0100)]
Fix some arguments missing dup_config_arg()

These weren't getting convert to UTF-8.

Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
11 years agoTake a copy of the string that nl_langinfo() returns
David Woodhouse [Wed, 30 Jul 2014 10:36:43 +0000 (11:36 +0100)]
Take a copy of the string that nl_langinfo() returns

Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
11 years agoUse setlocale() unconditionally, complain if non-UTF8 locale and no iconv
David Woodhouse [Tue, 29 Jul 2014 14:57:24 +0000 (15:57 +0100)]
Use setlocale() unconditionally, complain if non-UTF8 locale and no iconv

Hopefully setlocale() is ubiquitous. Certainly nl_langinfo() seems to be
more often available than iconv(), so we can certainly complain if we are
run in a legacy non-UTF8 locale and we *don't* have conversion support.

Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
11 years agoAdd missing 'Proxy CONNECT request failed: %d' translation back
David Woodhouse [Tue, 29 Jul 2014 14:56:26 +0000 (15:56 +0100)]
Add missing 'Proxy CONNECT request failed: %d' translation back

We had a '%s' version of this, so just put that one back with the
appropriate substitution.

Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
11 years agoAdd conversion to UTF-8 of command-line arguments
David Woodhouse [Tue, 29 Jul 2014 14:01:35 +0000 (15:01 +0100)]
Add conversion to UTF-8 of command-line arguments

Hm, this isn't ideal in all cases; we end up converting filenames into
UTF-8 too, and we don't (yet) have facilities to convert *back* to the
local charset when trying to access them. And it's not entirely clear
we really want to have to.

But it does fix other things like '--interface=TAP♥', and is consistent
with the methodology of converting *everything* on the way in and out,
and being entirely consistent with UTF-8 internally.

We *might* want to add special-case hacks for keeping filenames in the
legacy charset internally, but then again we'd only have to convert *to*
UTF-8 for printing them if we did that.

Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
11 years agoIntroduce dup_config_arg() macro
David Woodhouse [Tue, 29 Jul 2014 12:41:39 +0000 (13:41 +0100)]
Introduce dup_config_arg() macro

Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
11 years agoMove Windows UTF-8 stdio functions up to live with POSIX ones
David Woodhouse [Tue, 29 Jul 2014 12:38:01 +0000 (13:38 +0100)]
Move Windows UTF-8 stdio functions up to live with POSIX ones

Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
11 years agoFix tun device matching with --interface on Windows
David Woodhouse [Tue, 29 Jul 2014 11:04:47 +0000 (12:04 +0100)]
Fix tun device matching with --interface on Windows

Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
11 years agoUse _wputenv() for Windows environment
David Woodhouse [Tue, 29 Jul 2014 10:22:38 +0000 (11:22 +0100)]
Use _wputenv() for Windows environment

This fixes the handling of non-ASCII (and out-of-codepage) tundev names.
It looks like cscript/vpnc-script-win.js/netsh all Just Work™ at least
here on Windows 7 with my 'TAP♥' device.

Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
11 years agoFixes for buf_append_utf16le()
David Woodhouse [Tue, 29 Jul 2014 10:18:34 +0000 (11:18 +0100)]
Fixes for buf_append_utf16le()

Make it set buf_error() when it returns -EINVAL, to ensure callers will
catch the problem. Previously, ntlm_set_string_binary() and  sspi_setup()
would not have noticed.

Also, NUL-terminate the buffer. Not accounting for it, but just putting
two zero bytes after the string so that it can be used as a
NUL-terminated (wchar_t *). Not entirely sure how sspi_setup() was
working before this, except perhaps pure luck.

Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
11 years agoHandle UTF-8 output on Windows too
David Woodhouse [Mon, 28 Jul 2014 16:00:37 +0000 (17:00 +0100)]
Handle UTF-8 output on Windows too

Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
11 years agoHandle UTF-8 input on Windows
David Woodhouse [Mon, 28 Jul 2014 15:49:50 +0000 (16:49 +0100)]
Handle UTF-8 input on Windows

Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
11 years agoSeparate read_stdin() implementations for Windows vs. POSIX
David Woodhouse [Mon, 28 Jul 2014 15:23:59 +0000 (16:23 +0100)]
Separate read_stdin() implementations for Windows vs. POSIX

They're about to get even *more* different...

Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
11 years agoConvert to UTF-8 when reading from stdin
David Woodhouse [Mon, 28 Jul 2014 14:25:57 +0000 (15:25 +0100)]
Convert to UTF-8 when reading from stdin

Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
11 years agoAttempt to convert output to locale charset from UTF-8
David Woodhouse [Mon, 28 Jul 2014 14:03:30 +0000 (15:03 +0100)]
Attempt to convert output to locale charset from UTF-8

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