From 0b10e1d0196fa33d1ba67623bc7a1270d5481d5d Mon Sep 17 00:00:00 2001 From: Cristobal Rosa Date: Fri, 27 Sep 2013 09:14:11 +0200 Subject: [PATCH 1/2] Added a new check to check whether an network interface is in promiscuous mode --- system/setup | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/system/setup b/system/setup index a0901ec366e..7ede90c98de 100755 --- a/system/setup +++ b/system/setup @@ -1440,6 +1440,15 @@ class LinuxNetwork(Network): path = os.path.join(path, 'bonding', 'all_slaves_active') if os.path.exists(path): interfaces[device]['all_slaves_active'] = open(path).read() == '1' + #Check whether a interface is in promiscuous mode + if os.path.exists(os.path.join(path,'flags')): + promisc_mode = False + # The second byte indicates whether the interface is in promiscuous mode. + # 1 = promisc + # 0 = no promisc + data = int(open(os.path.join(path, 'flags')).read().strip(),16) + promisc_mode = (data & 0x0100 > 0) + interfaces[device]['promisc'] = promisc_mode ip_path = module.get_bin_path("ip") output = subprocess.Popen([ip_path, 'addr', 'show', device], stdout=subprocess.PIPE, stderr=subprocess.PIPE).communicate()[0] for line in output.split('\n'): From 0cbb97bddc07882277f4ff7d9e1003bbf259a21e Mon Sep 17 00:00:00 2001 From: Cristobal Rosa Date: Fri, 27 Sep 2013 23:29:05 +0200 Subject: [PATCH 2/2] Added an space between code and comments in order to follow the coding standars --- system/setup | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/system/setup b/system/setup index 7ede90c98de..e3279717a84 100755 --- a/system/setup +++ b/system/setup @@ -1440,7 +1440,7 @@ class LinuxNetwork(Network): path = os.path.join(path, 'bonding', 'all_slaves_active') if os.path.exists(path): interfaces[device]['all_slaves_active'] = open(path).read() == '1' - #Check whether a interface is in promiscuous mode + # Check whether a interface is in promiscuous mode if os.path.exists(os.path.join(path,'flags')): promisc_mode = False # The second byte indicates whether the interface is in promiscuous mode.