1
0
mirror of https://github.com/GNS3/gns3-server synced 2024-12-25 00:08:11 +00:00

Check for VPCS version >= 0.5b1

This commit is contained in:
grossmj 2014-07-02 15:04:39 -06:00
parent 15bc2221b9
commit 329891fc83
3 changed files with 27 additions and 3 deletions

View File

@ -121,11 +121,14 @@ def has_privileged_access(executable):
:returns: True or False
"""
if sys.platform.startswith("win"):
# do not check anything on Windows
return True
if os.geteuid() == 0:
# we are root, so we should have privileged access.
return True
if not sys.platform.startswith("win") and os.stat(executable).st_mode & stat.S_ISVTX == stat.S_ISVTX:
if os.stat(executable).st_mode & stat.S_ISVTX == stat.S_ISVTX:
# the executable has a sticky bit.
return True

View File

@ -806,7 +806,6 @@ class IOUDevice(object):
-N Ignore the NETMAP file
"""
#TODO: add support for keepalive and watchdog
command = [self._path]
if len(self._ethernet_adapters) != 2:
command.extend(["-e", str(len(self._ethernet_adapters))])

View File

@ -25,7 +25,9 @@ import sys
import subprocess
import signal
import shutil
import re
from pkg_resources import parse_version
from .vpcs_error import VPCSError
from .adapters.ethernet_adapter import EthernetAdapter
from .nios.nio_udp import NIO_UDP
@ -343,6 +345,24 @@ class VPCSDevice(object):
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):
"""
Starts the VPCS process.
@ -359,6 +379,8 @@ class VPCSDevice(object):
if not os.access(self._path, os.X_OK):
raise VPCSError("VPCS program '{}' is not executable".format(self._path))
self._check_vpcs_version()
if not self._ethernet_adapter.get_nio(0):
raise VPCSError("This VPCS instance must be connected in order to start")