From f94d571d19c00ab9978eb0462f11bbac81548d1e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Krist=C3=B3f=20T=C3=B3th?= Date: Sat, 4 May 2019 21:10:05 +0200 Subject: [PATCH] Support initializing IO pipes with specific permissions --- lib/tfw/components/pipe_io_event_handler.py | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/lib/tfw/components/pipe_io_event_handler.py b/lib/tfw/components/pipe_io_event_handler.py index df3d012..d610f4f 100644 --- a/lib/tfw/components/pipe_io_event_handler.py +++ b/lib/tfw/components/pipe_io_event_handler.py @@ -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)