From bbb3263003ac271caff1f9dfce979b03d0209532 Mon Sep 17 00:00:00 2001 From: Teddy Reed Date: Sun, 28 May 2017 17:50:48 -0700 Subject: [PATCH] Disable thrift module logging (#35) --- osquery/__init__.py | 2 +- osquery/management.py | 24 ++++++++++++------------ 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/osquery/__init__.py b/osquery/__init__.py index 9361d77..5768502 100644 --- a/osquery/__init__.py +++ b/osquery/__init__.py @@ -4,7 +4,7 @@ """ __title__ = "osquery" -__version__ = "2.2.0" +__version__ = "2.2.1" __author__ = "osquery developers" __license__ = "BSD" __copyright__ = "Copyright 2015 Facebook" diff --git a/osquery/management.py b/osquery/management.py index eebbd3c..a63fce3 100644 --- a/osquery/management.py +++ b/osquery/management.py @@ -9,6 +9,7 @@ from __future__ import unicode_literals import argparse +import logging import os import shutil import socket @@ -54,17 +55,15 @@ def __init__(self, path=None): else: self.path = path self._socket = tempfile.mkstemp(prefix="pyosqsock") - self._pidfile = tempfile.mkstemp(prefix="pyosqpid") - with open(self._pidfile[1], "w") as fh: - fh.write("100000") - self._dbpath = tempfile.mkdtemp(prefix="pyoqsdb") + + # Disable logging for the thrift module (can be loud). + logging.getLogger('thrift').addHandler(logging.NullHandler()) def __del__(self): if self.connection is not None: self.connection.close() if self.instance is not None: self.instance.kill() - shutil.rmtree(self._dbpath) self.instance.wait() def open(self, timeout=2, interval=0.01): @@ -79,13 +78,10 @@ def open(self, timeout=2, interval=0.01): self.path, "--extensions_socket", self._socket[1], - "--database_path", - # This is a temporary directory, there is not FD tuple. - self._dbpath, - "--pidfile", - self._pidfile[1], + "--disable_database", "--disable_watchdog", "--disable_logging", + "--ephemeral", "--config_path", "/dev/null", ] @@ -133,12 +129,12 @@ def parse_cli_params(): parser.add_argument( "--timeout", type=int, - default=0, + default=1, help="Seconds to wait for autoloaded extensions") parser.add_argument( "--interval", type=int, - default=0, + default=1, help="Seconds delay between connectivity checks") parser.add_argument( "--verbose", @@ -171,6 +167,10 @@ def start_extension(name="", version="0.0.0", sdk_version="1.8.0", min_sdk_version -- the minimum version of the osquery SDK that you can use """ args = parse_cli_params() + + # Disable logging for the thrift module (can be loud). + logging.getLogger('thrift').addHandler(logging.NullHandler()) + client = ExtensionClient(path=args.socket) if not client.open(args.timeout): return