Fix tests about images paths security

This commit is contained in:
Julien Duponchelle
2015-11-10 15:21:10 +01:00
parent 390c88d7cd
commit caade47e16
5 changed files with 33 additions and 31 deletions

View File

@ -417,9 +417,9 @@ class BaseManager:
else:
# For non local server we disallow using absolute path outside image directory
if Config.instance().get_section_config("Server").get("local", False) is False:
img_directory = self.config.get_section_config("Server").get("images_path", "~/GNS3/images")
img_directory = self.config.get_section_config("Server").get("images_path", os.path.expanduser("~/GNS3/images"))
if len(os.path.commonprefix([img_directory, path])) < len(img_directory):
raise VMError("%s is not allowed on this remote server. Please use only the image filename.".format(path))
raise VMError("{} is not allowed on this remote server. Please use only a filename in {}.".format(path, img_directory))
return force_unix_path(path)