Package: schroot
Version: 1.6.10-4
Severity: minor
Tags: patch

Hi,

on one of my systems, schroot --end-session frequently fails when
15killprocs tries to kill processes in a directory that does no longer
exists. I have not bothered to investigate why this happens, but have
implemented instead a patch that makes schroot handle this situation
more gracefully.

Please consider applying this patch.

Greetings
Marc


-- System Information:
Debian Release: buster/sid
  APT prefers unstable
  APT policy: (500, 'unstable')
Architecture: amd64 (x86_64)

Kernel: Linux 4.16.8-zgsrv20080 (SMP w/4 CPU cores; PREEMPT)
Locale: LANG=de_DE.utf8, LC_CTYPE=de_DE.utf8 (charmap=UTF-8), LANGUAGE=en 
(charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash
Init: systemd (via /run/systemd/system)

Versions of packages schroot depends on:
ii  init-system-helpers             1.51
ii  libboost-filesystem1.62.0       1.62.0+dfsg-5+b1
ii  libboost-iostreams1.62.0        1.62.0+dfsg-5+b1
ii  libboost-program-options1.62.0  1.62.0+dfsg-5+b1
ii  libboost-system1.62.0           1.62.0+dfsg-5+b1
ii  libc6                           2.27-3
ii  libgcc1                         1:8.1.0-1
ii  libpam0g                        1.1.8-3.7
ii  libstdc++6                      8.1.0-1
ii  libuuid1                        2.31.1-0.5
ii  lsb-base                        9.20170808
ii  schroot-common                  1.6.10-4

schroot recommends no packages.

Versions of packages schroot suggests:
pn  aufs-tools | unionfs-fuse  <none>
ii  btrfs-tools                4.15.1-2
ii  debootstrap                1.0.97
ii  lvm2                       2.02.176-4.1
pn  qemu-user-static           <none>

-- Configuration Files:
/etc/schroot/setup.d/15killprocs changed:
set -e
. "$SETUP_DATA_DIR/common-data"
. "$SETUP_DATA_DIR/common-functions"
. "$SETUP_DATA_DIR/common-config"
kill_proc()
{
    if ! kill "$@" 2>/dev/null; then
        info "kill $@ failed: process already terminated?"
    fi
}
do_kill_all()
{
    if [ -z "$1" ]; then
        fatal "No path for finding stray processes: not reaping processes in 
chroot"
    fi
    if ! [ -e "$1" ]; then
        info "no stray processes inside non-existing path $1; not reaping 
processes in chroot"
        return
    fi
    chroot_path=$(realpath "$1")
    info "Killing processes run inside $1"
    ls /proc | egrep '^[[:digit:]]+$' |
    while read pid; do
        # Check if process root are the same device/inode as chroot
        # root (for efficiency)
        if [ /proc/"$pid"/root -ef "$chroot_path" ]; then
            # Check if process and chroot root are the same (may be
            # different even if device/inode match).
            root=$(readlink --canonicalize /proc/"$pid"/root || true)
            if [ "$root" = "$chroot_path" ]; then
                exe=$(readlink /proc/"$pid"/exe || true)
                info "Killing left-over pid $pid (${exe##$1})"
                info "  Sending SIGTERM to pid $pid"
                kill_proc -TERM "$pid"
                count=0
                max=5
                while [ -d /proc/"$pid" ]; do
                    count=$(( $count + 1 ))
                    info "  Waiting for pid $pid to shut down... ($count/$max)"
                    sleep 1
                # Wait for $max seconds for process to die before -9'ing it
                    if [ "$count" -eq "$max" ]; then
                        info "  Sending SIGKILL to pid $pid"
                        kill_proc -KILL "$pid"
                        sleep 1
                        break
                    fi
                done
            fi
        fi
    done
}
if [ $STAGE = "setup-recover" ] || [ $STAGE = "setup-stop" ]; then
    do_kill_all "$CHROOT_PATH"
fi


-- no debconf information
--- 15killprocs 2018-05-12 16:16:12.451296753 +0200
+++ /etc/schroot/setup.d/15killprocs    2018-05-12 16:22:24.437504748 +0200
@@ -39,10 +39,14 @@
 # $1: mount base location
 do_kill_all()
 {
-    chroot_path=$(realpath "$1")
     if [ -z "$1" ]; then
         fatal "No path for finding stray processes: not reaping processes in 
chroot"
     fi
+    if ! [ -e "$1" ]; then
+        info "no stray processes inside non-existing path $1; not reaping 
processes in chroot"
+       return
+    fi
+    chroot_path=$(realpath "$1")
 
     info "Killing processes run inside $1"
     ls /proc | egrep '^[[:digit:]]+$' |

Reply via email to