bug-coreutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: 4.5.9 test failure: fail-2eperm


From: Jim Meyering
Subject: Re: 4.5.9 test failure: fail-2eperm
Date: Sat, 08 Mar 2003 17:56:52 +0100

Thanks for reporting that.
I'll readily admit that poking around in /etc/passwd
is not the best approach :-)

I also considered using sudo, but I didn't see a way (without prompting
the user) to determine whether it would work noninteractively

For the time being, I've made the following change:

        * tests/rm/fail-2eperm: Rather than simply using the first non-root
        user name, make sure that the selected user name has a usable shell.

There's also the `check-root' target in the tests directory,
so you can do `make -C tests check-root' to run only the ones
that require root access.

Index: tests/rm/fail-2eperm
===================================================================
RCS file: /fetish/cu/tests/rm/fail-2eperm,v
retrieving revision 1.1
diff -u -p -u -p -r1.1 fail-2eperm
--- tests/rm/fail-2eperm        4 Mar 2003 19:49:35 -0000       1.1
+++ tests/rm/fail-2eperm        8 Mar 2003 16:39:37 -0000
@@ -15,13 +15,17 @@ t0=`echo "$0"|sed 's,.*/,,'`.tmp; tmp=$t
 trap 'status=$?; cd $pwd; chmod -R u+rwx $t0; rm -rf $t0 && exit $status' 0
 trap '(exit $?); exit $?' 1 2 13 15
 
-# Find a username with UID != 0.
-non_root_username=`grep -v '[^:]*:[^:]*:0:' /etc/passwd| sed -n '1s/:.*//p'`
-test "x$non_root_username" = x && framework_failure=1
-
 framework_failure=0
 mkdir -p $tmp || framework_failure=1
 cd $tmp || framework_failure=1
+
+# Find a username with UID != 0, and a valid shell.
+non_root_username=
+names=`grep -v '[^:]*:[^:]*:0:' /etc/passwd| sed 's/:.*//'`
+for name in $names; do
+  su -c ':' $name && { non_root_username=$name; break; }
+done
+test "x$non_root_username" = x && framework_failure=1
 
 # The containing directory must be owned by the user who eventually runs rm.
 chown $non_root_username .

address@hidden (Paul Jarc) wrote:
> On my system, the "nobody" user does not have a usable shell.
>
> make  check-TESTS
> make[3]: Entering directory 
> `/fs/data/mount/home/prj/src/spf/coreutils-4.5.9/tests/rm'
> out exp differ: char 1, line 1
> 1c1
> < su: /nil/nobody/shell: No such file or directory
> ---
>> rm: cannot remove `a/b': Operation not permitted
> FAIL: fail-2eperm
>
> I think the right way to do this sort of thing is to let the user
> specify a username or UID to use for non-root tests.  Then you can
> pass the UID directly to setuid() rather than using su, so you don't

That'd work in the perl test scripts, but what about the
bourne shell ones?

> have to worry about the shell.  This would also make it possible to
> run all the tests in a single "make check" run, rather than getting




reply via email to

[Prev in Thread] Current Thread [Next in Thread]