olsrd: init: fix all work with is done via IFS (storing old value, set IFS, work, set back to old value)
This commit is contained in:
parent
1d387e8dd2
commit
08ab70a984
1 changed files with 9 additions and 28 deletions
|
@ -39,9 +39,7 @@ validate_olsrd_option() {
|
||||||
|
|
||||||
system_config() {
|
system_config() {
|
||||||
local cfg="$1"
|
local cfg="$1"
|
||||||
local cfgt
|
local cfgt hostname latlon oldIFS
|
||||||
local hostname
|
|
||||||
local latlon
|
|
||||||
|
|
||||||
config_get cfgt "$cfg" TYPE
|
config_get cfgt "$cfg" TYPE
|
||||||
|
|
||||||
|
@ -53,9 +51,7 @@ system_config() {
|
||||||
|
|
||||||
if [ -z "$SYSTEM_LAT" -o -z "$SYSTEM_LON" ]; then
|
if [ -z "$SYSTEM_LAT" -o -z "$SYSTEM_LON" ]; then
|
||||||
config_get latlon "$cfg" latlon
|
config_get latlon "$cfg" latlon
|
||||||
IFS=" ${T}${N},"
|
oldIFS="$IFS"; IFS=" ${T}${N},"; set -- $latlon; IFS="$oldIFS"
|
||||||
set -- $latlon
|
|
||||||
unset IFS
|
|
||||||
SYSTEM_LAT="$1"
|
SYSTEM_LAT="$1"
|
||||||
SYSTEM_LON="$2"
|
SYSTEM_LON="$2"
|
||||||
fi
|
fi
|
||||||
|
@ -139,7 +135,7 @@ olsrd_write_plparam() {
|
||||||
validate_varname "$option" || return 1
|
validate_varname "$option" || return 1
|
||||||
local value="$4"
|
local value="$4"
|
||||||
local option_type="$5"
|
local option_type="$5"
|
||||||
local _option
|
local _option oldIFS
|
||||||
|
|
||||||
if [ "$option_type" = bool ]; then
|
if [ "$option_type" = bool ]; then
|
||||||
case "$value" in
|
case "$value" in
|
||||||
|
@ -154,17 +150,17 @@ olsrd_write_plparam() {
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
IFS='-_'
|
oldIFS="$IFS"; IFS='-_'; set -- $option; IFS="$oldIFS"
|
||||||
set -- $option
|
|
||||||
option="$*"
|
option="$*"
|
||||||
unset IFS
|
|
||||||
_option="$option"
|
_option="$option"
|
||||||
|
|
||||||
if [ "$option" = 'hosts' ]; then
|
if [ "$option" = 'hosts' ]; then
|
||||||
set -- $value
|
set -- $value
|
||||||
option="$1"
|
option="$1"
|
||||||
shift
|
shift
|
||||||
value="$*"
|
value="$*"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ "$option" = 'NonOlsrIf' ]; then
|
if [ "$option" = 'NonOlsrIf' ]; then
|
||||||
if validate_varname "$value"; then
|
if validate_varname "$value"; then
|
||||||
if network_get_device ifname "$value"; then
|
if network_get_device ifname "$value"; then
|
||||||
|
@ -184,7 +180,6 @@ olsrd_write_plparam() {
|
||||||
}
|
}
|
||||||
|
|
||||||
config_update_schema() {
|
config_update_schema() {
|
||||||
unset IFS
|
|
||||||
local schema_varname="$1"
|
local schema_varname="$1"
|
||||||
validate_varname "$schema_varname" || return 1
|
validate_varname "$schema_varname" || return 1
|
||||||
local command="$2"
|
local command="$2"
|
||||||
|
@ -226,7 +221,6 @@ config_update_schema() {
|
||||||
|
|
||||||
config_write_options() {
|
config_write_options() {
|
||||||
local funcname="config_write_options"
|
local funcname="config_write_options"
|
||||||
unset IFS
|
|
||||||
local schema="$1"
|
local schema="$1"
|
||||||
local cfg="$2"
|
local cfg="$2"
|
||||||
validate_varname "$cfg" || return 1
|
validate_varname "$cfg" || return 1
|
||||||
|
@ -234,18 +228,7 @@ config_write_options() {
|
||||||
[ -z "$write_func" ] && output_func=echo
|
[ -z "$write_func" ] && output_func=echo
|
||||||
local write_param="$4"
|
local write_param="$4"
|
||||||
|
|
||||||
local schema_entry
|
local schema_entry option option_length option_type default value list_size list_item list_value i position speed oldIFS
|
||||||
local option
|
|
||||||
local option_length
|
|
||||||
local option_type
|
|
||||||
local default
|
|
||||||
local value
|
|
||||||
local list_size
|
|
||||||
local list_item
|
|
||||||
local list_value
|
|
||||||
local i
|
|
||||||
local position
|
|
||||||
local speed
|
|
||||||
local list_speed_vars="HelloInterval HelloValidityTime TcInterval TcValidityTime MidInterval MidValidityTime HnaInterval HnaValidityTime"
|
local list_speed_vars="HelloInterval HelloValidityTime TcInterval TcValidityTime MidInterval MidValidityTime HnaInterval HnaValidityTime"
|
||||||
|
|
||||||
get_value_for_entry()
|
get_value_for_entry()
|
||||||
|
@ -256,7 +239,7 @@ config_write_options() {
|
||||||
[ "$default" = "$schema_entry" ] && default=
|
[ "$default" = "$schema_entry" ] && default=
|
||||||
option="${schema_entry%%[=]*}"
|
option="${schema_entry%%[=]*}"
|
||||||
|
|
||||||
IFS=':'; set -- $option; unset IFS
|
oldIFS="$IFS"; IFS=':'; set -- $option; IFS="$oldIFS"
|
||||||
option="$1"
|
option="$1"
|
||||||
option_type="$2"
|
option_type="$2"
|
||||||
|
|
||||||
|
@ -349,9 +332,7 @@ config_write_options() {
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -z "$value" ]; then
|
if [ -z "$value" ]; then
|
||||||
IFS='+'
|
oldIFS="$IFS"; IFS='+'; set -- $default; IFS="$oldIFS"
|
||||||
set -- $default
|
|
||||||
unset IFS
|
|
||||||
value=$*
|
value=$*
|
||||||
elif [ "$value" = '-' -a -n "$default" ]; then
|
elif [ "$value" = '-' -a -n "$default" ]; then
|
||||||
continue
|
continue
|
||||||
|
|
Loading…
Reference in a new issue