9
9
from __future__ import unicode_literals
10
10
11
11
import argparse
12
+ import logging
12
13
import os
13
14
import shutil
14
15
import socket
@@ -54,17 +55,15 @@ def __init__(self, path=None):
54
55
else :
55
56
self .path = path
56
57
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 ())
61
61
62
62
def __del__ (self ):
63
63
if self .connection is not None :
64
64
self .connection .close ()
65
65
if self .instance is not None :
66
66
self .instance .kill ()
67
- shutil .rmtree (self ._dbpath )
68
67
self .instance .wait ()
69
68
70
69
def open (self , timeout = 2 , interval = 0.01 ):
@@ -79,13 +78,10 @@ def open(self, timeout=2, interval=0.01):
79
78
self .path ,
80
79
"--extensions_socket" ,
81
80
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" ,
87
82
"--disable_watchdog" ,
88
83
"--disable_logging" ,
84
+ "--ephemeral" ,
89
85
"--config_path" ,
90
86
"/dev/null" ,
91
87
]
@@ -133,12 +129,12 @@ def parse_cli_params():
133
129
parser .add_argument (
134
130
"--timeout" ,
135
131
type = int ,
136
- default = 0 ,
132
+ default = 1 ,
137
133
help = "Seconds to wait for autoloaded extensions" )
138
134
parser .add_argument (
139
135
"--interval" ,
140
136
type = int ,
141
- default = 0 ,
137
+ default = 1 ,
142
138
help = "Seconds delay between connectivity checks" )
143
139
parser .add_argument (
144
140
"--verbose" ,
@@ -171,6 +167,10 @@ def start_extension(name="<unknown>", version="0.0.0", sdk_version="1.8.0",
171
167
min_sdk_version -- the minimum version of the osquery SDK that you can use
172
168
"""
173
169
args = parse_cli_params ()
170
+
171
+ # Disable logging for the thrift module (can be loud).
172
+ logging .getLogger ('thrift' ).addHandler (logging .NullHandler ())
173
+
174
174
client = ExtensionClient (path = args .socket )
175
175
if not client .open (args .timeout ):
176
176
return
0 commit comments