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

Remove checks for access to TAP and Ethernet interfaces.

This commit is contained in:
grossmj 2014-04-16 18:33:29 -06:00
parent ada36e5382
commit f5d1184b29

View File

@ -580,31 +580,31 @@ class IOU(IModule):
elif request["nio"] == "NIO_TAP": elif request["nio"] == "NIO_TAP":
tap_device = request["tap_device"] tap_device = request["tap_device"]
# check that we have access to the tap device # # check that we have access to the tap device
TUNSETIFF = 0x400454ca # TUNSETIFF = 0x400454ca
IFF_TAP = 0x0002 # IFF_TAP = 0x0002
IFF_NO_PI = 0x1000 # IFF_NO_PI = 0x1000
try: # try:
tun = os.open("/dev/net/tun", os.O_RDWR) # tun = os.open("/dev/net/tun", os.O_RDWR)
except OSError as e: # except OSError as e:
raise IOUError("Could not open /dev/net/tun: {}".format(e)) # raise IOUError("Could not open /dev/net/tun: {}".format(e))
ifr = struct.pack("16sH", tap_device.encode("utf-8"), IFF_TAP | IFF_NO_PI) # ifr = struct.pack("16sH", tap_device.encode("utf-8"), IFF_TAP | IFF_NO_PI)
try: # try:
fcntl.ioctl(tun, TUNSETIFF, ifr) # fcntl.ioctl(tun, TUNSETIFF, ifr)
os.close(tun) # os.close(tun)
except IOError as e: # except IOError as e:
raise IOUError("TAP NIO {}: {}".format(tap_device, e)) # raise IOUError("TAP NIO {}: {}".format(tap_device, e))
nio = NIO_TAP(tap_device) nio = NIO_TAP(tap_device)
elif request["nio"] == "NIO_GenericEthernet": elif request["nio"] == "NIO_GenericEthernet":
ethernet_device = request["ethernet_device"] ethernet_device = request["ethernet_device"]
# check that we have access to the Ethernet device # # check that we have access to the Ethernet device
try: # try:
with socket.socket(socket.AF_INET, socket.SOCK_RAW, socket.IPPROTO_RAW): # with socket.socket(socket.AF_INET, socket.SOCK_RAW, socket.IPPROTO_RAW):
pass # pass
except socket.error as e: # except socket.error as e:
raise IOUError("Generic Ethernet NIO {}: {}".format(ethernet_device, e)) # raise IOUError("Generic Ethernet NIO {}: {}".format(ethernet_device, e))
nio = NIO_GenericEthernet(ethernet_device) nio = NIO_GenericEthernet(ethernet_device)
if not nio: if not nio:
raise IOUError("Requested NIO doesn't exist or is not supported: {}".format(request["nio"])) raise IOUError("Requested NIO doesn't exist or is not supported: {}".format(request["nio"]))