wifi-scripts: ucode: fix ssid handling
Add proper escaping for ssid values. Use it to fix multi-ap backhaul ssid. Signed-off-by: Felix Fietkau <nbd@nbd.name>
This commit is contained in:
@@ -4,7 +4,7 @@ import * as libuci from 'uci';
|
||||
import { md5 } from 'digest';
|
||||
import * as fs from 'fs';
|
||||
|
||||
import { append, append_raw, append_value, append_vars, comment, push_config, set_default, touch_file } from 'wifi.common';
|
||||
import { append, append_raw, append_value, append_vars, append_string_vars, comment, push_config, set_default, touch_file } from 'wifi.common';
|
||||
import * as netifd from 'wifi.netifd';
|
||||
import * as iface from 'wifi.iface';
|
||||
|
||||
@@ -44,17 +44,19 @@ function iface_setup(config) {
|
||||
config.ap_isolate = 1;
|
||||
|
||||
append('bssid', config.macaddr);
|
||||
config.ssid2 = config.ssid;
|
||||
append_string_vars(config, [ 'ssid2' ]);
|
||||
|
||||
append_vars(config, [
|
||||
append_vars(config, [
|
||||
'ctrl_interface', 'ap_isolate', 'max_num_sta', 'ap_max_inactivity', 'airtime_bss_weight',
|
||||
'airtime_bss_limit', 'airtime_sta_weight', 'bss_load_update_period', 'chan_util_avg_period',
|
||||
'disassoc_low_ack', 'skip_inactivity_poll', 'ignore_broadcast_ssid', 'uapsd_advertisement_enabled',
|
||||
'utf8_ssid', 'multi_ap', 'ssid', 'tdls_prohibit', 'bridge', 'wds_sta', 'wds_bridge',
|
||||
'utf8_ssid', 'multi_ap', 'tdls_prohibit', 'bridge', 'wds_sta', 'wds_bridge',
|
||||
'snoop_iface', 'vendor_elements', 'nas_identifier', 'radius_acct_interim_interval',
|
||||
'ocv', 'multicast_to_unicast', 'preamble', 'wmm_enabled', 'proxy_arp', 'per_sta_vif', 'mbo',
|
||||
'bss_transition', 'wnm_sleep_mode', 'wnm_sleep_mode_no_keys', 'qos_map_set', 'max_listen_int',
|
||||
'dtim_period',
|
||||
]);
|
||||
]);
|
||||
}
|
||||
|
||||
function iface_authentication_server(config) {
|
||||
@@ -102,11 +104,9 @@ function iface_auth_type(config) {
|
||||
config.wps_possible = 1;
|
||||
config.wps_state = 1;
|
||||
|
||||
if (config.owe_transition_ssid)
|
||||
config.owe_transition_ssid = `"${config.owe_transition_ssid}"`;
|
||||
|
||||
append_string_vars(config, [ 'owe_transition_ssid' ]);
|
||||
append_vars(config, [
|
||||
'owe_transition_ssid', 'owe_transition_bssid', 'owe_transition_ifname',
|
||||
'owe_transition_bssid', 'owe_transition_ifname',
|
||||
]);
|
||||
break;
|
||||
|
||||
@@ -200,7 +200,7 @@ function iface_wps(config) {
|
||||
set_default(config, 'upnp_iface', config.network_bridge);
|
||||
|
||||
if (config.multi_ap && config.multi_ap_backhaul_ssid) {
|
||||
append_vars(config, [ 'multi_ap_backhaul_ssid' ]);
|
||||
append_string_vars(config, [ 'multi_ap_backhaul_ssid' ]);
|
||||
if (length(config.multi_ap_backhaul_key) == 64)
|
||||
append('multi_ap_backhaul_wpa_psk', config.multi_ap_backhaul_key);
|
||||
else if (length(config.multi_ap_backhaul_key) > 8)
|
||||
|
||||
@@ -32,11 +32,31 @@ export function append(key, value) {
|
||||
append_raw(key + '=' + value);
|
||||
};
|
||||
|
||||
function escape_string(value) {
|
||||
let chars = map(split(value, ''), (v) => ord(v));
|
||||
if (length(filter(chars, (v) => (v < 32 || v >= 128))) > 0)
|
||||
return hexenc(value);
|
||||
|
||||
return `"${value}"`;
|
||||
}
|
||||
|
||||
export function append_string(key, value) {
|
||||
if (value == null)
|
||||
return;
|
||||
|
||||
append(key, escape_string(value));
|
||||
};
|
||||
|
||||
export function append_vars(dict, keys) {
|
||||
for (let key in keys)
|
||||
append(key, dict[key]);
|
||||
};
|
||||
|
||||
export function append_string_vars(dict, keys) {
|
||||
for (let key in keys)
|
||||
append_string(key, dict[key]);
|
||||
};
|
||||
|
||||
export function network_append_raw(value) {
|
||||
network_data += value + '\n';
|
||||
};
|
||||
@@ -57,11 +77,23 @@ export function network_append(key, value) {
|
||||
network_append_raw('\t' + key + '=' + value);
|
||||
};
|
||||
|
||||
export function network_append_string(key, value) {
|
||||
if (value == null)
|
||||
return;
|
||||
|
||||
network_append_raw('\t' + key + '=' + escape_string(value));
|
||||
};
|
||||
|
||||
export function network_append_vars(dict, keys) {
|
||||
for (let key in keys)
|
||||
network_append(key, dict[key]);
|
||||
};
|
||||
|
||||
export function network_append_string_vars(dict, keys) {
|
||||
for (let key in keys)
|
||||
network_append_string(key, dict[key]);
|
||||
};
|
||||
|
||||
export function set_default(dict, key, value) {
|
||||
if (dict[key] == null)
|
||||
dict[key] = value;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
'use strict';
|
||||
|
||||
import { append, append_raw, append_vars, network_append, network_append_raw, network_append_vars,
|
||||
set_default, dump_network, flush_network } from 'wifi.common';
|
||||
network_append_string_vars, set_default, dump_network, flush_network } from 'wifi.common';
|
||||
import * as netifd from 'wifi.netifd';
|
||||
import * as iface from 'wifi.iface';
|
||||
import * as fs from 'fs';
|
||||
@@ -157,14 +157,14 @@ function setup_sta(data, config) {
|
||||
|
||||
config.basic_rate = ratelist(config.basic_rate);
|
||||
config.mcast_rate = ratestr(config.mcast_rate);
|
||||
config.ssid = `"${config.ssid}"`;
|
||||
|
||||
network_append_string_vars(config, [ 'ssid' ]);
|
||||
network_append_vars(config, [
|
||||
'scan_ssid', 'noscan', 'disabled', 'multi_ap_backhaul_sta',
|
||||
'ocv', 'key_mgmt', 'psk', 'sae_password', 'pairwise', 'group', 'bssid',
|
||||
'proto', 'mesh_fwding', 'mesh_rssi_threshold', 'frequency', 'fixed_freq',
|
||||
'disable_ht', 'disable_ht40', 'disable_vht', 'vht', 'max_oper_chwidth',
|
||||
'ht40', 'ssid', 'beacon_int', 'ieee80211w', 'basic_rate', 'mcast_rate',
|
||||
'ht40', 'beacon_int', 'ieee80211w', 'basic_rate', 'mcast_rate',
|
||||
'bssid_blacklist', 'bssid_whitelist', 'erp', 'ca_cert', 'identity',
|
||||
'anonymous_identity', 'client_cert', 'private_key', 'private_key_passwd',
|
||||
'subject_match', 'altsubject_match', 'domain_match', 'domain_suffix_match',
|
||||
|
||||
Reference in New Issue
Block a user