sendto permission denied, 为什么?

ajige 2012-08-18 03:35:17
写了一个简单的 unix 域通信的程序, 是按照 unix网络编程的格式写的,点对点通信,一个用作client 一个用作server。用的是datagram 方式的socket。
但运行时,client向server发包时, 总是提示错误 sendto permission denied.

求助,非常急。。。
...全文
1146 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
qq120848369 2012-08-18
  • 打赏
  • 举报
回复
In the Linux implementation, sockets which are visible in the filesystem honour 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 sockets. Portable programs should not rely on this feature for security.
ajige 2012-08-18
  • 打赏
  • 举报
回复
弄了一下午,原来是程序里 有一段代码 调用了setguid, 改变了用户的权限。
我不明白为什么程序里要调用 setguid 呢
fdl19881 2012-08-18
  • 打赏
  • 举报
回复
unix域使用了一个文件作为其中介(当然数据流并不存在文件中,只是作为了一种标识和权限控制方法)
所以,你使用ls -l命令看下那个unix域中对应的文件的所属用户ID,组ID,,及权限。
你既然是使用的root用户运行的。
那么这个文件不管是什么属主你都是应试有权限的,,
但是:
若属主,和组ID都 为root:root,
若此时用户权限没有写权限,则可能你发送不成功。如
ls -l unixfile
-r--rw-r-- root root unixfile
但root没有写权限。
使用chmod更改下吧。
ajige 2012-08-18
  • 打赏
  • 举报
回复
就是用 root 运行的
morris88 2012-08-18
  • 打赏
  • 举报
回复
用 root 用户运行

23,125

社区成员

发帖
与我相关
我的任务
社区描述
Linux/Unix社区 应用程序开发区
社区管理员
  • 应用程序开发区社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧