blob: 4ea22a01c8ece1828a29909c882a35227d62a510 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
|
#!/bin/bash
# SPDX-License-Identifier: GPL-2.0
# Copyright (c) 2023 Meta Platforms, Inc. All Rights Reserved.
#
# FS QA Test 300
#
# Validate that snapshots taken while in a remapped namespace preserve
# the permissions of the user.
#
. ./common/preamble
_begin_fstest auto quick subvol snapshot
_register_cleanup "cleanup"
_supported_fs btrfs
_fixed_by_kernel_commit 94628ad94408 \
"btrfs: copy dir permission and time when creating a stub subvolume"
_require_test
_require_user
_require_group
_require_unix_perm_checking
_require_unshare --keep-caps --map-auto --map-root-user
test_dir="${TEST_DIR}/${seq}"
cleanup() {
rm -rf $test_dir
cd /
rm -rf $tmp.*
}
rm -rf $test_dir
mkdir $test_dir
chown $qa_user:$qa_group $test_dir
# _user_do executes each command as $qa_user in its own subshell. unshare
# sets the namespace for the running shell. The test must run in one user
# subshell to preserve the namespace over multiple commands.
_user_do "
cd ${test_dir};
unshare --user --keep-caps --map-auto --map-root-user;
$BTRFS_UTIL_PROG subvolume create subvol;
touch subvol/{1,2,3};
$BTRFS_UTIL_PROG subvolume create subvol/subsubvol;
touch subvol/subsubvol/{4,5,6};
$BTRFS_UTIL_PROG subvolume snapshot subvol snapshot > /dev/null;
"
find $test_dir/. -printf "%M %u %g ./%P\n"
status=0
exit
|