[Libreoffice-commits] core.git: Branch 'distro/collabora/co-23.05' - sal/osl sal/qa

2023-11-30 Thread Szymon Kłos (via logerrit)
 sal/osl/unx/file.cxx |   46 ++-
 sal/qa/osl/file/osl_File.cxx |   25 +++
 2 files changed, 62 insertions(+), 9 deletions(-)

New commits:
commit c3bdba781e8c9d61ca9e2a3d8d2eaca435b9aaad
Author: Szymon Kłos 
AuthorDate: Wed Nov 29 14:00:32 2023 +0100
Commit: Szymon Kłos 
CommitDate: Thu Nov 30 20:08:06 2023 +0100

sal: osl::File allow to create files in sandbox

"realpath" returns NULL for path which doesn't exist.
Allow usage of non-existing paths if parent is allowed.
This allows to successfully start the sandboxed kit.

osl_setAllowedPaths will allow now to use:
/foo/bar/nonexisting - previously it was ignored, is needed for LOK
but /foo/bar/nonexisting/newlevel - still cannot be used

isForbidden now checks parents of non-existing dir and assumes
the same permissions, if parent doesn't exist - it tries with
parent of parent, etc ...

Change-Id: I1052747ca284d2f81dfd5c5fbf893936e7426220
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/160111
Tested-by: Jenkins CollaboraOffice 
Reviewed-by: Michael Meeks 

diff --git a/sal/osl/unx/file.cxx b/sal/osl/unx/file.cxx
index 0556be7fc97a..d5b76a09a47a 100644
--- a/sal/osl/unx/file.cxx
+++ b/sal/osl/unx/file.cxx
@@ -788,6 +788,18 @@ static std::vector allowedPathsRead;
 static std::vector allowedPathsReadWrite;
 static std::vector allowedPathsExecute;
 
+static OString getParentFolder(const OString )
+{
+sal_Int32 n = rFilePath.lastIndexOf('/');
+OString folderPath;
+if (n < 1)
+folderPath = ".";
+else
+folderPath = rFilePath.copy(0, n);
+
+return folderPath;
+}
+
 SAL_DLLPUBLIC void osl_setAllowedPaths(
 rtl_uString *pustrFilePaths
 )
@@ -818,9 +830,25 @@ SAL_DLLPUBLIC void osl_setAllowedPaths(
 }
 
 char resolvedPath[PATH_MAX];
-if (realpath(aPath.getStr(), resolvedPath))
+bool isResolved = !!realpath(aPath.getStr(), resolvedPath);
+bool notExists = !isResolved && errno == ENOENT;
+
+if (notExists)
 {
-OString aPushPath = OString(resolvedPath, strlen(resolvedPath));
+sal_Int32 n = aPath.lastIndexOf('/');
+OString folderPath = getParentFolder(aPath);
+isResolved = !!realpath(folderPath.getStr(), resolvedPath);
+notExists = !isResolved && errno == ENOENT;
+
+if (notExists || !isResolved || strlen(resolvedPath) + 
aPath.getLength() - n + 1 >= PATH_MAX)
+return; // too bad
+else
+strcat(resolvedPath, aPath.getStr() + n);
+}
+
+if (isResolved)
+{
+OString aPushPath(resolvedPath, strlen(resolvedPath));
 if (eType == 'r')
 allowedPathsRead.push_back(aPushPath);
 else if (eType == 'w')
@@ -850,13 +878,13 @@ bool isForbidden(const OString , int nFlags)
 // fail to resolve. Thankfully our I/O APIs don't allow
 // symlink creation to race here.
 sal_Int32 n = filePath.lastIndexOf('/');
-OString folderPath;
-if (n < 1)
-folderPath = ".";
-else
-folderPath = filePath.copy(0, n);
-if (!realpath(folderPath.getStr(), resolvedPath) ||
-strlen(resolvedPath) + filePath.getLength() - n + 1 >= PATH_MAX)
+OString folderPath = getParentFolder(filePath);
+
+bool isResolved = !!realpath(folderPath.getStr(), resolvedPath);
+bool notExists = !isResolved && errno == ENOENT;
+if (notExists) // folder doesn't exist, check parent, in the end of 
chain checks "."
+return isForbidden(folderPath, nFlags);
+else if (!isResolved || strlen(resolvedPath) + filePath.getLength() - 
n + 1 >= PATH_MAX)
 return true; // too bad
 else
 strcat(resolvedPath, filePath.getStr() + n);
diff --git a/sal/qa/osl/file/osl_File.cxx b/sal/qa/osl/file/osl_File.cxx
index 0703e89493b9..cdd72d45fa72 100644
--- a/sal/qa/osl/file/osl_File.cxx
+++ b/sal/qa/osl/file/osl_File.cxx
@@ -1352,6 +1352,19 @@ namespace osl_Forbidden
 void forbidden()
 {
 File::setAllowedPaths(maScratchGood);
+
+// check some corner cases first
+CPPUNIT_ASSERT_EQUAL_MESSAGE("read bad should be forbidden",
+ true, File::isForbidden(".", 
osl_File_OpenFlag_Read));
+CPPUNIT_ASSERT_EQUAL_MESSAGE("read bad should be forbidden",
+ true, File::isForbidden("", 
osl_File_OpenFlag_Read));
+CPPUNIT_ASSERT_EQUAL_MESSAGE("read bad should be forbidden",
+ true, File::isForbidden("a", 
osl_File_OpenFlag_Read));
+CPPUNIT_ASSERT_EQUAL_MESSAGE("read bad should be forbidden",
+ true, File::isForbidden("/", 

[Libreoffice-commits] core.git: Branch 'distro/collabora/co-23.05' - sal/osl vcl/inc vcl/ios

2023-10-06 Thread Caolán McNamara (via logerrit)
 sal/osl/unx/process.cxx|4 
 vcl/inc/ios/iosinst.hxx|2 +-
 vcl/inc/quartz/ctfonts.hxx |3 ---
 vcl/ios/iosinst.cxx|9 -
 4 files changed, 5 insertions(+), 13 deletions(-)

New commits:
commit a65607eb4667af7c7e508fefcdb1b02ef8526ff9
Author: Caolán McNamara 
AuthorDate: Fri Oct 6 15:10:53 2023 +0100
Commit: Andras Timar 
CommitDate: Fri Oct 6 16:16:02 2023 +0200

Revert "Fix iOS build breakages when building on macOS Sonoma"

This reverts commit 24d41f7e965ca0dab19bfde1570419c15508ee5d.
Reason: pushed by mistake, not needed.

Change-Id: I9f5278ab15687b8410fe6cfa8e0249531bd9f281
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/157645
Reviewed-by: Andras Timar 
Tested-by: Andras Timar 

diff --git a/sal/osl/unx/process.cxx b/sal/osl/unx/process.cxx
index 5ad579ae0f72..f75534fdc311 100644
--- a/sal/osl/unx/process.cxx
+++ b/sal/osl/unx/process.cxx
@@ -40,10 +40,6 @@
 #include 
 #endif
 
-#ifdef IOS
-#include 
-#endif
-
 #include "system.hxx"
 #include "unixerrnostring.hxx"
 #if defined(__sun)
diff --git a/vcl/inc/ios/iosinst.hxx b/vcl/inc/ios/iosinst.hxx
index 63182bcd0c0a..6ba433eed104 100644
--- a/vcl/inc/ios/iosinst.hxx
+++ b/vcl/inc/ios/iosinst.hxx
@@ -44,7 +44,7 @@ public:
 css::uno::Reference
 CreateClipboard(const css::uno::Sequence& i_rArguments) 
override;
 
-void GetWorkArea(AbsoluteScreenPixelRectangle& rRect);
+void GetWorkArea(tools::Rectangle& rRect);
 SalFrame* CreateFrame(SalFrame* pParent, SalFrameStyleFlags nStyle) 
override;
 SalFrame* CreateChildFrame(SystemParentData* pParent, SalFrameStyleFlags 
nStyle) override;
 };
diff --git a/vcl/inc/quartz/ctfonts.hxx b/vcl/inc/quartz/ctfonts.hxx
index dcf0dbff843c..be68dea71c9a 100644
--- a/vcl/inc/quartz/ctfonts.hxx
+++ b/vcl/inc/quartz/ctfonts.hxx
@@ -24,9 +24,6 @@
 #include 
 
 std::unique_ptr GetCoretextFontList();
-#ifdef IOS
-#include 
-#endif
 FontAttributes DevFontFromCTFontDescriptor(CTFontDescriptorRef, bool*);
 
 #endif // INCLUDED_VCL_INC_QUARTZ_CTFONTS_HXX
diff --git a/vcl/ios/iosinst.cxx b/vcl/ios/iosinst.cxx
index 371d5c246ca1..533fef269a07 100644
--- a/vcl/ios/iosinst.cxx
+++ b/vcl/ios/iosinst.cxx
@@ -26,17 +26,16 @@
 #include "headless/svpdata.hxx"
 #include "headless/svpdummies.hxx"
 #include "quartz/utils.h"
-#include "quartz/SystemFontList.hxx"
 #include 
 #include 
 
 // Totally wrong of course but doesn't seem to harm much in the iOS app.
 static int viewWidth = 1, viewHeight = 1;
 
-void IosSalInstance::GetWorkArea( AbsoluteScreenPixelRectangle& rRect )
+void IosSalInstance::GetWorkArea( tools::Rectangle& rRect )
 {
-rRect = AbsoluteScreenPixelRectangle( AbsoluteScreenPixelPoint( 0, 0 ),
-   AbsoluteScreenPixelSize( viewWidth, viewHeight ) );
+rRect = tools::Rectangle( Point( 0, 0 ),
+   Size( viewWidth, viewHeight ) );
 }
 
 IosSalInstance *IosSalInstance::getInstance()
@@ -81,7 +80,7 @@ public:
 SetPosSize(0, 0, viewWidth, viewHeight, SAL_FRAME_POSSIZE_WIDTH | 
SAL_FRAME_POSSIZE_HEIGHT);
 }
 
-virtual void GetWorkArea( AbsoluteScreenPixelRectangle& rRect ) override
+virtual void GetWorkArea( tools::Rectangle& rRect ) override
 {
 IosSalInstance::getInstance()->GetWorkArea( rRect );
 }


[Libreoffice-commits] core.git: Branch 'distro/collabora/co-23.05' - sal/osl

2023-02-23 Thread Tor Lillqvist (via logerrit)
 sal/osl/unx/process_impl.cxx |8 
 1 file changed, 8 insertions(+)

New commits:
commit 701f0037383d9e10befec710d2a59e9adc91e588
Author: Tor Lillqvist 
AuthorDate: Tue Dec 13 10:47:15 2022 +0200
Commit: Tor Lillqvist 
CommitDate: Fri Feb 24 07:57:46 2023 +

Add Emscripten ifdef to bootstrap_getExecutableFile()

Change-Id: I15d31873a27ace544a76a64fe354edb97b144424
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/144039
Tested-by: Jenkins
Reviewed-by: Tor Lillqvist 
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/147563
Tested-by: Tor Lillqvist 

diff --git a/sal/osl/unx/process_impl.cxx b/sal/osl/unx/process_impl.cxx
index 5d7f7644feb0..a61df87c2cff 100644
--- a/sal/osl/unx/process_impl.cxx
+++ b/sal/osl/unx/process_impl.cxx
@@ -97,6 +97,13 @@ oslProcessError bootstrap_getExecutableFile(rtl_uString ** 
ppFileURL)
 {
 oslProcessError result = osl_Process_E_NotFound;
 
+#ifdef EMSCRIPTEN
+// Just return some dummy file: URL for now to see what happens
+OUString fileURL = "vnd.sun.star.pathname:/instdir/program/soffice";
+rtl_uString_acquire(fileURL.pData);
+*ppFileURL = fileURL.pData;
+return osl_Process_E_None;
+#else
 #ifdef ANDROID
 /* Now with just a single DSO, this one from lo-bootstrap.c is as good as
  * any */
@@ -136,6 +143,7 @@ oslProcessError bootstrap_getExecutableFile(rtl_uString ** 
ppFileURL)
 }
 
 return result;
+#endif
 }
 
 }