MCPcopy Create free account
hub / github.com/apache/mesos / reinitialize

Function reinitialize

3rdparty/libprocess/src/openssl.cpp:443–810  ·  view source on GitHub ↗

Tests can declare this function and use it to re-configure the SSL environment variables programatically. Without explicitly declaring this function, it is not visible. This is the preferred behavior as we do not want applications changing these settings while they are running (this would be undefined behavior). NOTE: This does not change the configuration of existing sockets, such as the server s

Source from the content-addressed store, hash-verified

441// as the server socket spawned during libprocess initialization.
442// See `reinitialize` in `process.cpp`.
443void reinitialize()
444{
445 // Wipe out and recreate the default flags.
446 // This is especially important for tests, which might repeatedly
447 // change environment variables and call `reinitialize`.
448 *ssl_flags = Flags();
449
450 // Load all the flags prefixed by LIBPROCESS_SSL_ from the
451 // environment. See comment at top of openssl.hpp for a full list.
452 //
453 // NOTE: We used to look for environment variables prefixed by SSL_.
454 // To be backward compatible, we interpret environment variables
455 // prefixed with either SSL_ and LIBPROCESS_SSL_ where the latter
456 // one takes precedence. See details in MESOS-5863.
457 map<string, Option<string>> environment_ssl =
458 ssl_flags->extract("SSL_");
459 map<string, Option<string>> environments =
460 ssl_flags->extract("LIBPROCESS_SSL_");
461 foreachpair (
462 const string& key, const Option<string>& value, environment_ssl) {
463 if (environments.count(key) > 0 && environments.at(key) != value) {
464 LOG(WARNING) << "Mismatched values for SSL environment variables "
465 << "SSL_" << key << " and "
466 << "LIBPROCESS_SSL_" << key;
467 }
468 }
469 environments.insert(environment_ssl.begin(), environment_ssl.end());
470
471 Try<flags::Warnings> load = ssl_flags->load(environments);
472 if (load.isError()) {
473 EXIT(EXIT_FAILURE)
474 << "Failed to load flags from environment variables "
475 << "prefixed by LIBPROCESS_SSL_ or SSL_ (deprecated): "
476 << load.error();
477 }
478
479 // Log any flag warnings.
480 foreach (const flags::Warning& warning, load->warnings) {
481 LOG(WARNING) << warning.message;
482 }
483
484 // Exit early if SSL is not enabled.
485 if (!ssl_flags->enabled) {
486 return;
487 }
488
489 static Once* initialized_single_entry = new Once();
490
491 // We don't want to initialize everything multiple times, as we
492 // don't clean up some of these structures. The things we DO tend
493 // to re-initialize are things that are overwrites of settings,
494 // rather than allocations of new data structures.
495 if (!initialized_single_entry->once()) {
496 // We MUST have entropy, or else there's no point to crypto.
497 if (!RAND_poll()) {
498 EXIT(EXIT_FAILURE) << "SSL socket requires entropy";
499 }
500

Callers 15

initializeFunction · 0.70
SetUpMethod · 0.50
TearDownTestCaseMethod · 0.50
SetUpMethod · 0.50
TearDownTestCaseMethod · 0.50
TESTFunction · 0.50
TEST_PFunction · 0.50
TEST_FFunction · 0.50
SetUpMethod · 0.50
TearDownTestCaseMethod · 0.50
TEST_PFunction · 0.50

Calls 15

error_stringFunction · 0.85
initialize_ecdh_curveFunction · 0.85
insertMethod · 0.80
onceMethod · 0.80
atMethod · 0.80
FlagsClass · 0.70
errorMethod · 0.65
stringifyClass · 0.50
environmentFunction · 0.50
extractMethod · 0.45
beginMethod · 0.45
endMethod · 0.45

Tested by 15

SetUpMethod · 0.40
TearDownTestCaseMethod · 0.40
SetUpMethod · 0.40
TearDownTestCaseMethod · 0.40
TESTFunction · 0.40
TEST_PFunction · 0.40
TEST_FFunction · 0.40
SetUpMethod · 0.40
TearDownTestCaseMethod · 0.40
TEST_PFunction · 0.40
TEST_FFunction · 0.40