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 19
19
from scapy .config import conf
20
20
from scapy .data import MTU
21
21
from scapy .error import Scapy_Exception
22
- from scapy .consts import OPENBSD
23
22
import scapy .modules .six as six
24
23
25
24
if not WINDOWS :
@@ -32,18 +31,19 @@ def _check_tcpdump():
32
31
"""
33
32
Return True if the tcpdump command can be started
34
33
"""
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
47
47
48
48
49
49
# This won't be used on Windows
You can’t perform that action at this time.
0 commit comments