Skip to content

Commit 2bc42e7

Browse files
committed
Fix tcpdump detection
1 parent 0c3d5e4 commit 2bc42e7

File tree

1 file changed

+13
-13
lines changed

1 file changed

+13
-13
lines changed

scapy/arch/common.py

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
from scapy.config import conf
2020
from scapy.data import MTU
2121
from scapy.error import Scapy_Exception
22-
from scapy.consts import OPENBSD
2322
import scapy.modules.six as six
2423

2524
if 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

0 commit comments

Comments
 (0)