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:
Veiko Aasa authored and James Valleroy committed 2020-01-26 07:32:04 -05:00
1 parent d2286ca093
commit 9d653d87ec
3 files changed
+19 -11

No files matched your search

-10
View File
@@ -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')