From 46d88add087f59bb836e05ae9114747977924da8 Mon Sep 17 00:00:00 2001 From: Andrew Walker Date: Tue, 30 Jul 2024 06:03:41 -0700 Subject: [PATCH] Properly exclude ix-apps dataset from filesystem.listdir ix-apps dataset is mounted to a special mountpoint in /mnt and so must be excluded explicitly only if path being listed is /mnt. --- src/middlewared/middlewared/plugins/filesystem.py | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/middlewared/middlewared/plugins/filesystem.py b/src/middlewared/middlewared/plugins/filesystem.py index 79ee19ed5969b..dfde7b4c57a84 100644 --- a/src/middlewared/middlewared/plugins/filesystem.py +++ b/src/middlewared/middlewared/plugins/filesystem.py @@ -12,6 +12,7 @@ from itertools import product from middlewared.event import EventSource from middlewared.plugins.pwenc import PWENC_FILE_SECRET, PWENC_FILE_SECRET_MODE +from middlewared.plugins.docker.state_utils import IX_APPS_DIR_NAME from middlewared.plugins.filesystem_ import chflags from middlewared.schema import accepts, Bool, Dict, Float, Int, List, Ref, returns, Path, Str, UnixPerm from middlewared.service import private, CallError, filterable_returns, filterable, Service, job @@ -273,10 +274,6 @@ def listdir(self, path, filters, options): if not path.is_dir(): raise CallError(f'Path {path} is not a directory', errno.ENOTDIR) - for ds in ('ix-applications', 'ix-apps'): - if ds in path.parts: - raise CallError(f'{ds!r} is a system managed dataset and its contents cannot be listed') - file_type = None for filter_ in filters: if filter_[0] not in ['type']: @@ -301,7 +298,7 @@ def listdir(self, path, filters, options): # prevent shares from being configured to point to # a path that doesn't exist on a zpool, we'll # filter these here. - filters.append(['is_mountpoint', '=', True]) + filters.extend([['is_mountpoint', '=', True], ['name', '!=', IX_APPS_DIR_NAME]]) with DirectoryIterator(path, file_type=file_type) as d_iter: return filter_list(d_iter, filters, options)