mirror of
https://github.com/avatao-content/baseimage-tutorial-framework
synced 2024-11-22 07:51:32 +00:00
Support initializing IO pipes with specific permissions
This commit is contained in:
parent
065aa56182
commit
f94d571d19
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user