Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[RFC] Add a systemd-based implementation to the "devices" subsystem
I tested this with Podman using: $ podman --runtime ~/go/src/github.com/opencontainers/runc/runc run -t fedora:29 echo hello And also bringing up a container and checking the contents of "device.list" in the cgroup subtree: $ podman --runtime ~/go/src/github.com/opencontainers/runc/runc run -t fedora:29 sleep 1h $ cat /sys/fs/cgroup/devices/machine.slice/libpod-12fc7bd62fd6*/devices.list c 10:200 rwm c 5:2 rwm c 136:* rwm c 5:1 rwm c 1:9 rwm c 1:5 rwm c 5:0 rwm c 1:7 rwm c 1:8 rwm c 1:3 rwm b *:* m c *:* m This matches the output of devices.list when using the official "runc" binary, only difference being the lines are inverted in order (again, we can fix that on a second step.) Querying systemd for this unit also works as expected: $ systemctl show libpod-12fc7bd62fd66ff62fa1b045c2d717c7b2076c072c20de14f5c1ad86b78865eb.scope -p DevicePolicy -p DeviceAllow DevicePolicy=strict DeviceAllow=/dev/net/tun rwm DeviceAllow=/dev/ptmx rwm DeviceAllow=char-136 rwm DeviceAllow=/dev/console rwm DeviceAllow=/dev/urandom rwm DeviceAllow=/dev/zero rwm DeviceAllow=/dev/tty rwm DeviceAllow=/dev/full rwm DeviceAllow=/dev/random rwm DeviceAllow=/dev/null rwm DeviceAllow=block-* m DeviceAllow=char-* m v2: Now using systemd support for /dev/{char,block}/<major>:<minor> instead, which results into these properties being set instead: DevicePolicy=strict DeviceAllow=/dev/char/10:200 rwm DeviceAllow=/dev/char/5:2 rwm DeviceAllow=char-136 rwm DeviceAllow=/dev/char/5:1 rwm DeviceAllow=/dev/char/1:9 rwm DeviceAllow=/dev/char/1:5 rwm DeviceAllow=/dev/char/5:0 rwm DeviceAllow=/dev/char/1:7 rwm DeviceAllow=/dev/char/1:8 rwm DeviceAllow=/dev/char/1:3 rwm DeviceAllow=block-* m DeviceAllow=char-* m Unclear whether we should really be using this unconditionally, or only in the cases where a device name hasn't been supplied through d.Path. Signed-off-by: Filipe Brandenburger <[email protected]>
- Loading branch information