From c5faae4b26390fcedebd1ac2646f868a81eef6bf Mon Sep 17 00:00:00 2001 From: david Date: Wed, 3 Oct 2012 15:43:24 +0000 Subject: [PATCH] Call socket_bindtodevice for -sT scan. --- scan_engine.cc | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/scan_engine.cc b/scan_engine.cc index 3725be5cd..ba998650f 100644 --- a/scan_engine.cc +++ b/scan_engine.cc @@ -2978,7 +2978,8 @@ static void ultrascan_port_probe_update(UltraScanInfo *USI, HostScanStats *hss, /* Set the socket lingering so we will RST connections instead of wasting - bandwidth with the four-step close. Set the source address if needed. */ + bandwidth with the four-step close. Set the source address if needed. Bind to + a specific interface if needed. */ static void init_socket(int sd) { static int bind_failed = 0; struct linger l; @@ -3000,6 +3001,14 @@ static void init_socket(int sd) { bind_failed = 1; } } + errno = 0; + if (!socket_bindtodevice(sd, o.device)) { + /* EPERM is expected when not running as root. */ + if (errno != EPERM) { + error("Problem binding to interface %s, errno: %d", o.device, socket_errno()); + perror("socket_bindtodevice"); + } + } } /* If this is NOT a ping probe, set pingseq to 0. Otherwise it will be the