MCPcopy Create free account
hub / github.com/3rdparty/libprocess / reinitialize

Function reinitialize

src/openssl.cpp:412–763  ·  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

410// as the server socket spawned during libprocess initialization.
411// See `reinitialize` in `process.cpp`.
412void reinitialize()
413{
414 // Wipe out and recreate the default flags.
415 // This is especially important for tests, which might repeatedly
416 // change environment variables and call `reinitialize`.
417 *ssl_flags = Flags();
418
419 // Load all the flags prefixed by LIBPROCESS_SSL_ from the
420 // environment. See comment at top of openssl.hpp for a full list.
421 //
422 // NOTE: We used to look for environment variables prefixed by SSL_.
423 // To be backward compatible, we interpret environment variables
424 // prefixed with either SSL_ and LIBPROCESS_SSL_ where the latter
425 // one takes precedence. See details in MESOS-5863.
426 map<string, Option<string>> environment_ssl =
427 ssl_flags->extract("SSL_");
428 map<string, Option<string>> environments =
429 ssl_flags->extract("LIBPROCESS_SSL_");
430 foreachpair (
431 const string& key, const Option<string>& value, environment_ssl) {
432 if (environments.count(key) > 0 && environments.at(key) != value) {
433 LOG(WARNING) << "Mismatched values for SSL environment variables "
434 << "SSL_" << key << " and "
435 << "LIBPROCESS_SSL_" << key;
436 }
437 }
438 environments.insert(environment_ssl.begin(), environment_ssl.end());
439
440 Try<flags::Warnings> load = ssl_flags->load(environments);
441 if (load.isError()) {
442 EXIT(EXIT_FAILURE)
443 << "Failed to load flags from environment variables "
444 << "prefixed by LIBPROCESS_SSL_ or SSL_ (deprecated): "
445 << load.error();
446 }
447
448 // Log any flag warnings.
449 foreach (const flags::Warning& warning, load->warnings) {
450 LOG(WARNING) << warning.message;
451 }
452
453 // Exit early if SSL is not enabled.
454 if (!ssl_flags->enabled) {
455 return;
456 }
457
458 static Once* initialized_single_entry = new Once();
459
460 // We don't want to initialize everything multiple times, as we
461 // don't clean up some of these structures. The things we DO tend
462 // to re-initialize are things that are overwrites of settings,
463 // rather than allocations of new data structures.
464 if (!initialized_single_entry->once()) {
465 // We MUST have entropy, or else there's no point to crypto.
466 if (!RAND_poll()) {
467 EXIT(EXIT_FAILURE) << "SSL socket requires entropy";
468 }
469

Callers 9

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

Calls 8

error_stringFunction · 0.85
initialize_ecdh_curveFunction · 0.85
extractMethod · 0.80
onceMethod · 0.80
doneMethod · 0.80
FlagsClass · 0.70
countMethod · 0.45
getMethod · 0.45

Tested by 8

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