[Buildd-tools-devel] Bug#391319: updated patch

Kees Cook kees at outflux.net
Tue Oct 31 21:12:56 CET 2006


Oops.  Prior patch was not /bin/sh safe.  New patch attached...

-- 
Kees Cook                                            @outflux.net
-------------- next part --------------
--- 10mount.orig	2006-10-24 09:29:21.058205453 -0700
+++ 10mount	2006-10-24 09:29:31.718742234 -0700
@@ -23,10 +23,37 @@ do_mount()
     mount $VERBOSE $1 "$2" "$3"
 }
 
+# Kill all processes that were run from within the chroot environment
+# $1: mount base location
+do_kill_all()
+{
+    if [ "$AUTH_VERBOSITY" = "verbose" ]; then
+        echo "Killing processes run inside $1"
+    fi
+    ls /proc | egrep '^[[:digit:]]+$' |
+    while read pid; do
+        if readlink /proc/"$pid"/exe | grep ^"$1"/ >/dev/null; then
+            kill "$pid" 2>/dev/null
+            # Wait 5 seconds for process to release resources
+            count=0
+            while kill -0 "$pid" 2>/dev/null ; do
+                sleep 1
+                count=$(( $count + 1 ))
+                if [ "$count" -eq 5 ]; then
+                    kill -9 "$pid" 2>/dev/null
+                    sleep 1
+                    break
+                fi
+            done
+        fi
+    done
+}
+
 # Unmount all filesystem under specified location
 # $1: mount base location
 do_umount_all()
 {
+    do_kill_all "$1"
     "$LIBEXEC_DIR/schroot-listmounts" -m "$1" |
     while read mountloc; do
 	if [ "$AUTH_VERBOSITY" = "verbose" ]; then


More information about the Buildd-tools-devel mailing list