]> git.ipfire.org Git - thirdparty/rsync.git/commitdiff
testsuite: fix executability test skip on FreeBSD (EFTYPE)
authorWill Sarg <12886992+willsarg@users.noreply.github.com>
Thu, 11 Jun 2026 05:02:42 +0000 (01:02 -0400)
committerAndrew Tridgell <andrew@tridgell.net>
Thu, 11 Jun 2026 06:47:39 +0000 (16:47 +1000)
FreeBSD and OpenBSD return EFTYPE (errno 79) when chmod-ing a sticky bit
onto a regular file as non-root, rather than EPERM/EACCES. Catch OSError
and check errno against the expected skip set so the test skips correctly
on those platforms instead of erroring out.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
testsuite/executability_test.py

index 349dc679b24f4f411331cf2d473cb99159e9fb97..13f7a77e68b7277b818c0ebf2f5954fbea48fd83 100644 (file)
@@ -5,6 +5,7 @@
 # from source to destination (other permission changes ignored), while a
 # normal copy without -E should leave the destination permissions alone.
 
+import errno
 import os
 
 from rsyncfns import FROMDIR, TODIR, check_perms, run_rsync, test_skipped
@@ -15,11 +16,14 @@ FROMDIR.mkdir(parents=True, exist_ok=True)
 (FROMDIR / '2').write_text("#!/bin/sh\necho 'Program Two!'\n")
 
 # Setuid-and-rwx for owner, nothing else. Some platforms reject 1700 for
-# non-root callers (no permission to set sticky); the shell test treats
-# that case as a skip.
+# non-root callers (no permission to set sticky); FreeBSD rejects it with
+# EFTYPE rather than EPERM. Only skip on those; re-raise anything unexpected.
+_STICKY_SKIP_ERRNOS = {errno.EPERM, errno.EACCES, getattr(errno, 'EFTYPE', None)}
 try:
     os.chmod(FROMDIR / '1', 0o1700)
-except PermissionError:
+except OSError as e:
+    if e.errno not in _STICKY_SKIP_ERRNOS:
+        raise
     test_skipped("Can't chmod")
 os.chmod(FROMDIR / '2', 0o600)