[WPE] Enable web process sandbox
authormcatanzaro@igalia.com <mcatanzaro@igalia.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 4 Mar 2019 15:25:43 +0000 (15:25 +0000)
committermcatanzaro@igalia.com <mcatanzaro@igalia.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 4 Mar 2019 15:25:43 +0000 (15:25 +0000)
https://bugs.webkit.org/show_bug.cgi?id=195169

Reviewed by Daniel Bates.

.:

* Source/cmake/BubblewrapSandboxChecks.cmake: Added.
* Source/cmake/OptionsGTK.cmake:
* Source/cmake/OptionsWPE.cmake:

Source/WebKit:

* PlatformWPE.cmake:
* UIProcess/Launcher/glib/BubblewrapLauncher.cpp:
(WebKit::bubblewrapSpawn):
* UIProcess/glib/WebProcessPoolGLib.cpp:
(WebKit::WebProcessPool::platformInitialize):

Tools:

* wpe/install-dependencies:
* wpe/jhbuild.modules:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@242354 268f45cc-cd09-0410-ab3c-d52691b4dbfc

ChangeLog
Source/WebKit/ChangeLog
Source/WebKit/PlatformWPE.cmake
Source/WebKit/UIProcess/Launcher/glib/BubblewrapLauncher.cpp
Source/WebKit/UIProcess/glib/WebProcessPoolGLib.cpp
Source/cmake/BubblewrapSandboxChecks.cmake [new file with mode: 0644]
Source/cmake/OptionsGTK.cmake
Source/cmake/OptionsWPE.cmake
Tools/ChangeLog
Tools/wpe/install-dependencies
Tools/wpe/jhbuild.modules

index feae961..8c90892 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+2019-03-04  Michael Catanzaro  <mcatanzaro@igalia.com>
+
+        [WPE] Enable web process sandbox
+        https://bugs.webkit.org/show_bug.cgi?id=195169
+
+        Reviewed by Daniel Bates.
+
+        * Source/cmake/BubblewrapSandboxChecks.cmake: Added.
+        * Source/cmake/OptionsGTK.cmake:
+        * Source/cmake/OptionsWPE.cmake:
+
 2019-03-01  Don Olmstead  <don.olmstead@sony.com>
 
         [WinCairo] Enable service worker
index 8bfaf57..41f51be 100644 (file)
@@ -1,3 +1,16 @@
+2019-03-04  Michael Catanzaro  <mcatanzaro@igalia.com>
+
+        [WPE] Enable web process sandbox
+        https://bugs.webkit.org/show_bug.cgi?id=195169
+
+        Reviewed by Daniel Bates.
+
+        * PlatformWPE.cmake:
+        * UIProcess/Launcher/glib/BubblewrapLauncher.cpp:
+        (WebKit::bubblewrapSpawn):
+        * UIProcess/glib/WebProcessPoolGLib.cpp:
+        (WebKit::WebProcessPool::platformInitialize):
+
 2019-03-04  Adrian Perez de Castro  <aperez@igalia.com>
 
         [GTK][WPE] Wrong license header in WebKit{,WebExtension}Autocleanups.h
index 13197d3..cbdf487 100644 (file)
@@ -16,6 +16,7 @@ configure_file(wpe/wpe-web-extension.pc.in ${WPEWebExtension_PKGCONFIG_FILE} @ON
 
 add_definitions(-DWEBKIT2_COMPILATION)
 
+add_definitions(-DLIBDIR="${LIB_INSTALL_DIR}")
 add_definitions(-DPKGLIBDIR="${LIB_INSTALL_DIR}/wpe-webkit-${WPE_API_VERSION}")
 add_definitions(-DPKGLIBEXECDIR="${LIBEXEC_INSTALL_DIR}")
 add_definitions(-DDATADIR="${CMAKE_INSTALL_FULL_DATADIR}")
@@ -279,6 +280,7 @@ list(APPEND WebKit_SYSTEM_INCLUDE_DIRECTORIES
     ${GLIB_INCLUDE_DIRS}
     ${GSTREAMER_INCLUDE_DIRS}
     ${HARFBUZZ_INCLUDE_DIRS}
+    ${LIBSECCOMP_INCLUDE_DIRS}
     ${LIBSOUP_INCLUDE_DIRS}
     ${WPE_INCLUDE_DIRS}
 )
@@ -291,6 +293,7 @@ list(APPEND WebKit_LIBRARIES
         ${GLIB_GMODULE_LIBRARIES}
         ${GSTREAMER_LIBRARIES}
         ${HARFBUZZ_LIBRARIES}
+        ${LIBSECCOMP_LIBRARIES}
         ${LIBSOUP_LIBRARIES}
         ${WPE_LIBRARIES}
 )
index f8b102a..b753b25 100644 (file)
@@ -668,11 +668,13 @@ GRefPtr<GSubprocess> bubblewrapSpawn(GSubprocessLauncher* launcher, const Proces
 {
     ASSERT(launcher);
 
+#if ENABLE(NETSCAPE_PLUGIN_API)
     // It is impossible to know what access arbitrary plugins need and since it is for legacy
     // reasons lets just leave it unsandboxed.
     if (launchOptions.processType == ProcessLauncher::ProcessType::Plugin64
         || launchOptions.processType == ProcessLauncher::ProcessType::Plugin32)
         return adoptGRef(g_subprocess_launcher_spawnv(launcher, argv, error));
+#endif
 
     // For now we are just considering the network process trusted as it
     // requires a lot of access but doesn't execute arbitrary code like
index b5fd6c4..45d52e1 100644 (file)
@@ -73,6 +73,10 @@ static bool memoryPressureMonitorDisabled()
 
 void WebProcessPool::platformInitialize()
 {
+#if PLATFORM(WPE)
+    m_sandboxEnabled = true;
+#endif
+
 #if PLATFORM(GTK)
     m_alwaysUsesComplexTextCodePath = true;
 #endif
diff --git a/Source/cmake/BubblewrapSandboxChecks.cmake b/Source/cmake/BubblewrapSandboxChecks.cmake
new file mode 100644 (file)
index 0000000..ac8fbbf
--- /dev/null
@@ -0,0 +1,31 @@
+if (ENABLE_BUBBLEWRAP_SANDBOX)
+    find_program(BWRAP_EXECUTABLE bwrap)
+    if (NOT BWRAP_EXECUTABLE)
+        message(FATAL_ERROR "bwrap executable is needed for ENABLE_BUBBLEWRAP_SANDBOX")
+    endif ()
+    add_definitions(-DBWRAP_EXECUTABLE="${BWRAP_EXECUTABLE}")
+
+    execute_process(
+        COMMAND "${BWRAP_EXECUTABLE}" --version
+        RESULT_VARIABLE BWRAP_RET
+        OUTPUT_VARIABLE BWRAP_OUTPUT
+    )
+    if (BWRAP_RET)
+        message(FATAL_ERROR "Failed to run ${BWRAP_EXECUTABLE}")
+    endif ()
+    string(REGEX MATCH "([0-9]+.[0-9]+.[0-9]+)" BWRAP_VERSION "${BWRAP_OUTPUT}")
+    if (NOT "${BWRAP_VERSION}" VERSION_GREATER_EQUAL "0.3.1")
+        message(FATAL_ERROR "bwrap must be >= 0.3.1 but ${BWRAP_VERSION} found")
+    endif ()
+
+    find_package(Libseccomp)
+    if (NOT LIBSECCOMP_FOUND)
+        message(FATAL_ERROR "libseccomp is needed for ENABLE_BUBBLEWRAP_SANDBOX")
+    endif ()
+
+    find_program(DBUS_PROXY_EXECUTABLE xdg-dbus-proxy)
+    if (NOT DBUS_PROXY_EXECUTABLE)
+        message(FATAL_ERROR "xdg-dbus-proxy not found and is needed for ENABLE_BUBBLEWRAP_SANDBOX")
+    endif ()
+    add_definitions(-DDBUS_PROXY_EXECUTABLE="${DBUS_PROXY_EXECUTABLE}")
+endif ()
index fa73cea..8a0cd3b 100644 (file)
@@ -123,7 +123,7 @@ endif ()
 if (CMAKE_SYSTEM_NAME MATCHES "Linux" AND NOT EXISTS "/.flatpak-info")
     WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_BUBBLEWRAP_SANDBOX PUBLIC ON)
 else ()
-    WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_BUBBLEWRAP_SANDBOX PRIVATE OFF)
+    WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_BUBBLEWRAP_SANDBOX PUBLIC OFF)
 endif ()
 
 # Enable variation fonts when cairo >= 1.16, fontconfig >= 2.13.0, freetype >= 2.9.0 and harfbuzz >= 1.4.2.
@@ -215,38 +215,6 @@ if (ENABLE_ACCELERATED_2D_CANVAS)
     endif ()
 endif ()
 
-if (ENABLE_BUBBLEWRAP_SANDBOX)
-    find_program(BWRAP_EXECUTABLE bwrap)
-    if (NOT BWRAP_EXECUTABLE)
-        message(FATAL_ERROR "bwrap executable is needed for ENABLE_BUBBLEWRAP_SANDBOX")
-    endif ()
-    add_definitions(-DBWRAP_EXECUTABLE="${BWRAP_EXECUTABLE}")
-
-    execute_process(
-        COMMAND "${BWRAP_EXECUTABLE}" --version
-        RESULT_VARIABLE BWRAP_RET
-        OUTPUT_VARIABLE BWRAP_OUTPUT
-    )
-    if (BWRAP_RET)
-        message(FATAL_ERROR "Failed to run ${BWRAP_EXECUTABLE}")
-    endif ()
-    string(REGEX MATCH "([0-9]+.[0-9]+.[0-9]+)" BWRAP_VERSION "${BWRAP_OUTPUT}")
-    if (NOT "${BWRAP_VERSION}" VERSION_GREATER_EQUAL "0.3.1")
-        message(FATAL_ERROR "bwrap must be >= 0.3.1 but ${BWRAP_VERSION} found")
-    endif ()
-
-    find_package(Libseccomp)
-    if (NOT LIBSECCOMP_FOUND)
-        message(FATAL_ERROR "libseccomp is needed for ENABLE_BUBBLEWRAP_SANDBOX")
-    endif ()
-
-    find_program(DBUS_PROXY_EXECUTABLE xdg-dbus-proxy)
-    if (NOT DBUS_PROXY_EXECUTABLE)
-        message(FATAL_ERROR "xdg-dbus-proxy not found and is needed for ENABLE_BUBBLEWRAP_SANDBOX")
-    endif ()
-    add_definitions(-DDBUS_PROXY_EXECUTABLE="${DBUS_PROXY_EXECUTABLE}")
-endif ()
-
 if (USE_LIBSECRET)
     find_package(Libsecret)
     if (NOT LIBSECRET_FOUND)
@@ -470,4 +438,5 @@ macro(ADD_WHOLE_ARCHIVE_TO_LIBRARIES _list_name)
     endif ()
 endmacro()
 
+include(BubblewrapSandboxChecks)
 include(GStreamerChecks)
index c430ba8..d0f643e 100644 (file)
@@ -86,6 +86,12 @@ if (DEVELOPER_MODE)
     WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_MINIBROWSER PUBLIC ON)
 endif ()
 
+if (CMAKE_SYSTEM_NAME MATCHES "Linux" AND NOT EXISTS "/.flatpak-info")
+    WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_BUBBLEWRAP_SANDBOX PUBLIC ON)
+else ()
+    WEBKIT_OPTION_DEFAULT_PORT_VALUE(ENABLE_BUBBLEWRAP_SANDBOX PUBLIC OFF)
+endif ()
+
 # Enable variation fonts when cairo >= 1.16, fontconfig >= 2.13.0, freetype >= 2.9.0 and harfbuzz >= 1.4.2.
 if (("${PC_CAIRO_VERSION}" VERSION_GREATER "1.16.0" OR "${PC_CAIRO_VERSION}" STREQUAL "1.16.0")
     AND ("${PC_FONTCONFIG_VERSION}" VERSION_GREATER "2.13.0" OR "${PC_FONTCONFIG_VERSION}" STREQUAL "2.13.0")
@@ -183,4 +189,5 @@ set(DERIVED_SOURCES_WPE_API_DIR ${DERIVED_SOURCES_WEBKIT_DIR}/wpe)
 set(WPE_PKGCONFIG_FILE ${CMAKE_BINARY_DIR}/wpe-webkit-${WPE_API_VERSION}.pc)
 set(WPEWebExtension_PKGCONFIG_FILE ${CMAKE_BINARY_DIR}/wpe-web-extension-${WPE_API_VERSION}.pc)
 
+include(BubblewrapSandboxChecks)
 include(GStreamerChecks)
index c1bc050..f29c5d7 100644 (file)
@@ -1,3 +1,13 @@
+2019-03-04  Michael Catanzaro  <mcatanzaro@igalia.com>
+
+        [WPE] Enable web process sandbox
+        https://bugs.webkit.org/show_bug.cgi?id=195169
+
+        Reviewed by Daniel Bates.
+
+        * wpe/install-dependencies:
+        * wpe/jhbuild.modules:
+
 2019-03-04  Carlos Garcia Campos  <cgarcia@igalia.com>
 
         [GLib] Returning G_TYPE_OBJECT from a constructor does not work
index 4646db9..d785fac 100755 (executable)
@@ -58,6 +58,7 @@ function installDependenciesWithApt {
         automake \
         autopoint \
         autotools-dev \
+        bubblewrap \
         cmake \
         g++ \
         gawk \
@@ -77,6 +78,7 @@ function installDependenciesWithApt {
         libjpeg-dev \
         libfile-copy-recursive-perl \
         $(aptIfElse libpng-dev libpng12-dev) \
+        libseccomp-dev \
         libsqlite3-dev \
         libtasn1-6-dev \
         libtool \
@@ -148,6 +150,7 @@ function installDependenciesWithPacman {
         alsa-lib \
         autoconf \
         automake \
+        bubblewrap \
         cmake \
         file \
         findutils \
@@ -168,6 +171,7 @@ function installDependenciesWithPacman {
         libevent \
         libjpeg-turbo \
         libpng \
+        libseccomp \
         libtasn1 \
         libtool \
         libwebp \
@@ -247,6 +251,7 @@ function installDependenciesWithDnf {
         autoconf \
         automake \
         alsa-lib-devel \
+        bubblewrap \
         cmake \
         gcc-c++ \
         gnutls-devel \
@@ -261,6 +266,7 @@ function installDependenciesWithDnf {
         libicu-devel \
         libjpeg-turbo-devel \
         libpng-devel \
+        libseccomp-devel \
         libtasn1-devel \
         libtool \
         libwebp-devel \
index 20a594a..ac0db0b 100644 (file)
@@ -26,6 +26,7 @@
       <dep package="libepoxy"/>
       <dep package="wayland-protocols"/>
       <dep package="openjpeg"/>
+      <dep package="xdg-dbus-proxy"/>
     </dependencies>
   </metamodule>
 
     </dependencies>
   </distutils>
 
+  <autotools id="xdg-dbus-proxy" autogen-sh="configure">
+    <branch repo="github-tarball"
+            version="0.1.0"
+            module="flatpak/xdg-dbus-proxy/releases/download/${version}/xdg-dbus-proxy-${version}.tar.xz"
+            checkoutdir="xdg-dbus-proxy-${version}"
+            hash="sha256:9eefd30fe66940c8daf0e8ce6479307694814edb8b636caeb5aa6d6a46a4bc14"/>
+    <dependencies>
+      <dep package="glib"/>
+    </dependencies>
+  </autotools>
+
 </moduleset>