From fb34edff70665f6c2fde319fd7a71d7953ce74e3 Mon Sep 17 00:00:00 2001 From: Karel Zak Date: Mon, 24 Oct 2022 13:02:26 +0200 Subject: [PATCH] tetss: use stat(1) in mount/set_ugid_mode The permissions output from ls(1) is not portable. The output contains '.' when SELinux context is enabled for the directory. stat(1) also provides full control over formatting, so we do not need to parse ls(1) output. Signed-off-by: Karel Zak --- tests/ts/mount/set_ugid_mode | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/tests/ts/mount/set_ugid_mode b/tests/ts/mount/set_ugid_mode index 810f81f38c..ed8a84ba5c 100755 --- a/tests/ts/mount/set_ugid_mode +++ b/tests/ts/mount/set_ugid_mode @@ -15,7 +15,7 @@ ts_skip_nonroot ts_check_losetup ts_check_prog "mkfs.ext2" ts_check_prog "id" -ts_check_prog "ls" +ts_check_prog "stat" do_one() { @@ -23,8 +23,7 @@ do_one() { what="$1"; shift where="$1"; shift $TS_CMD_MOUNT "$@" "$what" "$where" >> $TS_OUTPUT 2>> $TS_ERRLOG - read -r m _ o g _ < <(ls -nd "$where") - actual="$m $o $g" + actual=$(stat --format="%A %u %g" "$where") [ "$actual" = "$expected" ] || echo "$*: $actual != $expected" >> $TS_ERRLOG $TS_CMD_UMOUNT "$where" >> $TS_OUTPUT 2>> $TS_ERRLOG } -- 2.47.3