File tree Expand file tree Collapse file tree 1 file changed +13
-13
lines changed Expand file tree Collapse file tree 1 file changed +13
-13
lines changed Original file line number Diff line number Diff line change 1919from scapy .config import conf
2020from scapy .data import MTU
2121from scapy .error import Scapy_Exception
22- from scapy .consts import OPENBSD
2322import scapy .modules .six as six
2423
2524if not WINDOWS :
@@ -32,18 +31,19 @@ def _check_tcpdump():
3231 """
3332 Return True if the tcpdump command can be started
3433 """
35- with open (os .devnull , 'wb' ) as devnull :
36- try :
37- proc = subprocess .Popen ([conf .prog .tcpdump , "--version" ],
38- stdout = devnull , stderr = subprocess .STDOUT )
39- except OSError :
40- return False
41-
42- if OPENBSD :
43- # 'tcpdump --version' returns 1 on OpenBSD 6.4
44- return proc .wait () == 1
45- else :
46- return proc .wait () == 0
34+ try :
35+ proc = subprocess .Popen (
36+ [conf .prog .tcpdump , "--version" ],
37+ stdout = subprocess .PIPE ,
38+ stderr = subprocess .STDOUT
39+ )
40+ output = proc .communicate ()[0 ]
41+ except OSError :
42+ return False
43+
44+ # tcpdump acts strangely on some OSes and returns 1
45+ # therefore we also checks the output
46+ return b"tcpdump" in output or proc .returncode == 0
4747
4848
4949# This won't be used on Windows
You can’t perform that action at this time.
0 commit comments