*: Use action_utils.run instead of subprocess.check_output

- 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:56 +03:00
1 parent bf9005ac48
commit b253166f6d
17 files changed
+101 -72

No files matched your search

+2 -2
View File
@@ -155,7 +155,7 @@ def _get_mount_point(path):
def _get_shares() -> list[dict[str, str]]:
"""Get shares."""
shares = []
output = subprocess.check_output(['net', 'conf', 'list'])
output = action_utils.run(['net', 'conf', 'list'], check=True).stdout
config = configparser.RawConfigParser()
config.read_string(output.decode())
for name in config.sections():
@@ -272,7 +272,7 @@ def get_shares() -> list[dict[str, str]]:
@privileged
def get_users() -> list[str]:
"""Get users from Samba database."""
output = subprocess.check_output(['pdbedit', '-L']).decode()
output = action_utils.run(['pdbedit', '-L'], check=True).stdout.decode()
samba_users = [line.split(':')[0] for line in output.split()]
return samba_users