Annotation of embedaddon/rsync/testsuite/chown.test, revision 1.1.1.3
1.1 misho 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:
14: . "$suitedir/rsync.fns"
15:
16: case $0 in
17: *fake*)
1.1.1.3 ! misho 18: $RSYNC --version | grep "[, ] xattrs" >/dev/null || test_skipped "Rsync needs xattrs for fake device tests"
1.1 misho 19: RSYNC="$RSYNC --fake-super"
20: TLS_ARGS="$TLS_ARGS --fake-super"
1.1.1.2 misho 21: case "$HOST_OS" in
22: darwin*)
1.1 misho 23: chown() {
24: own=$1
25: shift
26: xattr -s 'rsync.%stat' "100644 0,0 $own" "${@}"
27: }
28: ;;
1.1.1.2 misho 29: solaris*)
30: chown() {
31: own=$1
32: shift
33: for fn in "${@}"; do
34: runat "$fn" "$SHELL_PATH" <<EOF
35: echo "100644 0,0 $own" > rsync.%stat
36: EOF
37: done
38: }
39: ;;
1.1.1.3 ! misho 40: freebsd*)
! 41: chown() {
! 42: own=$1
! 43: shift
! 44: setextattr -h user "rsync.%stat" "100644 0,0 $own" "${@}"
! 45: }
! 46: ;;
1.1 misho 47: *)
48: chown() {
49: own=$1
50: shift
51: setfattr -n 'user.rsync.%stat' -v "100644 0,0 $own" "${@}"
52: }
53: ;;
54: esac
55: ;;
56: *)
57: RSYNC="$RSYNC --super"
1.1.1.3 ! misho 58: my_uid=`get_testuid`
! 59: root_uid=`get_rootuid`
! 60: if test x"$my_uid" = x; then
! 61: : # If "id" failed, try to continue...
! 62: elif test x"$my_uid" != x"$root_uid"; then
! 63: if [ -e "$FAKEROOT_PATH" ]; then
1.1 misho 64: echo "Let's try re-running the script under fakeroot..."
1.1.1.2 misho 65: exec "$FAKEROOT_PATH" "$SHELL_PATH" "$0"
1.1 misho 66: fi
1.1.1.3 ! misho 67: fi
1.1 misho 68: ;;
69: esac
70:
71: # Build some hardlinks
72:
73: mkdir "$fromdir"
74: name1="$fromdir/name1"
75: name2="$fromdir/name2"
76: echo "This is the file" > "$name1"
77: echo "This is the other file" > "$name2"
78:
79: chown 5000:5002 "$name1" || test_skipped "Can't chown (probably need root)"
80: chown 5001:5003 "$name2" || test_skipped "Can't chown (probably need root)"
81:
82: cd "$fromdir/.."
83: checkit "$RSYNC -aHvv from/ to/" "$fromdir" "$todir"
84:
85: # The script would have aborted on error, so getting here means we've won.
86: exit 0
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>