I'm setting up a minimal chroot and want to avoid having sudo or su in it but still run the my processes as non-root. This is a bit of a trick as chroot requiers root. I could write a program that does this that would look something like:
uid = LookupUser(args[username]) // no /etc/passwd in jail
chroot(args[newroot])
cd("/")
setuids(uid)
execve(args[exe:])
Is that my best bet or is there a standard tool that does that for me?
I rolled my own here: