Ahmed Ammar wrote:
> > > > so maybe it makes sense to simply have useradd call chroot()
> > > > according to an option early on in main()?
> > > 
> > > This will definitely not work on cross targets?
> > 
> > Why not? useradd doesn't fork, it does all file IO on it's own, so I
> > think it could work.
> 
> Well how exactly do you expect chroot to succeed when the host is
> x86 and the ${ROOT} is arm?

It should work fine. Note chroot() system call, not the chroot
utility.

useradd is a C program and my idea is to make it use the chroot()
system call. This system call changes the root directory for the
calling process. The chroot utility uses this system call, and then
executes a shell or other program inside the new root. The utility
will of course not work cross platform.

As long as the useradd C program does not rely on other executables
at runtime, which I severly doubt considering the nature of the
program, calling chroot() early in useradd would work regardless of
what binaries, if any, are inside the new root dir. useradd only
touches the user database text files.


//Peter

Reply via email to