*: Use action_utils.run instead of subprocess.run

- This is to capture stdout and stderr and transmit that from privileged daemon
back to the service to be displayed in HTML.

Tests:

- Unit tests and code checks pass.

- Some of the modified actions work as expected.

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: Veiko Aasa <veiko17@disroot.org>
This commit is contained in:
Sunil Mohan Adapa authored and Veiko Aasa committed 2025-09-29 16:58:53 +03:00
1 parent 355812c9f2
commit 61ff15a04f
36 files changed
+257 -244

No files matched your search

+2 -1
View File
@@ -9,6 +9,7 @@ import re
import shutil
import subprocess
from plinth import action_utils
from plinth.actions import privileged
from plinth.privileged import service as service_privileged
@@ -54,7 +55,7 @@ def setup_dkim(domain: str):
# Ed25519 is widely *not* accepted as of 2022-01. See:
# https://serverfault.com/questions/1023674
subprocess.run([
action_utils.run([
'rspamadm', 'dkim_keygen', '-t', 'rsa', '-b', '2048', '-s', 'dkim',
'-d', domain, '-k', (str(key_file))
], check=True)
+2 -3
View File
@@ -6,8 +6,7 @@ See:
https://doc.dovecot.org/configuration_manual/authentication/user_databases_userdb/
"""
import subprocess
from plinth import action_utils
from plinth.actions import privileged
@@ -19,4 +18,4 @@ def setup_home():
Dovecot creates new directories with the same permissions as the parent
directory. Ensure that 'others' can't access /var/mail/.
"""
subprocess.run(['chmod', 'o-rwx', '/var/mail'], check=True)
action_utils.run(['chmod', 'o-rwx', '/var/mail'], check=True)
+5 -4
View File
@@ -10,8 +10,8 @@ For testing DKIM signatures: https://www.mail-tester.com/
import pathlib
import re
import subprocess
from plinth import action_utils
from plinth.actions import privileged
from plinth.modules.email import postfix
@@ -31,10 +31,11 @@ def setup_spam():
def _compile_sieve():
"""Compile all .sieve script to binary format for performance."""
sieve_dirs = ['/etc/dovecot/freedombox-sieve-after/',
'/etc/dovecot/freedombox-sieve']
sieve_dirs = [
'/etc/dovecot/freedombox-sieve-after/', '/etc/dovecot/freedombox-sieve'
]
for sieve_dir in sieve_dirs:
subprocess.run(['sievec', sieve_dir], check=True)
action_utils.run(['sievec', sieve_dir], check=True)
def _setup_rspamd():