99from __future__ import unicode_literals
1010
1111import argparse
12+ import logging
1213import os
1314import shutil
1415import socket
@@ -54,17 +55,15 @@ def __init__(self, path=None):
5455 else :
5556 self .path = path
5657 self ._socket = tempfile .mkstemp (prefix = "pyosqsock" )
57- self ._pidfile = tempfile .mkstemp (prefix = "pyosqpid" )
58- with open (self ._pidfile [1 ], "w" ) as fh :
59- fh .write ("100000" )
60- self ._dbpath = tempfile .mkdtemp (prefix = "pyoqsdb" )
58+
59+ # Disable logging for the thrift module (can be loud).
60+ logging .getLogger ('thrift' ).addHandler (logging .NullHandler ())
6161
6262 def __del__ (self ):
6363 if self .connection is not None :
6464 self .connection .close ()
6565 if self .instance is not None :
6666 self .instance .kill ()
67- shutil .rmtree (self ._dbpath )
6867 self .instance .wait ()
6968
7069 def open (self , timeout = 2 , interval = 0.01 ):
@@ -79,13 +78,10 @@ def open(self, timeout=2, interval=0.01):
7978 self .path ,
8079 "--extensions_socket" ,
8180 self ._socket [1 ],
82- "--database_path" ,
83- # This is a temporary directory, there is not FD tuple.
84- self ._dbpath ,
85- "--pidfile" ,
86- self ._pidfile [1 ],
81+ "--disable_database" ,
8782 "--disable_watchdog" ,
8883 "--disable_logging" ,
84+ "--ephemeral" ,
8985 "--config_path" ,
9086 "/dev/null" ,
9187 ]
@@ -133,12 +129,12 @@ def parse_cli_params():
133129 parser .add_argument (
134130 "--timeout" ,
135131 type = int ,
136- default = 0 ,
132+ default = 1 ,
137133 help = "Seconds to wait for autoloaded extensions" )
138134 parser .add_argument (
139135 "--interval" ,
140136 type = int ,
141- default = 0 ,
137+ default = 1 ,
142138 help = "Seconds delay between connectivity checks" )
143139 parser .add_argument (
144140 "--verbose" ,
@@ -171,6 +167,10 @@ def start_extension(name="<unknown>", version="0.0.0", sdk_version="1.8.0",
171167 min_sdk_version -- the minimum version of the osquery SDK that you can use
172168 """
173169 args = parse_cli_params ()
170+
171+ # Disable logging for the thrift module (can be loud).
172+ logging .getLogger ('thrift' ).addHandler (logging .NullHandler ())
173+
174174 client = ExtensionClient (path = args .socket )
175175 if not client .open (args .timeout ):
176176 return
0 commit comments