views:

41

answers:

1

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:

+1  A: 

fakechroot, in combination with fakeroot, will allow you to do this. They'll make all programs that are running act as if they're being run in a chroot as root but they'll actually be running as you.

See also fakechroot's man page.

Eric Warmenhoven
I need a real chroot as I'm going to be compiling and running untrusted code that could include inline ASM.
BCS