run_as: adapt run_as implementation to support complex payloads
authorFrancis Deslauriers <francis.deslauriers@efficios.com>
Thu, 28 Jun 2018 15:39:30 +0000 (11:39 -0400)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Fri, 24 Aug 2018 19:56:21 +0000 (15:56 -0400)
commitfe9f7760c61d1248a062138fd059c84ec03967f6
tree679b90772d79c4209e6574e42803cb2d602726aa
parentf4d0bb2e92e94cb5eb304c8e92afcc804591539d
run_as: adapt run_as implementation to support complex payloads

This commits changes 4 elements of the run_as implementation:
  1. Allow for commands with complex return types,
  2. Detect worker crashes and restart it,
  3. Enable commands that take FD as input.
  4. Define master-worker protocol

In the past, run_as commands were simple and were all returning int
values (e.g. open(), mkdir()). With the introduction of the future, more
complex run_as commands such as the one to extract elf symbol offsets
for the userspace-probe instrumentation, we need to allow arbitrary
return types such as long and arrays. Creating a return type abstraction
allows to add new return types. To implement this new abstraction, this
commit adds the passing of the run_as_ret structure as parameter to the
command functions that are responsible to set the errno and the return
value according to their semantics. The run_as_ret struct now contains
an union of return types.

More complex run_as commands are more prone to crashes, we thus make the
master process restart the worker process if it detects it has exited.

Enable passing FD to worker process for commands that take file
descriptor as input.

Rework data and FD sending and receiving functions for both side of the
master-worker control channel and add comments describing each steps of
the protocol.

Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
src/common/runas.c
This page took 0.025891 seconds and 4 git commands to generate.