[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Why it matters to build disk images in a VM



or at least a chroot environment

I wrote a fai script to set the root passwords of the vagrant boxes.
There are multiple ways of doing this but I settled to use:

echo root:vagrant | chpasswd

now as this should happen in the FAI install chroot I initially wrote:

$ROOTCMD echo root:vagrant | chpasswd
where $ROOTCMD is interpolated to chroot /tmp/fai-tmp-build

and it changed the root password of my *build* host.
See the mistake ?

Things before the pipe are interpreted by the shell as a single command
construct, so /bin/echo was running inside the chroot, but chpasswd was
running outside the chroot.

The proper fix was of course to write:
echo root:vagrant | $ROOTCMD chpasswd

Emmanuel


Reply to: