diff --git a/gns3server/modules/attic.py b/gns3server/modules/attic.py index 8c1fae63..fa31e50e 100644 --- a/gns3server/modules/attic.py +++ b/gns3server/modules/attic.py @@ -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 diff --git a/gns3server/modules/iou/iou_device.py b/gns3server/modules/iou/iou_device.py index 6c5b8704..ece451be 100644 --- a/gns3server/modules/iou/iou_device.py +++ b/gns3server/modules/iou/iou_device.py @@ -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))]) diff --git a/gns3server/modules/vpcs/vpcs_device.py b/gns3server/modules/vpcs/vpcs_device.py index 8fb674ed..9c7957a8 100644 --- a/gns3server/modules/vpcs/vpcs_device.py +++ b/gns3server/modules/vpcs/vpcs_device.py @@ -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")