Subject: tests/ls/readdir-mountpoint-inode.sh is unstable and should require root privileges
From: Thomas Deutschmann <[email-masked]>
To: [email-masked]
Date: Mon, 6 Nov 2017 11:42:23 +0100
List-Id: <debbugs-submit.debbugs.gnu.org>

Hi,

test "tests/ls/readdir-mountpoint-inode.sh" is unstable and should
require root privileges because it will fail when it encounters
permissions like

> # df --local --out=target | sed -n '/^\/./p'
> /dev
> /run
> /dev/shm
> /sys/fs/cgroup
> /boot
> /usr/portage
> /usr/portage/distfiles
> /var/log
> /backup
> /srv
> /srv/mysql

Where "/srv" isn't readable for the user currently running the test:

> # stat --format=%A /srv
> drwxr-x--x
> # stat --format=%A /srv/mysql/
> drwxrwx---

Test output:

> +++ dirname /srv/mysql
> ++ parent_dir=/srv
> ++ eval 'ls -i -I '\''.?*'\'' -I '\''mysql?*'\'' -I '\''mysq[^l]*'\'' -I '\''????'\'' -I '\''mys[^q]*'\'' -I '\''???'\'' -I '\''my[^s]*'\'' -I '\''??'\'' -I '\''m[^y]*'\'' -I '\''?'\'' -I '\''[^m]*'\'' '\''/srv'\'''
> ++ sed 's/ .*//'
> +++ ls -i -I '.?*' -I 'mysql?*' -I 'mysq[^l]*' -I '????' -I 'mys[^q]*' -I '???' -I 'my[^s]*' -I '??' -I 'm[^y]*' -I '?' -I '[^m]*' /srv
> ls: cannot open directory '/srv': Permission denied
> + readdir_inode=
> + test 0 = 77
> ++ timeout 1 stat --format=%i /srv/mysql
> + stat_inode=96
> + case $stat_inode in
> + test '' = 96
> + fail=1

Full test output: https://paste.pound-python.org/show/VRD8hTfErxNtrqkZ3Muj

Tested with coreutils-8.28.

Suggested patch:

diff --git a/tests/ls/readdir-mountpoint-inode.sh b/tests/ls/readdir-mountpoint-inode.sh
index b4ca9e46e..57ec74740 100755
--- a/tests/ls/readdir-mountpoint-inode.sh
+++ b/tests/ls/readdir-mountpoint-inode.sh
@@ -18,6 +18,7 @@

 . "${srcdir=.}/tests/init.sh"; path_prepend_ ./src
 print_ver_ ls
+require_root_

 # We use --local here so as to not activate
 # potentially very many remote mounts.

-- 
Regards,
Thomas Deutschmann / Gentoo Linux Developer
C4DD 695F A713 8F24 2AA1 5638 5849 7EE5 1D5D 74A5