mirror of
https://github.com/avatao-content/baseimage-tutorial-framework
synced 2024-11-22 14:11:31 +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):
|
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)
|
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()
|
self._pipe_io_server.start()
|
||||||
|
|
||||||
def cleanup(self):
|
def cleanup(self):
|
||||||
@ -23,8 +28,8 @@ class PipeIOEventHandler(EventHandlerBase):
|
|||||||
|
|
||||||
|
|
||||||
class JSONProxyPipeIOServer(PipeIOServer):
|
class JSONProxyPipeIOServer(PipeIOServer):
|
||||||
def __init__(self, in_pipe_path, out_pipe_path, proxy_method):
|
def __init__(self, in_pipe_path, out_pipe_path, proxy_method, permissions):
|
||||||
super().__init__(in_pipe_path, out_pipe_path)
|
super().__init__(in_pipe_path, out_pipe_path, permissions)
|
||||||
self.proxy = proxy_method
|
self.proxy = proxy_method
|
||||||
|
|
||||||
def handle_message(self, message):
|
def handle_message(self, message):
|
||||||
@ -32,4 +37,4 @@ class JSONProxyPipeIOServer(PipeIOServer):
|
|||||||
json = loads(message)
|
json = loads(message)
|
||||||
self.proxy(json)
|
self.proxy(json)
|
||||||
except JSONDecodeError:
|
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