0

As root run:

cd /tmp
seq 10 > foo
chmod 666 foo
seq 10 >> foo
chown daemon foo
seq 10 >> foo

This gives:

-bash: foo: Permission denied

It is clear that it is due to /tmp's special permission (drwxrwxrwt), because it works fine in /tmp/bardir.

But why? Should the group ownership and permission not allow root to append to the file?

$ ls -l foo
-rw-rw-rw- 1 daemon root 42 Dec  6 09:11 foo
$ lsattr foo
-------------------- foo
$ ls -ld /tmp
drwxrwxrwt 34 root root 137 Dec  6 09:11 /tmp
$ lsattr -d /tmp
-------------------- /tmp
Ole Tange
  • 35,514
  • Is SELinux enabled? – Nasir Riley Dec 06 '20 at 08:28
  • @NasirRiley Not that I know of. It is a normal Ubuntu 20.04, and I have not actively installed SELinux. – Ole Tange Dec 06 '20 at 08:39
  • 1
    The behavior has been changed in Ubuntu 20.04. The same doesn't occur in Debian 10 (Buster) or CentOS 8.2. To set it back to what it was in Ubuntu 18.04, use this answer: https://askubuntu.com/questions/1250974/user-root-cant-write-to-file-in-tmp-owned-by-someone-else-in-20-04-but-can-in – Nasir Riley Dec 06 '20 at 09:09

0 Answers0