mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-11-29 08:25:10 +00:00
*: 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:
1 parent
61ff15a04f
commit
80e6d940a4
9 files changed
+44
-44
No files matched your search
@@ -7,6 +7,7 @@ import pathlib
|
||||
import shutil
|
||||
import subprocess
|
||||
|
||||
from plinth import action_utils
|
||||
from plinth.actions import privileged
|
||||
|
||||
DEFAULT_FILE = '/etc/default/samba'
|
||||
@@ -51,12 +52,13 @@ CONF = r'''
|
||||
|
||||
def _close_share(share_name):
|
||||
"""Disconnect all samba users who are connected to the share."""
|
||||
subprocess.check_call(['smbcontrol', 'smbd', 'close-share', share_name])
|
||||
action_utils.run(['smbcontrol', 'smbd', 'close-share', share_name],
|
||||
check=True)
|
||||
|
||||
|
||||
def _conf_command(parameters, **kwargs):
|
||||
"""Run samba configuration registry command."""
|
||||
subprocess.check_call(['net', 'conf'] + parameters, **kwargs)
|
||||
action_utils.run(['net', 'conf'] + parameters, check=True, **kwargs)
|
||||
|
||||
|
||||
def _create_share(mount_point, share_type, windows_filesystem=False):
|
||||
@@ -198,8 +200,8 @@ def _set_open_share_permissions(directory):
|
||||
file_path = os.path.join(root, file)
|
||||
shutil.chown(file_path, group='freedombox-share')
|
||||
os.chmod(file_path, 0o0664)
|
||||
subprocess.check_call(['setfacl', '-Rm', 'g::rwX', directory])
|
||||
subprocess.check_call(['setfacl', '-Rdm', 'g::rwX', directory])
|
||||
action_utils.run(['setfacl', '-Rm', 'g::rwX', directory], check=True)
|
||||
action_utils.run(['setfacl', '-Rdm', 'g::rwX', directory], check=True)
|
||||
|
||||
|
||||
def _use_config_file(conf_file):
|
||||
@@ -229,8 +231,8 @@ def _set_share_permissions(directory):
|
||||
file_path = os.path.join(root, file)
|
||||
shutil.chown(file_path, group='freedombox-share')
|
||||
os.chmod(file_path, 0o0664)
|
||||
subprocess.check_call(['setfacl', '-Rm', 'g::rwX', directory])
|
||||
subprocess.check_call(['setfacl', '-Rdm', 'g::rwX', directory])
|
||||
action_utils.run(['setfacl', '-Rm', 'g::rwX', directory], check=True)
|
||||
action_utils.run(['setfacl', '-Rdm', 'g::rwX', directory], check=True)
|
||||
|
||||
|
||||
@privileged
|
||||
|
||||
Reference in new issue
Block a user