bccu#1909 - loolwsd command line options vs. config file and package upgrades

Removed admin-console creds and allow-local-storage.

Change-Id: If281b6320caee5d28007063591325eb98ba8e01b
Reviewed-on: https://gerrit.libreoffice.org/26670
Reviewed-by: Ashod Nakashian <ashnakash@gmail.com>
Tested-by: Ashod Nakashian <ashnakash@gmail.com>
private/Ashod/repairactions
Ashod Nakashian 2016-06-25 20:10:48 -04:00 committed by Ashod Nakashian
parent 6501a21114
commit d281813c06
5 changed files with 16 additions and 42 deletions

View File

@ -82,8 +82,8 @@ public:
Log::info("Invalid JWT token, let the administrator re-login");
}
const auto user = config.getString("admin_console_username", "");
const auto pass = config.getString("admin_console_password", "");
const auto user = config.getString("admin_console.username", "");
const auto pass = config.getString("admin_console.password", "");
if (user.empty() || pass.empty())
{
Log::error("Admin Console credentials missing. Denying access until set.");

View File

@ -854,6 +854,10 @@ public:
}
}
}
else
{
Log::error("Unknown resource: " + request.getURI());
}
}
catch (const Exception& exc)
{
@ -1173,9 +1177,7 @@ std::string LOOLWSD::ChildRoot;
std::string LOOLWSD::LoSubPath = "lo";
std::string LOOLWSD::ServerName;
std::string LOOLWSD::FileServerRoot;
std::string LOOLWSD::AdminCreds;
std::string LOOLWSD::LOKitVersion;
bool LOOLWSD::AllowLocalStorage = false;
bool LOOLWSD::SSLEnabled =
#if ENABLE_SSL
true;
@ -1264,21 +1266,6 @@ void LOOLWSD::initialize(Application& self)
AutoPtr<AppConfigMap> pOverrideConfig(new AppConfigMap(_overrideSettings));
conf.addWriteable(pOverrideConfig, PRIO_APPLICATION); // Highest priority
// 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.
StringTokenizer tokens(AdminCreds, "/", StringTokenizer::TOK_IGNORE_EMPTY | StringTokenizer::TOK_TRIM);
if (tokens.count() == 2)
{
config().setString("admin_console_username", tokens[0]);
config().setString("admin_console_password", tokens[1]);
}
}
// Allow UT to manipulate before using configuration values.
UnitWSD::get().configure(config());
@ -1366,15 +1353,6 @@ void LOOLWSD::defineOptions(OptionSet& optionSet)
.repeatable(false)
.argument("port number"));
optionSet.addOption(Option("admincreds", "", "Admin 'username/password' used to access the admin console.")
.required(false)
.repeatable(false)
.argument("credentials"));
optionSet.addOption(Option("allowlocalstorage", "", "When true will allow highly insecure loading of files from local storage.")
.required(false)
.repeatable(false));
optionSet.addOption(Option("override", "o", "Override any setting by providing fullxmlpath=value.")
.required(false)
.repeatable(true)
@ -1411,10 +1389,6 @@ void LOOLWSD::handleOption(const std::string& optionName,
DisplayVersion = true;
else if (optionName == "port")
ClientPortNumber = std::stoi(value);
else if (optionName == "admincreds")
AdminCreds = value;
else if (optionName == "allowlocalstorage")
AllowLocalStorage = true;
#if ENABLE_DEBUG
else if (optionName == "unitlib")
UnitTestLibrary = value;
@ -1522,18 +1496,13 @@ int LOOLWSD::main(const std::vector<std::string>& /*args*/)
ChildRoot += '/';
if (FileServerRoot.empty())
FileServerRoot = Path(Application::instance().commandPath()).parent().parent().toString();
FileServerRoot = Poco::Path(Application::instance().commandPath()).parent().parent().toString();
FileServerRoot = Poco::Path(FileServerRoot).absolute().toString();
Log::debug("FileServerRoot: " + FileServerRoot);
if (ClientPortNumber == MasterPortNumber)
throw IncompatibleOptionsException("port");
if (AdminCreds.empty())
{
Log::warn("No admin credentials set via 'admincreds' command-line argument. Admin Console will be disabled.");
}
// Create the directory where the fifo pipe with ForKit will be.
const Path pipePath = Path::forDirectory(ChildRoot + "/" + FIFO_PATH);
if (!File(pipePath).exists() && !File(pipePath).createDirectory())

View File

@ -43,9 +43,7 @@ public:
static std::string LoSubPath;
static std::string ServerName;
static std::string FileServerRoot;
static std::string AdminCreds;
static std::string LOKitVersion;
static bool AllowLocalStorage;
static bool SSLEnabled;
static

View File

@ -143,8 +143,9 @@ run: all @JAILS_PATH@ @SYSTEMPLATE_PATH@/system_stamp
@PROTOCOL="http" ; if test "z@ENABLE_SSL@" != "z"; then PROTOCOL="https" ; fi ; \
echo " $$PROTOCOL://localhost:9980/loleaflet/@LOOLWSD_VERSION_HASH@/loleaflet.html?file_path=file://$(abs_top_srcdir)/test/data/hello-world.odt"
@echo
./loolwsd --systemplate="@SYSTEMPLATE_PATH@" --lotemplate="@LO_PATH@" \
--childroot="@JAILS_PATH@" --allowlocalstorage --admincreds=admin/admin
./loolwsd --o:sys_template_path="@SYSTEMPLATE_PATH@" --o:lo_template_path="@LO_PATH@" \
--o:child_root_path="@JAILS_PATH@" --o:storage.filesystem[@allow]=true \
--o:admin_console.username=admin --o:admin_console.password=admin
run_valgrind: all @JAILS_PATH@ @SYSTEMPLATE_PATH@/system_stamp
@echo "Launching loolwsd under valgrind (but not forkit/loolkit, yet)"

View File

@ -48,4 +48,10 @@
<host desc="Hostname to allow" allow="false">localhost</host>
</webdav>
</storage>
<admin_console desc="Web admin console settings.">
<username desc="The username of the admin console. Must be set."></username>
<password desc="The password of the admin console. Must be set."></password>
</admin_console>
</config>