actions: Use separate IPC for communicating results

Currently privileged actions use stdout for returning the results. If any of the
sub-processes accidentally output to stdout, decoding errors occur. Prevent this
by opening a pipe to the privileged action and returning the output in that
pipe.

Tests:

- Run unit tests
- Functional tests for other apps pass

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
This commit is contained in:
Sunil Mohan Adapa authored and James Valleroy committed 2022-10-08 18:50:37 -04:00
1 parent 585092ca63
commit 6f5410931e
7 files changed
+190 -55

No files matched your search

+4 -2
View File
@@ -650,8 +650,10 @@ def _setup_users(image_file):
str(gid), 'plinth'], stdout=subprocess.DEVNULL)
logger.info('In container: Setting up sudo for users "fbx" and "plinth"')
sudo_config = 'plinth ALL=(ALL:ALL) NOPASSWD:SETENV : ' \
'/usr/share/plinth/actions/* , /freedombox/actions/*\n' \
sudo_config = 'Cmnd_Alias FREEDOMBOX_ACTION_DEV = /usr/share/plinth/' \
'actions/actions, /freedombox/actions/actions\n' \
'Defaults!FREEDOMBOX_ACTION_DEV closefrom_override\n' \
'plinth ALL=(ALL:ALL) NOPASSWD:SETENV : FREEDOMBOX_ACTION_DEV\n' \
'fbx ALL=(ALL:ALL) NOPASSWD : ALL\n'
_runc(image_file, ['tee', '/etc/sudoers.d/01-freedombox-development'],
input=sudo_config.encode(), stdout=subprocess.DEVNULL)