andreafrancia / trash-cli

Command line interface to the freedesktop.org trashcan.
GNU General Public License v2.0
3.63k stars 177 forks source link

test_trash_empty_will_skip_unreadable_dir tries to touch system directories breaking the sandbox #217

Closed zpuskas closed 2 years ago

zpuskas commented 2 years ago

Describe the bug Running tests for trash-cli break the sandbox by trying to touch trash folders for every mount besides the test directory.

trash-cli version trash 0.21.10.24

Operating system:

# emerge --info trash-cli
Portage 3.0.28 (python 3.9.7-final-0, default/linux/amd64/17.1/desktop/plasma/systemd, gcc-10.3.0, glibc-2.33-r7, 5.15.0-gentoo x86_64)
=================================================================
                         System Settings
=================================================================
System uname: Linux-5.15.0-gentoo-x86_64-Intel-R-_Core-TM-_i7-8550U_CPU_@_1.80GHz-with-glibc2.33
KiB Mem:    32774044 total,  23331244 free
KiB Swap:    2097128 total,   2097128 free
Timestamp of repository gentoo: Sat, 04 Dec 2021 16:00:01 +0000
Head commit of repository gentoo: 6b80f3ebc54556c4118d54434fd457969b1115a0
Head commit of repository sinustrom: b00db0bb93abf83d5d80f3c36f03d0d31475c8f1

sh bash 5.1_p8
ld GNU ld (Gentoo 2.37_p1 p0) 2.37
distcc 3.4 x86_64-pc-linux-gnu [enabled]
app-shells/bash:          5.1_p8::gentoo
dev-java/java-config:     2.3.1::gentoo
dev-lang/perl:            5.34.0-r5::gentoo
dev-lang/python:          2.7.18_p13::gentoo, 3.8.12_p1::gentoo, 3.9.7_p1::gentoo, 3.10.0_p1::gentoo
dev-lang/rust:            1.56.1::gentoo
dev-util/cmake:           3.21.4::gentoo
sys-apps/baselayout:      2.8::gentoo
sys-apps/sandbox:         2.29::gentoo
sys-devel/autoconf:       2.13-r1::gentoo, 2.71-r1::gentoo
sys-devel/automake:       1.16.5::gentoo
sys-devel/binutils:       2.37_p1::gentoo
sys-devel/gcc:            10.3.0-r2::gentoo
sys-devel/gcc-config:     2.4::gentoo
sys-devel/libtool:        2.4.6-r6::gentoo
sys-devel/make:           4.3::gentoo
sys-kernel/linux-headers: 5.14::gentoo (virtual/os-headers)
sys-libs/glibc:           2.33-r7::gentoo

To Reproduce

$ cd /tmp
$ tar xvf /var/cache/distfiles/trash-cli-0.21.10.24.tar.gz
$ cd trash-cli-0.21.10.24
$ python -m unittest discover -v 2>&1 | tee /tmp/test.txt
...
test_trash_empty_will_skip_unreadable_dir (tests.test_trash_empty.TestTrashEmptyCmd) ... Would empty the following trash directories:
    - /tmp/tmpthw8qic5/data/Trash
    - /.Trash-1000
    - /dev/.Trash-1000
    - /proc/.Trash-1000
    - /sys/.Trash-1000
    - /sys/kernel/security/.Trash-1000
    - /dev/shm/.Trash-1000
    - /dev/pts/.Trash-1000
    - /run/.Trash-1000
    - /sys/fs/cgroup/.Trash-1000
    - /sys/firmware/efi/efivars/.Trash-1000
    - /sys/fs/bpf/.Trash-1000
    - /proc/sys/fs/binfmt_misc/.Trash-1000
    - /dev/hugepages/.Trash-1000
    - /dev/mqueue/.Trash-1000
    - /sys/kernel/debug/.Trash-1000
    - /sys/kernel/tracing/.Trash-1000
    - /sys/fs/fuse/connections/.Trash-1000
    - /boot/.Trash-1000
    - /tmp/.Trash-1000
    - /home/.Trash-1000
    - /var/cache/.Trash-1000
    - /var/db/repos/gentoo/.Trash-1000
    - /var/log/.Trash-1000
    - /run/user/1000/.Trash-1000
    - /home/<user>/documents/.Trash-1000
    - /home/<user>/sandbox/.Trash-1000
    - /home/<user>/pub/.Trash-1000
    - /sys/fs/cgroup/portage/.Trash-1000
    - /proc/sys/fs/binfmt_misc/.Trash-1000
Proceed? (y/n) y
ok
...

Expected behavior Tests only touch temporary test directories and not system ones.

andreafrancia commented 2 years ago

Fixed in 49807b3da83284b74a882376e27bad1995d88e42