[Libreoffice-commits] core.git: sal/osl

Tor Lillqvist (via logerrit) logerrit at kemper.freedesktop.org
Wed Apr 29 19:46:27 UTC 2020


 sal/osl/unx/process_impl.cxx |   12 ++++++++++++
 1 file changed, 12 insertions(+)

New commits:
commit 740af1cf9be661b6074e4ce69c41cfba56853a2b
Author:     Tor Lillqvist <tml at collabora.com>
AuthorDate: Wed Apr 29 03:17:52 2020 +0300
Commit:     Tor Lillqvist <tml at collabora.com>
CommitDate: Wed Apr 29 21:45:52 2020 +0200

    Fix problems when running a sandboxed LO as instdir/.../soffice on macOS
    
    The argv[0] passed to osl_setCommandArgs will then be the relative
    path and osl::realpath() will fail. Instead, use
    bootstrap_getExecutableFile() which calls _NSGetExecutablePath() to
    get the executable's pathname for g_command_args.
    
    Change-Id: I1345afe158d7b64871f6340733fb5490d5ca6bd8
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/93123
    Tested-by: Jenkins
    Reviewed-by: Tor Lillqvist <tml at collabora.com>

diff --git a/sal/osl/unx/process_impl.cxx b/sal/osl/unx/process_impl.cxx
index fe7dc9db5ccf..5d7f7644feb0 100644
--- a/sal/osl/unx/process_impl.cxx
+++ b/sal/osl/unx/process_impl.cxx
@@ -17,6 +17,8 @@
  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
  */
 
+#include <config_features.h>
+
 #include <osl/process.h>
 
 #include <limits.h>
@@ -224,6 +226,15 @@ void SAL_CALL osl_setCommandArgs (int argc, char ** argv)
             }
             if (ppArgs[0] != nullptr)
             {
+#if HAVE_FEATURE_MACOSX_SANDBOX
+                // If we are called with a relative path in argv[0] in a sandboxed process
+                // osl::realpath() fails. So just use bootstrap_getExecutableFile() instead.
+                // Somewhat silly to use argv[0] and tediously figure out the absolute path from it
+                // anyway.
+                bootstrap_getExecutableFile(&ppArgs[0]);
+                OUString pArg0(ppArgs[0]);
+                osl_getFileURLFromSystemPath (pArg0.pData, &(ppArgs[0]));
+#else
 #if !defined(ANDROID) && !defined(IOS) // No use searching PATH on Android or iOS
                 /* see @ osl_getExecutableFile(). */
                 if (rtl_ustr_indexOfChar (rtl_uString_getStr(ppArgs[0]), '/') == -1)
@@ -250,6 +261,7 @@ void SAL_CALL osl_setCommandArgs (int argc, char ** argv)
                 {
                     osl_getFileURLFromSystemPath (pArg0.pData, &(ppArgs[0]));
                 }
+#endif // !HAVE_FEATURE_MACOSX_SANDBOX
             }
             g_command_args.m_nCount = argc;
             g_command_args.m_ppArgs = ppArgs;


More information about the Libreoffice-commits mailing list