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

+10 -18
View File
@@ -1,24 +1,16 @@
#!/usr/bin/python3
# -*- mode: python -*-
# SPDX-License-Identifier: AGPL-3.0-or-later
"""
Set required permissions for user "plinth" to run plinth in the development
environment.
"""
"""Set required permissions for user "plinth" to run plinth in dev setup."""
import augeas
import pathlib
sudoers_file = '/etc/sudoers.d/plinth'
aug = augeas.Augeas(flags=augeas.Augeas.NO_LOAD +
augeas.Augeas.NO_MODL_AUTOLOAD)
content = '''
Cmnd_Alias FREEDOMBOX_ACTION_DEV = /usr/share/plinth/actions/actions, /vagrant/actions/actions
Defaults!FREEDOMBOX_ACTION_DEV closefrom_override
plinth ALL=(ALL:ALL) NOPASSWD:SETENV : FREEDOMBOX_ACTION_DEV
fbx ALL=(ALL:ALL) NOPASSWD : ALL
'''
# lens for shell-script config file
aug.set('/augeas/load/Shellvars/lens', 'Sudoers.lns')
aug.set('/augeas/load/Shellvars/incl[last() + 1]', sudoers_file)
aug.load()
aug.set('/files{}/spec[1]/host_group/command[2]'.format(sudoers_file),
'/vagrant/actions/*')
aug.set('/files{}/spec[1]/host_group/command[1]/tag[2]'.format(sudoers_file),
'SETENV')
aug.save()
sudoers_file = pathlib.Path('/etc/sudoers.d/01-freedombox-development')
sudoers_file.write_text(content)