Title: [260991] trunk/Tools
Revision
260991
Author
lmo...@igalia.com
Date
2020-05-01 02:48:21 -0700 (Fri, 01 May 2020)

Log Message

[Flatpak SDK] Honor XDG_RUNTIME_DIR when setting the document path
https://bugs.webkit.org/show_bug.cgi?id=211277

Reviewed by Philippe Normand.

* flatpak/flatpakutils.py:
(WebkitFlatpak.run_in_sandbox): Prefer using the value of
$XDG_RUNTIME_DIR instead of the hardcoded path when setting the
document portal path mount.

Modified Paths

Diff

Modified: trunk/Tools/ChangeLog (260990 => 260991)


--- trunk/Tools/ChangeLog	2020-05-01 08:45:20 UTC (rev 260990)
+++ trunk/Tools/ChangeLog	2020-05-01 09:48:21 UTC (rev 260991)
@@ -1,3 +1,15 @@
+2020-05-01  Lauro Moura  <lmo...@igalia.com>
+
+        [Flatpak SDK] Honor XDG_RUNTIME_DIR when setting the document path
+        https://bugs.webkit.org/show_bug.cgi?id=211277
+
+        Reviewed by Philippe Normand.
+
+        * flatpak/flatpakutils.py:
+        (WebkitFlatpak.run_in_sandbox): Prefer using the value of
+        $XDG_RUNTIME_DIR instead of the hardcoded path when setting the
+        document portal path mount.
+
 2020-05-01  Adrian Perez de Castro  <ape...@igalia.com>
 
         [GTK] File GtkVersioning.h should be excluded from the style checker

Modified: trunk/Tools/flatpak/flatpakutils.py (260990 => 260991)


--- trunk/Tools/flatpak/flatpakutils.py	2020-05-01 08:45:20 UTC (rev 260990)
+++ trunk/Tools/flatpak/flatpakutils.py	2020-05-01 09:48:21 UTC (rev 260991)
@@ -659,17 +659,23 @@
                 "--talk-name=org.freedesktop.Flatpak"
             ])
 
-            try:
-                with open(os.devnull, 'w') as devnull:
-                    uid = subprocess.check_output(("id", "-u"), stderr=devnull).strip().decode()
-                    uid_doc_path = '/run/user/{uid}/doc'.format(uid=uid)
-                    if os.path.exists(uid_doc_path):
-                        flatpak_command.append("--bind-mount={uid_doc_path}={uid_doc_path}".format(uid_doc_path=uid_doc_path))
-                    else:
-                        _log.debug("Can't find user document path at '{uid_doc_path}'. Not mounting it.".format(uid_doc_path=uid_doc_path))
-            except subprocess.CalledProcessError:
-                pass
+            xdg_runtime_dir = os.environ.get('XDG_RUNTIME_DIR', None)
+            if not xdg_runtime_dir:
+                _log.debug('XDG_RUNTIME_DIR not set. Trying default location.')
+                try:
+                    with open(os.devnull, 'w') as devnull:
+                        uid = subprocess.check_output(("id", "-u"), stderr=devnull).decode().strip()
+                        xdg_runtime_dir = '/run/user/{uid}'.format(uid=uid)
+                except subprocess.CalledProcessError:
+                    _log.debug("Could not determine XDG_RUNIME_DIR. This may cause bubblewrap to fail.")
 
+            if xdg_runtime_dir:
+                uid_doc_path = os.path.join(xdg_runtime_dir, 'doc')
+                if os.path.exists(uid_doc_path):
+                    flatpak_command.append("--bind-mount={uid_doc_path}={uid_doc_path}".format(uid_doc_path=uid_doc_path))
+                else:
+                    _log.debug("Can't find user document path at '{uid_doc_path}'. Not mounting it.".format(uid_doc_path=uid_doc_path))
+
             forwarded.update({
                 "TZ": "PST8PDT",
                 "LANG": "en_US.UTF-8"
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to