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

Method initialize

src/authentication/cram_md5/authenticator.cpp:493–551  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

491
492
493Try<Nothing> CRAMMD5Authenticator::initialize(
494 const Option<Credentials>& credentials)
495{
496 static Once* initialize = new Once();
497
498 // The 'error' is set atmost once per os process.
499 // To allow subsequent calls to return the possibly set Error
500 // object, we make this a static pointer.
501 static Option<Error>* error = new Option<Error>();
502
503 if (process != nullptr) {
504 return Error("Authenticator initialized already");
505 }
506
507 if (credentials.isSome()) {
508 // Load the credentials into the auxiliary memory plugin's storage.
509 // It is necessary for this to be re-entrant as our tests may
510 // re-load credentials.
511 secrets::load(credentials.get());
512 } else {
513 LOG(WARNING) << "No credentials provided, authentication requests will be "
514 << "refused";
515 }
516
517 // Initialize SASL and add the auxiliary memory plugin. We must
518 // not do this more than once per os-process.
519 if (!initialize->once()) {
520 LOG(INFO) << "Initializing server SASL";
521
522 int result = sasl_server_init(nullptr, "mesos");
523
524 if (result != SASL_OK) {
525 *error = Error(
526 string("Failed to initialize SASL: ") +
527 sasl_errstring(result, nullptr, nullptr));
528 } else {
529 result = sasl_auxprop_add_plugin(
530 InMemoryAuxiliaryPropertyPlugin::name(),
531 &InMemoryAuxiliaryPropertyPlugin::initialize);
532
533 if (result != SASL_OK) {
534 *error = Error(
535 string("Failed to add in-memory auxiliary property plugin: ") +
536 sasl_errstring(result, nullptr, nullptr));
537 }
538 }
539
540 initialize->done();
541 }
542
543 if (error->isSome()) {
544 return error->get();
545 }
546
547 process = new CRAMMD5AuthenticatorProcess();
548 spawn(process);
549
550 return Nothing();

Callers

nothing calls this directly

Calls 9

loadFunction · 0.85
nameFunction · 0.85
NothingClass · 0.85
onceMethod · 0.80
ErrorFunction · 0.50
spawnFunction · 0.50
isSomeMethod · 0.45
getMethod · 0.45
doneMethod · 0.45

Tested by

no test coverage detected