summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorJim Meyering <jim@meyering.net>2003-03-08 16:43:43 +0000
committerJim Meyering <jim@meyering.net>2003-03-08 16:43:43 +0000
commit6df9b9041db60ec1bebb8c20456ea7b4d8b0c0d1 (patch)
tree4abefc4a424ce1124c9eb135685d82d838caaab3 /tests
parent777ac50d21f0fcb859dcb206ad997a217dc320a7 (diff)
downloadcoreutils-6df9b9041db60ec1bebb8c20456ea7b4d8b0c0d1.tar.xz
Rather than simply using the first non-root
username, make sure that the selected user name has a usable shell.
Diffstat (limited to 'tests')
-rwxr-xr-xtests/rm/fail-2eperm12
1 files changed, 8 insertions, 4 deletions
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 .