File:  [ELWIX - Embedded LightWeight unIX -] / embedaddon / rsync / testsuite / chown.test
Revision 1.1.1.2 (vendor branch): download - view: text, annotated - select for diffs - revision graph
Mon Oct 14 07:51:15 2013 UTC (10 years, 8 months ago) by misho
Branches: rsync, MAIN
CVS tags: v3_1_2p5, RSYNC3_1_0, HEAD
v 3.1.0

    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*)
   18:     $RSYNC --version | grep ", xattrs" >/dev/null || test_skipped "Rsync needs xattrs for fake device tests"
   19:     RSYNC="$RSYNC --fake-super"
   20:     TLS_ARGS="$TLS_ARGS --fake-super"
   21:     case "$HOST_OS" in
   22:     darwin*)
   23: 	chown() {
   24: 	    own=$1
   25: 	    shift
   26: 	    xattr -s 'rsync.%stat' "100644 0,0 $own" "${@}"
   27: 	}
   28: 	;;
   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: 	;;
   40:     *)
   41: 	chown() {
   42: 	    own=$1
   43: 	    shift
   44: 	    setfattr -n 'user.rsync.%stat' -v "100644 0,0 $own" "${@}"
   45: 	}
   46: 	;;
   47:     esac
   48:     ;;
   49: *)
   50:     RSYNC="$RSYNC --super"
   51:     case `get_testuid` in
   52:     '') ;; # If "id" failed, try to continue...
   53:     0)  ;;
   54:     *)  if [ -e "$FAKEROOT_PATH" ]; then
   55: 	    echo "Let's try re-running the script under fakeroot..."
   56: 	    exec "$FAKEROOT_PATH" "$SHELL_PATH" "$0"
   57: 	fi
   58: 	;;
   59:     esac
   60:     ;;
   61: esac
   62: 
   63: # Build some hardlinks
   64: 
   65: mkdir "$fromdir"
   66: name1="$fromdir/name1"
   67: name2="$fromdir/name2"
   68: echo "This is the file" > "$name1"
   69: echo "This is the other file" > "$name2"
   70: 
   71: chown 5000:5002 "$name1" || test_skipped "Can't chown (probably need root)"
   72: chown 5001:5003 "$name2" || test_skipped "Can't chown (probably need root)"
   73: 
   74: cd "$fromdir/.."
   75: checkit "$RSYNC -aHvv from/ to/" "$fromdir" "$todir"
   76: 
   77: # The script would have aborted on error, so getting here means we've won.
   78: exit 0

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>