Skip to content

Commit

Permalink
SERVER-88284 upgrade windows cyrus sasl to 2.1.28 (#26444)
Browse files Browse the repository at this point in the history
GitOrigin-RevId: f068fc1b1ccc00d045e17e98b9df676149ddfe27
  • Loading branch information
dmoody256 authored and MongoDB Bot committed Nov 26, 2024
1 parent 2564e09 commit 1d98379
Show file tree
Hide file tree
Showing 10 changed files with 93 additions and 18 deletions.
2 changes: 2 additions & 0 deletions README.third_party.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ a notice will be included in
| [benchmark] | Apache-2.0 | 1.5.2 | | |
| [Boost] | BSL-1.0 | 1.79.0 | ||
| [c-ares] | MIT | 1.19.1 | ||
| [Cyrus SASL] | BSD-Attribution-HPND-disclaimer | 2.1.28 | unknown | |
| [fmt] | BSD-2-Clause | 7.1.3 | ||
| [GPerfTools] | BSD-3-Clause | 2.9.1 | ||
| [gRPC] | Apache-2.0 | 1.46.6 | ||
Expand Down Expand Up @@ -66,6 +67,7 @@ a notice will be included in
[ASIO]: https://github.com/chriskohlhoff/asio
[benchmark]: https://github.com/google/benchmark
[Boost]: http://www.boost.org/
[Cyrus SASL]: https://www.cyrusimap.org/sasl/
[fmt]: http://fmtlib.net/
[GPerfTools]: https://github.com/gperftools/gperftools
[ICU4]: http://site.icu-project.org/download/
Expand Down
8 changes: 8 additions & 0 deletions SConstruct
Original file line number Diff line number Diff line change
Expand Up @@ -1805,6 +1805,14 @@ if unknown_vars:

install_actions.setup(env, get_option('install-action'))

if env.TargetOSIs("windows") and os.path.exists(
env.File("#/src/mongo/db/modules/enterprise/SConscript").abspath):
# the sasl zip can be rebuilt by following the instructions at:
# https://github.com/mongodb-forks/cyrus-sasl/blob/mongo-sasl-2-1-28/README.md
import mongo.download_windows_sasl

mongo.download_windows_sasl.download_sasl(env)


def set_config_header_define(env, varname, varval=1):
env['CONFIG_HEADER_DEFINES'][varname] = varval
Expand Down
8 changes: 0 additions & 8 deletions etc/evergreen.yml
Original file line number Diff line number Diff line change
Expand Up @@ -171,8 +171,6 @@ variables:
compile_flags: >-
--ssl
MONGO_DISTMOD=windows
CPPPATH="c:/sasl/include"
LIBPATH="c:/sasl/lib"
-j$(( $(grep -c ^processor /proc/cpuinfo) / 2 ))
--win-version-min=win10
num_scons_link_jobs_available: 0.5
Expand Down Expand Up @@ -762,8 +760,6 @@ buildvariants:
--opt=off
--ssl
MONGO_DISTMOD=windows
CPPPATH="c:/sasl/include"
LIBPATH="c:/sasl/lib"
-j$(bc <<< "$(grep -c '^processor' /proc/cpuinfo) / 1.5")
--win-version-min=win10
num_scons_link_jobs_available: 0.25
Expand Down Expand Up @@ -1644,8 +1640,6 @@ buildvariants:
expansions:
num_scons_link_jobs_available: 0.1
compile_flags: >-
CPPPATH="c:/sasl/include"
LIBPATH="c:/sasl/lib"
-j$(( $(grep -c ^processor /proc/cpuinfo) / 2 ))
--win-version-min=win10
python: '/cygdrive/c/python/python37/python.exe'
Expand Down Expand Up @@ -2796,8 +2790,6 @@ buildvariants:
# --link-model=dynamic is set by visiblity_test's task_compile_flags
# expansion
compile_flags: >-
CPPPATH="c:/sasl/include"
LIBPATH="c:/sasl/lib"
-j$(( $(grep -c ^processor /proc/cpuinfo) / 2 ))
--win-version-min=win10
--modules=
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -181,8 +181,6 @@ buildvariants:
compile_flags: >-
--ssl
MONGO_DISTMOD=windows
CPPPATH="c:/sasl/include"
LIBPATH="c:/sasl/lib"
-j$(bc <<< "$(grep -c '^processor' /proc/cpuinfo) / 1.8")
--win-version-min=win10
num_scons_link_jobs_available: 0.2
Expand Down
3 changes: 1 addition & 2 deletions etc/evergreen_yml_components/variants/in_memory.yml
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,7 @@ buildvariants:
compile_flags: >-
--ssl
MONGO_DISTMOD=windows
CPPPATH="c:/sasl/include"
LIBPATH="c:/sasl/lib" -j$(bc <<< "$(grep -c '^processor' /proc/cpuinfo) / 1.5")
-j$(bc <<< "$(grep -c '^processor' /proc/cpuinfo) / 1.5")
--win-version-min=win10
num_scons_link_jobs_available: 0.25
python: '/cygdrive/c/python/python37/python.exe'
Expand Down
2 changes: 0 additions & 2 deletions etc/evergreen_yml_components/variants/misc_release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2490,8 +2490,6 @@ buildvariants:
compile_flags: >-
--ssl
MONGO_DISTMOD=windows
CPPPATH="c:/sasl/include"
LIBPATH="c:/sasl/lib"
-j$(bc <<< "$(grep -c '^processor' /proc/cpuinfo) / 1.5")
--win-version-min=win10
num_scons_link_jobs_available: 0.25
Expand Down
4 changes: 2 additions & 2 deletions etc/evergreen_yml_components/variants/ninja.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ buildvariants:
display_name: "Ninja Build: Enterprise Windows"
cron: "0 4 * * *" # From the ${project_nightly_cron} parameter.
expansions:
compile_flags: --ssl MONGO_DISTMOD=windows CPPPATH="c:/sasl/include c:/snmp/include" LIBPATH="c:/sasl/lib c:/snmp/lib" -j$(bc <<< "$(grep -c '^processor' /proc/cpuinfo) / 1.5") --win-version-min=win10
compile_flags: --ssl MONGO_DISTMOD=windows -j$(bc <<< "$(grep -c '^processor' /proc/cpuinfo) / 1.5") --win-version-min=win10
compile_variant: enterprise-windows-ninja
tasks:
- name: compile_ninja_next_TG
Expand Down Expand Up @@ -59,7 +59,7 @@ buildvariants:
display_name: "Ninja Build Profiles: Windows"
cron: "0 4 * * *" # From the ${project_nightly_cron} parameter.
expansions:
compile_flags: --ssl MONGO_DISTMOD=windows CPPPATH="c:/sasl/include c:/snmp/include" LIBPATH="c:/sasl/lib c:/snmp/lib" -j$(bc <<< "$(grep -c '^processor' /proc/cpuinfo) / 1.5") --win-version-min=win10
compile_flags: --ssl MONGO_DISTMOD=windows -j$(bc <<< "$(grep -c '^processor' /proc/cpuinfo) / 1.5") --win-version-min=win10
tasks:
- name: compile_ninja_default_profile_TG
distros:
Expand Down
8 changes: 8 additions & 0 deletions etc/third_party_components.yml
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,14 @@ components:
team_owner: "Service Architecture"
upgrade_suppression: TODO SERVER-74870

"Cyrus SASL":
homepage_url: https://www.cyrusimap.org/sasl/
open_hub_url: https://openhub.net/p/cyrus-sasl
release_monitoring_id: 13280
# Empty since the library is linked and not in the source tree
local_directory_path:
team_owner: "Server Security"

"dcleblanc/SafeInt":
homepage_url: https://github.com/dcleblanc/SafeInt
open_hub_url: https://www.openhub.net/p/SafeInt
Expand Down
4 changes: 2 additions & 2 deletions sbom.json
Original file line number Diff line number Diff line change
Expand Up @@ -271,15 +271,15 @@
"name": "Organization: github"
},
"name": "Cyrus SASL",
"version": "2.1.26",
"version": "2.1.28",
"licenses": [
{
"license": {
"id": "BSD-Attribution-HPND-disclaimer"
}
}
],
"purl": "pkg:github/cyrusimap/cyrus-sasl@cyrus-sasl-2.1.26",
"purl": "pkg:github/cyrusimap/cyrus-sasl@cyrus-sasl-2.1.28",
"properties": [
{
"name": "internal:team_responsible",
Expand Down
70 changes: 70 additions & 0 deletions site_scons/mongo/download_windows_sasl.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
import urllib
import urllib.request
import hashlib
import zipfile
import os
import time

SASL_HASH = "3e22e2b16f802277123590f64dfda44f1c9c8a2b7e758180cd956d8ab0965817"
SASL_URL = "https://s3.amazonaws.com/boxes.10gen.com/build/windows_cyrus_sasl-2.1.28.zip"


def hash_sasl(sasl_dir):
md5_hash = hashlib.md5()
for root, _, files in os.walk(sasl_dir):
for name in files:
if name.endswith("md5sum"):
continue
with open(os.path.join(root, name), "rb") as f:
for block in iter(lambda: f.read(4096), b""):
md5_hash.update(block)
return md5_hash.hexdigest()


def hash_sasl_zip(sasl_zip):
sha_hash = hashlib.sha256()
with open(sasl_zip, "rb") as f:
for block in iter(lambda: f.read(4096), b""):
sha_hash.update(block)
return sha_hash.hexdigest()


def download_sasl(env):
complete = False
sasl_dir = env.Dir("$BUILD_ROOT/sasl_2_1_28").path
sasl_md5 = os.path.join(sasl_dir, "sasl.md5sum")
os.makedirs(sasl_dir, exist_ok=True)
if os.path.exists(sasl_md5):
with open(sasl_md5) as md5_file:
if hash_sasl(sasl_dir) == md5_file.read():
complete = True

if not complete:
print(f"Downloading sasl {SASL_URL}...")
for i in range(1, 5):
try:
local_filename, _ = urllib.request.urlretrieve(SASL_URL)
downloaded_hash = hash_sasl_zip(local_filename)
if downloaded_hash != SASL_HASH:
raise urllib.error.URLError(
f"Downloaded file hash: {downloaded_hash} does not match expected hash: {SASL_HASH}"
)
except urllib.error.URLError as exc:
wait_time = i * i * 10
if i == 4:
raise exc
else:
print(f"Failed to download {SASL_URL} because of:\n{exc}")
print(f"Retrying in {wait_time}...")
time.sleep(wait_time)

zip_file_object = zipfile.ZipFile(local_filename, "r")
zip_file_object.extractall(sasl_dir)
zip_file_object.close()
os.remove(local_filename)

with open(sasl_md5, "w") as md5_file:
md5_file.write(hash_sasl(sasl_dir))

env.Append(CPPPATH=[f"#{sasl_dir}/include"])
env.Append(LIBPATH=[f"#{sasl_dir}/lib"])

0 comments on commit 1d98379

Please sign in to comment.