[Libreoffice-commits] online.git: loolwsd/DocumentBroker.cpp loolwsd/LOOLKit.cpp loolwsd/LOOLWSD.cpp loolwsd/LOOLWSD.hpp

Michael Meeks michael.meeks at collabora.com
Mon Aug 1 16:18:49 UTC 2016


 loolwsd/DocumentBroker.cpp |    5 ++++-
 loolwsd/LOOLKit.cpp        |   13 ++++++++-----
 loolwsd/LOOLWSD.cpp        |    2 +-
 loolwsd/LOOLWSD.hpp        |    1 +
 4 files changed, 14 insertions(+), 7 deletions(-)

New commits:
commit 9a0c5d8571bdece8c2a717f6fc4c3fc28b7465fa
Author: Michael Meeks <michael.meeks at collabora.com>
Date:   Mon Aug 1 09:05:37 2016 +0100

    Continue nocaps work to improve valgrindability.

diff --git a/loolwsd/DocumentBroker.cpp b/loolwsd/DocumentBroker.cpp
index 052ef0c..7b4640b 100644
--- a/loolwsd/DocumentBroker.cpp
+++ b/loolwsd/DocumentBroker.cpp
@@ -164,10 +164,13 @@ bool DocumentBroker::load(const std::string& jailId)
 
     // user/doc/jailId
     const auto jailPath = Poco::Path(JAILED_DOCUMENT_ROOT, jailId);
-    const std::string jailRoot = getJailRoot();
+    std::string jailRoot = getJailRoot();
 
     Log::info("jailPath: " + jailPath.toString() + ", jailRoot: " + jailRoot);
 
+    if (LOOLWSD::NoCapsForKit)
+        jailRoot = jailPath.toString() + "/" + getJailRoot();
+
     auto storage = StorageBase::create(jailRoot, jailPath.toString(), _uriPublic);
     if (storage)
     {
diff --git a/loolwsd/LOOLKit.cpp b/loolwsd/LOOLKit.cpp
index e3b5ec1..9b72946 100644
--- a/loolwsd/LOOLKit.cpp
+++ b/loolwsd/LOOLKit.cpp
@@ -1029,20 +1029,22 @@ void lokit_main(const std::string& childRoot,
     Util::setTerminationSignals();
     Util::setFatalSignals();
 
+    std::string userdir_url;
     std::string instdir_path;
 
     Path jailPath;
     bool bRunInsideJail = !noCapabilities;
     try
     {
+        jailPath = Path::forDirectory(childRoot + "/" + jailId);
+        Log::info("Jail path: " + jailPath.toString());
+        File(jailPath).createDirectories();
+
         if (bRunInsideJail)
         {
+            userdir_url = "file:///user";
             instdir_path = "/" + loSubPath + "/program";
 
-            jailPath = Path::forDirectory(childRoot + "/" + jailId);
-            Log::info("Jail path: " + jailPath.toString());
-            File(jailPath).createDirectories();
-
             // Create a symlink inside the jailPath so that the absolute pathname loTemplate, when
             // interpreted inside a chroot at jailPath, points to loSubPath (relative to the chroot).
             symlinkPathToJail(jailPath, loTemplate, loSubPath);
@@ -1131,13 +1133,14 @@ void lokit_main(const std::string& childRoot,
         else // noCapabilities set
         {
             Log::info("Using template " + loTemplate + " as install subpath - skipping jail setup");
+            userdir_url = "file:///" + jailPath.toString() + "/user";
             instdir_path = "/" + loTemplate + "/program";
         }
 
         std::shared_ptr<lok::Office> loKit;
         {
             const char *instdir = instdir_path.c_str();
-            const char *userdir = "file:///user";
+            const char *userdir = userdir_url.c_str();
             auto kit = UnitKit::get().lok_init(instdir, userdir);
             if (!kit)
             {
diff --git a/loolwsd/LOOLWSD.cpp b/loolwsd/LOOLWSD.cpp
index 6654f1f..8ba1fee 100644
--- a/loolwsd/LOOLWSD.cpp
+++ b/loolwsd/LOOLWSD.cpp
@@ -161,7 +161,6 @@ int MasterPortNumber = DEFAULT_MASTER_PORT_NUMBER;
 /// New LOK child processes ready to host documents.
 //TODO: Move to a more sensible namespace.
 static bool DisplayVersion = false;
-static bool NoCapsForKit = false;
 static std::vector<std::shared_ptr<ChildProcess>> newChildren;
 static std::mutex newChildrenMutex;
 static std::condition_variable newChildrenCV;
@@ -1251,6 +1250,7 @@ std::string lcl_getLaunchURI()
 
 std::atomic<unsigned> LOOLWSD::NextSessionId;
 int LOOLWSD::ForKitWritePipe = -1;
+bool LOOLWSD::NoCapsForKit = false;
 std::string LOOLWSD::Cache = LOOLWSD_CACHEDIR;
 std::string LOOLWSD::SysTemplate;
 std::string LOOLWSD::LoTemplate;
diff --git a/loolwsd/LOOLWSD.hpp b/loolwsd/LOOLWSD.hpp
index ae4eca1..74fba62 100644
--- a/loolwsd/LOOLWSD.hpp
+++ b/loolwsd/LOOLWSD.hpp
@@ -35,6 +35,7 @@ public:
     // so just keep these as statics.
     static std::atomic<unsigned> NextSessionId;
     static unsigned int NumPreSpawnedChildren;
+    static bool NoCapsForKit;
     static int ForKitWritePipe;
     static std::string Cache;
     static std::string SysTemplate;


More information about the Libreoffice-commits mailing list