Bug 540060 - The webkit dbus IPC should use a private bus
Summary: The webkit dbus IPC should use a private bus
Status: VERIFIED FIXED
Alias: None
Product: Platform
Classification: Eclipse Project
Component: SWT (show other bugs)
Version: 4.9   Edit
Hardware: PC Linux
: P3 normal (vote)
Target Milestone: 4.15 M1   Edit
Assignee: Eric Williams CLA
QA Contact:
URL:
Whiteboard: RHT
Keywords: triaged
Depends on:
Blocks:
 
Reported: 2018-10-11 13:57 EDT by Mat Booth CLA
Modified: 2020-12-21 04:28 EST (History)
5 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Mat Booth CLA 2018-10-11 13:57:30 EDT
AIUI, the webkit dbus IPC currently tries to own the dbus namespace "org.eclipse.swt.<PID>" on the session bus.

This can't work when an SWT-based application is sandboxed with Flatpak because your PID is only guaranteed to be unique within the sandbox.

Because there are usually not many processes running inside the sandbox, it's actually highly likely (but not guaranteed) that a sandboxed process will be given a PID of 2.

This makes it entirely within the realm of possibility that two SWT-based applications will try to own the same namespace.

Please consider using a private bus for this feature.
Comment 1 Alexander Kurtakov CLA 2018-11-15 07:35:41 EST
I read more about it and I don't think there is really such thing as private bus. At least all webkitgtk extensions I checked use the public one. 
Closing, please reopen if one has pointers to documentation how this can be done.
Comment 2 Mat Booth CLA 2018-11-15 09:51:19 EST
There is still the problem that two SWT-based applications can try to own the same dbus name on the session bus due to both applications being extremely likely to have the same PID.

PIDs are only unique within the sandbox, so if I have to expose the host session bus to the sandboxes there will be a clash.

Also, opening up the host session bus is fine for a development tool like the IDE, but is not a very nice way to deal with other kinds of SWT application.
Comment 3 Mat Booth CLA 2018-11-15 10:04:23 EST
BTW the advice I got from Flatpak guys was to use a private bus. Epiphany is one example of an application that does this for a web extension:

> mbooth, Epiphany is one example
> mbooth, much of the magic is here: https://github.com/GNOME/epiphany/blob/68b0f85747a177047a7b49d839895aad54b05309/embed/web-extension/ephy-web-extension.c
> mbooth, also: https://github.com/GNOME/epiphany/blob/b570c29ce814f916078b4d5e33252c66af799dc9/embed/ephy-embed-shell.c#L1021-L1061
> so the latter is the UI process making a private dbus server, the former is the web processes connecting to it
Comment 4 Alexander Kurtakov CLA 2018-11-15 10:09:23 EST
(In reply to Mat Booth from comment #3)
> BTW the advice I got from Flatpak guys was to use a private bus. Epiphany is
> one example of an application that does this for a web extension:
> 
> > mbooth, Epiphany is one example
> > mbooth, much of the magic is here: https://github.com/GNOME/epiphany/blob/68b0f85747a177047a7b49d839895aad54b05309/embed/web-extension/ephy-web-extension.c
> > mbooth, also: https://github.com/GNOME/epiphany/blob/b570c29ce814f916078b4d5e33252c66af799dc9/embed/ephy-embed-shell.c#L1021-L1061
> > so the latter is the UI process making a private dbus server, the former is the web processes connecting to it

Thanks Mat, that's quite valuable
Comment 5 Eric Williams CLA 2019-10-03 15:51:30 EDT
Is it only the webkit DBus that is causing problems? Or all SWT GDBus interaction? Webkit isn't the only use case for DBus, we also use it for OpenFile (bug 528414).

Some of my research shows that we should be able to make it private: https://developer.gnome.org/gio//2.44/GDBusServer.html
Comment 6 Alexander Kurtakov CLA 2019-10-03 16:10:12 EDT
(In reply to Eric Williams from comment #5)
> Is it only the webkit DBus that is causing problems? Or all SWT GDBus
> interaction? Webkit isn't the only use case for DBus, we also use it for
> OpenFile (bug 528414).
> 
> Some of my research shows that we should be able to make it private:
> https://developer.gnome.org/gio//2.44/GDBusServer.html

IMHO the OpenFile dbus interface should stay public to allow dbus integration with eclipse not only command line.
Comment 7 Eric Williams CLA 2019-10-03 16:20:47 EDT
(In reply to Alexander Kurtakov from comment #6)
> (In reply to Eric Williams from comment #5)
> > Is it only the webkit DBus that is causing problems? Or all SWT GDBus
> > interaction? Webkit isn't the only use case for DBus, we also use it for
> > OpenFile (bug 528414).
> > 
> > Some of my research shows that we should be able to make it private:
> > https://developer.gnome.org/gio//2.44/GDBusServer.html
> 
> IMHO the OpenFile dbus interface should stay public to allow dbus
> integration with eclipse not only command line.

Agreed.
Comment 8 Mat Booth CLA 2019-11-16 16:52:41 EST
Flatpak guys prompted me again about SWT requiring the sandbox to be exposed for the whole session bus.

Any progress on making the webkit IPC use a private bus?
Comment 9 Eric Williams CLA 2019-11-16 17:18:32 EST
(In reply to Mat Booth from comment #8)
> Flatpak guys prompted me again about SWT requiring the sandbox to be exposed
> for the whole session bus.
> 
> Any progress on making the webkit IPC use a private bus?

Not yet, I hope to have something in Gerrit before the Christmas holidays. I didn't find the time during 4.14.
Comment 11 Eric Williams CLA 2019-12-16 14:36:33 EST
(In reply to Eclipse Genie from comment #10)
> Gerrit change https://git.eclipse.org/r/153741 was merged to [master].
> Commit:
> http://git.eclipse.org/c/platform/eclipse.platform.swt.git/commit/
> ?id=558be9a19c6de3c914ccbed0ac541d5c849bf1f5

In master now.
Comment 12 Sravan Kumar Lakkimsetti CLA 2020-01-07 05:30:51 EST
Verified in Eclipse SDK
Version: 2020-03 (4.15)
Build id: I20200106-1805
OS: Linux, v.4.15.0-72-generic, x86_64 / gtk 3.22.30, WebKit 2.26.2
Java version: 13.0.1
Comment 13 Andrey Loskutov CLA 2020-05-12 11:22:46 EDT
(In reply to Eclipse Genie from comment #10)
> Gerrit change https://git.eclipse.org/r/153741 was merged to [master].
> Commit:
> http://git.eclipse.org/c/platform/eclipse.platform.swt.git/commit/
> ?id=558be9a19c6de3c914ccbed0ac541d5c849bf1f5

For the record: this caused regression in bug 562443.
Comment 14 Simeon Andreev CLA 2020-12-21 04:28:52 EST
The change here causes occasional crashes in the JVM when calling jstack, see bug 569853.