unix 域套接字 - 保护接收器

unix domain socket - securing receiver

我正在研究一个关于 unix 域套接字的 tutorial。我对接收器部分有疑问。

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

关于 Linux 的一般想法是,安全性是由文件系统中 UNIX 套接字 "file" 上的文件权限强制执行的。进程必须 read/write 访问套接字特殊文件。

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.

不过,似乎目录搜索权限 无处不在。因此,您的套接字只能由对套接字专用文件的整个路径具有执行权限的用户 connect() 编辑 - 这在所有操作系统上都是如此。

相关: