From d8a75b744acff605107c55a4ebbe84f7a2b93560 Mon Sep 17 00:00:00 2001 From: Guillaume Valadon Date: Mon, 28 Oct 2013 11:37:16 +0100 Subject: [PATCH] Catch IOError exception --HG-- branch : Issue #5061 --- scapy/arch/linux.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/scapy/arch/linux.py b/scapy/arch/linux.py index 65347695a..abd46c748 100644 --- a/scapy/arch/linux.py +++ b/scapy/arch/linux.py @@ -89,7 +89,11 @@ def get_if_raw_addr(iff): def get_if_list(): - f=open("/proc/net/dev","r") + try: + f=open("/proc/net/dev","r") + except IOError: + warning("Can't open /proc/net/dev !") + return [] lst = [] f.readline() f.readline() @@ -145,7 +149,11 @@ def set_promisc(s,iff,val=1): def read_routes(): - f=open("/proc/net/route","r") + try: + f=open("/proc/net/route","r") + except IOError: + warning("Can't open /proc/net/route !") + return [] routes = [] s=socket.socket(socket.AF_INET, socket.SOCK_DGRAM) ifreq = ioctl(s, SIOCGIFADDR,struct.pack("16s16x",LOOPBACK_NAME))