Added native utilities to mount/umount/chroot via capabilities(7).

Three new helpers will now be installed into ${libexecdir}:
 - xbps-src-capchroot needs to have set CAP_SYS_CHROOT ep.
 - xbps-src-chroot-cap{,u}mount: needs to have set CAP_SYS_ADMIN ep.

That means that libcap and setcap(8) are now required to install
xbps-src and use it as normal user.

--HG--
extra : convert_revision : 586d6526079e085f86bf3e393459d429f6f0ef99
This commit is contained in:
Juan RP 2010-04-26 14:15:49 +02:00
parent 6673252679
commit e3dc3e3066
9 changed files with 293 additions and 34 deletions

View file

@ -35,20 +35,26 @@ REQFS="sys proc dev xbps"
mount_chroot_fs()
{
local cnt f blah
local cnt f blah dowrite
for f in ${REQFS}; do
if [ ! -f ${XBPS_MASTERDIR}/.${f}_mount_bind_done ]; then
unset dowrite
echo -n "=> Mounting /${f} in chroot... "
if [ ! -d ${XBPS_MASTERDIR}/${f} ]; then
mkdir -p ${XBPS_MASTERDIR}/${f}
fi
case ${f} in
xbps) blah=${XBPS_DISTRIBUTIONDIR};;
xbps)
blah=${XBPS_DISTRIBUTIONDIR}
dowrite="-w"
;;
*) blah=/${f};;
esac
[ ! -d ${blah} ] && echo "failed." && continue
mount --bind ${blah} ${XBPS_MASTERDIR}/${f}
@@XBPS_INSTALL_LIBEXECDIR@@/xbps-src-chroot-capmount \
${dowrite} ${blah} ${XBPS_MASTERDIR}/${f} \
2>/dev/null
if [ $? -eq 0 ]; then
echo 1 > ${XBPS_MASTERDIR}/.${f}_mount_bind_done
echo "done."
@ -75,7 +81,8 @@ umount_chroot_fs()
echo ${cnt} > ${XBPS_MASTERDIR}/.${fs}_mount_bind_done
else
echo -n "=> Unmounting ${fs} from chroot... "
umount -f ${XBPS_MASTERDIR}/${fs}
@@XBPS_INSTALL_LIBEXECDIR@@/xbps-src-chroot-capumount \
${XBPS_MASTERDIR}/${fs} 2>/dev/null
if [ $? -eq 0 ]; then
rm -f ${XBPS_MASTERDIR}/.${fs}_mount_bind_done
echo "done."