我怎样才能改变一个linux套接字文件的权限? [英] how can I change the permissions of a linux socket file?

查看:1199
本文介绍了我怎样才能改变一个linux套接字文件的权限?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有它创建了一个插座程序,然后我想改变套接字文件的权限:

I have a program which creates a socket, and then I want to change the permissions of the socket file:

ret_val = chmod(filename, 0777);

,但它不会改变,即使RET_VAL为0。如果我试图对一个普通文件一样的东西,它的工作原理。

, but it doesn't change, even though ret_val will be 0. If I try the same thing on a regular file, it works.

任何想法?

P.S:我正在运行的程序作为根,所以它具有所有必要的权威

P.S: I am running the program as root, so it has all the authority needed.

推荐答案

人7 UNIX

在Linux实现,插座这是在文件系统中可见
  兑现他们在,他们的所有者目录的权限,
  基和他们的权限是可以改变的。一个新的套接字的创作
  如果进程没有写和搜索(执行)将失败许可的插座中创建的目录。连接到
  插座对象需要读/写权限。此行为不同
  从中忽略权限UNIX域许多BSD衍生系统
  插座。移植程序不应该依赖此功能的安全性。
  

In the Linux implementation, sockets which are visible in the file system honor the permissions of the directory they are in. Their owner, group and their 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.

所以,如果你想控制一个插座上的权限,以手提,您应该控制含有套接字的目录的权限。

So if you want to control permissions on a socket, in order to be portable, you should instead control the permissions of the directory containing the socket.

这篇关于我怎样才能改变一个linux套接字文件的权限?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆