From: Karel Zak Date: Mon, 24 Oct 2022 11:02:26 +0000 (+0200) Subject: tetss: use stat(1) in mount/set_ugid_mode X-Git-Tag: v2.39-rc1~466 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=fb34edff70665f6c2fde319fd7a71d7953ce74e3;p=thirdparty%2Futil-linux.git 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 --- 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 }