V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
Distributions
Ubuntu
Fedora
CentOS
中文资源站
网易开源镜像站
vencentge
V2EX  ›  Linux

关于 A 用户设置的符号链接, B 用户无法访问的问题

  •  
  •   vencentge · 2020-04-10 21:48:10 +08:00 · 2223 次点击
    这是一个创建于 1482 天前的主题,其中的信息可能已经有所发展或是发生改变。

    image.png 如上图所示,造成这个原因是什么啊

    8 条回复    2020-04-11 15:48:47 +08:00
    liuxu
        1
    liuxu  
       2020-04-10 21:57:26 +08:00
    google 一下你就知道了。权限在 inode 里,软连接只是指向了文件的 inode,然后读取 passwd 的 inode 里面的权限数据,你这用户的权限没有
    vencentge
        2
    vencentge  
    OP
       2020-04-10 22:00:08 +08:00
    @liuxu 可是我两个用户,都是能直接读取到 /etc/passwd 这样的文件,具备你说的用户读取权限吧。
    choury
        3
    choury  
       2020-04-10 23:11:01 +08:00
    strace cat xxx
    看下什么错误不就知道了
    cnt2ex
        4
    cnt2ex  
       2020-04-11 00:27:51 +08:00
    似乎是和目录的 sticky bits 有关。

    https://lwn.net/Articles/390565/

    The solution is to permit symlinks to only be followed when outside a sticky world-writable directory, or when the uid of the symlink and follower match, or when the directory owner matches the symlink's owner.
    cnt2ex
        5
    cnt2ex  
       2020-04-11 00:32:02 +08:00   ❤️ 1
    /proc/sys/fs/protected_symlinks
    把值改成 0 就可以了。具体可以看
    https://www.kernel.org/doc/Documentation/sysctl/fs.txt
    liuxu
        6
    liuxu  
       2020-04-11 08:31:34 +08:00
    你把 passwd 权限贴出来
    vencentge
        7
    vencentge  
    OP
       2020-04-11 15:45:34 +08:00
    @cnt2ex 正解,非常感谢。
    vencentge
        8
    vencentge  
    OP
       2020-04-11 15:48:47 +08:00
    这是修改为 1 的演示
    ![image.png]( https://i.loli.net/2020/04/11/RWjnurzai9SwlVE.png)
    这是修改 0 的演示
    ![image.png]( https://i.loli.net/2020/04/11/USvD9FfczAPx1Ya.png)
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   2219 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 25ms · UTC 02:27 · PVG 10:27 · LAX 19:27 · JFK 22:27
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.