diff options
Diffstat (limited to 'src/conf_mode/interfaces-wireless.py')
-rwxr-xr-x | src/conf_mode/interfaces-wireless.py | 30 |
1 files changed, 11 insertions, 19 deletions
diff --git a/src/conf_mode/interfaces-wireless.py b/src/conf_mode/interfaces-wireless.py index 2c67c39ae..b6e62b0aa 100755 --- a/src/conf_mode/interfaces-wireless.py +++ b/src/conf_mode/interfaces-wireless.py @@ -25,15 +25,15 @@ from grp import getgrnam from re import findall from subprocess import Popen, PIPE -from psutil import pid_exists from netifaces import interfaces from netaddr import * -from vyos.ifconfig import WiFiIf -from vyos.ifconfig_vlan import apply_vlan_config, verify_vlan_config +from vyos import ConfigError from vyos.configdict import list_diff, vlan_to_dict from vyos.config import Config -from vyos import ConfigError +from vyos.ifconfig import WiFiIf +from vyos.ifconfig_vlan import apply_vlan_config, verify_vlan_config +from vyos.util import process_running user = 'root' group = 'vyattacfg' @@ -1364,15 +1364,9 @@ def verify(wifi): return None def generate(wifi): - pid = 0 # always stop hostapd service first before reconfiguring it pidfile = get_pid('hostapd', wifi['intf']) - if os.path.isfile(pidfile): - pid = 0 - with open(pidfile, 'r') as f: - pid = int(f.read()) - - if pid_exists(pid): + if process_running(pidfile): cmd = 'start-stop-daemon' cmd += ' --stop ' cmd += ' --quiet' @@ -1382,12 +1376,7 @@ def generate(wifi): # always stop wpa_supplicant service first before reconfiguring it pidfile = get_pid('wpa_supplicant', wifi['intf']) - if os.path.isfile(pidfile): - pid = 0 - with open(pidfile, 'r') as f: - pid = int(f.read()) - - if pid_exists(pid): + if process_running(pidfile): cmd = 'start-stop-daemon' cmd += ' --stop ' cmd += ' --quiet' @@ -1409,7 +1398,10 @@ def generate(wifi): # http://wiki.stocksy.co.uk/wiki/Multiple_SSIDs_with_hostapd # generate locally administered MAC address from used phy interface with open('/sys/class/ieee80211/{}/addresses'.format(wifi['phy']), 'r') as f: - tmp = EUI(f.read().rstrip()).value + # some PHYs tend to have multiple interfaces and thus supply multiple MAC + # addresses - we only need the first one for our calculation + tmp = f.readline().rstrip() + tmp = EUI(tmp).value # mask last nibble from the MAC address tmp &= 0xfffffffffff0 # set locally administered bit in MAC address @@ -1496,7 +1488,7 @@ def apply(wifi): # if custom mac is removed if wifi['mac']: w.set_mac(wifi['mac']) - else: + elif wifi['hw_id']: w.set_mac(wifi['hw_id']) # configure ARP filter configuration |