Added options to tls.c to allow us to ask for mtime and ownership info
[rsync/rsync.git] / testsuite / chown.test
CommitLineData
b0d4f4c1
MP
1#! /bin/sh
2
3# Copyright (C) 2002 by Martin Pool <mbp@samba.org>
4
5# This program is distributable under the terms of the GNU GPL (see
6# COPYING).
7
8# Test that when rsync is running as root and has -a it correctly sets
9# the ownership of the destination.
10
11# We don't know what users will be present on this system, so we just
12# use random numeric uids and gids.
13
b0e9bafc 14. "$suitedir/rsync.fns"
b0d4f4c1 15
b3fbe3ce
WD
16case $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"
5b385336 20 TLS_ARGS="$TLS_ARGS --fake-super"
b3fbe3ce
WD
21 case "`xattr 2>&1`" in
22 *--list:*)
23 chown() {
24 own=$1
25 shift
26 xattr -s 'rsync.%stat' "100644 0,0 $own" "${@}"
27 }
28 ;;
29 *)
30 chown() {
31 own=$1
32 shift
33 setfattr -n 'user.rsync.%stat' -v "100644 0,0 $own" "${@}"
34 }
35 ;;
36 esac
37 ;;
38*)
548ca46f 39 RSYNC="$RSYNC --super"
b3fbe3ce
WD
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"
46 fi
47 ;;
48 esac
648859bd
WD
49 ;;
50esac
51
b0d4f4c1
MP
52# Build some hardlinks
53
b0d4f4c1
MP
54mkdir "$fromdir"
55name1="$fromdir/name1"
56name2="$fromdir/name2"
57echo "This is the file" > "$name1"
58echo "This is the other file" > "$name2"
59
b3fbe3ce
WD
60chown 5000:5002 "$name1" || test_skipped "Can't chown (probably need root)"
61chown 5001:5003 "$name2" || test_skipped "Can't chown (probably need root)"
b0d4f4c1 62
25c2a6ac 63cd "$fromdir/.."
dbb20f6b 64checkit "$RSYNC -aHvv from/ to/" "$fromdir" "$todir"
b0d4f4c1 65
05118158 66# The script would have aborted on error, so getting here means we've won.
b0d4f4c1 67exit 0