On 20/02/2026 03:16, Collin Funk wrote:
It probably isn't super clear what this test case is for, so here is a more obvious example:$ stat --format=%U / root $ id -un collin $ chmod = / chmod: changing permissions of '/': Operation not permitted
For ref that was previously discussed at: http://bugs.debian.org/497514 We don't make this a noop as there can be ACL clearing side effects. Also there are TOCTOU issues with doing this in userspace.
If one tries to skip calling chmod(2) because the file mode bits are unchanged, they will get the incorrect behavior. That obviously wouldn't work when the tests are run as root, so I think that 'strace' is the best way to test this.
+print_ver_ chmod +uses_strace_ +getlimits_ + +echo 'hello' > file || framework_failure_ + +cat <<EOF > exp || framework_failure_ +chmod: changing permissions of 'file': $EPERM +EOF + +for op in '+' '-' '='; do + returns_ 1 strace -o /dev/null -P file -e quiet=path-resolution \ + -e '/f?chmod' -e fault=all:error=EPERM chmod "$op" file 2>err \ + || fail=1 + compare exp err || fail=1 +done
I don't think this would get EPERM on AIX, or if strace is not installed? I'm thinking not using strace and just using skip_if_root_ would be safer anyway. We don't need this to run as root so it's fine to skip in that edge case. You could also: test "$(stat --format=%U /)" = 'root' || skip_ ... for extra safety. thanks, Padraig
