Handle new PATCH-$name files, improved $last_touch code,
[rsync.git] / testsuite / chown.test
blob289889032ad5a5b2bae8faa13daf3b2deea2c526
1 #! /bin/sh
3 # Copyright (C) 2002 by Martin Pool <mbp@samba.org>
5 # This program is distributable under the terms of the GNU GPL (see
6 # COPYING).
8 # Test that when rsync is running as root and has -a it correctly sets
9 # the ownership of the destination.
11 # We don't know what users will be present on this system, so we just
12 # use random numeric uids and gids.
14 . "$suitedir/rsync.fns"
16 case $0 in
17 *fake*)
18 $RSYNC --version | grep ", xattrs" >/dev/null || test_skipped "Rsync needs xattrs for fake device tests"
19 RSYNC="$RSYNC --fake-super"
20 TLS_ARGS=--fake-super
21 case "`xattr 2>&1`" in
22 *--list:*)
23 chown() {
24 own=$1
25 shift
26 xattr -s 'rsync.%stat' "100644 0,0 $own" "${@}"
30 chown() {
31 own=$1
32 shift
33 setfattr -n 'user.rsync.%stat' -v "100644 0,0 $own" "${@}"
36 esac
39 RSYNC="$RSYNC --super"
40 case `id -u` in
41 '') ;; # If "id" failed, try to continue...
42 0) ;;
43 *) if [ -f /usr/bin/fakeroot ]; then
44 echo "Let's try re-running the script under fakeroot..."
45 exec /usr/bin/fakeroot /bin/sh "$0"
48 esac
50 esac
52 # Build some hardlinks
54 mkdir "$fromdir"
55 name1="$fromdir/name1"
56 name2="$fromdir/name2"
57 echo "This is the file" > "$name1"
58 echo "This is the other file" > "$name2"
60 chown 5000:5002 "$name1" || test_skipped "Can't chown (probably need root)"
61 chown 5001:5003 "$name2" || test_skipped "Can't chown (probably need root)"
63 cd "$fromdir/.."
64 checkit "$RSYNC -aHvv from/ to/" "$fromdir" "$todir"
66 # The script would have aborted on error, so getting here means we've won.
67 exit 0