[evolution] Make it possible to disable WebKit sandbox usage with an environment variable



commit 6959aeb5bba888885025c732054311b547850f3c
Author: Milan Crha <mcrha redhat com>
Date:   Mon May 11 14:23:32 2020 +0200

    Make it possible to disable WebKit sandbox usage with an environment variable
    
    Define DISABLE_WEBKIT_SANDBOX=1 environment variable before running
    evolution to disable WebKitGTK sandbox usage. That would be usable
    in cases when the sandbox refuses to run, which can happen and which
    had been noticed on terminal with this output:
    
       terminate called after throwing an instance of 'std::system_error'
         what():  Operation not permitted
    
    This showed when opening a message composer.

 src/e-util/e-web-view.c                     | 7 ++++++-
 src/modules/webkit-editor/e-webkit-editor.c | 7 ++++++-
 2 files changed, 12 insertions(+), 2 deletions(-)
---
diff --git a/src/e-util/e-web-view.c b/src/e-util/e-web-view.c
index d5bf1488fc..08a9e069a5 100644
--- a/src/e-util/e-web-view.c
+++ b/src/e-util/e-web-view.c
@@ -902,11 +902,16 @@ web_view_constructor (GType type,
                        static gpointer web_context = NULL;
 
                        if (!web_context) {
+                               static gchar sandbox_option = -1;
+
+                               if (sandbox_option == -1)
+                                       sandbox_option = g_strcmp0 (g_getenv ("DISABLE_WEBKIT_SANDBOX"), "1") 
== 0 ? 0 : 1;
+
                                web_context = webkit_web_context_new ();
 
                                webkit_web_context_set_cache_model (web_context, 
WEBKIT_CACHE_MODEL_DOCUMENT_VIEWER);
                                webkit_web_context_set_web_extensions_directory (web_context, 
EVOLUTION_WEB_EXTENSIONS_DIR);
-                               webkit_web_context_set_sandbox_enabled (web_context, TRUE);
+                               webkit_web_context_set_sandbox_enabled (web_context, sandbox_option != 0);
                                webkit_web_context_add_path_to_sandbox (web_context, EVOLUTION_WEBKITDATADIR, 
TRUE);
                                #if ENABLE_MAINTAINER_MODE
                                webkit_web_context_add_path_to_sandbox (web_context, 
EVOLUTION_SOURCE_WEBKITDATADIR, TRUE);
diff --git a/src/modules/webkit-editor/e-webkit-editor.c b/src/modules/webkit-editor/e-webkit-editor.c
index a300f3b980..3d26dca3c6 100644
--- a/src/modules/webkit-editor/e-webkit-editor.c
+++ b/src/modules/webkit-editor/e-webkit-editor.c
@@ -4194,11 +4194,16 @@ webkit_editor_constructor (GType type,
                        static gpointer web_context = NULL;
 
                        if (!web_context) {
+                               static gchar sandbox_option = -1;
+
+                               if (sandbox_option == -1)
+                                       sandbox_option = g_strcmp0 (g_getenv ("DISABLE_WEBKIT_SANDBOX"), "1") 
== 0 ? 0 : 1;
+
                                web_context = webkit_web_context_new ();
 
                                webkit_web_context_set_cache_model (web_context, 
WEBKIT_CACHE_MODEL_DOCUMENT_VIEWER);
                                webkit_web_context_set_web_extensions_directory (web_context, 
EVOLUTION_WEB_EXTENSIONS_WEBKIT_EDITOR_DIR);
-                               webkit_web_context_set_sandbox_enabled (web_context, TRUE);
+                               webkit_web_context_set_sandbox_enabled (web_context, sandbox_option != 0);
                                webkit_web_context_add_path_to_sandbox (web_context, EVOLUTION_WEBKITDATADIR, 
TRUE);
                                #if ENABLE_MAINTAINER_MODE
                                webkit_web_context_add_path_to_sandbox (web_context, 
EVOLUTION_SOURCE_WEBKITDATADIR, TRUE);


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