From 6df9b9041db60ec1bebb8c20456ea7b4d8b0c0d1 Mon Sep 17 00:00:00 2001 From: Jim Meyering Date: Sat, 8 Mar 2003 16:43:43 +0000 Subject: Rather than simply using the first non-root username, make sure that the selected user name has a usable shell. --- tests/rm/fail-2eperm | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'tests') diff --git a/tests/rm/fail-2eperm b/tests/rm/fail-2eperm index d2a200262..18662e3f5 100755 --- a/tests/rm/fail-2eperm +++ b/tests/rm/fail-2eperm @@ -15,14 +15,18 @@ t0=`echo "$0"|sed 's,.*/,,'`.tmp; tmp=$t0/$$ 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 . -- cgit v1.2.3-70-g09d2