diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2014-01-09 11:53:26 +0100 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2014-01-09 11:53:26 +0100 |
commit | f0058b1b1fe9f7e69b415616096fb9347f599426 (patch) | |
tree | a76be37a1cf04573d73fca6ed70eb08de4f0fe81 | |
parent | e4569be24488242eb190b379003a9afe789c844b (diff) | |
download | busybox-w32-f0058b1b1fe9f7e69b415616096fb9347f599426.tar.gz busybox-w32-f0058b1b1fe9f7e69b415616096fb9347f599426.tar.bz2 busybox-w32-f0058b1b1fe9f7e69b415616096fb9347f599426.zip |
ping: revert "try SOCK_DGRAM if no root privileges"
It wasn't working, and fixes on top of it would make ping
noticeably larger.
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r-- | networking/ping.c | 19 |
1 files changed, 3 insertions, 16 deletions
diff --git a/networking/ping.c b/networking/ping.c index 5d71fe8cc..5e4771f5a 100644 --- a/networking/ping.c +++ b/networking/ping.c | |||
@@ -168,22 +168,9 @@ create_icmp_socket(void) | |||
168 | #endif | 168 | #endif |
169 | sock = socket(AF_INET, SOCK_RAW, 1); /* 1 == ICMP */ | 169 | sock = socket(AF_INET, SOCK_RAW, 1); /* 1 == ICMP */ |
170 | if (sock < 0) { | 170 | if (sock < 0) { |
171 | if (errno != EPERM) | 171 | if (errno == EPERM) |
172 | bb_perror_msg_and_die(bb_msg_can_not_create_raw_socket); | 172 | bb_error_msg_and_die(bb_msg_perm_denied_are_you_root); |
173 | #if defined(__linux__) || defined(__APPLE__) | 173 | bb_perror_msg_and_die(bb_msg_can_not_create_raw_socket); |
174 | /* We don't have root privileges. Try SOCK_DGRAM instead. | ||
175 | * Linux needs net.ipv4.ping_group_range for this to work. | ||
176 | * MacOSX allows ICMP_ECHO, ICMP_TSTAMP or ICMP_MASKREQ | ||
177 | */ | ||
178 | #if ENABLE_PING6 | ||
179 | if (lsa->u.sa.sa_family == AF_INET6) | ||
180 | sock = socket(AF_INET6, SOCK_DGRAM, IPPROTO_ICMPV6); | ||
181 | else | ||
182 | #endif | ||
183 | sock = socket(AF_INET, SOCK_DGRAM, 1); /* 1 == ICMP */ | ||
184 | if (sock < 0) | ||
185 | #endif | ||
186 | bb_error_msg_and_die(bb_msg_perm_denied_are_you_root); | ||
187 | } | 174 | } |
188 | 175 | ||
189 | xmove_fd(sock, pingsock); | 176 | xmove_fd(sock, pingsock); |