To run some tests, I want to revoke write permissions for a folder. This is a minimal example:
$ mkdir test
$ chmod a-w test
$ touch test/test || printf '%s\n' "write permissions successfully revoked"
touch: cannot touch 'test/test': Permission denied
write permissions successfully revoked
However, if I run it with fakeroot, this doesn't work:
$ fakeroot sh
# mkdir test
# chmod a-w test
# touch test/test || printf '%s\n' "write permissions successfully revoked"
# ls test
test
For an explanation why this doesn't work, see this question, for example: Issue with changing permissions
However, my question is: how can I get around this? Can I temporarily disable fakeroot for the chmod command? Or can I make fakeroot permission changes permanent anyway?