freebsd / crochet

Build FreeBSD images for RaspberryPi, BeagleBone, PandaBoard, and others.
BSD 2-Clause "Simplified" License
611 stars 188 forks source link

Image missing overlay files if $WORKDIR path includes symlink #212

Open chrullrich opened 7 years ago

chrullrich commented 7 years ago

When FreeBSD is installed without a dedicated /home filesystem, /home is a symlink to /usr/home. I have put crochet in my home directory, and crochet.log reports:

Overlaying board-specific files from /home/chul/crochet/board/RaspberryPi3/overlay
cpio: .: Cannot extract through symlink /home/chul/crochet/work/_.mount.freebsd
cpio: ./boot: Cannot extract through symlink /home/chul/crochet/work/_.mount.freebsd/boot
cpio: ./boot/loader.conf: Cannot extract through symlink /home/chul/crochet/work/_.mount.freebsd/boot/loader.conf
cpio: ./boot/loader.rc: Cannot extract through symlink /home/chul/crochet/work/_.mount.freebsd/boot/loader.rc
cpio: ./etc: Cannot extract through symlink /home/chul/crochet/work/_.mount.freebsd/etc
cpio: ./etc/fstab: Cannot extract through symlink /home/chul/crochet/work/_.mount.freebsd/etc/fstab
cpio: ./etc/rc.conf: Cannot extract through symlink /home/chul/crochet/work/_.mount.freebsd/etc/rc.conf
0 blocks

This will happen whenever the $WORKDIR path contains a symlink. It looks like cpio intentionally refuses to write to a path containing a symlink, for security purposes.

Fix: In crochet.sh, replace

TOPDIR=`cd \`dirname $0\`; pwd`

with

TOPDIR=`cd \`dirname $0\`; realpath .`

Alternatively and untestedly, replace find . | cpio -pmud $X with cp -pr . $X everywhere, or use cpio --insecure, but that is apparently insecure.