[Libreoffice-commits] online.git: loolwsd/LOOLWSD.cpp loolwsd/Unit.hpp
Ashod Nakashian
ashod.nakashian at collabora.co.uk
Sun Apr 17 15:20:32 UTC 2016
loolwsd/LOOLWSD.cpp | 35 ++++++++++++++++++-----------------
loolwsd/Unit.hpp | 16 ++++++++++++----
2 files changed, 30 insertions(+), 21 deletions(-)
New commits:
commit ea83ed237436945ad47b99bed80e3520d0ba6d5f
Author: Ashod Nakashian <ashod.nakashian at collabora.co.uk>
Date: Sat Apr 16 14:37:38 2016 -0400
loolwsd: configuration manipulation UT hook added
Change-Id: If5ab75ee3630e629179dfc8d3c3374795bd2a221
Reviewed-on: https://gerrit.libreoffice.org/24156
Reviewed-by: Ashod Nakashian <ashnakash at gmail.com>
Tested-by: Ashod Nakashian <ashnakash at gmail.com>
diff --git a/loolwsd/LOOLWSD.cpp b/loolwsd/LOOLWSD.cpp
index 90a7843..99ab259 100644
--- a/loolwsd/LOOLWSD.cpp
+++ b/loolwsd/LOOLWSD.cpp
@@ -1030,6 +1030,17 @@ LOOLWSD::~LOOLWSD()
void LOOLWSD::initialize(Application& self)
{
+ if (geteuid() == 0)
+ {
+ throw std::runtime_error("Do not run as root. Please run as lool user.");
+ }
+
+ if (!UnitWSD::init(UnitWSD::UnitType::TYPE_WSD,
+ UnitTestLibrary))
+ {
+ throw std::runtime_error("Failed to load wsd unit test library.");
+ }
+
// Load default configuration files, if present.
if (loadConfiguration() == 0)
{
@@ -1038,6 +1049,10 @@ void LOOLWSD::initialize(Application& self)
loadConfiguration(configPath);
}
+ // This overrides whatever is in the config file,
+ // which forces admins to set this flag on the command-line.
+ config().setBool("storage.filesystem[@allow]", AllowLocalStorage);
+
if (!AdminCreds.empty())
{
// Set the Admin Console credentials, if provided.
@@ -1049,6 +1064,9 @@ void LOOLWSD::initialize(Application& self)
}
}
+ // Allow UT to manipulate before using configuration values.
+ UnitWSD::get().configure(config());
+
if (Cache.empty())
{
Cache = getPathFromConfig("tile_cache_path");
@@ -1090,10 +1108,6 @@ void LOOLWSD::initialize(Application& self)
NumPreSpawnedChildren = config().getUInt("num_prespawn_children", 10);
}
- // This overrides whatever is in the config file,
- // which forces admins to set this flag on the command-line.
- config().setBool("storage.filesystem[@allow]", AllowLocalStorage);
-
StorageBase::initialize();
ServerApplication::initialize(self);
@@ -1313,19 +1327,6 @@ int LOOLWSD::main(const std::vector<std::string>& /*args*/)
if (DisplayVersion)
Util::displayVersionInfo("loolwsd");
- if (geteuid() == 0)
- {
- Log::error("Don't run this as root");
- return Application::EXIT_USAGE;
- }
-
- if (!UnitWSD::init(UnitWSD::UnitType::TYPE_WSD,
- UnitTestLibrary))
- {
- Log::error("Failed to load wsd unit test library");
- return Application::EXIT_USAGE;
- }
-
#if ENABLE_SSL
initializeSSL();
#endif
diff --git a/loolwsd/Unit.hpp b/loolwsd/Unit.hpp
index ac925f2..4ae4634 100644
--- a/loolwsd/Unit.hpp
+++ b/loolwsd/Unit.hpp
@@ -21,10 +21,17 @@ class UnitTimeout;
class UnitHTTPServerRequest;
class UnitHTTPServerResponse;
-namespace Poco { namespace Net {
+// Forward declaration to avoid pulling the world here.
+namespace Poco {
+ namespace Net {
class HTTPServerRequest;
class HTTPServerResponse;
-} }
+ }
+
+ namespace Util {
+ class LayeredConfiguration;
+ }
+}
class StorageBase;
@@ -103,10 +110,12 @@ public:
// ---------------- WSD hooks ----------------
+ /// Manipulate and modify the configuration before any usage.
+ virtual void configure(Poco::Util::LayeredConfiguration & /* config */) {}
/// Main-loop reached, time for testing
virtual void invokeTest() {}
/// Tweak the count of pre-spawned kits.
- virtual void preSpawnCount(int & /* numPrefork */) {}
+ virtual void preSpawnCount(int & /* numPrefork */) {}
/// When a new child kit process reports
virtual void newChild(const std::shared_ptr<Poco::Net::WebSocket> & /* socket */) {}
/// Intercept createStorage
@@ -121,7 +130,6 @@ public:
Poco::Net::HTTPServerRequest& /* request */,
Poco::Net::HTTPServerResponse& /* response */)
{ return false; }
-
};
/// Derive your Kit unit test / hooks from me.
More information about the Libreoffice-commits
mailing list