mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-09-19 04:59:01 +00:00
samba: Hide common system partitions
Hide some common partitions where users shouldn't create a share - /.snapshots, /boot and /boot/firmware. Tested that mount points 'boot' and '.snapshots' do not appear in the list of shareable disks on Pioneer Freedombox. Signed-off-by: Veiko Aasa <veiko17@disroot.org> [sunil: Add /boot/efi to list of ignored mount points] [sunil: Update test to check if mounts points are ignored] Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org> Reviewed-by: Sunil Mohan Adapa <sunil@medhas.org>
This commit is contained in:
parent
c7bf1bb46f
commit
31eb35cb9e
@ -27,6 +27,14 @@ DISKS = [{
|
|||||||
'percent_used': 63,
|
'percent_used': 63,
|
||||||
'size_str': '9.5 GiB',
|
'size_str': '9.5 GiB',
|
||||||
'used_str': '5.7 GiB'
|
'used_str': '5.7 GiB'
|
||||||
|
}, {
|
||||||
|
'device': '/dev/sda2',
|
||||||
|
'label': '',
|
||||||
|
'filesystem_type': 'vfat',
|
||||||
|
'mount_point': '/boot/efi',
|
||||||
|
'percent_used': 50,
|
||||||
|
'size_str': '150 MiB',
|
||||||
|
'used_str': '75 MiB'
|
||||||
}]
|
}]
|
||||||
|
|
||||||
SHARES = [
|
SHARES = [
|
||||||
@ -96,7 +104,7 @@ def test_samba_shares_view(rf):
|
|||||||
view = views.SambaAppView.as_view()
|
view = views.SambaAppView.as_view()
|
||||||
response, _ = make_request(rf.get(''), view)
|
response, _ = make_request(rf.get(''), view)
|
||||||
|
|
||||||
assert response.context_data['disks'] == DISKS
|
assert response.context_data['disks'] == [DISKS[0]]
|
||||||
assert response.context_data['shared_mounts'] == {
|
assert response.context_data['shared_mounts'] == {
|
||||||
'/': ['open', 'home'],
|
'/': ['open', 'home'],
|
||||||
'/media/root/otherdisk': ['open']
|
'/media/root/otherdisk': ['open']
|
||||||
|
|||||||
@ -12,7 +12,6 @@ from django.shortcuts import redirect
|
|||||||
from django.urls import reverse
|
from django.urls import reverse
|
||||||
from django.utils.translation import ugettext as _
|
from django.utils.translation import ugettext as _
|
||||||
from django.views.decorators.http import require_POST
|
from django.views.decorators.http import require_POST
|
||||||
|
|
||||||
from plinth import views
|
from plinth import views
|
||||||
from plinth.errors import ActionError
|
from plinth.errors import ActionError
|
||||||
from plinth.modules import samba, storage
|
from plinth.modules import samba, storage
|
||||||
@ -20,6 +19,15 @@ from plinth.modules import samba, storage
|
|||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
|
def get_share_mounts():
|
||||||
|
"""Return list of mount points."""
|
||||||
|
ignore_points = ('/boot', '/boot/efi', '/boot/firmware', '/.snapshots')
|
||||||
|
return [
|
||||||
|
mount for mount in storage.get_mounts()
|
||||||
|
if mount['mount_point'] not in ignore_points
|
||||||
|
]
|
||||||
|
|
||||||
|
|
||||||
class SambaAppView(views.AppView):
|
class SambaAppView(views.AppView):
|
||||||
"""Samba sharing basic configuration."""
|
"""Samba sharing basic configuration."""
|
||||||
app_id = 'samba'
|
app_id = 'samba'
|
||||||
@ -28,7 +36,7 @@ class SambaAppView(views.AppView):
|
|||||||
def get_context_data(self, *args, **kwargs):
|
def get_context_data(self, *args, **kwargs):
|
||||||
"""Return template context data."""
|
"""Return template context data."""
|
||||||
context = super().get_context_data(*args, **kwargs)
|
context = super().get_context_data(*args, **kwargs)
|
||||||
disks = storage.get_mounts()
|
disks = get_share_mounts()
|
||||||
shares = samba.get_shares()
|
shares = samba.get_shares()
|
||||||
|
|
||||||
for disk in disks:
|
for disk in disks:
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user