Avoid quoting of tilde when it's a destination arg.
[rsync.git] / testsuite / protected-regular.test
1 #!/bin/sh
2
3 # Copyright (C) 2021 by Achim Leitner <aleitner@lis-engineering.de>
4 # This program is distributable under the terms of the GNU GPL (see COPYING)
5 #
6 # Modern linux systems have the protected_regular feature set to 1 or 2
7 # See https://www.kernel.org/doc/Documentation/sysctl/fs.txt
8 # Make sure we can still write these files in --inplace mode
9
10 . "$suitedir/rsync.fns"
11
12 test -f /proc/sys/fs/protected_regular || test_skipped "Can't find protected_regular setting (only available on Linux)"
13 pr_lvl=`cat /proc/sys/fs/protected_regular 2>/dev/null` || test_skipped "Can't check if fs.protected_regular is enabled (probably need root)"
14 test "$pr_lvl" != 0 || test_skipped "fs.protected_regular is not enabled"
15
16 workdir="$tmpdir/files"
17 mkdir "$workdir"
18 chmod 1777 "$workdir"
19
20 echo "Source" > "$workdir/src"
21 echo ""       > "$workdir/dst"
22 chown 5001 "$workdir/dst" || test_skipped "Can't chown (probably need root)"
23
24 # Output is only shown in case of an error
25 echo "Contents of $workdir:"
26 ls -al "$workdir"
27
28 $RSYNC --inplace "$workdir/src" "$workdir/dst" || test_fail
29
30 # The script would have aborted on error, so getting here means we've won.
31 exit 0