RESOLVED FIXED 188002
[Flatpak] Pass more environment variables to sandbox
https://bugs.webkit.org/show_bug.cgi?id=188002
Summary [Flatpak] Pass more environment variables to sandbox
Charlie Turner
Reported 2018-07-25 07:15:33 PDT
[Flatpak] Pass environment variables starting with WEBKIT to sandbox
Attachments
Patch (1.24 KB, patch)
2018-07-25 07:22 PDT, Charlie Turner
no flags
Patch (1.24 KB, patch)
2018-07-25 07:53 PDT, Charlie Turner
no flags
Patch (1.86 KB, patch)
2018-07-25 09:01 PDT, Charlie Turner
no flags
Charlie Turner
Comment 1 2018-07-25 07:22:41 PDT
Adrian Perez
Comment 2 2018-07-25 07:42:27 PDT
Comment on attachment 345757 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=345757&action=review Reviewing informally... I have a comment about this, please read below. > Tools/flatpak/flatpakutils.py:683 > + if envvar.split("_")[0] in ("GST", "GTK", "G", "WEBKIT", "WEBKIT2") or \ I would also add variables with the WPE_ prefix. At least WPEBackend checks WPE_BACKEND_LIBRARY in developer mode builds, and WPEBackend-rdk also picks some variables from the environment like WPE_INIT_VIEW_{WIDTH,HEIGHT} and WPE_BCMRPI_{TOUCH,CURSOR}.
Charlie Turner
Comment 3 2018-07-25 07:53:42 PDT
Created attachment 345759 [details] Patch Thanks for the review Adrian, WPE_ prefixed variables are passed through as well now
Michael Catanzaro
Comment 4 2018-07-25 07:55:55 PDT
I think we should just pass through the entire environment. Look at https://trac.webkit.org/wiki/EnvironmentVariables. We also need at least GIGACAGE_ENABLED, JavaScriptCoreUseJIT, and Malloc. What still uses WEBKIT2? Any such environment variable should probably be renamed.
Adrian Perez
Comment 5 2018-07-25 08:25:19 PDT
(In reply to Michael Catanzaro from comment #4) > I think we should just pass through the entire environment. Look at > https://trac.webkit.org/wiki/EnvironmentVariables. We also need at least > GIGACAGE_ENABLED, JavaScriptCoreUseJIT, and Malloc. > > What still uses WEBKIT2? Any such environment variable should probably be > renamed. There's this one for pausing the Web process at launch time: % rg 'getenv.*WEBKIT2' Source/ Source/WebKit/WebProcess/gtk/WebProcessMainGtk.cpp 49: if (g_getenv("WEBKIT2_PAUSE_WEB_PROCESS_ON_LAUNCH")) Source/WebKit/WebProcess/wpe/WebProcessMainWPE.cpp 47: if (g_getenv("WEBKIT2_PAUSE_WEB_PROCESS_ON_LAUNCH")) %
Charlie Turner
Comment 6 2018-07-25 08:27:50 PDT
(In reply to Michael Catanzaro from comment #4) > I think we should just pass through the entire environment. Look at > https://trac.webkit.org/wiki/EnvironmentVariables. We also need at least > GIGACAGE_ENABLED, JavaScriptCoreUseJIT, and Malloc. My gut feeling is that passing the entire environment would not be a good idea, the sandbox sets up some environment variables of its own, and generally having uncontrolled environment pollution like that sounds a bit risky. I would prefer to just special case the WebKit environment variables as needed, even if there are a lot of special cases. > > What still uses WEBKIT2? Any such environment variable should probably be > renamed. WEBKIT2_PAUSE_WEB_PROCESS_ON_LAUNCH is the only one I can find.
Michael Catanzaro
Comment 7 2018-07-25 08:40:28 PDT
(In reply to Charlie Turner from comment #6) > My gut feeling is that passing the entire environment would not be a good > idea, the sandbox sets up some environment variables of its own, and > generally having uncontrolled environment pollution like that sounds a bit > risky. I would prefer to just special case the WebKit environment variables > as needed, even if there are a lot of special cases. OK (In reply to Charlie Turner from comment #6) > WEBKIT2_PAUSE_WEB_PROCESS_ON_LAUNCH is the only one I can find. We can consider in another bug whether it's better to rename, or if the cost of breaking old tutorials is too high.
Charlie Turner
Comment 8 2018-07-25 09:01:38 PDT
Adrian Perez
Comment 9 2018-07-25 09:13:40 PDT
FWIW, I agree with Charlie that it's better to pass a controlled and well-known set of environment variables. Otherwise we may run into the kind of weird situations which containers and sandboxing are supposed to fix. As a matter of fact, I would go as far as reporting which environment variables are being copied inside the sandbox before entering the Flatpak environment. That would help replicate the running conditions reported e.g. by other developers or build bots, for debugging. It can also help developers notice that they are unintentionally setting variables.
WebKit Commit Bot
Comment 10 2018-07-25 09:58:36 PDT
The commit-queue encountered the following flaky tests while processing attachment 345761 [details]: fast/repaint/canvas-object-fit.html bug 188004 (author: simon.fraser@apple.com) The commit-queue is continuing to process your patch.
WebKit Commit Bot
Comment 11 2018-07-25 09:59:20 PDT
Comment on attachment 345761 [details] Patch Clearing flags on attachment: 345761 Committed r234199: <https://trac.webkit.org/changeset/234199>
WebKit Commit Bot
Comment 12 2018-07-25 09:59:21 PDT
All reviewed patches have been landed. Closing bug.
Radar WebKit Bug Importer
Comment 13 2018-07-25 10:00:27 PDT
Note You need to log in before you can comment on or make changes to this bug.