[Libreoffice-commits] online.git: loolwsd/LOOLKit.cpp loolwsd/LOOLWSD.cpp loolwsd/loolwsd-systemplate-setup

Michael Meeks michael.meeks at collabora.com
Fri Apr 15 15:17:45 UTC 2016


 loolwsd/LOOLKit.cpp               |   42 ++++++++++++++++++++++++++++----------
 loolwsd/LOOLWSD.cpp               |    1 
 loolwsd/loolwsd-systemplate-setup |    8 -------
 3 files changed, 32 insertions(+), 19 deletions(-)

New commits:
commit ebfa339da02337274d332763b0e1ace952550f2a
Author: Michael Meeks <michael.meeks at collabora.com>
Date:   Fri Apr 15 16:16:36 2016 +0100

    Cleanup symlinking and add realpath symlink if necessary.

diff --git a/loolwsd/LOOLKit.cpp b/loolwsd/LOOLKit.cpp
index 18b0da2..7f55ec9 100644
--- a/loolwsd/LOOLKit.cpp
+++ b/loolwsd/LOOLKit.cpp
@@ -16,6 +16,9 @@
 #include <sys/capability.h>
 #include <unistd.h>
 #include <utime.h>
+#include <limits.h>
+#include <stdlib.h>
+#include <malloc.h>
 
 #include <atomic>
 #include <cassert>
@@ -820,6 +823,27 @@ private:
     std::atomic_size_t _clientViews;
 };
 
+namespace {
+    void symlinkPathToJail(const Path jailPath, const std::string &loTemplate,
+                           const std::string &loSubPath)
+    {
+        Path symlinkSource(jailPath, Path(loTemplate.substr(1)));
+        File(symlinkSource.parent()).createDirectories();
+
+        std::string symlinkTarget;
+        for (auto i = 0; i < Path(loTemplate).depth(); i++)
+            symlinkTarget += "../";
+        symlinkTarget += loSubPath;
+
+        Log::debug("symlink(\"" + symlinkTarget + "\",\"" + symlinkSource.toString() + "\")");
+        if (symlink(symlinkTarget.c_str(), symlinkSource.toString().c_str()) == -1)
+        {
+            Log::syserror("symlink(\"" + symlinkTarget + "\",\"" + symlinkSource.toString() + "\") failed");
+            throw Exception("symlink() failed");
+        }
+    }
+}
+
 void lokit_main(const std::string& childRoot,
                 const std::string& sysTemplate,
                 const std::string& loTemplate,
@@ -861,19 +885,15 @@ void lokit_main(const std::string& childRoot,
 
         // 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).
-        Path symlinkSource(jailPath, Path(loTemplate.substr(1)));
-        File(symlinkSource.parent()).createDirectories();
-
-        std::string symlinkTarget;
-        for (auto i = 0; i < Path(loTemplate).depth(); i++)
-            symlinkTarget += "../";
-        symlinkTarget += loSubPath;
+        symlinkPathToJail(jailPath, loTemplate, loSubPath);
 
-        Log::debug("symlink(\"" + symlinkTarget + "\",\"" + symlinkSource.toString() + "\")");
-        if (symlink(symlinkTarget.c_str(), symlinkSource.toString().c_str()) == -1)
+        // Font paths can end up as realpaths so match that too.
+        char *resolved = realpath(loTemplate.c_str(), NULL);
+        if (resolved)
         {
-            Log::syserror("symlink(\"" + symlinkTarget + "\",\"" + symlinkSource.toString() + "\") failed");
-            throw Exception("symlink() failed");
+            if (strcmp(loTemplate.c_str(), resolved))
+                symlinkPathToJail(jailPath, std::string(resolved), loSubPath);
+            free (resolved);
         }
 
         Path jailLOInstallation(jailPath, loSubPath);
diff --git a/loolwsd/LOOLWSD.cpp b/loolwsd/LOOLWSD.cpp
index 31ed0d2..db27edc 100644
--- a/loolwsd/LOOLWSD.cpp
+++ b/loolwsd/LOOLWSD.cpp
@@ -479,6 +479,7 @@ private:
                 response.setStatus(HTTPResponse::HTTP_NOT_FOUND);
                 response.setContentLength(0);
                 response.send();
+                Log::info("file not found.");
             }
         }
         else
diff --git a/loolwsd/loolwsd-systemplate-setup b/loolwsd/loolwsd-systemplate-setup
index d6539e3..27c760c 100755
--- a/loolwsd/loolwsd-systemplate-setup
+++ b/loolwsd/loolwsd-systemplate-setup
@@ -87,14 +87,6 @@ if [ -h usr/share/fonts/ghostscript ]; then
     cp -r -p /usr/share/ghostscript/fonts usr/share/ghostscript
 fi
 
-# Our Libreoffice install often comes with pre-bundled fonts.
-# we need to ensure that there is a link to these with the same
-# path that fontconfig found.
-mkdir -p ./lo
-mkdir -p ./$INSTDIR
-rmdir ./$INSTDIR
-ln -s /lo $CHROOT/$INSTDIR
-
 # Debugging only hackery to avoid confusion.
 if test "z$ENABLE_DEBUG" != "z" -a "z$HOME" != "z"; then
     echo "Copying development users's fonts into systemplate"


More information about the Libreoffice-commits mailing list