Added support for passing the options allow-other and allow-root to the

FUSE index mirror. GitLab issue #385

Signed-off-by: Roberto Rosario <roberto.rosario.gonzalez@gmail.com>
This commit is contained in:
Roberto Rosario
2017-05-24 03:24:23 -04:00
parent d00f3aaff4
commit 4ffc6fc94f
3 changed files with 31 additions and 5 deletions

View File

@@ -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