Debian Bug report logs - #987046
autopkgtest: VirtSubproc's execute_timeout leaves sudoify'd processes behind

version graph

Package: autopkgtest; Maintainer for autopkgtest is Debian CI team <[email protected]>; Source for autopkgtest is src:autopkgtest (PTS, buildd, popcon).

Reported by: Sebastien Delafond <[email protected]>

Date: Fri, 16 Apr 2021 11:27:01 UTC

Severity: normal

Found in version autopkgtest/5.16

Reply or subscribe to this bug.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to [email protected], Debian CI team <[email protected]>:
Bug#987046; Package autopkgtest. (Fri, 16 Apr 2021 11:27:03 GMT) (full text, mbox, link).


Acknowledgement sent to Sebastien Delafond <[email protected]>:
New Bug report received and forwarded. Copy sent to Debian CI team <[email protected]>. (Fri, 16 Apr 2021 11:27:03 GMT) (full text, mbox, link).


Message #5 received at [email protected] (full text, mbox, reply):

From: Sebastien Delafond <[email protected]>
To: Debian Bug Tracking System <[email protected]>
Subject: autopkgtest: VirtSubproc's execute_timeout leaves sudoify'd processes behind
Date: Fri, 16 Apr 2021 13:23:03 +0200
[Message part 1 (text/plain, inline)]
Package: autopkgtest
Version: 5.16
Severity: normal
User: [email protected]
Usertags: origin-kali

If the execution duration exceeds the specified timeout,
`execute_timeout` tries to kill the process it started. This will
systematically fail if the command was wrapped in `sudoify`, because
`execute_timeout` will of course not be able to terminate a process
owned by UID 0.

Here's an actual example, where an lxc test container took too long to
get its networking available (the corresponding call is in
autopkgtest-virt-lxc's `wait_booted` at line 131):

```
autopkgtest-virt-lxc [06:18:24]: ERROR: WARNING: Cannot kill timed out process ['sudo', 'lxc-attach', '--name', 'ci-106-c7628f8c', '--', 'sh', '-ec', 'if [ -d /run/systemd/system ]; then systemctl start network-online.target; else while ps -ef | grep -q "/etc/init\\.d/rc"; do sleep 1; done; fi']: [Errno 1] Operation not permitted
```

I used the following pytest code to isolate and reproduce the error:

```python
import pytest
import re
import sys
sys.path.append('lib')

import VirtSubproc


@pytest.mark.parametrize("cmd", (["sleep", "10"], ["sudo", "sleep", "10"]))
def test_timeout_one_second(cmd, capfd):
    with pytest.raises(VirtSubproc.Timeout):
        VirtSubproc.execute_timeout(None, 1, cmd)

    out, err = capfd.readouterr()
    assert not re.search(r'WARNING.*Cannot.*timed out process', err)
```

I don't see an easy solution to this problem; I am able to work around
the issue by using the attached patch, combined with giving the `debci` user
(that runs our autopkgtests) additional sudo permissions for the
commands that timeout for us, but that's suboptimal.

-- System Information:
Debian Release: bullseye/sid
  APT prefers unstable
  APT policy: (500, 'unstable'), (500, 'testing'), (500, 'stable'), (1, 'experimental')
Architecture: amd64 (x86_64)
Foreign Architectures: i386

Kernel: Linux 5.10.0-4-amd64 (SMP w/36 CPU threads)
Kernel taint flags: TAINT_PROPRIETARY_MODULE, TAINT_OOT_MODULE, TAINT_UNSIGNED_MODULE
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8), LANGUAGE not set
Shell: /bin/sh linked to /usr/bin/dash
Init: systemd (via /run/systemd/system)
LSM: AppArmor: enabled

Versions of packages autopkgtest depends on:
ii  apt-utils       2.1.20
ii  libdpkg-perl    1.20.7.1
ii  procps          2:3.3.17-2
ii  python3         3.9.1-1
ii  python3-debian  0.1.39

Versions of packages autopkgtest recommends:
ii  autodep8  0.24

Versions of packages autopkgtest suggests:
ii  lxc               1:4.0.6-1
pn  lxd               <none>
ii  ovmf              2020.11-2
ii  qemu-efi-aarch64  2020.11-2
ii  qemu-efi-arm      2020.11-2
ii  qemu-system       1:5.2+dfsg-3
ii  qemu-utils        1:5.2+dfsg-9
ii  schroot           1.6.10-11+b1
ii  vmdb2             0.22-1

-- no debconf information
[autopkgtest-virtsubproc-timeout.patch (text/plain, attachment)]

Send a report that this bug log contains spam.


Debian bug tracking system administrator <[email protected]>. Last modified: Tue May 13 15:01:39 2025; Machine Name: bembo

Debian Bug tracking system

Debbugs is free software and licensed under the terms of the GNU General Public License version 2. The current version can be obtained from https://bugs.debian.org/debbugs-source/.

Copyright © 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson, 2005-2017 Don Armstrong, and many other contributors.