Procházet zdrojové kódy

check_icmp Resolve #451 by moving call to bind() after call to socket()

madlohe před 6 roky
rodič
revize
2d9908b532
1 změnil soubory, kde provedl 6 přidání a 1 odebrání
  1. 6 1
      plugins-root/check_icmp.c

+ 6 - 1
plugins-root/check_icmp.c

@@ -489,6 +489,7 @@ static int handle_random_icmp(unsigned char *packet,
 int main(int argc, char **argv) {
   int i;
   char *ptr;
+  char *bind_address = NULL;
   long int arg;
   int icmp_sockerrno, udp_sockerrno, tcp_sockerrno;
   int result;
@@ -654,7 +655,7 @@ int main(int argc, char **argv) {
 
       case 's':
         /* specify source IP address */
-        set_source_ip(optarg);
+        bind_address = optarg;
         break;
 
       case 'V':
@@ -711,6 +712,10 @@ int main(int argc, char **argv) {
     icmp_sockerrno = errno;
   }
 
+  if (bind_address != NULL) {
+    set_source_ip(bind_address);
+  }
+
   /* now drop privileges (no effect if not setsuid or geteuid() == 0) */
   setuid(getuid());