Greetings, On Wednesday, 2022-03-09 19:28:49 +0100, I myself wrote:
> ... > until recently my system behaves sort of strangely: > > $ touch /tmp/file > $ ls -l /tmp/file > -rw------- 1 rainer rainer 0 2022-03-09 19:06 /tmp/file > $ echo x | sudo tee /tmp/file > Password: > tee: /tmp/file: Permission denied > x > $ chmod a+w /tmp/file > $ ls -l /tmp/file > -rw--w--w- 1 rainer rainer 0 2022-03-09 19:06 /tmp/file > $ echo x | sudo tee /tmp/file > tee: /tmp/file: Permission denied > x > $ > > Since when can't root write to files it doesn't own? And not even, if > the file has write permission for everybody? Turns out it's not a bug but a feature, more precisely a security feat- ure. Its purpose is to prevent an unprivileged local user from luring user "root" into writing possibly sensitive information to an already existing file owned by and thus accessible to the local attacker. This protection feature was introduced as an option deactivated by def- ault way back in some 4.* kernel, and somewhere between kernels 5.15.19 and 5.15.26 the default was changed to on. If you want or have to, you can again disable this feature at runtime using # sysctl fs.protected_regular=0 or permanently from the next boot onwards via # echo fs.protected_regular = 0 >> /etc/sysctl.d/local.conf Personally, I've decided to again boot kernel 5.15.26, to leave the new default setting (even on my laptop), and to adapt my script which had problems with this new behaviour accordingly. Your milage may vary. Sincerely, Rainer