blob: 914c86753968db1bdf2e07006207a0cca04b96f8 [file] [log] [blame] [view]
Mike Frysinger182d4522018-06-14 19:02:18 -04001# Minijail
2
Jorge Lucangeli Obes58483092018-06-21 19:03:54 -04003The Minijail homepage and main repo is
Mike Frysinger182d4522018-06-14 19:02:18 -04004https://android.googlesource.com/platform/external/minijail/.
5
6There might be other copies floating around, but this is the official one!
7
8[TOC]
9
10## What is it?
11
Jorge Lucangeli Obes58483092018-06-21 19:03:54 -040012Minijail is a sandboxing and containment tool used in Chrome OS and Android.
Mike Frysinger182d4522018-06-14 19:02:18 -040013It provides an executable that can be used to launch and sandbox other programs,
14and a library that can be used by code to sandbox itself.
15
Jorge Lucangeli Obes58483092018-06-21 19:03:54 -040016## Getting the code
Mike Frysinger182d4522018-06-14 19:02:18 -040017
Jorge Lucangeli Obes58483092018-06-21 19:03:54 -040018You're one `git clone` away from happiness.
Mike Frysinger182d4522018-06-14 19:02:18 -040019
20```
21$ git clone https://android.googlesource.com/platform/external/minijail
22$ cd minijail
23```
24
25Releases are tagged as `linux-vXX`:
26https://android.googlesource.com/platform/external/minijail/+refs
27
28## Building
29
30See the [HACKING.md](./HACKING.md) document for more details.
31
Jorge Lucangeli Obes58483092018-06-21 19:03:54 -040032## Release process
Mike Frysinger182d4522018-06-14 19:02:18 -040033
34See the [RELEASE.md](./RELEASE.md) document for more details.
35
Luis Hector Chaveza6b88f12019-12-11 18:03:47 -080036## Additional tools
37
38See the [tools/README.md](./tools/README.md) document for more details.
39
Mike Frysinger182d4522018-06-14 19:02:18 -040040## Contact
41
42We've got a couple of contact points.
43
44* [minijail@chromium.org]: Public user & developer mailing list.
45* [minijail-users@google.com]: Internal Google user mailing list.
46* [minijail-dev@google.com]: Internal Google developer mailing list.
47* [crbug.com/list]: Existing bug reports & feature requests.
48* [crbug.com/new]: File new bug reports & feature requests.
49* [AOSP Gerrit]: Code reviews.
50
51[minijail@chromium.org]: https://groups.google.com/a/chromium.org/forum/#!forum/minijail
52[minijail-users@google.com]: https://groups.google.com/a/google.com/forum/#!forum/minijail-users
53[minijail-dev@google.com]: https://groups.google.com/a/google.com/forum/#!forum/minijail-dev
54[crbug.com/list]: https://crbug.com/?q=component:OS>Systems>Minijail
55[crbug.com/new]: https://bugs.chromium.org/p/chromium/issues/entry?components=OS>Systems>Minijail
56[AOSP Gerrit]: https://android-review.googlesource.com/q/project:platform/external/minijail
57
Jorge Lucangeli Obes58483092018-06-21 19:03:54 -040058## Talks and presentations
Mike Frysinger182d4522018-06-14 19:02:18 -040059
60The following talk serves as a good introduction to Minijail and how it can be used.
61
62[Video](https://drive.google.com/file/d/0BwPS_JpKyELWZTFBcTVsa1hhYjA/preview),
63[slides](https://docs.google.com/presentation/d/1r6LpvDZtYrsl7ryOV4HtpUR-phfCLRL6PA-chcL1Kno/present).
64
Jorge Lucangeli Obes58483092018-06-21 19:03:54 -040065## Example usage
Mike Frysinger182d4522018-06-14 19:02:18 -040066
67The Chromium OS project has a comprehensive
68[sandboxing](https://chromium.googlesource.com/chromiumos/docs/+/master/sandboxing.md)
69document that is largely based on Minijail.
70
71After you play with the simple examples below, you should check that out.
72
73### Change root to any user
74
75```
76# id
77uid=0(root) gid=0(root) groups=0(root),128(pkcs11)
78# minijail0 -u jorgelo -g 5000 /usr/bin/id
79uid=72178(jorgelo) gid=5000(eng) groups=5000(eng)
80```
81
82### Drop root while keeping some capabilities
83
84```
85# minijail0 -u jorgelo -c 3000 -- /bin/cat /proc/self/status
86Name: cat
87...
88CapInh: 0000000000003000
89CapPrm: 0000000000003000
90CapEff: 0000000000003000
91CapBnd: 0000000000003000
92```