root로 충분한 권한을 가졌음에도 파일에 대한 write permission이 없는 경우가 있다.
su max
touch /tmp/test.txt
chmod 777 /tmp/test.txt
su root
chown max:root /tmp/test.txt
# ls -l /tmp/test.txt
-rwxrwxrwx 1 max root 0 26. Feb 12:08 test.txt
# echo "foobar" > /tmp/test.txt
bash: /tmp/test.txt: Permission denied
Disallows open of FIFOs or regular files not owned by the user in world writable sticky directories, unless the owner is the same as that of the directory or the file is opened without the O_CREAT flag. The purpose is to make data spoofing attacks harder. .
검색을 해보니 fs.protected_regular 값에 따라 동작이 달라질 것으로 보인다.
sysctl fs.protected_regular=0
$ su - root
# sysctl fs.protected_regular
fs.protected_regular = 1
# cd /
# mkdir test
# chmod 1777 test
# su - otheruser
$ echo hello >/test/somefile
$ exit
logout
# cat /test/somefile
hello
# ls -lah test/somefile
-rw-r--r-- 1 otheruser otheruser 6 Feb 26 17:21 test/somefile
# echo root >>test/somefile
-bash: test/somefile: Permission denied
# sysctl fs.protected_regular=0
fs.protected_regular = 0
# echo root >>test/somefile
# cat /test/somefile
hello
root
# sysctl fs.protected_regular=1
fs.protected_regular = 1
# echo root >>test/somefile
-bash: test/somefile: Permission denied
# chmod 0777 /test/
# echo root >>test/somefile
# cat test/somefile
hello
root
root
하기 링크 참조..
https://unix.stackexchange.com/questions/691441/root-cannot-write-to-file-that-is-owned-by-regular-user
https://unix.stackexchange.com/questions/503111/group-permissions-for-root-not-working-in-tmp
'linux' 카테고리의 다른 글
gst와 omx IL의 관계 (0) | 2022.11.03 |
---|---|
KMS, DRM, DRI 에 대한 개요 (0) | 2022.09.10 |
wayland, x-server 관련 (0) | 2022.09.10 |
GPL ko(kernel object) 배포 관련 (0) | 2022.09.10 |
GPL 관련 tip (0) | 2022.09.10 |