Support initializing IO pipes with specific permissions

This commit is contained in:
Kristóf Tóth 2019-05-04 21:10:05 +02:00
parent 065aa56182
commit f94d571d19

View File

@ -9,9 +9,14 @@ LOG = logging.getLogger(__name__)
class PipeIOEventHandler(EventHandlerBase):
def __init__(self, key, in_pipe_path, out_pipe_path):
def __init__(self, key, in_pipe_path, out_pipe_path, permissions=0o600):
super().__init__(key)
self._pipe_io_server = JSONProxyPipeIOServer(in_pipe_path, out_pipe_path, self.server_connector.send)
self._pipe_io_server = JSONProxyPipeIOServer(
in_pipe_path,
out_pipe_path,
self.server_connector.send,
permissions
)
self._pipe_io_server.start()
def cleanup(self):
@ -23,8 +28,8 @@ class PipeIOEventHandler(EventHandlerBase):
class JSONProxyPipeIOServer(PipeIOServer):
def __init__(self, in_pipe_path, out_pipe_path, proxy_method):
super().__init__(in_pipe_path, out_pipe_path)
def __init__(self, in_pipe_path, out_pipe_path, proxy_method, permissions):
super().__init__(in_pipe_path, out_pipe_path, permissions)
self.proxy = proxy_method
def handle_message(self, message):
@ -32,4 +37,4 @@ class JSONProxyPipeIOServer(PipeIOServer):
json = loads(message)
self.proxy(json)
except JSONDecodeError:
LOG.debug("Invalid JSON received on %s! Ignoring...", self._in_pipe)
LOG.error("Invalid JSON received on %s! Ignoring...", self._in_pipe)