Diff
Modified: trunk/Tools/ChangeLog (273239 => 273240)
--- trunk/Tools/ChangeLog 2021-02-22 12:24:38 UTC (rev 273239)
+++ trunk/Tools/ChangeLog 2021-02-22 12:27:44 UTC (rev 273240)
@@ -1,5 +1,30 @@
2021-02-22 Philippe Normand <pnorm...@igalia.com>
+ [Flatpak SDK] gdb unusable in sandbox
+ https://bugs.webkit.org/show_bug.cgi?id=222247
+
+ Reviewed by Žan Doberšek.
+
+ This patch adds support for unix signals disabling in developer builds, for the Flatpak SDK
+ runtime. Currently SIGINT, SIGHUP and SIGTERM will be ignored by the flatpak and bwrap
+ processes when they're running gdb in the sandbox runtime. This allows for nicer interactive
+ debugging sessions where Ctrl-C is actually handled by gdb.
+
+ * PlatformGTK.cmake:
+ * PlatformWPE.cmake:
+ * flatpak/CMakeLists.txt: Added.
+ * flatpak/flatpakutils.py:
+ (nullcontext):
+ (disable_signals):
+ (WebkitFlatpak.execute_command):
+ (WebkitFlatpak.run_in_sandbox):
+ * flatpak/sigaction-disabler.c: Added.
+ (real_sigaction):
+ (sigaction):
+ * flatpak/webkit-bwrap:
+
+2021-02-22 Philippe Normand <pnorm...@igalia.com>
+
[Flatpak SDK] Add Monado for XR runtime support
https://bugs.webkit.org/show_bug.cgi?id=220738
Modified: trunk/Tools/PlatformGTK.cmake (273239 => 273240)
--- trunk/Tools/PlatformGTK.cmake 2021-02-22 12:24:38 UTC (rev 273239)
+++ trunk/Tools/PlatformGTK.cmake 2021-02-22 12:27:44 UTC (rev 273240)
@@ -2,6 +2,7 @@
add_subdirectory(TestRunnerShared)
add_subdirectory(WebKitTestRunner)
add_subdirectory(ImageDiff)
+ add_subdirectory(flatpak)
if (ENABLE_API_TESTS)
add_subdirectory(TestWebKitAPI/glib)
Modified: trunk/Tools/PlatformWPE.cmake (273239 => 273240)
--- trunk/Tools/PlatformWPE.cmake 2021-02-22 12:24:38 UTC (rev 273239)
+++ trunk/Tools/PlatformWPE.cmake 2021-02-22 12:27:44 UTC (rev 273240)
@@ -6,6 +6,7 @@
add_subdirectory(ImageDiff)
add_subdirectory(TestRunnerShared)
add_subdirectory(WebKitTestRunner)
+ add_subdirectory(flatpak)
if (ENABLE_API_TESTS)
add_subdirectory(TestWebKitAPI/glib)
Added: trunk/Tools/flatpak/CMakeLists.txt (0 => 273240)
--- trunk/Tools/flatpak/CMakeLists.txt (rev 0)
+++ trunk/Tools/flatpak/CMakeLists.txt 2021-02-22 12:27:44 UTC (rev 273240)
@@ -0,0 +1,4 @@
+
+add_library(sigaction-disabler SHARED sigaction-disabler.c)
+target_link_libraries(sigaction-disabler dl)
+add_definitions(-DLINUX -D_GNU_SOURCE)
Modified: trunk/Tools/flatpak/flatpakutils.py (273239 => 273240)
--- trunk/Tools/flatpak/flatpakutils.py 2021-02-22 12:24:38 UTC (rev 273239)
+++ trunk/Tools/flatpak/flatpakutils.py 2021-02-22 12:27:44 UTC (rev 273240)
@@ -50,6 +50,13 @@
except ImportError:
from urllib2 import urlopen
+try:
+ from contextlib import nullcontext
+except ImportError:
+ @contextmanager
+ def nullcontext(enter_result=None):
+ yield enter_result
+
FLATPAK_REQUIRED_VERSION = "1.4.4"
scriptdir = os.path.abspath(os.path.dirname(__file__))
@@ -389,11 +396,13 @@
@contextmanager
-def disable_signals(signals=[signal.SIGINT]):
+def disable_signals(signals=[signal.SIGINT, signal.SIGTERM, signal.SIGHUP]):
old_signal_handlers = []
for disabled_signal in signals:
- old_signal_handlers.append((disabled_signal, signal.getsignal(disabled_signal)))
+ handler = signal.getsignal(disabled_signal)
+ if handler:
+ old_signal_handlers.append((disabled_signal, handler))
signal.signal(disabled_signal, signal.SIG_IGN)
yield
@@ -517,20 +526,25 @@
self.sccache_token = ""
self.sccache_scheduler = DEFAULT_SCCACHE_SCHEDULER
- def execute_command(self, args, stdout=None, stderr=None, env=None):
+ def execute_command(self, args, stdout=None, stderr=None, env=None, keep_signals=True):
+ if keep_signals:
+ ctx_manager = nullcontext()
+ else:
+ ctx_manager = disable_signals()
_log.debug('Running: %s\n' % ' '.join(string_utils.decode(arg) for arg in args))
result = 0
- try:
- result = subprocess.check_call(args, stdout=stdout, stderr=stderr, env=env)
- except subprocess.CalledProcessError as err:
- if self.verbose:
- cmd = ' '.join(string_utils.decode(arg) for arg in err.cmd)
- message = "'%s' returned a non-zero exit code." % cmd
- if stderr:
- with open(stderr.name, 'r') as stderrf:
- message += " Stderr: %s" % stderrf.read()
- Console.error_message(message)
- return err.returncode
+ with ctx_manager:
+ try:
+ result = subprocess.check_call(args, stdout=stdout, stderr=stderr, env=env)
+ except subprocess.CalledProcessError as err:
+ if self.verbose:
+ cmd = ' '.join(string_utils.decode(arg) for arg in err.cmd)
+ message = "'%s' returned a non-zero exit code." % cmd
+ if stderr:
+ with open(stderr.name, 'r') as stderrf:
+ message += " Stderr: %s" % stderrf.read()
+ Console.error_message(message)
+ return err.returncode
return result
def clean_args(self):
@@ -883,6 +897,14 @@
# all `LANG` vars.
flatpak_env["LANG"] = "en_US.UTF-8"
+ keep_signals = args[0] != "gdb"
+ if not keep_signals:
+ module_path = os.path.join(self.build_path, "lib", "libsigaction-disabler.so")
+ # Enable module in bwrap child processes.
+ extra_flatpak_args.append("--env=WEBKIT_FLATPAK_LD_PRELOAD=%s" % module_path)
+ # Enable module in `flatpak run`.
+ flatpak_env["LD_PRELOAD"] = module_path
+
flatpak_command += extra_flatpak_args + ['--command=%s' % args[0], "org.webkit.Sdk"] + args[1:]
flatpak_env.update({
@@ -896,7 +918,7 @@
flatpak_env["WEBKIT_FLATPAK_DISPLAY"] = display
try:
- return self.execute_command(flatpak_command, stdout=stdout, env=flatpak_env)
+ return self.execute_command(flatpak_command, stdout=stdout, env=flatpak_env, keep_signals=keep_signals)
except KeyboardInterrupt:
return 0
Added: trunk/Tools/flatpak/sigaction-disabler.c (0 => 273240)
--- trunk/Tools/flatpak/sigaction-disabler.c (rev 0)
+++ trunk/Tools/flatpak/sigaction-disabler.c 2021-02-22 12:27:44 UTC (rev 273240)
@@ -0,0 +1,36 @@
+/*
+ * Copyright (C) 2021 Igalia S.L.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this program; if not, write to the
+ * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#include <dlfcn.h>
+#include <signal.h>
+
+typedef int (*real_sigaction_t)(int, const struct sigaction*, struct sigaction*);
+
+int realSigaction(int signum, const struct sigaction* act, struct sigaction* oldact)
+{
+ return ((real_sigaction_t) dlsym(RTLD_NEXT, "sigaction"))(signum, act, oldact);
+}
+
+int sigaction(int signum, const struct sigaction* act, struct sigaction* oldact)
+{
+ if (signum == SIGINT || signum == SIGTERM || signum == SIGHUP)
+ return 0;
+
+ return realSigaction(signum, act, oldact);
+}
Modified: trunk/Tools/flatpak/webkit-bwrap (273239 => 273240)
--- trunk/Tools/flatpak/webkit-bwrap 2021-02-22 12:24:38 UTC (rev 273239)
+++ trunk/Tools/flatpak/webkit-bwrap 2021-02-22 12:27:44 UTC (rev 273240)
@@ -110,6 +110,9 @@
bwrap_args.extend(("--setenv", "PATH", "/usr/bin:/usr/lib/sdk/rust-stable/bin/"))
+ if environ.get("WEBKIT_FLATPAK_LD_PRELOAD"):
+ os.environ["LD_PRELOAD"] = environ["WEBKIT_FLATPAK_LD_PRELOAD"]
+
command_line = ' '.join(map(shlex.quote, itertools.chain(bwrap_args, args)))
# os.system return code behaves like os.wait. A 16 bit number with the