[Libreoffice-commits] online.git: loolwsd/ChildProcessSession.cpp loolwsd/Common.hpp loolwsd/LOOLSession.cpp loolwsd/LOOLSession.hpp loolwsd/LOOLWSD.cpp loolwsd/MasterProcessSession.cpp

Ashod Nakashian ashod.nakashian at collabora.co.uk
Wed Jan 6 21:53:57 PST 2016


 loolwsd/ChildProcessSession.cpp  |    8 ++++----
 loolwsd/Common.hpp               |    4 ++++
 loolwsd/LOOLSession.cpp          |    2 --
 loolwsd/LOOLSession.hpp          |    2 --
 loolwsd/LOOLWSD.cpp              |    8 +++-----
 loolwsd/MasterProcessSession.cpp |    4 ++--
 6 files changed, 13 insertions(+), 15 deletions(-)

New commits:
commit 900c344a7e80c0d7152bc4487d79b075a69cf1ef
Author: Ashod Nakashian <ashod.nakashian at collabora.co.uk>
Date:   Wed Jan 6 13:49:10 2016 -0500

    loolwsd: refactored JailedDocumentRoot path
    
    Change-Id: Ibee16e6ebde0ae1945be53903a0b0bad4f3300ed
    Reviewed-on: https://gerrit.libreoffice.org/21179
    Reviewed-by: Ashod Nakashian <ashnakash at gmail.com>
    Tested-by: Ashod Nakashian <ashnakash at gmail.com>

diff --git a/loolwsd/ChildProcessSession.cpp b/loolwsd/ChildProcessSession.cpp
index 8fa38fe..3267570 100644
--- a/loolwsd/ChildProcessSession.cpp
+++ b/loolwsd/ChildProcessSession.cpp
@@ -266,10 +266,10 @@ bool ChildProcessSession::loadDocument(const char *buffer, int length, StringTok
         Log::info("Loading view to document from URI: [" + aUri.toString() + "].");
 
     // The URL in the request is the original one, not visible in the chroot jail.
-    // The child process uses the fixed name jailDocumentURL.
+    // The child process uses the fixed name JailedDocumentRoot.
     if (aUri.isRelative() || aUri.getScheme() == "file")
     {
-        aUri = URI( URI("file://"), Path(jailDocumentURL + Path::separator() + std::to_string(Process::id()),
+        aUri = URI( URI("file://"), Path(JailedDocumentRoot + std::to_string(Process::id()),
                     Path(aUri.getPath()).getFileName()).toString() );
         Log::info("Local URI: [" + aUri.toString() + "].");
     }
@@ -519,7 +519,7 @@ bool ChildProcessSession::downloadAs(const char* /*buffer*/, int /*length*/, Str
             delete file;
         }
         tmpDir = std::to_string(Util::rng::getNext());
-        url = jailDocumentURL + "/" + tmpDir + "/" + name;
+        url = JailedDocumentRoot + tmpDir + "/" + name;
         file = new File(url);
     } while (file->exists());
     delete file;
@@ -596,7 +596,7 @@ bool ChildProcessSession::insertFile(const char* /*buffer*/, int /*length*/, Str
 
     if (type == "graphic")
     {
-        std::string fileName = "file://" + jailDocumentURL + "/insertfile/" + name;
+        std::string fileName = "file://" + JailedDocumentRoot + "insertfile/" + name;
         std::string command = ".uno:InsertGraphic";
         std::string arguments = "{"
             "\"FileName\":{"
diff --git a/loolwsd/Common.hpp b/loolwsd/Common.hpp
index 7330f83..04fb0d1 100644
--- a/loolwsd/Common.hpp
+++ b/loolwsd/Common.hpp
@@ -11,6 +11,8 @@
 #ifndef INCLUDED_COMMON_HPP
 #define INCLUDED_COMMON_HPP
 
+#include <string>
+
 constexpr int DEFAULT_CLIENT_PORT_NUMBER = 9980;
 constexpr int MASTER_PORT_NUMBER = 9981;
 constexpr int INTERVAL_PROBES = 10;
@@ -20,6 +22,8 @@ constexpr int POLL_TIMEOUT = 1000000;
 // work loads.
 constexpr int PIPE_BUFFER = 1024;
 
+static const std::string JailedDocumentRoot = "/user/doc/";
+
 // Flag to stop pump loops.
 static volatile bool TerminationFlag = false;
 
diff --git a/loolwsd/LOOLSession.cpp b/loolwsd/LOOLSession.cpp
index 96f844f..038dcfe 100644
--- a/loolwsd/LOOLSession.cpp
+++ b/loolwsd/LOOLSession.cpp
@@ -80,8 +80,6 @@ using Poco::Net::DialogSocket;
 using Poco::Net::SocketAddress;
 using Poco::Net::WebSocketException;
 
-const std::string LOOLSession::jailDocumentURL = "/user/thedocument";
-
 LOOLSession::LOOLSession(const std::string& id, const Kind kind,
                          std::shared_ptr<Poco::Net::WebSocket> ws) :
     _kind(kind),
diff --git a/loolwsd/LOOLSession.hpp b/loolwsd/LOOLSession.hpp
index 22a308f..2e3f213 100644
--- a/loolwsd/LOOLSession.hpp
+++ b/loolwsd/LOOLSession.hpp
@@ -55,8 +55,6 @@ public:
 
     bool handleInput(const char *buffer, int length);
 
-    static const std::string jailDocumentURL;
-
 protected:
     LOOLSession(const std::string& id, const Kind kind,
                 std::shared_ptr<Poco::Net::WebSocket> ws);
diff --git a/loolwsd/LOOLWSD.cpp b/loolwsd/LOOLWSD.cpp
index a4bec81..9b5276b 100644
--- a/loolwsd/LOOLWSD.cpp
+++ b/loolwsd/LOOLWSD.cpp
@@ -338,7 +338,7 @@ public:
                     // Convert it to the requested format.
                     Path toPath(fromPath);
                     toPath.setExtension(format);
-                    std::string toJailURL = filePrefix + LOOLSession::jailDocumentURL + Path::separator() + toPath.getFileName();
+                    std::string toJailURL = filePrefix + JailedDocumentRoot + toPath.getFileName();
                     std::string saveas = "saveas url=" + toJailURL + " format=" + format + " options=";
                     session->handleInput(saveas.data(), saveas.size());
                     std::string toURL = session->getSaveAs();
@@ -373,8 +373,7 @@ public:
                 if (form.has("childid") && form.has("name"))
                 {
                     const std::string dirPath = LOOLWSD::childRoot + form.get("childid")
-                                              + LOOLSession::jailDocumentURL
-                                              + Path::separator() + "insertfile";
+                                              + JailedDocumentRoot + "insertfile";
                     File(dirPath).createDirectory();
                     std::string fileName = dirPath + Path::separator() + form.get("name");
                     File(tmpPath).moveTo(fileName);
@@ -392,8 +391,7 @@ public:
             {
                 // The user might request a file to download
                 const std::string dirPath = LOOLWSD::childRoot + tokens[1]
-                                          + LOOLSession::jailDocumentURL
-                                          + Path::separator() + tokens[2];
+                                          + JailedDocumentRoot + tokens[2];
                 std::string fileName;
                 URI::decode(tokens[3], fileName);
                 const std::string filePath = dirPath + Path::separator() + fileName;
diff --git a/loolwsd/MasterProcessSession.cpp b/loolwsd/MasterProcessSession.cpp
index 704b93a..b420d76 100644
--- a/loolwsd/MasterProcessSession.cpp
+++ b/loolwsd/MasterProcessSession.cpp
@@ -17,6 +17,7 @@
 #include <Poco/URI.h>
 #include <Poco/URIStreamOpener.h>
 
+#include "Common.hpp"
 #include "LOOLProtocol.hpp"
 #include "LOOLSession.hpp"
 #include "LOOLWSD.hpp"
@@ -625,7 +626,7 @@ void MasterProcessSession::dispatchChild()
     // Copy document into jail using the fixed name
     if (!aUri.empty() && aUri.getScheme() == "file")
     {
-        const std::string aJailDoc = jailDocumentURL.substr(1) + Path::separator() + std::to_string(childSession->_pidChild);
+        const std::string aJailDoc = JailedDocumentRoot.substr(1) + Path::separator() + std::to_string(childSession->_pidChild);
         const Path aSrcFile(aUri.getPath());
         const Path aDstPath(getJailPath(childSession->_childId), aJailDoc);
         const Path aDstFile(aDstPath, aSrcFile.getFileName());
@@ -633,7 +634,6 @@ void MasterProcessSession::dispatchChild()
 
         Log::debug("JailDoc: " + aJailDoc);
         Log::debug("SrcFile: " + aSrcFile.toString());
-        Log::debug("DstPath: " + aDstPath.toString());
         Log::debug("DstFile: " + aDstFile.toString());
         Log::debug("JailFile: " + aJailFile.toString());
 


More information about the Libreoffice-commits mailing list