GNU bug report logs - #29167
tests/ls/readdir-mountpoint-inode.sh is unstable and should require root privileges

Previous Next

Package: coreutils;

Reported by: Thomas Deutschmann <whissi <at> gentoo.org>

Date: Mon, 6 Nov 2017 10:43:02 UTC

Severity: normal

Done: Pádraig Brady <P <at> draigBrady.com>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 29167 in the body.
You can then email your comments to 29167 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

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


Report forwarded to bug-coreutils <at> gnu.org:
bug#29167; Package coreutils. (Mon, 06 Nov 2017 10:43:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Thomas Deutschmann <whissi <at> gentoo.org>:
New bug report received and forwarded. Copy sent to bug-coreutils <at> gnu.org. (Mon, 06 Nov 2017 10:43:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Thomas Deutschmann <whissi <at> gentoo.org>
To: bug-coreutils <at> gnu.org
Subject: tests/ls/readdir-mountpoint-inode.sh is unstable and should require
 root privileges
Date: Mon, 6 Nov 2017 11:42:23 +0100
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




Information forwarded to bug-coreutils <at> gnu.org:
bug#29167; Package coreutils. (Mon, 06 Nov 2017 12:07:02 GMT) Full text and rfc822 format available.

Message #8 received at 29167 <at> debbugs.gnu.org (full text, mbox):

From: Thomas Deutschmann <whissi <at> gentoo.org>
To: 29167 <at> debbugs.gnu.org
Subject: Re: bug#29167: Acknowledgement (tests/ls/readdir-mountpoint-inode.sh
 is unstable and should require root privileges)
Date: Mon, 6 Nov 2017 13:06:37 +0100
Hi,

here's a better fix (from Sebastian Kühn via
https://bugs.gentoo.org/353164):

diff --git a/tests/ls/readdir-mountpoint-inode.sh
b/tests/ls/readdir-mountpoint-inode.sh
index b4ca9e46e..5270df079 100755
--- a/tests/ls/readdir-mountpoint-inode.sh
+++ b/tests/ls/readdir-mountpoint-inode.sh
@@ -55,7 +55,10 @@ inode_via_readdir()
   esac
   opts=$(ls_ignore_options "$base")
   parent_dir=$(dirname "$mount_point")
-  eval "ls -i $opts '$parent_dir'" | sed 's/ .*//'
+  ls_out=$(eval "ls -i $opts '$parent_dir'")
+  test $? -eq 0 || \
+    skip_ "'$parent_dir' is not readable for current user"
+  echo $ls_out | sed 's/ .*//'
 }

 while read dir; do


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




Reply sent to Pádraig Brady <P <at> draigBrady.com>:
You have taken responsibility. (Tue, 07 Nov 2017 05:38:02 GMT) Full text and rfc822 format available.

Notification sent to Thomas Deutschmann <whissi <at> gentoo.org>:
bug acknowledged by developer. (Tue, 07 Nov 2017 05:38:02 GMT) Full text and rfc822 format available.

Message #13 received at 29167-done <at> debbugs.gnu.org (full text, mbox):

From: Pádraig Brady <P <at> draigBrady.com>
To: Thomas Deutschmann <whissi <at> gentoo.org>, 29167-done <at> debbugs.gnu.org
Subject: Re: bug#29167: Acknowledgement (tests/ls/readdir-mountpoint-inode.sh
 is unstable and should require root privileges)
Date: Mon, 6 Nov 2017 21:37:25 -0800
On 06/11/17 04:06, Thomas Deutschmann wrote:
> Hi,
> 
> here's a better fix (from Sebastian Kühn via
> https://bugs.gentoo.org/353164):
> 
> diff --git a/tests/ls/readdir-mountpoint-inode.sh
> b/tests/ls/readdir-mountpoint-inode.sh
> index b4ca9e46e..5270df079 100755
> --- a/tests/ls/readdir-mountpoint-inode.sh
> +++ b/tests/ls/readdir-mountpoint-inode.sh
> @@ -55,7 +55,10 @@ inode_via_readdir()
>    esac
>    opts=$(ls_ignore_options "$base")
>    parent_dir=$(dirname "$mount_point")
> -  eval "ls -i $opts '$parent_dir'" | sed 's/ .*//'
> +  ls_out=$(eval "ls -i $opts '$parent_dir'")
> +  test $? -eq 0 || \
> +    skip_ "'$parent_dir' is not readable for current user"
> +  echo $ls_out | sed 's/ .*//'
>  }
> 
>  while read dir; do

Pushed at:
https://git.sv.gnu.org/gitweb/?p=coreutils.git;a=commitdiff;h=v8.28-29-gaebefc2
Marking this as done.

thanks,
Pádraig




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Tue, 05 Dec 2017 12:24:06 GMT) Full text and rfc822 format available.

This bug report was last modified 6 years and 136 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.