News for hackers. Stuff that matters.
Re:Running Systemd-Nspawn Containers by Imustaskforhelp on Friday February 21, 2025 @09:21AM (#43127744)
EDIT: it seems that for creating a chroot you still require root.

I don't have root on that system and so I can't create a chroot , there is fakeroot but it doesn't work since it uses qemu on that locked system.

Are there any other alternatives

Re:Running Systemd-Nspawn Containers by igor47 on Friday February 21, 2025 @11:38AM (#43129598)
fakeroot has nothing to do with qemu -- it simply uses LD preload to make commands think they're uid 0
Re:Running Systemd-Nspawn Containers by ttyprintk on Friday February 21, 2025 @09:38AM (#43127914)
Fakeroot is good for the debootstrap step, and then schroot runs unprivileged.
Re:Running Systemd-Nspawn Containers by NekkoDroid on Friday February 21, 2025 @06:37PM (#43134467)
> it seems that for creating a chroot you still require root.

You actually don't as long as you have user namespaces.

One thing I am working on I use chroot (rather unshare --root=) to minimally sandbox a subprocess. At the beginning of the script I have this little snippet:

    if [ "$(id --user)" -ne 0 ]; then
     exec unshare --map-root-user --mount -- "$0" "$@"
    fi
Though you can probably just do something roughtly as `unshare --map-root-user --root=<PATH>`.