Skip to content

Commit 5f9696f

Browse files
authored
management: Fix socket fd leak (#67)
Additionally, bump the version to 3.0.6.
1 parent 445c22f commit 5f9696f

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

osquery/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"""
55

66
__title__ = "osquery"
7-
__version__ = "3.0.5"
7+
__version__ = "3.0.6"
88
__author__ = "osquery developers"
99
__license__ = "BSD"
1010
__copyright__ = "Copyright 2015 Facebook"

osquery/management.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,6 @@ def __init__(self, path=None):
7171
self.path = LINUX_BINARY_PATH
7272
else:
7373
self.path = path
74-
self._socket = tempfile.mkstemp(prefix="pyosqsock")
7574

7675
# Disable logging for the thrift module (can be loud).
7776
logging.getLogger('thrift').addHandler(logging.NullHandler())
@@ -88,9 +87,16 @@ def __init__(self, path=None):
8887
def __del__(self):
8988
if self.connection is not None:
9089
self.connection.close()
90+
self.connection = None
9191
if self.instance is not None:
9292
self.instance.kill()
9393
self.instance.wait()
94+
self.instance = None
95+
96+
# On macOS and Linux mkstemp opens a descriptor.
97+
if self._socket is not None and self._socket[0] is not None:
98+
os.close(self._socket[0])
99+
self._socket = None
94100

95101
def open(self, timeout=2, interval=0.01):
96102
"""

0 commit comments

Comments
 (0)