Skip to content

Commit

Permalink
Core: use ResourceLocator created by Agent::Fundamentals::initializeA…
Browse files Browse the repository at this point in the history
…gent()

Instead of creating ones ourselves, which is redundant.
  • Loading branch information
FooBarWidget committed Oct 4, 2024
1 parent 8bda68d commit 7655b58
Showing 1 changed file with 6 additions and 10 deletions.
16 changes: 6 additions & 10 deletions src/agent/Core/CoreMain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,6 @@
#include <AppTypeDetector/Detector.h>
#include <IOTools/MessageSerialization.h>
#include <FileDescriptor.h>
#include <ResourceLocator.h>
#include <BackgroundEventLoop.cpp>
#include <FileTools/FileManip.h>
#include <FileTools/PathSecurityCheck.h>
Expand Down Expand Up @@ -145,7 +144,6 @@ namespace Core {

boost::mutex configSyncher;

ResourceLocator resourceLocator;
RandomGeneratorPtr randomGenerator;
SpawningKit::Context::Schema spawningKitContextSchema;
SpawningKit::ContextPtr spawningKitContext;
Expand Down Expand Up @@ -697,8 +695,6 @@ initializeNonPrivilegedWorkingObjects() {

setenv("SERVER_SOFTWARE", coreConfig->get("server_software").asCString(), 1);

wo->resourceLocator = ResourceLocator(coreConfig->get("passenger_root").asString());

wo->randomGenerator = boost::make_shared<RandomGenerator>();
// Check whether /dev/urandom is actually random.
// https://code.google.com/p/phusion-passenger/issues/detail?id=516
Expand All @@ -710,7 +706,7 @@ initializeNonPrivilegedWorkingObjects() {
UPDATE_TRACE_POINT();
wo->spawningKitContext = boost::make_shared<SpawningKit::Context>(
wo->spawningKitContextSchema);
wo->spawningKitContext->resourceLocator = &wo->resourceLocator;
wo->spawningKitContext->resourceLocator = Agent::Fundamentals::context->resourceLocator;
wo->spawningKitContext->wrapperRegistry = coreWrapperRegistry;
wo->spawningKitContext->randomGenerator = wo->randomGenerator;
wo->spawningKitContext->integrationMode = coreConfig->get("integration_mode").asString();
Expand Down Expand Up @@ -772,7 +768,7 @@ initializeNonPrivilegedWorkingObjects() {
&coreSchema->controllerSingleAppMode.schema,
&wo->singleAppModeConfig,
coreSchema->controllerSingleAppMode.translator);
two.controller->resourceLocator = &wo->resourceLocator;
two.controller->resourceLocator = Agent::Fundamentals::context->resourceLocator;
two.controller->wrapperRegistry = coreWrapperRegistry;
two.controller->appPool = wo->appPool;
two.controller->shutdownFinishCallback = controllerShutdownFinished;
Expand Down Expand Up @@ -877,7 +873,7 @@ initializeSecurityUpdateChecker() {
config,
coreSchema->securityUpdateChecker.translator);
workingObjects->securityUpdateChecker = checker;
checker->resourceLocator = &workingObjects->resourceLocator;
checker->resourceLocator = Agent::Fundamentals::context->resourceLocator;
checker->initialize();
checker->start();
}
Expand Down Expand Up @@ -927,7 +923,7 @@ initializeAdminPanelConnector() {
AdminPanelConnector *connector = new Core::AdminPanelConnector(
coreSchema->adminPanelConnector.schema, config,
coreSchema->adminPanelConnector.translator);
connector->resourceLocator = &wo.resourceLocator;
connector->resourceLocator = Agent::Fundamentals::context->resourceLocator;
connector->appPool = wo.appPool;
connector->configGetter = inspectConfig;
for (unsigned int i = 0; i < wo.threadWorkingObjects.size(); i++) {
Expand Down Expand Up @@ -956,7 +952,7 @@ prestartWebApps() {
}

boost::function<void ()> func = boost::bind(prestartWebApps,
wo->resourceLocator,
*Agent::Fundamentals::context->resourceLocator,
coreConfig->get("default_ruby").asString(),
prestartURLs
);
Expand All @@ -983,7 +979,7 @@ warnIfPassengerRootVulnerable() {
return; // Passenger is not root, so no escalation.
}

string root = workingObjects->resourceLocator.getInstallSpec();
string root = Agent::Fundamentals::context->resourceLocator->getInstallSpec();
vector<string> errors, checkErrors;
if (isPathProbablySecureForRootUse(root, errors, checkErrors)) {
if (!checkErrors.empty()) {
Expand Down

0 comments on commit 7655b58

Please sign in to comment.