32 Commits

Author SHA1 Message Date
Sunil Mohan Adapa
5c5fc9eb61
actions: Drop unused superuser_run and related methods
Tests:

- All tests in patch series have been done with this patch applied
- Unit tests pass

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
2022-10-08 18:54:03 -04:00
Sunil Mohan Adapa
0dff0fc293
actions: Implement getting raw output from the process
Tests:

- export-tar for a backup archive works. Yields reasonable speeds > 30 MB/s.

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
2022-10-08 18:50:40 -04:00
Sunil Mohan Adapa
6f5410931e
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>
2022-10-08 18:50:37 -04:00
Sunil Mohan Adapa
585092ca63
actions: Allow nested and top-level actions
- Currently, privileged actions are not allowed under top-level plinth module.
They are only allowed under each app module. Allow privileged actions under
plinth module.

- Currently, privileged actions are not allowed under a sub-module of
'privileged' package. They are allowed only in 'privileged' module. Allow
sub-modules under 'privileged' package.

Tests:

- Email app functional tests pass
- Functional tests for apps using package and service privileged methods pass

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
2022-10-08 18:50:34 -04:00
Sunil Mohan Adapa
fb70fdef6e
actions: Note that privileged actions can't output to stdout
- This can be improved later by using a IPC mechanism other than stdin/stdout.

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
2022-06-24 08:41:34 -04:00
Sunil Mohan Adapa
4fed6921d6
actions: Add a decorator for marking superuser actions
Any privileged action (a method) can be marked as such with the new decorator. A
call to the method will be serialized into a sudo call (or later into a D-Bus
call). The method arguments are turned to JSON and method is called as
superuser. Arguments are de-serialized and are verified for type before the
actual call as superuser. Return values are serialized and returned where they
are de-serialized. Exceptions are also serialized and de-serialized.

The method must have be strictly typed and should not have keyword-only
arguments. Currently supported types are int, float, str, dict/Dict, list/List
and Optional.

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
2022-06-20 18:16:47 -04:00
Sunil Mohan Adapa
b32d0f17f0
*: Use allow/denylist instead white/blacklist in comments
Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: Joseph Nuthalapati <njoseph@riseup.net>
2021-09-25 07:44:15 +05:30
Sunil Mohan Adapa
62fc33e12c
cfg: Eliminate the need for 'root' directory in configuration
Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
2020-06-28 21:01:31 -04:00
Sunil Mohan Adapa
9368504da5
*.py: Use SPDX license identifier
Reviewed-by: Veiko Aasa <veiko17@disroot.org>
2020-02-19 14:38:55 +02:00
Sunil Mohan Adapa
1b218666f4
actions: Fix issue with docstring causing issues with Sphnix
Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
2019-11-02 13:51:18 -04:00
Sunil Mohan Adapa
3bf4b217fe
actions: Improve log message about action execution
- Use '#' vs '$' to indicate root vs. user message.

- Remove '-n' argument to sudo as it is always present.

- Remove env arguments to sudo as they are only present during debug.

- Remove full path to the action as they are already thoroughly checked.

- Print the message as a shell command with escapes instead of as python list.

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
2019-09-08 09:49:24 -04:00
Sunil Mohan Adapa
34e0394713
backups: Minor styling fixes
- Run yapf

- Address some flake8 errors/warnings.

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
2019-02-03 17:00:19 -05:00
Sunil Mohan Adapa
623bbc87e8
backups: Remove incorrectly set buffer size during download
- Don't set bufsize to 1 while streaming backup download. This is only effective
  with text streams with universal_newline flag set. An actual buffer size of 1
  is very inefficient and plain wrong. Leave the python default of
  io.DEFAULT_BUFFER_SIZE.

- Minor simplification to argument passing.

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
2019-02-03 17:00:15 -05:00
Michael Pimmer
8cc74bd203
Backups: minor cleanups
- some variable names, indentation and documentation changes
- removed unused backups action
- changed name of upload session variable to 'fbx-backups-upload-path'

Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
2018-11-17 09:00:26 -05:00
Michael Pimmer
1f9bb624e8
Backups: Stream archive downloads/exports
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
2018-11-17 09:00:13 -05:00
Michael Pimmer
97f69eb3ee
Actions: path in development mode: do not preserve PYTHONPATH
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
2018-10-31 20:24:35 -04:00
Michael Pimmer
525638357f
Actions: use local plinth in development mode
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
2018-10-31 20:24:30 -04:00
Sunil Mohan Adapa
79276f14df
Don't use async for method parameters
async is a reserved keyword in Python 3.7. It can no longer be used as method
parameter. Change the name so that we are ready for Python 3.7.

See: https://www.python.org/dev/peps/pep-0492/#deprecation-plans

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
2018-02-24 19:14:13 +01:00
Sunil Mohan Adapa
dea4af17fb
Rename Plinth to FreedomBox in license headers
Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
2018-02-16 20:10:09 -05:00
Joseph Nuthalapati
9dae13ada5
actions: test case for is-package-manager-busy command
comments, import optimization and YAPF formatting.

Signed-off-by: Joseph Nuthalapati <njoseph@thoughtworks.com>
2018-01-30 10:57:58 +05:30
Vikas Singh
5c83dea442
actions: Allow not printing error when an action fails
Reviewed-by: Joseph Nuthalapati <njoseph@thoughtworks.com>
2018-01-30 10:57:48 +05:30
Joseph Nuthalpati
5ad180fcc9
Add Tahoe-LAFS module
- Created basic plinth app which starts an introducer and a storage
  node on the FreedomBox.
- Prompt user to set a domain name before creating Tahoe-LAFS nodes.
- Support adding and removing of introducers to the storage node.
- Serve Tahoe-LAFS from a different port.
- Start all nodes and introducers at system startup.
- Add utility class YAMLFile with test cases.
2017-06-10 09:38:57 -04:00
Sunil Mohan Adapa
52bfb475e8 Return the process for async actions
So that the caller can manage and later look for return status.
2015-11-03 20:24:40 -05:00
James Valleroy
cb7c9c26f7 Send LDAP user passwords to actions through stdin, not as arguments. 2015-07-23 22:30:50 +05:30
James Valleroy
86580c9121 Revert "Don't print LDAP user passwords in log."
This reverts commit b1c9c81d58c80d6b313dd2b8a5c5727ecdf6ac49.

Conflicts:
	plinth/modules/first_boot/forms.py
2015-07-23 22:30:50 +05:30
James Valleroy
b1c9c81d58 Don't print LDAP user passwords in log. 2015-07-13 19:50:58 +05:30
Sunil Mohan Adapa
b62f6746f4 Handle arguments to actions properly
- Don't allow strings to be sent as arguments.  The mixup with
  lists/tuples could be dangerous.

- Don't escape arguments.  subprocess.Popen takes care that arguments
  are passed on nicely to the actions.

- Update tests.
2015-05-01 18:52:17 +05:30
Sunil Mohan Adapa
5b969d9d30 Explicitly write license headers for each source file
The package license (AGPL3+) implicitly indicates the license of each
file.  However, it is desirable to have license headers in each file.
This is the case for many prominent projects like GNU project, Mozilla
etc.
2014-11-30 14:49:49 +05:30
Sunil Mohan Adapa
51247dae13 Remove #! from actions.py as it is not meant to run independently 2014-11-30 14:49:49 +05:30
Sunil Mohan Adapa
ea3d72175d Make actions work with Python3 2014-10-01 12:08:39 +05:30
Sunil Mohan Adapa
20dab06ea3 Eliminate implicit relative imports
Convert to either absolute imports or explicit relative imports
2014-09-19 19:09:49 +05:30
Sunil Mohan Adapa
65fa648d9f Reorganize python sources into 'plinth' package 2014-08-29 12:57:27 +05:30