From 4ffc6fc94fd863a4da82698507fc0bb0094d1df3 Mon Sep 17 00:00:00 2001 From: Roberto Rosario Date: Wed, 24 May 2017 03:24:23 -0400 Subject: [PATCH] Added support for passing the options allow-other and allow-root to the FUSE index mirror. GitLab issue #385 Signed-off-by: Roberto Rosario --- HISTORY.rst | 2 ++ docs/releases/2.2.1.rst | 3 ++ .../management/commands/mountindex.py | 31 ++++++++++++++++--- 3 files changed, 31 insertions(+), 5 deletions(-) diff --git a/HISTORY.rst b/HISTORY.rst index 3e2e221fc9..0eb3da1138 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -2,6 +2,8 @@ ================== - Allow for bigger indexing expression templates. - Auto select checkbox when updating metadata values. GitLab issue #371. +- Added support for passing the options allow-other and allow-root to the + FUSE index mirror. GitLab issue #385 2.2 (2017-04-26) ================ diff --git a/docs/releases/2.2.1.rst b/docs/releases/2.2.1.rst index da8b4abcfa..de50dcf4f1 100644 --- a/docs/releases/2.2.1.rst +++ b/docs/releases/2.2.1.rst @@ -16,6 +16,8 @@ Changes unlimited size text field to allow for complex indexing expressions. - When updating the metadata of a document, any input in the value form field will select the adjacent checkbox. +- Support for passing the FUSE option `allow-other` and `allow-root` was added + to the index mirroring management command. Removals -------- @@ -71,5 +73,6 @@ Bugs fixed or issues closed =========================== * `GitLab issue #371 `_ Auto select checkbox when updating metadata +* `GitLab issue #385 `_ mountindex: how to specify FUSE mount option allow_other? .. _PyPI: https://pypi.python.org/pypi/mayan-edms/ diff --git a/mayan/apps/mirroring/management/commands/mountindex.py b/mayan/apps/mirroring/management/commands/mountindex.py index 7244716dae..2a57b9b948 100644 --- a/mayan/apps/mirroring/management/commands/mountindex.py +++ b/mayan/apps/mirroring/management/commands/mountindex.py @@ -11,6 +11,7 @@ from fuse import FUSE, FuseOSError, Operations from django.core import management from django.core.cache import caches from django.core.exceptions import MultipleObjectsReturned +from django.core.management.base import CommandError from django.db.models import Count from document_indexing.models import Index, IndexInstanceNode @@ -214,15 +215,35 @@ class Command(management.BaseCommand): def add_arguments(self, parser): parser.add_argument('slug', nargs='?', help='Index slug') - parser.add_argument('mount_point', nargs='?', help='Mount point') + parser.add_argument( + '--allow-other', action='store_true', dest='allow_other', + default=False, + help='All users (including root) can access the index files.' + ) + parser.add_argument( + '--allow-root', action='store_true', dest='allow_root', + default=False, + help='Mount access is limited to the user mounting the index and ' + 'root. This option and --allow-other are mutually exclusive.' + ) def handle(self, *args, **options): if not options.get('slug') or not options.get('mount_point'): self.stderr.write(self.style.ERROR('Incorrect number of arguments')) exit(1) - FUSE( - operations=IndexFS(index_slug=options['slug']), - mountpoint=options['mount_point'], nothreads=True, foreground=True - ) + try: + FUSE( + operations=IndexFS(index_slug=options['slug']), + mountpoint=options['mount_point'], nothreads=True, foreground=True, + allow_other=options['allow_other'], + allow_root=options['allow_root'] + ) + except RuntimeError as exception: + if options['allow_other'] or options['allow_root']: + raise CommandError( + 'Make sure \'user_allow_other\' is set in /etc/fuse.conf' + ) + else: + raise