Distributions
Ubuntu
Fedora
CentOS
中文资源站
网易开源镜像站
vencentge
V2EX  ›  Linux

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

  •  
  •   vencentge · Apr 10, 2020 · 3025 views
    This topic created in 2247 days ago, the information mentioned may be changed or developed.

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

    8 replies    2020-04-11 15:48:47 +08:00
    liuxu
        1
    liuxu  
       Apr 10, 2020
    google 一下你就知道了。权限在 inode 里,软连接只是指向了文件的 inode,然后读取 passwd 的 inode 里面的权限数据,你这用户的权限没有
    vencentge
        2
    vencentge  
    OP
       Apr 10, 2020
    @liuxu 可是我两个用户,都是能直接读取到 /etc/passwd 这样的文件,具备你说的用户读取权限吧。
    choury
        3
    choury  
       Apr 10, 2020
    strace cat xxx
    看下什么错误不就知道了
    cnt2ex
        4
    cnt2ex  
       Apr 11, 2020
    似乎是和目录的 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  
       Apr 11, 2020   ❤️ 1
    /proc/sys/fs/protected_symlinks
    把值改成 0 就可以了。具体可以看
    https://www.kernel.org/doc/Documentation/sysctl/fs.txt
    liuxu
        6
    liuxu  
       Apr 11, 2020
    你把 passwd 权限贴出来
    vencentge
        7
    vencentge  
    OP
       Apr 11, 2020
    @cnt2ex 正解,非常感谢。
    vencentge
        8
    vencentge  
    OP
       Apr 11, 2020
    这是修改为 1 的演示
    ![image.png]( https://i.loli.net/2020/04/11/RWjnurzai9SwlVE.png)
    这是修改 0 的演示
    ![image.png]( https://i.loli.net/2020/04/11/USvD9FfczAPx1Ya.png)
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   2879 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 33ms · UTC 04:36 · PVG 12:36 · LAX 21:36 · JFK 00:36
    ♥ Do have faith in what you're doing.