Fping 不适用于退出代码 4。
鉴于:
$ fping 8.8.8.8
$
$ echo $?
4
$ fping -h
$ echo $?
4
然后在 fping 代码中注释一些与 if-s 相关的详细标志,构建它并查看:
./build/usr/local/sbin/fping: icmp: unknown protocol
斯特雷斯:
execve("/usr/bin/fping", ["fping", "ya.ru"], 0xbec606ec /* 23 vars */) = 0
brk(NULL) = 0x1268000
uname({sysname="Linux", nodename="blablabla.com", ...}) = 0
access("/etc/ld.so.nohwcap", F_OK) = -1 ENOENT (No such file or directory)
mmap2(NULL, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xb6f8c000
access("/etc/ld.so.preload", R_OK) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/etc/ld.so.cache", O_RDONLY|O_CLOEXEC) = 3
fstat64(3, {st_mode=S_IFREG|0644, st_size=40040, ...}) = 0
mmap2(NULL, 40040, PROT_READ, MAP_PRIVATE, 3, 0) = 0xb6f82000
close(3) = 0
access("/etc/ld.so.nohwcap", F_OK) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/lib/arm-linux-gnueabihf/libc.so.6", O_RDONLY|O_CLOEXEC) = 3
read(3, "\177ELF\1\1\1\3\0\0\0\0\0\0\0\0\3\0(\0\1\0\0\0\371p\1\0004\0\0\0"..., 512) = 512
_llseek(3, 944172, [944172], SEEK_SET) = 0
read(3, "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 3000) = 3000
_llseek(3, 937548, [937548], SEEK_SET) = 0
read(3, "A4\0\0\0aeabi\0\1*\0\0\0\0057-A\0\6\n\7A\10\1\t\2\n\3\f"..., 53) = 53
fstat64(3, {st_mode=S_IFREG|0755, st_size=947172, ...}) = 0
mmap2(NULL, 1013128, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0xb6e6e000
mprotect(0xb6f50000, 65536, PROT_NONE) = 0
mmap2(0xb6f60000, 12288, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0xe2000) = 0xb6f60000
mmap2(0xb6f63000, 9608, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0xb6f63000
close(3) = 0
set_tls(0xb6f8cdd0) = 0
mprotect(0xb6f60000, 8192, PROT_READ) = 0
mprotect(0x515000, 4096, PROT_READ) = 0
mprotect(0xb6f8e000, 4096, PROT_READ) = 0
munmap(0xb6f82000, 40040) = 0
brk(NULL) = 0x1268000
brk(0x1289000) = 0x1289000
openat(AT_FDCWD, "/etc/nsswitch.conf", O_RDONLY|O_CLOEXEC) = 3
fstat64(3, {st_mode=S_IFREG|0644, st_size=627, ...}) = 0
read(3, "# /etc/nsswitch.conf\n#\n# Example"..., 4096) = 627
read(3, "", 4096) = 0
close(3) = 0
openat(AT_FDCWD, "/etc/ld.so.cache", O_RDONLY|O_CLOEXEC) = 3
fstat64(3, {st_mode=S_IFREG|0644, st_size=40040, ...}) = 0
mmap2(NULL, 40040, PROT_READ, MAP_PRIVATE, 3, 0) = 0xb6f82000
close(3) = 0
access("/etc/ld.so.nohwcap", F_OK) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/lib/arm-linux-gnueabihf/libnss_compat.so.2", O_RDONLY|O_CLOEXEC) = 3
read(3, "\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0(\0\1\0\0\0\254\r\0\0004\0\0\0"..., 512) = 512
_llseek(3, 21220, [21220], SEEK_SET) = 0
read(3, "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., 1080) = 1080
_llseek(3, 20892, [20892], SEEK_SET) = 0
read(3, "A2\0\0\0aeabi\0\1(\0\0\0\0057-A\0\6\n\7A\10\1\t\2\n\4\22"..., 51) = 51
fstat64(3, {st_mode=S_IFREG|0644, st_size=22300, ...}) = 0
mmap2(NULL, 87672, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0xb6e58000
mprotect(0xb6e5d000, 61440, PROT_NONE) = 0
mmap2(0xb6e6c000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x4000) = 0xb6e6c000
close(3) = 0
mprotect(0xb6e6c000, 4096, PROT_READ) = 0
munmap(0xb6f82000, 40040) = 0
exit_group(4) = ?
+++ exited with 4 +++
答案1
这与进程能力和文件权限无关(例如互联网上到处提到的 setuid 位)。此外,这不涉及任何防火墙规则、ICMP 阻止或类似的东西。而且您的内核显然知道什么是 ICMP。例如:
$ sysctl net.ipv4 | grep icmp | wc -l
8
和
$ grep ICMP /etc/protocols
icmp 1 ICMP # internet control message protocol
可以看到有nsswitch.conf被打开并读取,libnss_compat.so.2也是如此,然后进程退出。打开nsswitch.conf,看到:
protocols: compat
services: compat
旧版模拟选项,某些发行版的默认选项。将它们更改为文件。
现在
$ fping 8.8.8.8
8.8.8.8 is alive