mirror of
https://github.com/linux-apfs/apfstests.git
synced 2026-05-01 15:01:44 -07:00
2b5cf241ec
Starting with version 2.41 of libcap, the output of the getcap program changed and therefore some existing tests fail when the installed version of libcap is >= 2.41 (the latest version available at the moment is 2.44). The change was made by the following commit of libcap: commit 177cd418031b1acfcf73fe3b1af9f3279828681c Author: Andrew G. Morgan <morgan@kernel.org> Date: Tue Jul 21 22:58:05 2020 -0700 A more compact form for the text representation of capabilities. While this does not change anything about the supported range of equivalent text specifications for capabilities, as accepted by cap_from_text(), this does alter the preferred output format of cap_to_text() to be two characters shorter in most cases. That is, what used to be summarized as: "= cap_foo+..." is now converted to the equivalent text: "cap_foo=..." which is also more intuitive. So add a filter to change the old format to the new one, an helper that calls getcap with that filter, make existing tests use the new helper and update their golden output to match the new output format of getcap. Signed-off-by: Filipe Manana <fdmanana@suse.com> Reviewed-by: Eryu Guan <guaneryu@gmail.com> Signed-off-by: Eryu Guan <guaneryu@gmail.com>
72 lines
1.6 KiB
Bash
Executable File
72 lines
1.6 KiB
Bash
Executable File
#! /bin/bash
|
|
# SPDX-License-Identifier: GPL-2.0
|
|
# Copyright (c) 2019 Red Hat Inc. All Rights Reserved.
|
|
#
|
|
# FS QA Test 064
|
|
#
|
|
# Make sure CAP_SETUID is not cleared over file copy up.
|
|
#
|
|
seq=`basename $0`
|
|
seqres=$RESULT_DIR/$seq
|
|
echo "QA output created by $seq"
|
|
|
|
here=`pwd`
|
|
tmp=/tmp/$$
|
|
status=1 # failure is the default!
|
|
trap "_cleanup; exit \$status" 0 1 2 3 15
|
|
|
|
_cleanup()
|
|
{
|
|
cd /
|
|
rm -f $tmp.*
|
|
}
|
|
|
|
# get standard environment, filters and checks
|
|
. ./common/rc
|
|
. ./common/filter
|
|
|
|
# remove previous $seqres.full before test
|
|
rm -f $seqres.full
|
|
|
|
# real QA test starts here
|
|
_supported_fs overlay
|
|
_require_scratch
|
|
_require_command "$SETCAP_PROG" setcap
|
|
_require_command "$GETCAP_PROG" getcap
|
|
_require_scratch_overlay_features metacopy
|
|
|
|
# Remove all files from previous tests
|
|
_scratch_mkfs
|
|
|
|
# Create test file
|
|
lowerdir=${OVL_BASE_SCRATCH_MNT}/${OVL_LOWER}
|
|
echo "This is lower1" >> ${lowerdir}/file1
|
|
echo "This is lower2" >> ${lowerdir}/file2
|
|
|
|
# set setuid bit
|
|
$SETCAP_PROG cap_setuid+ep ${lowerdir}/file1
|
|
$SETCAP_PROG cap_setuid+ep ${lowerdir}/file2
|
|
|
|
_scratch_mount "-o metacopy=on"
|
|
|
|
# Trigger file copy up without actually writing anything to file. This
|
|
# requires opening file with WRITE and xfs_io opens file with
|
|
# O_RDWR by default.
|
|
$XFS_IO_PROG -c "stat" ${SCRATCH_MNT}/file1 >>$seqres.full
|
|
|
|
# Make sure cap_setuid is still there
|
|
_getcap ${SCRATCH_MNT}/file1 | _filter_scratch
|
|
|
|
# Trigger metadata only copy-up
|
|
chmod 000 ${SCRATCH_MNT}/file2
|
|
|
|
# Trigger data copy-up
|
|
$XFS_IO_PROG -c "stat" ${SCRATCH_MNT}/file2 >>$seqres.full
|
|
|
|
# Make sure cap_setuid is still there
|
|
_getcap ${SCRATCH_MNT}/file2 | _filter_scratch
|
|
|
|
# success, all done
|
|
status=0
|
|
exit
|