3 unix
假设我有一个目录,除了 root 之外,任何人都无法访问。我是否保证目录中的所有内容对除 root 之外的所有人都无法访问?换句话说,文件权限是分层的,所以如果用户不能访问目录,他们就不能访问其中的任何内容,即使他们对目录中的某些内容有权限?
Wiile 的回答大多是“是”,在某些特殊情况下可以是“否”。
因为不能保证 unix 文件具有唯一路径。所以如果你有
$ ls -l
drwx------- 1 root root [...] root_only
Run Code Online (Sandbox Code Playgroud)
和
$ ls -l root_only
-rw-rw-rw-- 2 root root [...] hopefully_private_file
Run Code Online (Sandbox Code Playgroud)
并且hopefully_private_file
从其他地方硬链接它可能是普遍可读的。
你怎么知道的?再看看那个ls -l
:
$ ls -l root_only
-rw-rw-rw-- 2 root root [...] hopefully_private_file
^
|
Run Code Online (Sandbox Code Playgroud)
箭头上的数字是链接数(对于文件,它对目录有不同的含义)。如果链接数为 1,则您是安全的;如果是别的东西,可能有问题。