Skip to content
Permalink
Browse files

cmake: Enable SMB for Windows builds

- Define USE_WIN32_CRYPTO by default. This enables SMB.

- Show whether SMB is enabled in the "Enabled features" output.

- Fix mingw compiler warning for call to CryptHashData by casting away
  const param. mingw CryptHashData prototype is wrong.

Closes #4717
  • Loading branch information
marc-groundctl authored and jay committed Dec 13, 2019
1 parent c9c551f commit ea6d6205d9e13ce688afed28f6a09ade49b348d3
Showing with 22 additions and 6 deletions.
  1. +18 −5 CMakeLists.txt
  2. +3 −0 lib/curl_config.h.cmake
  3. +1 −1 lib/md4.c
@@ -172,6 +172,7 @@ if(HTTP_ONLY)
set(CURL_DISABLE_RTSP ON)
set(CURL_DISABLE_POP3 ON)
set(CURL_DISABLE_IMAP ON)
set(CURL_DISABLE_SMB ON)
set(CURL_DISABLE_SMTP ON)
set(CURL_DISABLE_GOPHER ON)
endif()
@@ -412,6 +413,10 @@ if(USE_NGHTTP2)
list(APPEND CURL_LIBS ${NGHTTP2_LIBRARIES})
endif()

if(WIN32)
set(USE_WIN32_CRYPTO ON)
endif()

if(NOT CURL_DISABLE_LDAP)
if(WIN32)
option(USE_WIN32_LDAP "Use Windows LDAP implementation" ON)
@@ -1199,6 +1204,14 @@ if(BUILD_TESTING)
add_subdirectory(tests)
endif()

# NTLM support requires crypto function adaptions from various SSL libs
# TODO alternative SSL libs tests for SSP1, GNUTLS, NSS
if(NOT CURL_DISABLE_CRYPTO_AUTH AND (USE_OPENSSL OR USE_WINDOWS_SSPI OR USE_DARWINSSL OR USE_MBEDTLS OR USE_WIN32_CRYPTO))
set(use_ntlm ON)
else()
set(use_ntlm OFF)
endif()

# Helper to populate a list (_items) with a label when conditions (the remaining
# args) are satisfied
function(_add_if label)
@@ -1228,11 +1241,9 @@ _add_if("Kerberos" NOT CURL_DISABLE_CRYPTO_AUTH AND
(HAVE_GSSAPI OR USE_WINDOWS_SSPI))
# NTLM support requires crypto function adaptions from various SSL libs
# TODO alternative SSL libs tests for SSP1, GNUTLS, NSS
if(NOT CURL_DISABLE_CRYPTO_AUTH AND (USE_OPENSSL OR USE_WINDOWS_SSPI OR USE_SECTRANSP OR USE_MBEDTLS OR USE_NSS))
_add_if("NTLM" 1)
# TODO missing option (autoconf: --enable-ntlm-wb)
_add_if("NTLM_WB" NOT CURL_DISABLE_HTTP AND NTLM_WB_ENABLED)
endif()
_add_if("NTLM" use_ntlm)
# TODO missing option (autoconf: --enable-ntlm-wb)
_add_if("NTLM_WB" use_ntlm AND NOT CURL_DISABLE_HTTP AND NTLM_WB_ENABLED)
# TODO missing option (--enable-tls-srp), depends on GNUTLS_SRP/OPENSSL_SRP
_add_if("TLS-SRP" USE_TLS_SRP)
# TODO option --with-nghttp2 tests for nghttp2 lib and nghttp2/nghttp2.h header
@@ -1261,6 +1272,8 @@ _add_if("POP3" NOT CURL_DISABLE_POP3)
_add_if("POP3S" NOT CURL_DISABLE_POP3 AND SSL_ENABLED)
_add_if("IMAP" NOT CURL_DISABLE_IMAP)
_add_if("IMAPS" NOT CURL_DISABLE_IMAP AND SSL_ENABLED)
_add_if("SMB" NOT CURL_DISABLE_SMB AND use_ntlm)
_add_if("SMBS" NOT CURL_DISABLE_SMB AND SSL_ENABLED AND use_ntlm)
_add_if("SMTP" NOT CURL_DISABLE_SMTP)
_add_if("SMTPS" NOT CURL_DISABLE_SMTP AND SSL_ENABLED)
_add_if("SCP" USE_LIBSSH2)
@@ -73,6 +73,9 @@
#define CURL_EXTERN_SYMBOL
#endif

/* Allow SMB to work on Windows */
#cmakedefine USE_WIN32_CRYPTO

/* Use Windows LDAP implementation */
#cmakedefine USE_WIN32_LDAP 1

@@ -156,7 +156,7 @@ static void MD4_Init(MD4_CTX *ctx)

static void MD4_Update(MD4_CTX *ctx, const void *data, unsigned long size)
{
CryptHashData(ctx->hHash, data, (unsigned int) size, 0);
CryptHashData(ctx->hHash, (BYTE *)data, (unsigned int) size, 0);
}

static void MD4_Final(unsigned char *result, MD4_CTX *ctx)

0 comments on commit ea6d620

Please sign in to comment.
You can’t perform that action at this time.