You are not logged in.
So I'm trying to write a very simple chroot sandboxing script. I want zero suid binaries inside the sandbox, so I remount all the requisite directories ro,nosuid. I figure I can avoid using su (and get a slightly more secure sandbox) by using --userspec when chrooting into the sandbox.
This mostly works - it chroots in with the limited user's permissions. Unfortunately though, it somehow keeps all the environment variables from when it was running as root. These can be changed manually, but I figure there has to be a better way.
Is there? Or is this another case of Linux chroot not being designed for security?
Offline
execute with "env -i", or if you are using systemd, there is a much better tool: systemd-nspawn.;)
Offline
Close but not quite there, that just wipes all the environment variables. Any idea how I could get the default variables for $USER from there? Thanks, BTW.
Offline
Assign each one, for example:
chroot $BASE /usr/bin/env -i HOME=/root USER=root /bin/bash -l
Offline