lib: make SMB support opt-in

The SMB protocol has weak security and is rarely used these days.

Note that SMB also requires NTLM enabled.

Closes #20846
This commit is contained in:
Daniel Stenberg 2026-03-21 15:37:58 +01:00
parent 06a83340b1
commit 6393103b99
No known key found for this signature in database
GPG key ID: 5CC908FDB71E12C2
12 changed files with 31 additions and 34 deletions

View file

@ -146,7 +146,7 @@
#cmakedefine CURL_DISABLE_SHUFFLE_DNS 1
/* disables SMB */
#cmakedefine CURL_DISABLE_SMB 1
#cmakedefine CURL_ENABLE_SMB 1
/* disables SMTP */
#cmakedefine CURL_DISABLE_SMTP 1

View file

@ -258,9 +258,6 @@
# ifndef CURL_DISABLE_RTSP
# define CURL_DISABLE_RTSP
# endif
# ifndef CURL_DISABLE_SMB
# define CURL_DISABLE_SMB
# endif
# ifndef CURL_DISABLE_SMTP
# define CURL_DISABLE_SMTP
# endif

View file

@ -309,10 +309,10 @@ const struct Curl_scheme Curl_scheme_scp = {
const struct Curl_scheme Curl_scheme_smb = {
"smb", /* scheme */
#if defined(CURL_DISABLE_SMB) || !defined(USE_CURL_NTLM_CORE)
ZERO_NULL,
#else
#if defined(CURL_ENABLE_SMB) && defined(USE_CURL_NTLM_CORE)
&Curl_protocol_smb,
#else
ZERO_NULL,
#endif
CURLPROTO_SMB, /* protocol */
CURLPROTO_SMB, /* family */
@ -322,11 +322,11 @@ const struct Curl_scheme Curl_scheme_smb = {
const struct Curl_scheme Curl_scheme_smbs = {
"smbs", /* scheme */
#if defined(CURL_DISABLE_SMB) || !defined(USE_CURL_NTLM_CORE) || \
!defined(USE_SSL)
ZERO_NULL,
#else
#if defined(CURL_ENABLE_SMB) && defined(USE_CURL_NTLM_CORE) && \
defined(USE_SSL)
&Curl_protocol_smb,
#else
ZERO_NULL,
#endif
CURLPROTO_SMBS, /* protocol */
CURLPROTO_SMB, /* family */

View file

@ -25,7 +25,7 @@
#include "curl_setup.h"
#include "urldata.h"
#if !defined(CURL_DISABLE_SMB) && defined(USE_CURL_NTLM_CORE)
#if defined(CURL_ENABLE_SMB) && defined(USE_CURL_NTLM_CORE)
#ifdef HAVE_ARPA_INET_H
#include <arpa/inet.h> /* for htons() */
@ -1228,4 +1228,4 @@ const struct Curl_protocol Curl_protocol_smb = {
ZERO_NULL, /* follow */
};
#endif /* CURL_DISABLE_SMB && USE_CURL_NTLM_CORE && SIZEOF_CURL_OFF_T > 4 */
#endif /* CURL_ENABLE_SMB && USE_CURL_NTLM_CORE && SIZEOF_CURL_OFF_T > 4 */

View file

@ -24,7 +24,7 @@
* SPDX-License-Identifier: curl
*
***************************************************************************/
#if !defined(CURL_DISABLE_SMB) && defined(USE_CURL_NTLM_CORE)
#if defined(CURL_ENABLE_SMB) && defined(USE_CURL_NTLM_CORE)
extern const struct Curl_protocol Curl_protocol_smb;
#endif

View file

@ -345,7 +345,7 @@ static const char * const supported_protocols[] = {
"scp",
"sftp",
#endif
#if !defined(CURL_DISABLE_SMB) && defined(USE_CURL_NTLM_CORE)
#if defined(CURL_ENABLE_SMB) && defined(USE_CURL_NTLM_CORE)
"smb",
# ifdef USE_SSL
"smbs",