Merge branch '2.2' into 3.0

# Conflicts:
#	gns3server/compute/qemu/qemu_vm.py
#	gns3server/handlers/api/compute/server_handler.py
#	gns3server/utils/path.py
#	gns3server/version.py
#	requirements.txt
#	tests/compute/qemu/test_qemu_vm.py
#	tests/compute/test_manager.py
This commit is contained in:
grossmj
2021-09-09 16:36:17 +09:30
571 changed files with 3964 additions and 13577 deletions

View File

@ -48,7 +48,7 @@ def is_safe_path(file_path: str, basedir: str) -> bool:
return Path(basedir).resolve() in test_path.resolve().parents
def check_path_allowed(path):
def check_path_allowed(path: str):
"""
If the server is non local raise an error if
the path is outside project directories
@ -62,3 +62,16 @@ def check_path_allowed(path):
if Config.instance().settings.Server.local is False:
raise HTTPException(status_code=status.HTTP_403_FORBIDDEN, detail="The path is not allowed")
def get_mountpoint(path: str):
"""
Find the mount point of a path.
"""
path = os.path.abspath(path)
while path != os.path.sep:
if os.path.ismount(path):
return path
path = os.path.abspath(os.path.join(path, os.pardir))
return path