misc/121763: TinyBSD remove_workdir function needs some extra
checking for existing mounts
Richard Arends
richard at unixguru.nl
Sun Mar 16 15:20:03 UTC 2008
>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 at 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:
More information about the freebsd-bugs
mailing list