mirror of
https://github.com/GNS3/gns3-server.git
synced 2025-01-18 07:23:47 +02:00
Only require privileged access for uBridge when connecting a cloud to an Ethernet/TAP interface. Fixes #1461.
This commit is contained in:
parent
ca6a0708a8
commit
3fae6ada95
@ -554,8 +554,8 @@ class BaseNode:
|
|||||||
if self.ubridge_path is None:
|
if self.ubridge_path is None:
|
||||||
raise NodeError("uBridge is not available, path doesn't exist, or you just installed GNS3 and need to restart your user session to refresh user permissions.")
|
raise NodeError("uBridge is not available, path doesn't exist, or you just installed GNS3 and need to restart your user session to refresh user permissions.")
|
||||||
|
|
||||||
if not self._manager.has_privileged_access(self.ubridge_path):
|
#if not self._manager.has_privileged_access(self.ubridge_path):
|
||||||
raise NodeError("uBridge requires root access or the capability to interact with network adapters")
|
# raise NodeError("uBridge requires root access or the capability to interact with network adapters")
|
||||||
|
|
||||||
server_config = self._manager.config.get_section_config("Server")
|
server_config = self._manager.config.get_section_config("Server")
|
||||||
server_host = server_config.get("host")
|
server_host = server_config.get("host")
|
||||||
|
@ -299,11 +299,13 @@ class Cloud(BaseNode):
|
|||||||
await self._ubridge_apply_filters(bridge_name, nio.filters)
|
await self._ubridge_apply_filters(bridge_name, nio.filters)
|
||||||
if port_info["type"] in ("ethernet", "tap"):
|
if port_info["type"] in ("ethernet", "tap"):
|
||||||
|
|
||||||
|
if not self.manager.has_privileged_access(self.ubridge_path):
|
||||||
|
raise NodeError("uBridge requires root access or the capability to interact with Ethernet and TAP adapters")
|
||||||
|
|
||||||
if sys.platform.startswith("win"):
|
if sys.platform.startswith("win"):
|
||||||
await self._add_ubridge_ethernet_connection(bridge_name, port_info["interface"])
|
await self._add_ubridge_ethernet_connection(bridge_name, port_info["interface"])
|
||||||
|
|
||||||
else:
|
else:
|
||||||
|
|
||||||
if port_info["type"] == "ethernet":
|
if port_info["type"] == "ethernet":
|
||||||
network_interfaces = [interface["name"] for interface in self._interfaces()]
|
network_interfaces = [interface["name"] for interface in self._interfaces()]
|
||||||
if not port_info["interface"] in network_interfaces:
|
if not port_info["interface"] in network_interfaces:
|
||||||
|
@ -160,6 +160,8 @@ def test_linux_ethernet_raw_add_nio(linux_platform, project, async_run, nio):
|
|||||||
cloud = Cloud("cloud1", str(uuid.uuid4()), project, MagicMock(), ports=ports)
|
cloud = Cloud("cloud1", str(uuid.uuid4()), project, MagicMock(), ports=ports)
|
||||||
cloud.status = "started"
|
cloud.status = "started"
|
||||||
|
|
||||||
|
with patch("shutil.which", return_value="/bin/ubridge"):
|
||||||
|
with patch("gns3server.compute.base_manager.BaseManager.has_privileged_access", return_value=True):
|
||||||
with asyncio_patch("gns3server.compute.builtin.nodes.cloud.Cloud._ubridge_send") as ubridge_mock:
|
with asyncio_patch("gns3server.compute.builtin.nodes.cloud.Cloud._ubridge_send") as ubridge_mock:
|
||||||
with patch("gns3server.compute.builtin.nodes.cloud.Cloud._interfaces", return_value=[{"name": "eth0"}]):
|
with patch("gns3server.compute.builtin.nodes.cloud.Cloud._interfaces", return_value=[{"name": "eth0"}]):
|
||||||
async_run(cloud.add_nio(nio, 0))
|
async_run(cloud.add_nio(nio, 0))
|
||||||
@ -188,6 +190,8 @@ def test_linux_ethernet_raw_add_nio_bridge(linux_platform, project, async_run, n
|
|||||||
cloud = Cloud("cloud1", str(uuid.uuid4()), project, MagicMock(), ports=ports)
|
cloud = Cloud("cloud1", str(uuid.uuid4()), project, MagicMock(), ports=ports)
|
||||||
cloud.status = "started"
|
cloud.status = "started"
|
||||||
|
|
||||||
|
with patch("shutil.which", return_value="/bin/ubridge"):
|
||||||
|
with patch("gns3server.compute.base_manager.BaseManager.has_privileged_access", return_value=True):
|
||||||
with asyncio_patch("gns3server.compute.builtin.nodes.cloud.Cloud._ubridge_send") as ubridge_mock:
|
with asyncio_patch("gns3server.compute.builtin.nodes.cloud.Cloud._ubridge_send") as ubridge_mock:
|
||||||
with patch("gns3server.compute.builtin.nodes.cloud.Cloud._interfaces", return_value=[{"name": "bridge0"}]):
|
with patch("gns3server.compute.builtin.nodes.cloud.Cloud._interfaces", return_value=[{"name": "bridge0"}]):
|
||||||
with patch("gns3server.utils.interfaces.is_interface_bridge", return_value=True):
|
with patch("gns3server.utils.interfaces.is_interface_bridge", return_value=True):
|
||||||
|
Loading…
Reference in New Issue
Block a user