
root
사용자~할 수 있다write
권한이 설정되지 않은 경우에도 파일에 쓸 수 있습니다 .
root
사용자~할 수 있다read
권한이 설정되지 않은 경우에도 파일을 읽습니다 .
root
사용자~할 수 있다 cd
execute
권한이 설정되지 않은 경우에도 디렉터리에 저장됩니다 .
root
사용자할 수 없다execute
권한이 설정되지 않은 경우 파일을 실행합니다 .
왜?
user$ echo '#!'$(which bash) > file
user$ chmod 000 file
user$ ls -l file
---------- 1 user user 12 Jul 17 11:11 file
user$ cat file # Normal user cannot read
cat: file: Permission denied
user$ su
root$ echo 'echo hello' >> file # root can write
root$ cat file # root can read
#!/bin/bash
echo hello
root$ ./file # root cannot execute
bash: ./file: Permission denied
답변1
간단히 말해서 실행 비트는 특별한 것으로 간주되기 때문입니다. 설정되어 있지 않으면조금도이면 해당 파일은 실행 파일이 아닌 것으로 간주되어 실행될 수 없습니다.
그러나 실행 비트 중 하나만 설정되어 있어도 루트는 이를 실행할 수 있고 실행할 것입니다.
관찰하다:
caleburn: ~/ >cat hello.sh
#!/bin/sh
echo "Hello!"
caleburn: ~/ >chmod 000 hello.sh
caleburn: ~/ >./hello.sh
-bash: ./hello.sh: Permission denied
caleburn: ~/ >sudo ./hello.sh
sudo: ./hello.sh: command not found
caleburn: ~/ >chmod 100 hello.sh
caleburn: ~/ >./hello.sh
/bin/sh: ./hello.sh: Permission denied
caleburn: ~/ >sudo ./hello.sh
Hello!
답변2
예전에는 , , , 등과 /etc
같은 시스템 관리 도구가 있었습니다 . 을 로 설정 하고 실행 하면 어떤 일이 일어날지 상상해 보십시오 ./etc/restore
/etc/rrestore
/etc/init
/etc/halt
root
PATH
/etc:/bin
root
passwd
제대로 작동하지 않을 것입니다.
설상가상으로 예전에는 바이너리 실행 파일에 매직 헤더가 없었기 때문에 권한 비트를 확인하는 것 외에는 바이너리가 실행 파일인지 확인하는 것이 실제로 불가능했습니다. 그래서 그들은 exec
실제로 파일이 아니고(디렉터리 등이 아닌) 적어도 하나의 실행 비트가 설정된 경우를 제외하고는 * 의 유효한 대상이 아닌 파일을 만들었습니다 .
*사용자 모드 기능인 execvp에서 검사가 수행되었을 수 있습니다.
이론상으로는 무엇이든 쉘 스크립트가 될 수 있으므로 여전히 유용한 검사입니다. 그런데 왜 제거합니까?