# or dnsmasq. This is important as the libc resolver isn't that powerful.
resolv_conf_dir="$state_dir/resolv.conf"
+NL="
+"
build_resolv_conf()
{
if [ -n "$2" ]; then
search="$search $*"
elif [ -n "$1" ]; then
- domain="domain $1\n"
+ domain="domain $1$NL"
fi
- [ -n "$search" ] && search="search $(uniqify $search)\n"
+ [ -n "$search" ] && search="search $(uniqify $search)$NL"
# Build the nameserver list
srvs=$(cd "$resolv_conf_dir"; \
key_get_value "nameserver " ${interfaces})
for x in $(uniqify ${srvs}); do
- servers="${servers}nameserver $x\n"
+ servers="${servers}nameserver $x$NL"
done
fi
header="$signature_base${header:+ $from }$header"
else
echo "# /etc/resolv.conf.head can replace this line" >> "$cf"
fi
- printf "$domain$search$servers" >> "$cf"
+ printf %s "$domain$search$servers" >> "$cf"
if [ -f /etc/resolv.conf.tail ]; then
cat /etc/resolv.conf.tail >> "$cf"
else
add_resolv_conf()
{
- local x= conf="$signature\n"
+ local x= conf="$signature$NL"
# If we don't have any configuration, remove it
if [ -z "$new_domain_name_servers" -a \
set -- $new_domain_name
new_domain_name="$1"
if valid_domainname "$new_domain_name"; then
- conf="${conf}domain $new_domain_name\n"
+ conf="${conf}domain $new_domain_name$NL"
else
syslog err "Invalid domain name: $new_domain_name"
fi
fi
if [ -n "$new_domain_search" ]; then
if valid_domainname_list; then
- conf="${conf}search $new_domain_search\n"
+ conf="${conf}search $new_domain_search$NL"
else
syslog err "Invalid domain name in list: $new_domain_search"
fi
fi
for x in ${new_domain_name_servers}; do
- conf="${conf}nameserver $x\n"
+ conf="${conf}nameserver $x$NL"
done
if type resolvconf >/dev/null 2>&1; then
[ -n "$ifmetric" ] && export IF_METRIC="$ifmetric"
- printf "$conf" | resolvconf -a "$interface"
+ printf %s "$conf" | resolvconf -a "$interface"
return $?
fi
rm -f "$resolv_conf_dir/$interface"
fi
[ -d "$resolv_conf_dir" ] || mkdir -p "$resolv_conf_dir"
- printf "$conf" > "$resolv_conf_dir/$interface"
+ printf %s "$conf" > "$resolv_conf_dir/$interface"
build_resolv_conf
}
ntp_conf_dir="$state_dir/ntp.conf"
ntp_conf=${NTP_CONF:-/etc/ntp.conf}
+NL="
+"
build_ntp_conf()
{
key_get_value "server " $interfaces)
if [ -n "$srvs" ]; then
for x in $(uniqify $srvs); do
- servers="${servers}server $x\n"
+ servers="${servers}server $x$NL"
done
fi
fi
if [ -n "$servers" ]; then
echo "$signature_base${header:+ $from }$header" >> "$cf"
- printf "$search$servers" >> "$cf"
+ printf %s "$search$servers" >> "$cf"
echo "$signature_base_end${header:+ $from }$header" >> "$cf"
else
[ -e "$ntp_conf" ] || return