-
Notifications
You must be signed in to change notification settings - Fork 455
CDRIVER-5511 disable loading Cyrus plugins on Windows by default #1561
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
Changes from 1 commit
40048bd
69a0085
d88a43a
4e4fd59
c98714c
8b7e1b5
ff2f6cb
c436cec
4b09320
2a79143
8fd99c0
583f7c6
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,10 @@ | ||
libmongoc 1.26.2 (unreleased) | ||
============================= | ||
|
||
Fixes: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't believe this is a "fix". Suggest "Changes:" or "Cyrus SASL:" instead. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Agreed. Updated to "Cyrus SASL:". Also replaced "Cyrus-SASL" and "cyrus-sasl" with "Cyrus SASL" to match naming in https://www.cyrusimap.org/sasl/ |
||
|
||
* Disable plug-in loading with Cyrus-SASL on Windows by default. To re-enable, set the CMake option `CYRUS_PLUGIN_PATH_PREFIX` to the path prefix of the Cyrus-SASL plug-ins. | ||
|
||
libmongoc 1.26.1 | ||
================ | ||
|
||
|
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -814,6 +814,8 @@ if (MONGOC_ENABLE_STATIC_BUILD) | |||||
set_target_properties (mcd_rpc PROPERTIES OUTPUT_NAME "mcd-rpc") | ||||||
endif () | ||||||
|
||||||
set_source_files_properties (src/mongoc/mongoc-cyrus.c PROPERTIES COMPILE_DEFINITIONS MONGOC_CYRUS_PLUGIN_PATH_PREFIX="${CYRUS_PLUGIN_PATH_PREFIX}") | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
Avoid overwriting any prior value(s) of |
||||||
|
||||||
if (ENABLE_SHARED) | ||||||
add_library (mongoc_shared SHARED ${SOURCES} ${HEADERS} ${HEADERS_FORWARDING}) | ||||||
if(WIN32) | ||||||
|
Original file line number | Diff line number | Diff line change | ||||||||
---|---|---|---|---|---|---|---|---|---|---|
|
@@ -126,6 +126,49 @@ _mongoc_cyrus_get_user (mongoc_cyrus_t *sasl, int param_id, const char **result, | |||||||||
return (sasl->credentials.user != NULL) ? SASL_OK : SASL_FAIL; | ||||||||||
} | ||||||||||
|
||||||||||
static const char * | ||||||||||
sasl_verify_type_to_str (sasl_verify_type_t type) | ||||||||||
{ | ||||||||||
switch (type) { | ||||||||||
case SASL_VRFY_PLUGIN: | ||||||||||
return "SASL_VRFY_PLUGIN"; | ||||||||||
case SASL_VRFY_CONF: | ||||||||||
return "SASL_VRFY_CONF"; | ||||||||||
case SASL_VRFY_PASSWD: | ||||||||||
return "SASL_VRFY_PASSWD"; | ||||||||||
case SASL_VRFY_OTHER: | ||||||||||
return "SASL_VRFY_OTHER"; | ||||||||||
default: | ||||||||||
return "Unknown"; | ||||||||||
} | ||||||||||
} | ||||||||||
|
||||||||||
int | ||||||||||
_mongoc_cyrus_verifyfile_cb (void *context, const char *file, sasl_verify_type_t type) | ||||||||||
{ | ||||||||||
TRACE ("Attempting to load file: `%s`. Type is %s\n", file, sasl_verify_type_to_str (type)); | ||||||||||
|
||||||||||
#ifdef _WIN32 | ||||||||||
// On Windows, Cyrus-SASL hard-codes the plugin path. | ||||||||||
// Only permit loading plug-in from user configured path to prevent unintentional library loading. | ||||||||||
if (type == SASL_VRFY_PLUGIN) { | ||||||||||
const char *path_prefix = MONGOC_CYRUS_PLUGIN_PATH_PREFIX; | ||||||||||
bool has_valid_prefix = (0 != strlen (path_prefix) && file == strstr (file, path_prefix)); | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Recommend using set_property(
SOURCE ${PROJECT_SOURCE_DIR}/src/mongoc/mongoc-cyrus.c
APPEND PROPERTY COMPILE_DEFINITIONS
"MONGOC_CYRUS_PLUGIN_PATH_PREFIX=$<IF:$<STREQUAL:${CYRUS_PLUGIN_PATH_PREFIX},>,NULL,${CYRUS_PLUGIN_PATH_PREFIX}>"
) bool has_valid_prefix = (path_prefix && file == strstr (file, path_prefix));
// ...
MONGOC_WARNING (
"... set CYRUS_PLUGIN_PATH_PREFIX (currently '%s') to ...",
// ...
path_prefix ? path_prefix : "(unset)"
); There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I like that suggestion. Applied with the addition of escaped quotes in |
||||||||||
// Check if `file` has necessary prefix. | ||||||||||
if (has_valid_prefix) { | ||||||||||
return SASL_OK; | ||||||||||
} | ||||||||||
MONGOC_WARNING ("Not loading Cyrus-SASL plugin: %s. If plugin is needed, set CMake option " | ||||||||||
"`CYRUS_PLUGIN_PATH_PREFIX (currently '%s')` to a non-empty string contain the path prefix.", | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
Message phrasing suggestion. |
||||||||||
file, | ||||||||||
path_prefix); | ||||||||||
return SASL_CONTINUE; | ||||||||||
} | ||||||||||
#endif | ||||||||||
|
||||||||||
return SASL_OK; | ||||||||||
} | ||||||||||
|
||||||||||
|
||||||||||
void | ||||||||||
_mongoc_cyrus_init (mongoc_cyrus_t *sasl) | ||||||||||
|
@@ -134,6 +177,7 @@ _mongoc_cyrus_init (mongoc_cyrus_t *sasl) | |||||||||
{SASL_CB_USER, SASL_CALLBACK_FN (_mongoc_cyrus_get_user), sasl}, | ||||||||||
{SASL_CB_PASS, SASL_CALLBACK_FN (_mongoc_cyrus_get_pass), sasl}, | ||||||||||
{SASL_CB_CANON_USER, SASL_CALLBACK_FN (_mongoc_cyrus_canon_user), sasl}, | ||||||||||
{SASL_CB_VERIFYFILE, SASL_CALLBACK_FN (_mongoc_cyrus_verifyfile_cb), NULL}, | ||||||||||
{SASL_CB_LIST_END}}; | ||||||||||
|
||||||||||
BSON_ASSERT (sasl); | ||||||||||
|
Uh oh!
There was an error while loading. Please reload this page.