--- embedaddon/rsync/testsuite/rsync.fns 2013/10/14 07:51:15 1.1.1.2 +++ embedaddon/rsync/testsuite/rsync.fns 2021/03/17 00:32:36 1.1.1.3 @@ -1,4 +1,4 @@ -#! /bin/sh +#!/bin/sh # Copyright (C) 2001 by Martin Pool @@ -23,9 +23,9 @@ todir="$tmpdir/to" chkdir="$tmpdir/chk" # For itemized output: -all_plus='+++++++++' -allspace=' ' -dots='.....' # trailing dots after changes +all_plus='++++++++++' +allspace=' ' +dots='......' # trailing dots after changes tab_ch=' ' # a single tab character # Berkley's nice. @@ -62,7 +62,7 @@ set_cp_destdir() { # Perform a "cp -p", making sure that timestamps are really the same, # even if the copy rounded microsecond times on the destination file. cp_touch() { - cp -p "${@}" || test_fail "cp -p failed" + cp_p "${@}" if test $# -gt 2 -o -d "$2"; then set_cp_destdir "${@}" # sets destdir var while test $# -gt 1; do @@ -97,13 +97,48 @@ printmsg() { } rsync_ls_lR() { - find "$@" -print | sort | sed 's/ /\\ /g' | xargs "$TOOLDIR/tls" $TLS_ARGS + find "$@" -name .git -prune -o -name auto-build-save -prune -o -print | \ + sort | sed 's/ /\\ /g' | xargs "$TOOLDIR/tls" $TLS_ARGS } get_testuid() { - id 2>/dev/null | sed 's/^[^0-9]*\([0-9][0-9]*\).*/\1/' + uid=`id -u 2>/dev/null || true` + case "$uid" in + [0-9]*) echo "$uid" ;; + *) id 2>/dev/null | sed 's/^[^0-9]*\([0-9][0-9]*\).*/\1/' ;; + esac } +get_rootuid() { + uid=`id -u root 2>/dev/null || true` + case "$uid" in + [0-9]*) echo "$uid" ;; + *) echo 0 ;; + esac +} + +get_rootgid() { + gid=`id -g root 2>/dev/null || true` + case "$gid" in + [0-9]*) echo "$gid" ;; + *) echo 0 ;; + esac +} + +# When copying via "cp -p", we want to ensure that a non-root user does not +# preserve ownership (we want our files to be created as the testing user). +# For instance, a Cygwin CI run might have git files owned by a different +# user than the (admin) user running the tests. +cp_cmd="cp -p" +if test x`get_testuid` != x0; then + case `cp --help 2>/dev/null` in + *--no-preserve=*) cp_cmd="cp -p --no-preserve=ownership" ;; + esac +fi +cp_p() { + $cp_cmd "${@}" || test_fail "$cp_cmd failed" +} + check_perms() { perms=`"$TOOLDIR/tls" "$1" | sed 's/^[-d]\(.........\).*/\1/'` if test $perms = $2; then @@ -183,7 +218,7 @@ makepath() { for p in "${@}"; do (echo " makepath $p" - # Absolut Unix. + # Absolute Unix path. if echo $p | grep '^/' >/dev/null then cd / @@ -219,6 +254,14 @@ checkit() { # We can just write everything to stdout/stderr, because the # wrapper hides it unless there is a problem. + case "x$TLS_ARGS" in + *--atimes*) + ( cd "$2" && rsync_ls_lR . ) > "$tmpdir/ls-from" + ;; + *) + ;; + esac + echo "Running: \"$1\"" eval "$1" status=$? @@ -226,10 +269,17 @@ checkit() { failed="$failed status=$status" fi + case "x$TLS_ARGS" in + *--atimes*) + ;; + *) + ( cd "$2" && rsync_ls_lR . ) > "$tmpdir/ls-from" + ;; + esac + echo "-------------" echo "check how the directory listings compare with diff:" echo "" - ( cd "$2" && rsync_ls_lR . ) > "$tmpdir/ls-from" ( cd "$3" && rsync_ls_lR . ) > "$tmpdir/ls-to" diff $diffopt "$tmpdir/ls-from" "$tmpdir/ls-to" || failed="$failed dir-diff" @@ -262,16 +312,18 @@ build_rsyncd_conf() { logfile="$scratchdir/rsyncd.log" hostname=`uname -n` - uid_setting='uid = 0' - gid_setting='gid = 0' - case `get_testuid` in - 0) ;; - *) + my_uid=`get_testuid` + root_uid=`get_rootuid` + root_gid=`get_rootgid` + + uid_setting="uid = $root_uid" + gid_setting="gid = $root_gid" + + if test x"$my_uid" != x"$root_uid"; then # Non-root cannot specify uid & gid settings uid_setting="#$uid_setting" gid_setting="#$gid_setting" - ;; - esac + fi cat >"$conf" <