*: Use action_utils.run instead of subprocess.check_call

- 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.

- systemd daemon-reload is performed during infinoted setup.

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:54 +03:00
1 parent 61ff15a04f
commit 80e6d940a4
9 files changed
+44 -44

No files matched your search

+3 -3
View File
@@ -339,14 +339,14 @@ def _get_samba_users():
def _delete_samba_user(username):
"""Delete a Samba user."""
if username in _get_samba_users():
subprocess.check_call(['smbpasswd', '-x', username])
action_utils.run(['smbpasswd', '-x', username], check=True)
_disconnect_samba_user(username)
def _disconnect_samba_user(username):
"""Disconnect a Samba user."""
try:
subprocess.check_call(['pkill', '-U', username, 'smbd'])
action_utils.run(['pkill', '-U', username, 'smbd'], check=True)
except subprocess.CalledProcessError as error:
if error.returncode != 1:
raise
@@ -679,7 +679,7 @@ def set_user_status(username: str, status: str, auth_user: str,
# Set user status in Samba password database
if username in _get_samba_users():
subprocess.check_call(['smbpasswd', smbpasswd_flag, username])
action_utils.run(['smbpasswd', smbpasswd_flag, username], check=True)
_flush_cache()