Aho,
On Friday, 2022-03-11 10:17:13 +0100, you wrote:
> ...
> I think Rainer's problem is the nosuid mount flag on his /tmp
>
> $ mount | grep \/tmp
> tmpfs on /tmp type tmpfs (rw,nosuid,nodev,noatime,size=3212160k,inode64)
>
> So if he would run the command against a file not located in /tmp I
> think it would work, at least it does for me as it's only /tmp that has
> nosuid.
No. My "/tmp/" directory is not mounted at all, it is just a genuine
directory in "/". And that root CAN overwrite a file it doesn't own in
other directories, is due to most directories not having the sticky bit
set (which is a (wanted) particularity of "/tmp/" and "/var/tmp/", in
that it prevents normal users from (re)moving other people's files):
$ ls -ld / /tmp /var/tmp
drwxr-xr-x 21 root root 4096 2021-01-25 12:17 /
drwxrwxrwt 10 root root 69632 2022-03-11 12:16 /tmp
drwxrwxrwt 3 root root 4096 2022-03-10 10:23 /var/tmp
$
^
This "t" indicates a set sticky bit.
Sincerely,
Rainer