mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-01-21 07:55:00 +00:00
storage: Make external disk mounts accessible by other users
- samba app doesn't need anymore to change mount permissions Fixes #1692 (in a different way) Signed-off-by: Veiko Aasa <veiko17@disroot.org> Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
This commit is contained in:
parent
d2286ca093
commit
9d653d87ec
@ -24,7 +24,6 @@ import configparser
|
||||
import json
|
||||
import os
|
||||
import shutil
|
||||
import stat
|
||||
import subprocess
|
||||
|
||||
SHARES_CONF_BACKUP_FILE = '/var/lib/plinth/backups-data/samba-shares-dump.conf'
|
||||
@ -120,8 +119,6 @@ def _create_share(mount_point, share_type, windows_filesystem=False):
|
||||
share_path = os.path.join(mount_point, shares_path, subdir)
|
||||
os.makedirs(share_path, exist_ok=True)
|
||||
|
||||
_make_mounts_readable_by_others(mount_point)
|
||||
|
||||
# FAT and NTFS partitions don't support setting permissions
|
||||
if not windows_filesystem:
|
||||
if share_type in ['open', 'group']:
|
||||
@ -235,13 +232,6 @@ def _get_shares_path(mount_point):
|
||||
return 'FreedomBox/shares/'
|
||||
|
||||
|
||||
def _make_mounts_readable_by_others(mount_point):
|
||||
"""Make mounted devices readable/traversible by others."""
|
||||
dirname = os.path.dirname(mount_point)
|
||||
stats = os.stat(dirname)
|
||||
os.chmod(dirname, stats.st_mode | stat.S_IROTH | stat.S_IXOTH)
|
||||
|
||||
|
||||
def _set_open_share_permissions(directory):
|
||||
"""Set file and directory permissions for open share."""
|
||||
shutil.chown(directory, group='freedombox-share')
|
||||
|
||||
@ -23,6 +23,7 @@ import argparse
|
||||
import json
|
||||
import os
|
||||
import re
|
||||
import stat
|
||||
import subprocess
|
||||
import sys
|
||||
|
||||
@ -34,6 +35,8 @@ def parse_arguments():
|
||||
parser = argparse.ArgumentParser()
|
||||
subparsers = parser.add_subparsers(dest='subcommand', help='Sub command')
|
||||
|
||||
subparsers.add_parser('setup', help='Configure storage after install')
|
||||
|
||||
subparser = subparsers.add_parser(
|
||||
'is-partition-expandable',
|
||||
help='Return whether a given partition can be expanded')
|
||||
@ -320,6 +323,20 @@ def umount_all_filesystems_of_drive(drive_object_path):
|
||||
umount_filesystem(obj.get_filesystem())
|
||||
|
||||
|
||||
def subcommand_setup(_):
|
||||
"""Configure storage."""
|
||||
# create udisks2 default mount directory
|
||||
mounts_directory = '/media/root'
|
||||
try:
|
||||
os.mkdir(mounts_directory)
|
||||
except FileExistsError:
|
||||
pass
|
||||
|
||||
# make the directory readable and traversible by other users
|
||||
stats = os.stat(mounts_directory)
|
||||
os.chmod(mounts_directory, stats.st_mode | stat.S_IROTH | stat.S_IXOTH)
|
||||
|
||||
|
||||
def subcommand_usage_info(_):
|
||||
"""Get information about disk space usage."""
|
||||
command = [
|
||||
|
||||
@ -32,7 +32,7 @@ from plinth.utils import format_lazy, import_from_gi
|
||||
|
||||
from .manifest import backup # noqa, pylint: disable=unused-import
|
||||
|
||||
version = 3
|
||||
version = 4
|
||||
|
||||
name = _('Storage')
|
||||
|
||||
@ -277,6 +277,7 @@ def get_error_message(error):
|
||||
def setup(helper, old_version=None):
|
||||
"""Install and configure the module."""
|
||||
helper.install(managed_packages, skip_recommends=True)
|
||||
helper.call('post', actions.superuser_run, 'storage', ['setup'])
|
||||
helper.call('post', app.enable)
|
||||
disks = get_disks()
|
||||
root_device = get_root_device(disks)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user