1
0
mirror of https://github.com/GNS3/gns3-server synced 2024-12-26 16:58:28 +00:00

Check if server config file is readable

This commit is contained in:
grossmj 2023-06-20 21:26:21 +09:30
parent a7a946c067
commit e5eeab662e

View File

@ -49,6 +49,8 @@ class Config:
self._profile = profile self._profile = profile
if files and len(files): if files and len(files):
if not os.access(files[0], os.R_OK) or not os.path.isfile(files[0]):
raise SystemExit(f"Unable to read configuration file: {files[0]}")
directory_name = os.path.dirname(files[0]) directory_name = os.path.dirname(files[0])
if not directory_name or directory_name == "": if not directory_name or directory_name == "":
files[0] = os.path.dirname(os.path.abspath(files[0])) + os.path.sep + files[0] files[0] = os.path.dirname(os.path.abspath(files[0])) + os.path.sep + files[0]