[epiphany/mcatanzaro/inside-flatpak] Ensure flatpak check is not used in web process code



commit 679853ce85ba4efd417f61effdd86af00df1c56c
Author: Michael Catanzaro <mcatanzaro gnome org>
Date:   Fri Nov 8 13:03:48 2019 -0600

    Ensure flatpak check is not used in web process code
    
    This function will do the wrong thing if it is ever called in the web
    process!

 .../ephy-web-process-extension-main.c                    |  2 ++
 lib/ephy-flatpak-utils.c                                 | 16 ++++++++++++++++
 lib/ephy-flatpak-utils.h                                 |  3 +++
 3 files changed, 21 insertions(+)
---
diff --git a/embed/web-process-extension/ephy-web-process-extension-main.c 
b/embed/web-process-extension/ephy-web-process-extension-main.c
index f235dd2dc..861e657e7 100644
--- a/embed/web-process-extension/ephy-web-process-extension-main.c
+++ b/embed/web-process-extension/ephy-web-process-extension-main.c
@@ -23,6 +23,7 @@
 #include "ephy-web-process-extension.h"
 #include "ephy-debug.h"
 #include "ephy-file-helpers.h"
+#include "ephy-flatpak-utils.h"
 #include "ephy-settings.h"
 
 #pragma GCC diagnostic push
@@ -52,6 +53,7 @@ webkit_web_extension_initialize_with_user_data (WebKitWebExtension *webkit_exten
     g_warning ("Failed to initialize file helpers: %s", error->message);
 
   ephy_debug_init ();
+  ephy_flatpak_utils_set_is_web_process_extension ();
 
   extension = ephy_web_process_extension_get ();
 
diff --git a/lib/ephy-flatpak-utils.c b/lib/ephy-flatpak-utils.c
index d6e401502..5407e43d9 100644
--- a/lib/ephy-flatpak-utils.c
+++ b/lib/ephy-flatpak-utils.c
@@ -34,6 +34,16 @@
 #include <sys/stat.h>
 #include <sys/types.h>
 
+static gboolean is_web_process = FALSE;
+
+void
+ephy_flatpak_utils_set_is_web_process_extension (void)
+{
+  g_assert (!is_web_process);
+
+  is_web_process = TRUE;
+}
+
 gboolean
 ephy_is_running_inside_flatpak (void)
 {
@@ -43,6 +53,12 @@ ephy_is_running_inside_flatpak (void)
   if (decided)
     return under_flatpak;
 
+  /* This function cannot be used in the web process extension, because WebKit
+   * creates a .flatpak-info in its web process sandbox even when we are not
+   * running under flatpak. It would always return TRUE.
+   */
+  g_assert (!is_web_process);
+
   under_flatpak = g_file_test ("/.flatpak-info", G_FILE_TEST_EXISTS);
   decided = TRUE;
   return under_flatpak;
diff --git a/lib/ephy-flatpak-utils.h b/lib/ephy-flatpak-utils.h
index 1af19f22b..c6c36da96 100644
--- a/lib/ephy-flatpak-utils.h
+++ b/lib/ephy-flatpak-utils.h
@@ -22,7 +22,10 @@
 
 #include <gio/gio.h>
 
+void     ephy_flatpak_utils_set_is_web_process_extension (void);
+
 gboolean ephy_is_running_inside_flatpak           (void);
+
 void     ephy_open_file_via_flatpak_portal        (const char          *path,
                                                    GCancellable        *cancellable,
                                                    GAsyncReadyCallback  callback,


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]