File: protected-regular.test

package info (click to toggle)
rsync 3.4.1%2Bds1-7
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 4,388 kB
  • sloc: ansic: 35,682; sh: 6,538; python: 1,759; asm: 829; perl: 479; makefile: 365; cpp: 298; awk: 191
file content (31 lines) | stat: -rw-r--r-- 1,153 bytes parent folder | download | duplicates (3)
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
#!/bin/sh

# Copyright (C) 2021 by Achim Leitner <aleitner@lis-engineering.de>
# This program is distributable under the terms of the GNU GPL (see COPYING)
#
# Modern linux systems have the protected_regular feature set to 1 or 2
# See https://www.kernel.org/doc/Documentation/sysctl/fs.txt
# Make sure we can still write these files in --inplace mode

. "$suitedir/rsync.fns"

test -f /proc/sys/fs/protected_regular || test_skipped "Can't find protected_regular setting (only available on Linux)"
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)"
test "$pr_lvl" != 0 || test_skipped "fs.protected_regular is not enabled"

workdir="$tmpdir/files"
mkdir "$workdir"
chmod 1777 "$workdir"

echo "Source" > "$workdir/src"
echo ""       > "$workdir/dst"
chown 5001 "$workdir/dst" || test_skipped "Can't chown (probably need root)"

# Output is only shown in case of an error
echo "Contents of $workdir:"
ls -al "$workdir"

$RSYNC --inplace "$workdir/src" "$workdir/dst" || test_fail

# The script would have aborted on error, so getting here means we've won.
exit 0