diff --git a/lib/Makefile.inc b/lib/Makefile.inc index 39884d0b15a6698e3b06d0ca930321d3e25a2806..186c683edce42eaccc22c02e7c4d08e373deacec 100644 --- a/lib/Makefile.inc +++ b/lib/Makefile.inc @@ -20,6 +20,10 @@ # ########################################################################### +LIB_VAUTH_CFILES = vauth/vauth.c + +LIB_VAUTH_HFILES = vauth/vauth.h + LIB_VTLS_CFILES = vtls/openssl.c vtls/gtls.c vtls/vtls.c vtls/nss.c \ vtls/polarssl.c vtls/polarssl_threadlock.c vtls/axtls.c \ vtls/cyassl.c vtls/schannel.c vtls/darwinssl.c vtls/gskit.c \ @@ -71,5 +75,5 @@ LIB_HFILES = arpa_telnet.h netrc.h file.h timeval.h hostip.h progress.h \ LIB_RCFILES = libcurl.rc -CSOURCES = $(LIB_CFILES) $(LIB_VTLS_CFILES) -HHEADERS = $(LIB_HFILES) $(LIB_VTLS_HFILES) +CSOURCES = $(LIB_CFILES) $(LIB_VAUTH_CFILES) $(LIB_VTLS_CFILES) +HHEADERS = $(LIB_HFILES) $(LIB_VAUTH_HFILES) $(LIB_VTLS_HFILES) diff --git a/lib/Makefile.vc6 b/lib/Makefile.vc6 index 18079f7c5c0e1725caf0cc599cfaca345124306b..ebd45ad451f90574626f3ad7cc7c307503f3e886 100644 --- a/lib/Makefile.vc6 +++ b/lib/Makefile.vc6 @@ -620,6 +620,7 @@ X_OBJS= \ $(DIROBJ)\speedcheck.obj \ $(DIROBJ)\splay.obj \ $(DIROBJ)\ssh.obj \ + $(DIROBJ)\vauth.obj \ $(DIROBJ)\vtls.obj \ $(DIROBJ)\openssl.obj \ $(DIROBJ)\strdup.obj \ diff --git a/lib/curl_sasl.c b/lib/curl_sasl.c index 945d7523256753ed118a17b724421285422ae02e..0a6e5e9247eb07793caba26afdaca1ee0c74dfba 100644 --- a/lib/curl_sasl.c +++ b/lib/curl_sasl.c @@ -36,6 +36,7 @@ #include "curl_base64.h" #include "curl_md5.h" +#include "vauth/vauth.h" #include "vtls/vtls.h" #include "curl_hmac.h" #include "curl_sasl.h" @@ -260,26 +261,6 @@ static CURLcode sasl_digest_get_qop_values(const char *options, int *value) } #endif /* !CURL_DISABLE_CRYPTO_AUTH && !USE_WINDOWS_SSPI */ -#if !defined(USE_WINDOWS_SSPI) -/* - * Curl_sasl_build_spn() - * - * This is used to build a SPN string in the format service/instance. - * - * Parameters: - * - * service [in] - The service type such as www, smtp, pop or imap. - * instance [in] - The host name or realm. - * - * Returns a pointer to the newly allocated SPN. - */ -char *Curl_sasl_build_spn(const char *service, const char *instance) -{ - /* Generate and return our SPN */ - return aprintf("%s/%s", service, instance); -} -#endif - /* * sasl_create_plain_message() * diff --git a/lib/curl_sasl.h b/lib/curl_sasl.h index 2175e03d47dd12d8c0074917d6ccce13e7088f9c..c0dd54cc0edc8bc1cc1eee2e6ef811ec581ef6ff 100644 --- a/lib/curl_sasl.h +++ b/lib/curl_sasl.h @@ -136,17 +136,6 @@ struct SASL { (wordlen == (sizeof(mech) - 1) / sizeof(char) && \ !memcmp(line, mech, wordlen)) -/* This is used to build a SPN string */ -#if !defined(USE_WINDOWS_SSPI) -char *Curl_sasl_build_spn(const char *service, const char *instance); -#else -TCHAR *Curl_sasl_build_spn(const char *service, const char *instance); -#endif - -#if defined(HAVE_GSSAPI) -char *Curl_sasl_build_gssapi_spn(const char *service, const char *instance); -#endif - #ifndef CURL_DISABLE_CRYPTO_AUTH /* This is used to extract the realm from a challenge message */ bool Curl_sasl_digest_get_pair(const char *str, char *value, char *content, diff --git a/lib/curl_sasl_gssapi.c b/lib/curl_sasl_gssapi.c index dcc0498b9fe658d3078306759042765dd27b8279..62a95a6c9f1a33ba6c506088f62ea4bf89344318 100644 --- a/lib/curl_sasl_gssapi.c +++ b/lib/curl_sasl_gssapi.c @@ -29,6 +29,7 @@ #include +#include "vauth/vauth.h" #include "curl_sasl.h" #include "urldata.h" #include "curl_base64.h" @@ -40,24 +41,6 @@ #include "curl_memory.h" #include "memdebug.h" -/* -* Curl_sasl_build_gssapi_spn() -* -* This is used to build a SPN string in the format service@instance. -* -* Parameters: -* -* service [in] - The service type such as www, smtp, pop or imap. -* instance [in] - The host name or realm. -* -* Returns a pointer to the newly allocated SPN. -*/ -char *Curl_sasl_build_gssapi_spn(const char *service, const char *instance) -{ - /* Generate and return our SPN */ - return aprintf("%s@%s", service, instance); -} - /* * Curl_sasl_create_gssapi_user_message() * diff --git a/lib/curl_sasl_sspi.c b/lib/curl_sasl_sspi.c index f46376cc45537d09bd461176c1a721cca3cb11c3..bdb1ea6d9b24dc1daf2a105e833bf321c01284f9 100644 --- a/lib/curl_sasl_sspi.c +++ b/lib/curl_sasl_sspi.c @@ -33,6 +33,7 @@ #include #include "curl_sasl.h" +#include "vauth/vauth.h" #include "urldata.h" #include "curl_base64.h" #include "warnless.h" @@ -46,51 +47,6 @@ #include "curl_memory.h" #include "memdebug.h" -/* - * Curl_sasl_build_spn() - * - * This is used to build a SPN string in the format service/instance. - * - * Parameters: - * - * serivce [in] - The service type such as www, smtp, pop or imap. - * instance [in] - The host name or realm. - * - * Returns a pointer to the newly allocated SPN. - */ -TCHAR *Curl_sasl_build_spn(const char *service, const char *instance) -{ - char *utf8_spn = NULL; - TCHAR *tchar_spn = NULL; - - /* Note: We could use DsMakeSPN() or DsClientMakeSpnForTargetServer() rather - than doing this ourselves but the first is only available in Windows XP - and Windows Server 2003 and the latter is only available in Windows 2000 - but not Windows95/98/ME or Windows NT4.0 unless the Active Directory - Client Extensions are installed. As such it is far simpler for us to - formulate the SPN instead. */ - - /* Allocate our UTF8 based SPN */ - utf8_spn = aprintf("%s/%s", service, instance); - if(!utf8_spn) { - return NULL; - } - - /* Allocate our TCHAR based SPN */ - tchar_spn = Curl_convert_UTF8_to_tchar(utf8_spn); - if(!tchar_spn) { - free(utf8_spn); - - return NULL; - } - - /* Release the UTF8 variant when operating with Unicode */ - Curl_unicodefree(utf8_spn); - - /* Return our newly allocated SPN */ - return tchar_spn; -} - #if !defined(CURL_DISABLE_CRYPTO_AUTH) /* * Curl_sasl_create_digest_md5_message() diff --git a/lib/http_negotiate.c b/lib/http_negotiate.c index 4a808f8f381daa76ddf39f97191df1afa079d75e..a22b3a3241b5b0290c32c671d0272e89e6307a1b 100644 --- a/lib/http_negotiate.c +++ b/lib/http_negotiate.c @@ -30,7 +30,7 @@ #include "rawstr.h" #include "curl_base64.h" #include "http_negotiate.h" -#include "curl_sasl.h" +#include "vauth/vauth.h" #include "url.h" #include "curl_printf.h" diff --git a/lib/http_negotiate_sspi.c b/lib/http_negotiate_sspi.c index d2643bb414d2c0c50fbf0c870345264fed8ec2c6..f3c8c4d108d901708202470bdfae7136b1a09332 100644 --- a/lib/http_negotiate_sspi.c +++ b/lib/http_negotiate_sspi.c @@ -31,7 +31,7 @@ #include "rawstr.h" #include "warnless.h" #include "curl_base64.h" -#include "curl_sasl.h" +#include "vauth/vauth.h" #include "http_negotiate.h" #include "curl_multibyte.h" #include "curl_printf.h" diff --git a/lib/vauth/vauth.c b/lib/vauth/vauth.c new file mode 100644 index 0000000000000000000000000000000000000000..38a9c793abdc81b2921f0c305e45c0ef51ec5879 --- /dev/null +++ b/lib/vauth/vauth.c @@ -0,0 +1,106 @@ +/*************************************************************************** + * _ _ ____ _ + * Project ___| | | | _ \| | + * / __| | | | |_) | | + * | (__| |_| | _ <| |___ + * \___|\___/|_| \_\_____| + * + * Copyright (C) 2014 - 2015, Steve Holme, . + * + * This software is licensed as described in the file COPYING, which + * you should have received as part of this distribution. The terms + * are also available at http://curl.haxx.se/docs/copyright.html. + * + * You may opt to use, copy, modify, merge, publish, distribute and/or sell + * copies of the Software, and permit persons to whom the Software is + * furnished to do so, under the terms of the COPYING file. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + ***************************************************************************/ + +#include "curl_setup.h" + +#include + +#include "vauth.h" +#include "curl_multibyte.h" +#include "curl_printf.h" + +/* The last #include files should be: */ +#include "curl_memory.h" +#include "memdebug.h" + +/* + * Curl_sasl_build_spn() + * + * This is used to build a SPN string in the format service/instance. + * + * Parameters: + * + * service [in] - The service type such as www, smtp, pop or imap. + * instance [in] - The host name or realm. + * + * Returns a pointer to the newly allocated SPN. + */ +#if !defined(USE_WINDOWS_SSPI) +char *Curl_sasl_build_spn(const char *service, const char *instance) +{ + /* Generate and return our SPN */ + return aprintf("%s/%s", service, instance); +} +#else +TCHAR *Curl_sasl_build_spn(const char *service, const char *instance) +{ + char *utf8_spn = NULL; + TCHAR *tchar_spn = NULL; + + /* Note: We could use DsMakeSPN() or DsClientMakeSpnForTargetServer() rather + than doing this ourselves but the first is only available in Windows XP + and Windows Server 2003 and the latter is only available in Windows 2000 + but not Windows95/98/ME or Windows NT4.0 unless the Active Directory + Client Extensions are installed. As such it is far simpler for us to + formulate the SPN instead. */ + + /* Allocate our UTF8 based SPN */ + utf8_spn = aprintf("%s/%s", service, instance); + if(!utf8_spn) { + return NULL; + } + + /* Allocate our TCHAR based SPN */ + tchar_spn = Curl_convert_UTF8_to_tchar(utf8_spn); + if(!tchar_spn) { + free(utf8_spn); + + return NULL; + } + + /* Release the UTF8 variant when operating with Unicode */ + Curl_unicodefree(utf8_spn); + + /* Return our newly allocated SPN */ + return tchar_spn; +} +#endif /* USE_WINDOWS_SSPI */ + +#if defined(HAVE_GSSAPI) +/* + * Curl_sasl_build_gssapi_spn() + * + * This is used to build a SPN string in the format service@instance. + * + * Parameters: + * + * service [in] - The service type such as www, smtp, pop or imap. + * instance [in] - The host name or realm. + * + * Returns a pointer to the newly allocated SPN. + */ +char *Curl_sasl_build_gssapi_spn(const char *service, const char *instance) +{ + /* Generate and return our SPN */ + return aprintf("%s@%s", service, instance); +} +#endif /* HAVE_GSSAPI */ diff --git a/lib/vauth/vauth.h b/lib/vauth/vauth.h new file mode 100644 index 0000000000000000000000000000000000000000..d0961e5a7161a255f97925da63ba9942a8d6329b --- /dev/null +++ b/lib/vauth/vauth.h @@ -0,0 +1,38 @@ +#ifndef HEADER_CURL_VAUTH_H +#define HEADER_CURL_VAUTH_H +/*************************************************************************** + * _ _ ____ _ + * Project ___| | | | _ \| | + * / __| | | | |_) | | + * | (__| |_| | _ <| |___ + * \___|\___/|_| \_\_____| + * + * Copyright (C) 2014 - 2015, Steve Holme, . + * + * This software is licensed as described in the file COPYING, which + * you should have received as part of this distribution. The terms + * are also available at http://curl.haxx.se/docs/copyright.html. + * + * You may opt to use, copy, modify, merge, publish, distribute and/or sell + * copies of the Software, and permit persons to whom the Software is + * furnished to do so, under the terms of the COPYING file. + * + * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY + * KIND, either express or implied. + * + ***************************************************************************/ + +#include + +/* This is used to build a SPN string */ +#if !defined(USE_WINDOWS_SSPI) +char *Curl_sasl_build_spn(const char *service, const char *instance); +#else +TCHAR *Curl_sasl_build_spn(const char *service, const char *instance); +#endif + +#if defined(HAVE_GSSAPI) +char *Curl_sasl_build_gssapi_spn(const char *service, const char *instance); +#endif + +#endif /* HEADER_CURL_VAUTH_H */ diff --git a/packages/Symbian/group/libcurl.mmp b/packages/Symbian/group/libcurl.mmp index 545cdee947acdf6c686a3e3c05476427ca8e34a9..dedd134fc460c199276f9e32fc89d8e30b4cfa33 100644 --- a/packages/Symbian/group/libcurl.mmp +++ b/packages/Symbian/group/libcurl.mmp @@ -40,7 +40,7 @@ SOURCE \ curl_ntlm.c curl_ntlm_wb.c curl_ntlm_core.c curl_ntlm_msgs.c \ curl_sasl.c vtls/schannel.c curl_multibyte.c vtls/darwinssl.c \ conncache.c curl_sasl_sspi.c smb.c curl_sasl_gssapi.c \ - curl_endian.c curl_des.c + curl_endian.c curl_des.c vauth/vauth.c USERINCLUDE ../../../lib ../../../include/curl #ifdef ENABLE_SSL