mirror of
https://github.com/GNS3/gns3-server
synced 2024-11-28 03:08:14 +00:00
Check for VPCS version >= 0.5b1
This commit is contained in:
parent
15bc2221b9
commit
329891fc83
@ -121,11 +121,14 @@ def has_privileged_access(executable):
|
|||||||
:returns: True or False
|
:returns: True or False
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
if sys.platform.startswith("win"):
|
||||||
|
# do not check anything on Windows
|
||||||
|
return True
|
||||||
|
|
||||||
if os.geteuid() == 0:
|
if os.geteuid() == 0:
|
||||||
# we are root, so we should have privileged access.
|
# we are root, so we should have privileged access.
|
||||||
return True
|
return True
|
||||||
|
if os.stat(executable).st_mode & stat.S_ISVTX == stat.S_ISVTX:
|
||||||
if not sys.platform.startswith("win") and os.stat(executable).st_mode & stat.S_ISVTX == stat.S_ISVTX:
|
|
||||||
# the executable has a sticky bit.
|
# the executable has a sticky bit.
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
@ -806,7 +806,6 @@ class IOUDevice(object):
|
|||||||
-N Ignore the NETMAP file
|
-N Ignore the NETMAP file
|
||||||
"""
|
"""
|
||||||
|
|
||||||
#TODO: add support for keepalive and watchdog
|
|
||||||
command = [self._path]
|
command = [self._path]
|
||||||
if len(self._ethernet_adapters) != 2:
|
if len(self._ethernet_adapters) != 2:
|
||||||
command.extend(["-e", str(len(self._ethernet_adapters))])
|
command.extend(["-e", str(len(self._ethernet_adapters))])
|
||||||
|
@ -25,7 +25,9 @@ import sys
|
|||||||
import subprocess
|
import subprocess
|
||||||
import signal
|
import signal
|
||||||
import shutil
|
import shutil
|
||||||
|
import re
|
||||||
|
|
||||||
|
from pkg_resources import parse_version
|
||||||
from .vpcs_error import VPCSError
|
from .vpcs_error import VPCSError
|
||||||
from .adapters.ethernet_adapter import EthernetAdapter
|
from .adapters.ethernet_adapter import EthernetAdapter
|
||||||
from .nios.nio_udp import NIO_UDP
|
from .nios.nio_udp import NIO_UDP
|
||||||
@ -343,6 +345,24 @@ class VPCSDevice(object):
|
|||||||
|
|
||||||
return self._started
|
return self._started
|
||||||
|
|
||||||
|
def _check_vpcs_version(self):
|
||||||
|
"""
|
||||||
|
Checks if the VPCS executable version is >= 0.5b1.
|
||||||
|
"""
|
||||||
|
|
||||||
|
try:
|
||||||
|
output = subprocess.check_output([self._path, "-v"], stderr=subprocess.STDOUT, cwd=self._working_dir)
|
||||||
|
match = re.search("Welcome to Virtual PC Simulator, version ([0-9a-z\.]+)", output.decode("utf-8"))
|
||||||
|
if match:
|
||||||
|
version = match.group(1)
|
||||||
|
print(version)
|
||||||
|
if parse_version(version) < parse_version("0.5b1"):
|
||||||
|
raise VPCSError("VPCS executable version must be >= 0.5b1")
|
||||||
|
else:
|
||||||
|
raise VPCSError("Could not determine the VPCS version for {}".format(self._path))
|
||||||
|
except OSError as e:
|
||||||
|
raise VPCSError("Error while looking for the VPCS version: {}".format(e))
|
||||||
|
|
||||||
def start(self):
|
def start(self):
|
||||||
"""
|
"""
|
||||||
Starts the VPCS process.
|
Starts the VPCS process.
|
||||||
@ -359,6 +379,8 @@ class VPCSDevice(object):
|
|||||||
if not os.access(self._path, os.X_OK):
|
if not os.access(self._path, os.X_OK):
|
||||||
raise VPCSError("VPCS program '{}' is not executable".format(self._path))
|
raise VPCSError("VPCS program '{}' is not executable".format(self._path))
|
||||||
|
|
||||||
|
self._check_vpcs_version()
|
||||||
|
|
||||||
if not self._ethernet_adapter.get_nio(0):
|
if not self._ethernet_adapter.get_nio(0):
|
||||||
raise VPCSError("This VPCS instance must be connected in order to start")
|
raise VPCSError("This VPCS instance must be connected in order to start")
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user