首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >当cd对符号链接的权限被拒绝时,/tmp中的dir为700,由普通用户拥有

当cd对符号链接的权限被拒绝时,/tmp中的dir为700,由普通用户拥有
EN

Unix & Linux用户
提问于 2019-03-21 17:36:46
回答 1查看 1.1K关注 0票数 4

问题:

为什么当我能够切换到目录本身时,我不能以root用户的身份cd到一个拥有700个权限的符号链接目录中呢?

示例:

代码语言:javascript
复制
ttucker@plato:/tmp# uname -a
Linux plato 4.4.0-140-generic #166~14.04.1-Ubuntu SMP Sat Nov 17 01:52:43 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux

ttucker@plato:/tmp$ whoami
ttucker
ttucker@plato:/tmp$ mkdir -v test_dir
mkdir: created directory ‘test_dir’
ttucker@plato:/tmp$ chmod -v 700 test_dir
mode of ‘test_dir’ changed from 0775 (rwxrwxr-x) to 0700 (rwx------)
ttucker@plato:/tmp$ ln -s -v test_dir/ test_sym
‘test_sym’ -> ‘test_dir/’
ttucker@plato:/tmp$ ls -ld test_*
drwx------ 2 ttucker ttucker 4096 Mar 21 10:29 test_dir
lrwxrwxrwx 1 ttucker ttucker    9 Mar 21 10:29 test_sym -> test_dir/

ttucker@plato:/tmp$ sudo su -
root@plato:~# whoami
root
root@plato:~# cd /tmp/test_sym/
-su: cd: /tmp/test_sym/: Permission denied
root@plato:~# cd /tmp/test_dir/
root@plato:/tmp/test_dir# pwd
/tmp/test_dir

其他信息:

这也发生在红帽上。

EN

回答 1

Unix & Linux用户

发布于 2019-03-21 17:40:07

我在这里找不到答案,所以我想把这个放在这里给其他人。

答案:

这里的行为取决于/proc/sys/fs/受保护_符号链接的设置。

代码语言:javascript
复制
root@plato:/tmp# cat /proc/sys/fs/protected_symlinks 
1

还请参见:

RedHat Bug 1034239 - root不能遵从其他用户拥有的符号链接

https://bugzilla.redhat.com/show_bug.cgi?id=1034239

票数 5
EN
页面原文内容由Unix & Linux提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://unix.stackexchange.com/questions/507781

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档