Saturday, May 4, 2024
25
rated 0 times [  25] [ 0]  / answers: 1 / hits: 6874  / 2 Years ago, thu, december 23, 2021, 4:00:49

In Ubuntu 18.04, I can create a file as one user in /tmp, and write to it as user root (despite the sticky bit being set on /tmp).


In Ubuntu 20.04, I get a Permission Denied error as user root.


Ubuntu 18.04:


# As user "ubuntu":
touch /tmp/tmplock

# As user "root":
echo "foo" > /tmp/tmplock

cat /tmp/tmplock
# Outputs "foo"

ls -lah /tmp
drwxrwxrwt 32 root root 20K Jun 16 18:36 .
-rw-rw-r-- 1 ubuntu ubuntu 4 Jun 16 18:36 tmplock

Ubuntu 20.04:


# As user "ubuntu":
touch /tmp/tmplock

# As user "root":
echo "foo" > /tmp/tmplock
# Outputs: bash: /tmp/tmplock: Permission denied

ls -lah /tmp
drwxrwxrwt 12 root root 4.0K Jun 16 18:15 .
-rw-rw-r-- 1 ubuntu ubuntu 0 Jun 16 18:14 tmplock

I can't find any information on if this is related to the sticky bit, or an underlying Linux kernel change, or anything.


Does anyone know what can explain the change in behavior?


More From » command-line

 Answers
7

To change the behavior back to the 18.04 default:


sudo sysctl fs.protected_regular=0  

See the accepted answer to


https://unix.stackexchange.com/questions/503111/group-permissions-for-root-not-working-in-tmp


Sigh, sometimes the cure is worse than the disease.


[#3193] Friday, December 24, 2021, 2 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
rowbris

Total Points: 419
Total Questions: 122
Total Answers: 101

Location: Norway
Member since Mon, May 23, 2022
2 Years ago
;