blob: bcec1bc50be582517df67db91c34367d6773680e [file] [log] [blame] [view]
Harvey Yang01729de2021-03-01 11:02:241# D-Bus Mojo Connection Service
2
3## Overview
4
5D-Bus Mojo Connection Service in Chrome is a D-Bus service that helps to
6bootstrap CrOS services' Mojo connection.
7
8## Bootstrap a new CrOS service
9
Yeunjoo Choiba677272021-06-15 06:34:0410D-Bus Mojo Connection Service lives in [//chrome/browser/ash/dbus/mojo_connection_service_provider.h](https://chromium.googlesource.com/chromium/src.git/+/main/chrome/browser/ash/dbus/mojo_connection_service_provider.h).
Harvey Yang01729de2021-03-01 11:02:2411
12Follow the example of CrOS Sensors' [changelist](https://chromium-review.googlesource.com/c/chromium/src/+/2352298).
13
14### Steps to Add a usage for a CrOS process with a new D-Bus method:
Harvey Yang8e23bb1b2021-03-09 07:37:50151. Add a method name in both CrOS platform and Chrome.
Harvey Yang01729de2021-03-01 11:02:2416 (Recommend: `platform2/system_api`)
172. Add the busconfig policy in [MojoConnectionService.conf].
183. Upon a D-Bus request coming from the CrOS service, pass one endpoint of the
19 generated Mojo pipe to the component in Chrome that needs a Mojo channel to
Yeunjoo Choiba677272021-06-15 06:34:0420 the CrOS service. Ex: [RegisterServer](https://chromium-review.googlesource.com/c/chromium/src/+/2352298/16/chrome/browser/ash/dbus/mojo_connection_service_provider.cc#74) in CrOS Sensors' usage.
Harvey Yang01729de2021-03-01 11:02:24214. Respond to the D-Bus request with the other endpoint of the generated Mojo
Yeunjoo Choiba677272021-06-15 06:34:0422 pipe. (Recommend: use the helper function [SendResponse](https://chromium-review.googlesource.com/c/chromium/src/+/2352298/16/chrome/browser/ash/dbus/mojo_connection_service_provider.h#75))
Harvey Yang01729de2021-03-01 11:02:2423
24The Mojo pipe can also be generated in the CrOS process, and pass the endpoint
25of it as the D-Bus argument to the service provider, instead of allowing Chrome
26to generate the pipe.
27
28### Steps to Add a usage for a CrOS process with an existing D-Bus method:
291. Add the busconfig policy in [MojoConnectionService.conf].
30
Harvey Yang8e23bb1b2021-03-09 07:37:5031And thats it. The method name and the logic in the service provider can be
32reused.
Harvey Yang01729de2021-03-01 11:02:2433
34## Security
35
36UID filtering should be used to ensure only the needed processes are calling
37the specific D-Bus methods, as processes/applications calling D-Bus APIs are
38trusted (written and reviewed by Chromium/CrOS teams) and should have a
39well-known UID to be filtered.
40
41UID filtering: Define access permission for each UID in
42[MojoConnectionService.conf]. Only the processes run under the specific UIDs can
43send respective D-Bus requests to the service provider.
44
45Arguments/tokens in D-Bus methods are still available if needed, which should
46be enough for multi-login situations and handling failures. The arguments can
47also be used to determine if Chromium should accept the request, and which Mojo
48interface should be used to establish the Mojo channel.
49
Yeunjoo Choiba677272021-06-15 06:34:0450[MojoConnectionService.conf]: https://chromium.googlesource.com/chromium/src.git/+/main/chrome/browser/ash/dbus/org.chromium.MojoConnectionService.conf