Subject: [PATCH] ping: Wrap SO_BINDTODEVICE with the correct capability.

From: Jan Synacek <[email-masked]>
Date: Mon, 12 Nov 2012 14:11:12 +0100

Signed-off-by: Jan Synacek <[email-masked]>
---
 ping.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/ping.c b/ping.c
index 2f70cec..c958f1a 100644
--- a/ping.c
+++ b/ping.c
@@ -316,6 +316,9 @@ main(int argc, char **argv)
 			struct ifreq ifr;
 			memset(&ifr, 0, sizeof(ifr));
 			strncpy(ifr.ifr_name, device, IFNAMSIZ-1);
+
+			enable_capability_raw();
+
 			if (setsockopt(probe_fd, SOL_SOCKET, SO_BINDTODEVICE, device,
strlen(device)+1) == -1) {
 				if (IN_MULTICAST(ntohl(dst.sin_addr.s_addr))) {
 					struct ip_mreqn imr;
@@ -331,6 +334,8 @@ main(int argc, char **argv)
 					}
 				}
 			}
+
+			disable_capability_raw();
 		}

 		if (settos &&
-- 
1.7.11.7