From 2c9bbd821d6cb6f9ea66435e5a2161e85c1b9350 Mon Sep 17 00:00:00 2001 From: Christian Poessinger Date: Thu, 21 May 2020 18:21:07 +0200 Subject: wireless: T1627: remove get_conf_file() --- src/conf_mode/interfaces-wireless.py | 27 ++++++++-------------- .../system/wpa_supplicant@.service.d/override.conf | 4 ++-- 2 files changed, 11 insertions(+), 20 deletions(-) (limited to 'src') diff --git a/src/conf_mode/interfaces-wireless.py b/src/conf_mode/interfaces-wireless.py index f13408fa2..0fa20c5f4 100755 --- a/src/conf_mode/interfaces-wireless.py +++ b/src/conf_mode/interfaces-wireless.py @@ -95,16 +95,9 @@ default_config_data = { 'vif_s_remove': [] } -def get_conf_file(conf_type, intf): - cfg_dir = '/run/' + conf_type - - # create directory on demand - if not os.path.exists(cfg_dir): - os.makedirs(cfg_dir, 0o755) - chown(cfg_dir, 'root', 'vyattacfg') - - cfg_file = cfg_dir + r'/{}.conf'.format(intf) - return cfg_file +# XXX: wpa_supplicant works on the source interface +wpa_suppl_conf = '/run/wpa_supplicant/{intf}.conf' +hostapd_conf = '/run/hostapd/{intf}.conf' def get_config(): # determine tagNode instance @@ -518,11 +511,11 @@ def generate(wifi): # Delete config files if interface is removed if wifi['deleted']: - if os.path.isfile(get_conf_file('hostapd', interface)): - os.unlink(get_conf_file('hostapd', interface)) + if os.path.isfile(hostapd_conf.format(**wifi)): + os.unlink(hostapd_conf.format(**wifi)) - if os.path.isfile(get_conf_file('wpa_supplicant', interface)): - os.unlink(get_conf_file('wpa_supplicant', interface)) + if os.path.isfile(wpa_suppl_conf.format(**wifi)): + os.unlink(wpa_suppl_conf.format(**wifi)) return None @@ -550,12 +543,10 @@ def generate(wifi): # render appropriate new config files depending on access-point or station mode if wifi['op_mode'] == 'ap': - conf = get_conf_file('hostapd', interface) - render(conf, 'wifi/hostapd.conf.tmpl', wifi) + render(hostapd_conf.format(**wifi), 'wifi/hostapd.conf.tmpl', wifi) elif wifi['op_mode'] == 'station': - conf = get_conf_file('wpa_supplicant', interface) - render(conf, 'wifi/wpa_supplicant.conf.tmpl', wifi) + render(wpa_suppl_conf.format(**wifi), 'wifi/wpa_supplicant.conf.tmpl', wifi) return None diff --git a/src/etc/systemd/system/wpa_supplicant@.service.d/override.conf b/src/etc/systemd/system/wpa_supplicant@.service.d/override.conf index 20b25b726..a895e675f 100644 --- a/src/etc/systemd/system/wpa_supplicant@.service.d/override.conf +++ b/src/etc/systemd/system/wpa_supplicant@.service.d/override.conf @@ -5,6 +5,6 @@ After=vyos-router.service [Service] WorkingDirectory= WorkingDirectory=/run/wpa_supplicant -EnvironmentFile= +PIDFile=/run/wpa_supplicant/%I.pid ExecStart= -ExecStart=/sbin/wpa_supplicant -c%I.conf -Dnl80211,wext -i%I +ExecStart=/sbin/wpa_supplicant -c/run/wpa_supplicant/%I.conf -Dnl80211,wext -i%I -- cgit v1.2.3