@jarkko presumably mount namespaces, you can bind mount inside "unshare -rm"
Here’s an example:
sudo unshare \
--mount \
--uts \
--root "$ROOTFS" \
sh -c "
mkdir -p /proc
mkdir -p /sys
mkdir -p /dev
mount -t sysfs /sys /sys
mount -t proc /proc /proc
mount -t devtmpfs /dev /dev
mount -t devpts /dev /dev/pts
hostname $MACHINE
su -c '$CMDLINE' $USER
"
If I took sudo away, the mounts would fail on permission error, even with --map-root-user
.
It’s even expected outcome, because if such tweak would work, it would be a privilege escalation i.e., a security vulnerability.
Still wondering what is the magic dust Podman uses here :-)
@lkundrak @vegard getting rid of /dev was at least dead easy:
+# Debootstrap populates `/dev/{null,zero,full,random,urandom,tty}`, meaning that
+# mounting devtmpfs to `/dev` is not required.
sudo unshare \
--mount \
--uts \
--root "$ROOTFS" \
sh -c "
- mkdir -p /proc
- mkdir -p /sys
- mkdir -p /dev
- mount -t sysfs /sys /sys
mount -t proc /proc /proc
- mount -t devtmpfs /dev /dev
mount -t devpts /dev /dev/pts
hostname $MACHINE
# ...
I think I can iterate from this :-) E.g, proc-mount can be probably (I’d guess) made unprivileged with “–fork –pid” i.e., creating PID namespace.