Some open rsync tests fail when run as regular user. If running
authorbluhm <bluhm@openbsd.org>
Fri, 28 Jul 2023 17:25:32 +0000 (17:25 +0000)
committerbluhm <bluhm@openbsd.org>
Fri, 28 Jul 2023 17:25:32 +0000 (17:25 +0000)
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
regress/usr.bin/rsync/test13_perms.test
regress/usr.bin/rsync/test13b_perms.test [new file with mode: 0644]
regress/usr.bin/rsync/test6_perms.test

index 3be5644..50b9496 100644 (file)
@@ -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
index 79a0103..52beff0 100644 (file)
@@ -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 (file)
index 0000000..092adb4
--- /dev/null
@@ -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
index 36f930b..c0461c2 100644 (file)
@@ -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 ..