Japin

登高必自卑,行远必自迩

今天在 CentOS 上遇到一个奇怪的问题,ping 程序在 root 用户下能正常使用,但是在非 root 用户下则出现如下错误:

1
2
user@host:~ $ ping 127.0.0.1
ping: socket: Permission denied

在 StackExchage 上也有人遇到了类似的问题,他需要在 PHP 中调用 ping 命令,并且他通过执行 setenforce 0 可以让 ping 命令正常使用,但是经我测试发现这种方法对我无效。

之后在 LinuxQuestions 上发现有人指出 ping 命名将创建原始套接字而非 TCP 套接字,然而 Linux 系统对于普通用户创建原开套接字是禁止的,因此我们就看到了文章开始的错误,针对这一问题他也提出了解决方案,即为 ping 命令添加 suid 权限。

1
2
3
user@host:~ $ chmod +s /bin/ping
user@host:~ $ ls -al /bin/ping
-rwsr-xr-x 1 root root 64424 Mar 10 2017 /bin/ping
阅读全文 »

Welcome to Hexo! This is your very first post. Check documentation for more info. If you get any problems when using Hexo, you can find the answer in troubleshooting or you can ask me on GitHub.

Quick Start

Create a new post

1
$ hexo new "My New Post"

More info: Writing

Run server

1
$ hexo server

More info: Server

Generate static files

1
$ hexo generate

More info: Generating

Deploy to remote sites

1
$ hexo deploy

More info: Deployment

0%