Date: Sun, 16 Mar 2008 15:12:44 GMT From: Richard Arends <richard@unixguru.nl> To: freebsd-gnats-submit@FreeBSD.org Subject: misc/121763: TinyBSD remove_workdir function needs some extra checking for existing mounts Message-ID: <200803161512.m2GFCiP1051457@www.freebsd.org> Resent-Message-ID: <200803161520.m2GFK3DL061454@freefall.freebsd.org>
next in thread | raw e-mail | index | archive | help
>Number: 121763 >Category: misc >Synopsis: TinyBSD remove_workdir function needs some extra checking for existing mounts >Confidential: no >Severity: serious >Priority: medium >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Sun Mar 16 15:20:03 UTC 2008 >Closed-Date: >Last-Modified: >Originator: Richard Arends >Release: 7.0-RELEASE >Organization: unixguru.nl >Environment: FreeBSD tinybsd.unixguru.nl 7.0-STABLE FreeBSD 7.0-STABLE #1: Sun Mar 16 11:17:33 CET 2008 root@tinybsd.unixguru.nl:/usr/obj/usr/src/sys/GENERIC i386 >Description: If a tinybsd build is interrupted and later started again, there's a possibility that directory's are still mounted with mount_nullfs. Running the remove_workdir function can than do severe damage to the build host, because it wil remove anything below $WORKDIR, thus also the mounted directory's like /lib. ..oops.. >How-To-Repeat: Interupt a tinybsd build at the time it is building the (optional) ports. Then start it again and the remove_workdir function will delete everything under $WORKDIR, >Fix: Apply the patch Patch attached with submission follows: --- tinybsd 2008-03-16 09:28:42.000000000 +0100 +++ tinybsd.new 2008-03-16 15:44:33.000000000 +0100 @@ -248,12 +248,21 @@ } remove_workdir() { - chflags -R noschg ${WORKDIR} - echo "${TS} Removing "${WORKDIR} - rm -rf ${WORKDIR} - echo "${TS} Removing Build Kernel Directory" - rm -rf /usr/obj/usr/src/sys/${KERNCONF} - echo "${TS} done." + # Before removing check if there is not a mount under $WORKDIR anymore + MOUNT_CHECK=`mount|egrep "on ${WORKDIR}"` + + if [ ! -z "${MOUNT_CHECK}" ]; then + echo "There are mounts under the workdir (${WORKDIR}). Please umount them before running this script" + exit 1 + else + exit 11 + chflags -R noschg ${WORKDIR} + echo "${TS} Removing "${WORKDIR} + rm -rf ${WORKDIR} + echo "${TS} Removing Build Kernel Directory" + rm -rf /usr/obj/usr/src/sys/${KERNCONF} + echo "${TS} done." + fi } >Release-Note: >Audit-Trail: >Unformatted:
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200803161512.m2GFCiP1051457>