gpt4 book ai didi

sockets - unix 域套接字 - 保护接收器

转载 作者:行者123 更新时间:2023-12-03 11:49:29 25 4
gpt4 key购买 nike

我正在学习 tutorial在 unix 域套接字上。我有一个关于接收器部分的问题。

如果进程正在使用 listen() 并等待传入​​请求:

  • 它有哪些选择来确保自身安全?有没有办法识别谁发送了请求?它可以对谁可以向它发送请求施加一些限制吗?
  • 是否有没有安全选项的情况,如果一个进程使用 listen() 它对任何请求完全开放?
  • 最佳答案

    Linux 上的一般想法是安全性是通过文件系统中 UNIX 套接字"file"上的文件权限来强制执行的。进程必须具有对套接字特殊文件的读/写访问权限。

    unix(7) man page表示:

    In the Linux implementation, sockets which are visible in the filesystem honor the permissions of the directory they are in. Their owner, group, and permissions can be changed. Creation of a new socket will fail if the process does not have write and search (execute) permission on the directory the socket is created in. Connecting to the socket object requires read/write permission. This behavior differs from many BSD-derived systems which ignore permissions for UNIX domain sockets. Portable programs should not rely on this feature for security.



    不过,似乎目录搜索权限在任何地方都受到尊重。所以你的socket只能是 connect()由对您的套接字特殊文件的整个路径具有执行访问权限的用户编辑 - 在所有操作系统上都是如此。

    相关:
  • Can UNIX Domain Sockets be locked by user ID?
  • Which systems do not honor socket read/write permissions?
  • 关于sockets - unix 域套接字 - 保护接收器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28776502/

    25 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com