]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
tetss: use stat(1) in mount/set_ugid_mode
authorKarel Zak <kzak@redhat.com>
Mon, 24 Oct 2022 11:02:26 +0000 (13:02 +0200)
committerKarel Zak <kzak@redhat.com>
Mon, 24 Oct 2022 11:02:26 +0000 (13:02 +0200)
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 <kzak@redhat.com>
tests/ts/mount/set_ugid_mode

index 810f81f38c3e581e287a51fcde87a390bea60ec1..ed8a84ba5c8f7c316faccbdef3ee647878ecdc93 100755 (executable)
@@ -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
 }