loolwsd: configure wsd using the config file

Most all configuration values can now be defined
in the configuration XML. The command-line arguments
can be used to override some of these values (for
the convenience of developement and testing) and,
in a few cases, as a security measure to avoid
storing sensitive data in the configuration file.

Change-Id: I040b807b1a59a3537bb94646150d3c7d711f8b62
Reviewed-on: https://gerrit.libreoffice.org/23880
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
private/mmeeks/unitbits
Ashod Nakashian 2016-04-06 23:51:58 -04:00 committed by Ashod Nakashian
parent 29c9ecba2a
commit 00940d5a0b
3 changed files with 50 additions and 6 deletions

View File

@ -965,7 +965,7 @@ std::string LOOLWSD::LoSubPath = "lo";
std::string LOOLWSD::FileServerRoot;
std::string LOOLWSD::AdminCreds;
int LOOLWSD::NumPreSpawnedChildren = 10;
unsigned int LOOLWSD::NumPreSpawnedChildren = 0;
bool LOOLWSD::DoTest = false;
LOOLWSD::LOOLWSD()
@ -997,6 +997,42 @@ void LOOLWSD::initialize(Application& self)
}
}
if (Cache.empty())
{
Cache = getPathFromConfig("tile_cache_path");
}
if (SysTemplate.empty())
{
SysTemplate = getPathFromConfig("sys_template_path");
}
if (LoTemplate.empty())
{
LoTemplate = getPathFromConfig("lo_template_path");
}
if (ChildRoot.empty())
{
ChildRoot = getPathFromConfig("child_root_path");
}
if (LoSubPath.empty())
{
LoSubPath = getPathFromConfig("lo_jail_subpath");
}
if (FileServerRoot.empty())
{
FileServerRoot = getPathFromConfig("file_server_root_path");
}
if (NumPreSpawnedChildren == 0)
{
// Default to 10 children.
NumPreSpawnedChildren = config().getUInt("num_prespawn_children", 10);
}
ServerApplication::initialize(self);
}

View File

@ -36,7 +36,7 @@ public:
// An Application is a singleton anyway,
// so just keep these as statics.
static std::atomic<unsigned> NextSessionId;
static int NumPreSpawnedChildren;
static unsigned int NumPreSpawnedChildren;
static int BrokerWritePipe;
static bool DoTest;
static std::string Cache;
@ -73,6 +73,13 @@ private:
std::string getPathFromConfig(const std::string& property) const
{
auto path = config().getString(property);
if (path.empty() && config().hasProperty(property + "[@default]"))
{
// Use the default value if empty and a default provided.
path = config().getString(property + "[@default]");
}
// Reconstruct absolute path if relative.
if (config().hasProperty(property + "[@relative]") &&
config().getBool(property + "[@relative]"))
{

View File

@ -1,12 +1,13 @@
<config>
<num_prespawn_kit desc="Number of child processes to keep started in advance and waiting for new clients." type="uint">1</num_prespawn_kit>
<sys_template_path desc="Path to a template tree with shared libraries etc to be used as source for chroot jails for child processes." type="path" relative="false"></sys_template_path>
<tile_cache_path desc="Path to a directory where to keep the persistent tile cache." type="path" relative="false" default="/usr/local/var/cache/loolwsd"></tile_cache_path>
<sys_template_path desc="Path to a template tree with shared libraries etc to be used as source for chroot jails for child processes." type="path" relative="true" default="systemplate"></sys_template_path>
<lo_template_path desc="Path to a LibreOffice installation tree to be copied (linked) into the jails for child processes. Should be on the same file system as systemplate." type="path" relative="false"></lo_template_path>
<child_root_path desc="Path to the directory under which the chroot jails for the child processes will be created. Should be on the same file system as systemplate and lotemplate." type="path" relative="false"></child_root_path>
<child_root_path desc="Path to the directory under which the chroot jails for the child processes will be created. Should be on the same file system as systemplate and lotemplate. Must be an empty directory." type="path" relative="true" default="jails"></child_root_path>
<lo_jail_subpath desc="Relative path where the LibreOffice installation will be copied inside a jail." type="path" relative="true" default="lo">lo</lo_jail_subpath>
<file_server_root_path desc="Path to the directory that should be considered root for the file server." type="path" relative="true" default="../loleaflet/">../loleaflet/</file_server_root_path>
<file_server_root_path desc="Path to the directory that should be considered root for the file server. This should be the directory containing loleaflet." type="path" relative="true" default="../loleaflet/../"></file_server_root_path>
<num_prespawn_children desc="Number of child processes to keep started in advance and waiting for new clients." type="uint" default="10">1</num_prespawn_children>
<logging>
<color type="bool">true</color>
<level type="string">trace</level>