From 932b7127be46854fb6d1ab69a58afbd62992e1ab Mon Sep 17 00:00:00 2001 From: bluhm Date: Fri, 28 Jul 2023 17:25:32 +0000 Subject: [PATCH] Some open rsync tests fail when run as regular user. If running as root, switch to build user to cover that case with new test13b_perms. Fix the original test6_perms and test13_perms to pass as root and regular user. Note that ports rsync does not have this problem. --- regress/usr.bin/rsync/Makefile | 24 +++++++++++++++++------- regress/usr.bin/rsync/test13_perms.test | 2 +- regress/usr.bin/rsync/test13b_perms.test | 24 ++++++++++++++++++++++++ regress/usr.bin/rsync/test6_perms.test | 2 +- 4 files changed, 43 insertions(+), 9 deletions(-) create mode 100644 regress/usr.bin/rsync/test13b_perms.test diff --git a/regress/usr.bin/rsync/Makefile b/regress/usr.bin/rsync/Makefile index 3be5644e784..50b9496156d 100644 --- a/regress/usr.bin/rsync/Makefile +++ b/regress/usr.bin/rsync/Makefile @@ -1,4 +1,4 @@ -# $OpenBSD: Makefile,v 1.4 2023/07/16 06:36:18 anton Exp $ +# $OpenBSD: Makefile,v 1.5 2023/07/28 17:25:32 bluhm Exp $ # evaluate once in main make invocation, then get list of test from environment .if ! (make(clean) || make(cleandir) || make(obj)) @@ -14,17 +14,15 @@ clean: # some of these tests pass or fail unreliably REGRESS_EXPECTED_FAILURES = run-openrsync-openrsync-test3_minusexclude \ - run-openrsync-openrsync-test6_perms \ run-openrsync-openrsync-test6b_perms \ run-openrsync-openrsync-test7_symlinks \ run-openrsync-openrsync-test10_perms \ - run-openrsync-openrsync-test13_perms \ + run-openrsync-openrsync-test13b_perms \ run-openrsync-rsync-test3_minusexclude \ - run-openrsync-rsync-test6_perms \ run-openrsync-rsync-test6b_perms \ run-openrsync-rsync-test7_symlinks \ run-openrsync-rsync-test10_perms \ - run-openrsync-rsync-test13_perms + run-openrsync-rsync-test13b_perms .if ! exists(${RSYNC_PORT}) .for t in ${RSYNC_TESTS} @@ -34,6 +32,18 @@ REGRESS_SKIP_TARGETS += run-${RSYNC_PORT:T}-${RSYNC_PORT:T}-${t:T:R} .endfor .endif +# these test have to run as regular user +USER_TESTS = test13b_perms + +ROOT_USER != id -g +.for t in ${RSYNC_TESTS} +.if ${ROOT_USER} != 0 || empty(USER_TESTS:M${t:T:R}) +SH_${t:T:R} = sh +.else +SH_${t:T:R} = su build +.endif +.endfor + .for l in ${RSYNC_OPEN} ${RSYNC_PORT} .for r in ${RSYNC_OPEN} ${RSYNC_PORT} @@ -41,8 +51,8 @@ RSYNC_$l_$r = $l --rsync-path=$r .for t in ${RSYNC_TESTS} REGRESS_TARGETS += run-${l:T}-${r:T}-${t:T:R} -run-${l:T}-${r:T}-${t:T:R}: - tstdir="${.CURDIR}" rsync="${RSYNC_$l_$l}" sh $t +run-${l:T}-${r:T}-${t:T:R}: clean + tstdir="${.CURDIR}" rsync="${RSYNC_$l_$l}" ${SH_${t:T:R}} $t .endfor .endfor diff --git a/regress/usr.bin/rsync/test13_perms.test b/regress/usr.bin/rsync/test13_perms.test index 79a010367be..52beff092fc 100644 --- a/regress/usr.bin/rsync/test13_perms.test +++ b/regress/usr.bin/rsync/test13_perms.test @@ -16,7 +16,7 @@ generate_tree dir2 # Also make the target tree and mess up some permissions in there. # We expect rsync to reset this to what dir1 has. generate_tree dir3 -chmod 070 dir3/one.txt +chmod 470 dir3/one.txt touch -m -t 199901020405 dir3/one.txt $rsync -a dir1/ dir3 diff --git a/regress/usr.bin/rsync/test13b_perms.test b/regress/usr.bin/rsync/test13b_perms.test new file mode 100644 index 00000000000..092adb4bca7 --- /dev/null +++ b/regress/usr.bin/rsync/test13b_perms.test @@ -0,0 +1,24 @@ +#! /bin/sh + +. ${tstdir-.}/lib.sh +. ${tstdir-.}/conf.sh + +generate_tree() { + mkdirfile "${1}/one.txt" +} + +rm -rf dir1 dir2 dir3 +# make the copy-from-here tree +generate_tree dir1 +# make the tree we want to compare to +generate_tree dir2 + +# Also make the target tree and mess up some permissions in there. +# We expect rsync to reset this to what dir1 has. +generate_tree dir3 +# regular user cannot read his own file, rsync must fix permissions first +chmod 070 dir3/one.txt +touch -m -t 199901020405 dir3/one.txt + +$rsync -a dir1/ dir3 +compare_trees dir2 dir3 diff --git a/regress/usr.bin/rsync/test6_perms.test b/regress/usr.bin/rsync/test6_perms.test index 36f930b1e95..c0461c22055 100644 --- a/regress/usr.bin/rsync/test6_perms.test +++ b/regress/usr.bin/rsync/test6_perms.test @@ -20,7 +20,7 @@ cd ../dir3 generate_tree_1 chmod 600 foo/bar/baz/one.txt touch -m -t 199901020405 foo/bar/baz/one.txt -chmod 070 foo/bar/baz/one2.txt +chmod 470 foo/bar/baz/one2.txt touch -m -t 199901020405 foo/bar/baz/one2.txt cd .. -- 2.20.1