Skip to content

CDRIVER-4680 Remove ENABLE_ICU option and related code #1342

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Jul 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 20 additions & 6 deletions .evergreen/etc/spec.patch
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
--- mongo-c-driver.spec.orig 2021-11-04 16:34:50.350572049 -0400
+++ mongo-c-driver.spec 2021-11-04 16:37:54.962271319 -0400
@@ -10,17 +10,17 @@
+--- mongo-c-driver.spec.orig 2023-07-17 14:42:52.236247070 -0400
++++ mongo-c-driver.spec 2023-07-17 14:43:16.572305452 -0400
@@ -10,7 +10,7 @@
%global gh_project mongo-c-driver
%global libname libmongoc
%global libver 1.0
Expand All @@ -9,9 +9,7 @@
#global up_prever rc0
# disabled as require a MongoDB server
%bcond_with tests

# disable for bootstrap (libmongocrypt needs libbson)
%bcond_without libmongocrypt
@@ -20,7 +20,7 @@

Name: mongo-c-driver
Summary: Client library written in C for MongoDB
Expand All @@ -20,3 +18,19 @@
Release: 1%{?dist}
# See THIRD_PARTY_NOTICES
License: Apache-2.0 AND ISC AND MIT AND Zlib
@@ -37,7 +37,6 @@
BuildRequires: pkgconfig(libsasl2)
BuildRequires: pkgconfig(zlib)
BuildRequires: pkgconfig(snappy)
-BuildRequires: pkgconfig(icu-uc)
BuildRequires: pkgconfig(libzstd)
%if %{with tests}
BuildRequires: mongodb-server
@@ -123,7 +122,6 @@
-DENABLE_SSL:STRING=OPENSSL \
-DENABLE_SASL:STRING=CYRUS \
-DENABLE_MONGODB_AWS_AUTH:STRING=ON \
- -DENABLE_ICU:STRING=ON \
-DENABLE_AUTOMATIC_INIT_AND_CLEANUP:BOOL=OFF \
-DENABLE_CRYPTO_SYSTEM_PROFILE:BOOL=ON \
-DENABLE_MAN_PAGES:BOOL=ON \
1 change: 0 additions & 1 deletion .evergreen/scripts/compile-scan-build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ configure_flags_append "-DCMAKE_SKIP_RPATH=TRUE" # Avoid hardcoding absolute pat
configure_flags_append "-DENABLE_AUTOMATIC_INIT_AND_CLEANUP=OFF"
configure_flags_append "-DENABLE_CLIENT_SIDE_ENCRYPTION=ON"
configure_flags_append "-DENABLE_DEBUG_ASSERTIONS=ON"
configure_flags_append "-DENABLE_ICU=OFF"
configure_flags_append "-DENABLE_MAINTAINER_FLAGS=ON"
configure_flags_append "-DENABLE_SASL=OFF"
configure_flags_append "-DENABLE_SNAPPY=OFF"
Expand Down
1 change: 0 additions & 1 deletion .evergreen/scripts/compile-test-azurekms.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ echo "Compile test-azurekms ... begin"
-DENABLE_SNAPPY=OFF \
-DENABLE_ZSTD=OFF \
-DENABLE_ZLIB=OFF \
-DENABLE_ICU=OFF \
-DENABLE_SRV=OFF \
-DENABLE_CLIENT_SIDE_ENCRYPTION=ON \
-DCMAKE_PREFIX_PATH="$INSTALL_DIR" \
Expand Down
1 change: 0 additions & 1 deletion .evergreen/scripts/compile-test-gcpkms.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ echo "Compile test-gcpkms ... begin"
-DENABLE_SNAPPY=OFF \
-DENABLE_ZSTD=OFF \
-DENABLE_ZLIB=OFF \
-DENABLE_ICU=OFF \
-DENABLE_SRV=OFF \
-DENABLE_CLIENT_SIDE_ENCRYPTION=ON \
-DCMAKE_PREFIX_PATH="$INSTALL_DIR" \
Expand Down
2 changes: 1 addition & 1 deletion .evergreen/scripts/debian_package_build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export DEBOOTSTRAP_DIR=`pwd`/debootstrap.git
sudo -E ./debootstrap.git/debootstrap unstable ./unstable-chroot/ http://cdn-aws.deb.debian.org/debian
cp -a mongoc ./unstable-chroot/tmp/
sudo chroot ./unstable-chroot /bin/bash -c "(\
apt-get install -y build-essential git-buildpackage fakeroot debhelper cmake libssl-dev pkg-config python3-sphinx zlib1g-dev libicu-dev libsasl2-dev libsnappy-dev libzstd-dev libmongocrypt-dev libjs-mathjax libutf8proc-dev && \
apt-get install -y build-essential git-buildpackage fakeroot debhelper cmake libssl-dev pkg-config python3-sphinx zlib1g-dev libsasl2-dev libsnappy-dev libzstd-dev libmongocrypt-dev libjs-mathjax libutf8proc-dev && \
chown -R root:root /tmp/mongoc && \
cd /tmp/mongoc && \
git clean -fdx && \
Expand Down
5 changes: 0 additions & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -127,9 +127,6 @@ mongo_setting(
]]
)

mongo_setting(ENABLE_ICU "Enable ICU support, needed for non-ASCII usernames and passwords"
OPTIONS ON OFF AUTO
DEFAULT VALUE AUTO)
mongo_setting(ENABLE_CLIENT_SIDE_ENCRYPTION "Enable In-Use Encryption support. Requires additional support libraries."
OPTIONS ON OFF AUTO
DEFAULT VALUE AUTO)
Expand Down Expand Up @@ -472,8 +469,6 @@ if (ENABLE_MONGOC)
${SOURCE_DIR}/src/zlib-1.2.13/gzwrite.c
)

set (MONGOC_ENABLE_ICU 0)

set (CPACK_RESOURCE_FILE_LICENSE "${SOURCE_DIR}/COPYING")

include (CPack)
Expand Down
7 changes: 7 additions & 0 deletions NEWS
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
libmongoc 1.25.0 (Unreleased)
=============================

Improvements:

* Remove optional dependency of libicu.

libmongoc 1.24.2
================

Expand Down
1 change: 0 additions & 1 deletion debian/control
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ Build-Depends: debhelper (>= 11),
python3-sphinx,
libmongocrypt-dev <!pkg.mongo-c-driver.no-libmongocrypt>,
zlib1g-dev,
libicu-dev,
libsasl2-dev,
libsnappy-dev,
libutf8proc-dev,
Expand Down
37 changes: 11 additions & 26 deletions src/libmongoc/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -366,28 +366,6 @@ if (ENABLE_SHM_COUNTERS)
endif ()
endif ()

if (NOT ENABLE_ICU MATCHES "AUTO|ON|OFF")
message (FATAL_ERROR, "ENABLE_ICU option must be AUTO, ON, or OFF")
endif()

if (NOT ENABLE_ICU STREQUAL OFF)
if (ENABLE_ICU STREQUAL ON)
# do not suppress log output if find_package cannot find ICU
find_package (ICU COMPONENTS uc)
elseif (ENABLE_ICU STREQUAL AUTO)
find_package (ICU QUIET COMPONENTS uc)
endif()
if (ICU_FOUND)
set (MONGOC_ENABLE_ICU 1)
include_directories ("${ICU_INCLUDE_DIR}")
elseif (ENABLE_ICU STREQUAL ON)
message (FATAL_ERROR "No ICU library found. If ICU is installed in a non-standard directory, define ICU_ROOT as the ICU installation path.")
elseif (ENABLE_ICU STREQUAL AUTO)
message (STATUS "No ICU library found, SASLPrep disabled for SCRAM-SHA-256 authentication.")
message (STATUS "If ICU is installed in a non-standard directory, define ICU_ROOT as the ICU installation path.")
endif()
endif()

# Configure In-Use Encryption
set (MONGOC_ENABLE_CLIENT_SIDE_ENCRYPTION 0)
if (NOT ENABLE_CLIENT_SIDE_ENCRYPTION MATCHES "AUTO|ON|OFF")
Expand Down Expand Up @@ -693,11 +671,11 @@ endif ()

set (LIBRARIES
${SASL_LIBRARIES} ${SSL_LIBRARIES} ${SHM_LIBRARIES}
${SNAPPY_LIBRARIES} ${ZLIB_LIBRARIES} ${MONGOC_ZSTD_LIBRARIES} ${ICU_LIBRARIES} ${LIBMONGOCRYPT_LIBRARY}
${SNAPPY_LIBRARIES} ${ZLIB_LIBRARIES} ${MONGOC_ZSTD_LIBRARIES} ${LIBMONGOCRYPT_LIBRARY}
)
set (STATIC_LIBRARIES
${SASL_LIBRARIES} ${SSL_LIBRARIES} ${SSL_STATIC_LIBRARIES} ${SHM_LIBRARIES}
${SNAPPY_LIBRARIES} ${ZLIB_LIBRARIES} ${MONGOC_ZSTD_LIBRARIES} ${ICU_LIBRARIES} ${LIBMONGOCRYPT_LIBRARY}
${SNAPPY_LIBRARIES} ${ZLIB_LIBRARIES} ${MONGOC_ZSTD_LIBRARIES} ${LIBMONGOCRYPT_LIBRARY}
)

add_library(_mongoc-dependencies INTERFACE)
Expand Down Expand Up @@ -781,6 +759,11 @@ target_compile_definitions (mongoc_shared
${KMS_MSG_DEFINITIONS}
MCOMMON_NAME_PREFIX=_mongoc_mcommon
)

if (USE_BUNDLED_UTF8PROC)
target_compile_definitions (mongoc_shared PRIVATE UTF8PROC_STATIC)
endif ()

# Several directories in the source and build trees contain headers we would like
# include via relative reference, but they all end up in the same install path
target_include_directories (
Expand Down Expand Up @@ -829,6 +812,9 @@ if (MONGOC_ENABLE_STATIC_BUILD)
${KMS_MSG_DEFINITIONS}
MCOMMON_NAME_PREFIX=_mongoc_mcommon
)
if (USE_BUNDLED_UTF8PROC)
target_compile_definitions (mongoc_static PRIVATE UTF8PROC_STATIC)
endif ()
# Several directories in the source and build trees contain headers we would like
# include via relative reference, but they all end up in the same install path
target_include_directories (
Expand Down Expand Up @@ -1212,8 +1198,7 @@ endif ()
if(TARGET mongoc_static)
set(link_options
${SASL_LIBRARIES} ${SSL_LIBRARIES} ${SHM_LIBRARIES} ${ZLIB_LIBRARIES}
${SNAPPY_LIBRARIES} ${MONGOC_ZSTD_LIBRARIES} ${ICU_LIBRARIES}
${LIBMONGOCRYPT_LIBRARY})
${SNAPPY_LIBRARIES} ${MONGOC_ZSTD_LIBRARIES} ${LIBMONGOCRYPT_LIBRARY})
# Replace all absolute paths with search-dir link-file options:
list(TRANSFORM link_options
REPLACE "^(.+)/lib([^/\\.]+)\\..+$"
Expand Down
2 changes: 1 addition & 1 deletion src/libmongoc/build/cmake/libmongoc-1.0-config.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ set (MONGOC_LIBRARIES ${MONGOC_LIBRARY} ${BSON_LIBRARIES})
set (IS_FRAMEWORK_VAR 0)
foreach (LIB
@SASL_LIBRARIES@ @SSL_LIBRARIES@ @SHM_LIBRARIES@ @RESOLVE_LIB_NAME@
@SNAPPY_LIBRARIES@ @ICU_LIBRARIES@ @MONGOC_ZSTD_LIBRARIES@ @LIBMONGOCRYPT_LIBRARY@
@SNAPPY_LIBRARIES@ @MONGOC_ZSTD_LIBRARIES@ @LIBMONGOCRYPT_LIBRARY@
)
if (LIB STREQUAL "-framework")
set (IS_FRAMEWORK_VAR 1)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ set (MONGOC_STATIC_LIBRARIES ${MONGOC_STATIC_LIBRARY} ${ZLIB_STATIC_LIBRARY} ${B
# like "-framework CoreFoundation;-framework Security".
set (IS_FRAMEWORK_VAR 0)
foreach (LIB @SASL_LIBRARIES@ @SSL_LIBRARIES@ @SHM_LIBRARIES@ @ZLIB_LIBRARIES@ @RESOLVE_LIB_NAME@
@SNAPPY_LIBRARIES@ @ICU_LIBRARIES@ @MONGOC_ZSTD_LIBRARIES@ @LIBMONGOCRYPT_LIBRARY@
@SNAPPY_LIBRARIES@ @MONGOC_ZSTD_LIBRARIES@ @LIBMONGOCRYPT_LIBRARY@
)
if (LIB STREQUAL "-framework")
set (IS_FRAMEWORK_VAR 1)
Expand Down
15 changes: 0 additions & 15 deletions src/libmongoc/doc/authentication.rst
Original file line number Diff line number Diff line change
Expand Up @@ -49,21 +49,6 @@ Alternatively, SCRAM-SHA-256 can be explicitly specified as an authMechanism.

mongoc_client_t *client = mongoc_client_new ("mongodb://user:password@localhost/?authMechanism=SCRAM-SHA-256&authSource=mydb");

Passwords for SCRAM-SHA-256 undergo the preprocessing step known as SASLPrep
specified in `RFC 4013 <https://tools.ietf.org/html/rfc4013>`_. SASLPrep will
only be performed for passwords containing non-ASCII characters. SASLPrep
requires libicu. If libicu is not available, attempting to authenticate over
SCRAM-SHA-256 with non-ASCII passwords will result in error.

Usernames *never* undergo SASLPrep.

By default, when building the C driver libicu is linked if available. This can
be changed with the ``ENABLE_ICU`` cmake option. To specify an installation
path of libicu, specify ``ICU_ROOT`` as a cmake option. See the
`FindICU <https://cmake.org/cmake/help/v3.7/module/FindICU.html>`_ documentation
for more information.


.. _authentication_scram_sha_1:

Basic Authentication (SCRAM-SHA-1)
Expand Down
1 change: 0 additions & 1 deletion src/libmongoc/examples/parse_handshake_cfg.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@
"MONGOC_MD_FLAG_HAVE_SCHED_GETCPU",
"MONGOC_MD_FLAG_ENABLE_SHM_COUNTERS",
"MONGOC_MD_FLAG_TRACE",
"MONGOC_MD_FLAG_ENABLE_ICU",
"MONGOC_MD_FLAG_ENABLE_CLIENT_SIDE_ENCRYPTION",
"MONGOC_MD_FLAG_ENABLE_MONGODB_AWS_AUTH",
"MONGOC_MD_FLAG_ENABLE_SRV",
Expand Down
9 changes: 0 additions & 9 deletions src/libmongoc/src/mongoc/mongoc-config.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -372,15 +372,6 @@
*/
#define MONGOC_TRACE @MONGOC_TRACE@

/*
* Set if we have ICU support.
*/
#define MONGOC_ENABLE_ICU @MONGOC_ENABLE_ICU@

#if MONGOC_ENABLE_ICU != 1
# undef MONGOC_ENABLE_ICU
#endif

/*
* Set if we have Client Side Encryption support.
*/
Expand Down
1 change: 0 additions & 1 deletion src/libmongoc/src/mongoc/mongoc-handshake-private.h
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@ typedef enum {
MONGOC_MD_FLAG_HAVE_SCHED_GETCPU,
MONGOC_MD_FLAG_ENABLE_SHM_COUNTERS,
MONGOC_MD_FLAG_TRACE,
MONGOC_MD_FLAG_ENABLE_ICU,
MONGOC_MD_FLAG_ENABLE_CLIENT_SIDE_ENCRYPTION,
MONGOC_MD_FLAG_ENABLE_MONGODB_AWS_AUTH,
MONGOC_MD_FLAG_ENABLE_SRV,
Expand Down
8 changes: 2 additions & 6 deletions src/libmongoc/src/mongoc/mongoc-handshake.c
Original file line number Diff line number Diff line change
Expand Up @@ -184,10 +184,6 @@ _mongoc_handshake_get_config_hex_string (void)
_set_bit (bf, byte_count, MONGOC_MD_FLAG_TRACE);
}

#ifdef MONGOC_ENABLE_ICU
_set_bit (bf, byte_count, MONGOC_MD_FLAG_ENABLE_ICU);
#endif

#ifdef MONGOC_ENABLE_CLIENT_SIDE_ENCRYPTION
_set_bit (bf, byte_count, MONGOC_MD_FLAG_ENABLE_CLIENT_SIDE_ENCRYPTION);
#endif
Expand Down Expand Up @@ -693,7 +689,7 @@ _mongoc_handshake_parse_sasl_supported_mechs (
find (keyWithType ("saslSupportedMechs", array),
visitEach (case (
when (strEqual ("SCRAM-SHA-256"),
do(sasl_supported_mechs->scram_sha_256 = true)),
do (sasl_supported_mechs->scram_sha_256 = true)),
when (strEqual ("SCRAM-SHA-1"),
do(sasl_supported_mechs->scram_sha_1 = true))))));
do (sasl_supported_mechs->scram_sha_1 = true))))));
}
19 changes: 0 additions & 19 deletions src/libmongoc/src/mongoc/mongoc-scram.c
Original file line number Diff line number Diff line change
Expand Up @@ -112,12 +112,6 @@ _mongoc_scram_cache_copy (const mongoc_scram_cache_t *cache)
return ret;
}

#ifdef MONGOC_ENABLE_ICU
#include <unicode/usprep.h>
#include <unicode/ustring.h>
#endif


void
_mongoc_scram_cache_destroy (mongoc_scram_cache_t *cache)
{
Expand Down Expand Up @@ -1058,7 +1052,6 @@ _mongoc_sasl_prep_required (const char *str)
return false;
}

#ifdef MONGOC_ENABLE_ICU
char *
_mongoc_sasl_prep_impl (const char *name,
const char *in_utf8,
Expand Down Expand Up @@ -1251,26 +1244,14 @@ _mongoc_sasl_prep_impl (const char *name,
return (char *) out_utf8;
#undef SASL_PREP_ERR_RETURN
}
#endif

char *
_mongoc_sasl_prep (const char *in_utf8, bson_error_t *err)
{
#ifdef MONGOC_ENABLE_ICU
if (_mongoc_sasl_prep_required (in_utf8)) {
return _mongoc_sasl_prep_impl ("password", in_utf8, err);
}
return bson_strdup (in_utf8);
#else
if (_mongoc_sasl_prep_required (in_utf8)) {
bson_set_error (err,
MONGOC_ERROR_SCRAM,
MONGOC_ERROR_SCRAM_PROTOCOL_ERROR,
"SCRAM Failure: ICU required to SASLPrep password");
return NULL;
}
return bson_strdup (in_utf8);
#endif
}

size_t
Expand Down
4 changes: 0 additions & 4 deletions src/libmongoc/tests/test-mongoc-handshake.c
Original file line number Diff line number Diff line change
Expand Up @@ -882,10 +882,6 @@ test_handshake_platform_config (void)
BSON_ASSERT (_get_bit (config_str, MONGOC_MD_FLAG_TRACE));
}

#ifdef MONGOC_ENABLE_ICU
BSON_ASSERT (_get_bit (config_str, MONGOC_MD_FLAG_ENABLE_ICU));
#endif

#ifdef MONGOC_ENABLE_CLIENT_SIDE_ENCRYPTION
BSON_ASSERT (
_get_bit (config_str, MONGOC_MD_FLAG_ENABLE_CLIENT_SIDE_ENCRYPTION));
Expand Down
Loading