diff options
Diffstat (limited to 'login.sh')
| -rw-r--r-- | login.sh | 26 |
1 files changed, 26 insertions, 0 deletions
@@ -10,6 +10,21 @@ fi for i in {0..7}; do [ -e "/dev/loop$i" ] || mknod "/dev/loop$i" b 7 $i done +# Rootless podman also opens /dev/net/tun (container network) and /dev/fuse +# (fuse-overlayfs fallback). They have to be world-readable, since the dev user +# is the one opening them. +[ -d /dev/net ] || mkdir -p /dev/net +[ -e /dev/net/tun ] || mknod /dev/net/tun c 10 200 +[ -e /dev/fuse ] || mknod /dev/fuse c 10 236 +chmod 0666 /dev/net/tun /dev/fuse + +# Nothing loads modules in a kata guest: there is no systemd, so no +# systemd-modules-load.service. These are what nested podman needs, and +# modprobe is a no-op for any of them that is built into the guest kernel. +for mod in loop overlay veth bridge; do + modprobe -q "$mod" 2>/dev/null || true +done + # Podman's overlay storage driver cannot live on virtiofs, so those graphroots # get a loop-mounted ext4 instead. Runs as root and hands the result to owner, # who is the user that will run podman on it. @@ -53,6 +68,17 @@ function overlay_fs() { overlay_fs "/var/lib/containers/storage" "/var/tmp/containers.img" "root:root" overlay_fs "/home/dev/.local/share/containers/storage" "/home/dev/.local/share/containers/img" "dev:dev" +# Without systemd nothing delegates the cgroup tree to dev, and rootless podman +# then cannot create a cgroup for a container. This is all delegation is; it is +# only safe when this container owns the tree it can see, which is the case with +# its own cgroup namespace (podman's default) and not with --cgroupns=host. +if [ "$(cat /proc/self/cgroup 2>/dev/null)" = "0::/" ] && [ -w /sys/fs/cgroup ]; then + for ctrl in $(cat /sys/fs/cgroup/cgroup.controllers 2>/dev/null); do + echo "+$ctrl" >/sys/fs/cgroup/cgroup.subtree_control 2>/dev/null || true + done + chown -R dev:dev /sys/fs/cgroup 2>/dev/null || true +fi + su dev # if [[ -z "${PASEO_PASSWORD:-}" ]]; then |
