[Libreoffice-commits] online.git: loolwsd/FileServer.hpp loolwsd/LOOLWSD.cpp loolwsd/LOOLWSD.hpp loolwsd/loolwsd.xml.in loolwsd/Makefile.am

Ashod Nakashian ashod.nakashian at collabora.co.uk
Sun Jun 26 00:31:18 UTC 2016


 loolwsd/FileServer.hpp |    4 ++--
 loolwsd/LOOLWSD.cpp    |   41 +++++------------------------------------
 loolwsd/LOOLWSD.hpp    |    2 --
 loolwsd/Makefile.am    |    5 +++--
 loolwsd/loolwsd.xml.in |    6 ++++++
 5 files changed, 16 insertions(+), 42 deletions(-)

New commits:
commit d281813c06eef8ac00a57ff7de70013619a4f1a1
Author: Ashod Nakashian <ashod.nakashian at collabora.co.uk>
Date:   Sat Jun 25 20:10:48 2016 -0400

    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 at gmail.com>
    Tested-by: Ashod Nakashian <ashnakash at gmail.com>

diff --git a/loolwsd/FileServer.hpp b/loolwsd/FileServer.hpp
index 2d23a74..7c19e10 100644
--- a/loolwsd/FileServer.hpp
+++ b/loolwsd/FileServer.hpp
@@ -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.");
diff --git a/loolwsd/LOOLWSD.cpp b/loolwsd/LOOLWSD.cpp
index c48e514..8e87bde 100644
--- a/loolwsd/LOOLWSD.cpp
+++ b/loolwsd/LOOLWSD.cpp
@@ -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())
diff --git a/loolwsd/LOOLWSD.hpp b/loolwsd/LOOLWSD.hpp
index 42780dd..d82e026 100644
--- a/loolwsd/LOOLWSD.hpp
+++ b/loolwsd/LOOLWSD.hpp
@@ -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
diff --git a/loolwsd/Makefile.am b/loolwsd/Makefile.am
index 8f03e35..cf4a37d 100644
--- a/loolwsd/Makefile.am
+++ b/loolwsd/Makefile.am
@@ -143,8 +143,9 @@ run: all @JAILS_PATH@ @SYSTEMPLATE_PATH@/system_stamp
 	@PROTOCOL="http" ; if test "z at 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)"
diff --git a/loolwsd/loolwsd.xml.in b/loolwsd/loolwsd.xml.in
index 8baa2c8..3399ef8 100644
--- a/loolwsd/loolwsd.xml.in
+++ b/loolwsd/loolwsd.xml.in
@@ -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>


More information about the Libreoffice-commits mailing list