diff options
author | Junichi Uekawa <dancer@netfort.gr.jp> | 2008-04-29 22:42:59 +0900 |
---|---|---|
committer | Junichi Uekawa <dancer@netfort.gr.jp> | 2008-04-29 22:42:59 +0900 |
commit | 9f58bfd6bdb0f717650ba45875696fa641275c1d (patch) | |
tree | f324465ddbe1366d239cfa23cd309bc0d23f8a1f /pbuilder-modules | |
parent | a86388a8e3b31d78fc3f4985a052e312282477c2 (diff) | |
download | pbuilder-9f58bfd6bdb0f717650ba45875696fa641275c1d.tar pbuilder-9f58bfd6bdb0f717650ba45875696fa641275c1d.tar.gz |
umount on failed bind-mount (closes: #474771)
Special-case bind-mounting points since it might result in user-data
loss when pbuilder clean is ran.
When multiple bind-mount points are specified in command-line options,
and one of them failed to mount, not all of them were umounted in
clean-up.
That is now fixed.
Diffstat (limited to 'pbuilder-modules')
-rw-r--r-- | pbuilder-modules | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/pbuilder-modules b/pbuilder-modules index c047fed..26626f9 100644 --- a/pbuilder-modules +++ b/pbuilder-modules @@ -227,10 +227,24 @@ function mountproc () { mkdir -p $BUILDPLACE/selinux mount -t selinuxfs /selinux "$BUILDPLACE/selinux" fi + local -a mounted for mnt in $BINDMOUNTS; do echo "-> Mounting $mnt" - mkdir -p "$BUILDPLACE/$mnt" - mount -obind "$mnt" "$BUILDPLACE/$mnt" + if mkdir -p "$BUILDPLACE/$mnt" && + mount -obind "$mnt" "$BUILDPLACE/$mnt"; then + # successful. + mounted[${#mounted[@]}]="$mnt" + else + # when unsuccessful, backtrack / umount and abort. + if [ -n "${mounted[*]}" ]; then + echo "-> error recovery: umount successfully mounted bind-mounts: ${mounted[@]}" + for umnt in "${mounted[@]}"; do + echo "-> umounting $umnt" + umount "$umnt" + done + fi + exit 1 + fi done if [ -f "$BUILDPLACE/usr/sbin/policy-rc.d" ]; then echo " -> policy-rc.d already exists" |