You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
gentoo-overlay/net-misc/dhcp/files/dhcp-4.3.6-dhclient-resolvc...

423 lines
15 KiB

--- dhcp-4.3.6/client/scripts/bsdos
+++ dhcp-4.3.6/client/scripts/bsdos
@@ -1,27 +1,25 @@
#!/bin/sh
make_resolv_conf() {
+ if [ x"$PEER_DNS" != x ] && [ x"$PEER_DNS" != xyes ]; then
+ return 0
+ fi
+ local conf=
if [ x"$new_domain_name_servers" != x ]; then
- cat /dev/null > /etc/resolv.conf.dhclient
if [ "x$new_domain_search" != x ]; then
- echo search $new_domain_search >> /etc/resolv.conf.dhclient
+ conf="${conf}search ${new_domain_search}\n"
elif [ "x$new_domain_name" != x ]; then
# Note that the DHCP 'Domain Name Option' is really just a domain
# name, and that this practice of using the domain name option as
# a search path is both nonstandard and deprecated.
- echo search $new_domain_name >> /etc/resolv.conf.dhclient
+ conf="${conf}search ${new_domain_name}\n"
fi
for nameserver in $new_domain_name_servers; do
- echo nameserver $nameserver >> /etc/resolv.conf.dhclient
+ conf="${conf}nameserver ${nameserver}\n"
done
-
- mv /etc/resolv.conf.dhclient /etc/resolv.conf
elif [ "x${new_dhcp6_name_servers}" != x ] ; then
- cat /dev/null > /etc/resolv.conf.dhclient6
- chmod 644 /etc/resolv.conf.dhclient6
-
if [ "x${new_dhcp6_domain_search}" != x ] ; then
- echo search ${new_dhcp6_domain_search} >> /etc/resolv.conf.dhclient6
+ conf="${conf}search ${new_dhcp6_domain_search}\n"
fi
for nameserver in ${new_dhcp6_name_servers} ; do
# If the nameserver has a link-local address
@@ -31,10 +29,18 @@
FE80:*) zone_id="%$interface";;
*) zone_id="";;
esac
- echo nameserver ${nameserver}$zone_id >> /etc/resolv.conf.dhclient6
+ conf="${conf}nameserver ${nameserver}$zone_id\n"
done
+ fi
- mv /etc/resolv.conf.dhclient6 /etc/resolv.conf
+ if [ x"$conf" != x ]; then
+ conf="# Generated by dhclient or interface $interface\n${conf}"
+ if type resolvconf >/dev/null 2>&1; then
+ printf "${conf}" | resolvconf -a $interface
+ else
+ printf "${conf}" > /etc/resolv.conf
+ chmod 644 /etc/resolv.conf
+ fi
fi
}
--- dhcp-4.3.6/client/scripts/freebsd
+++ dhcp-4.3.6/client/scripts/freebsd
@@ -11,54 +11,23 @@
fi
make_resolv_conf() {
+ if [ x"$PEER_DNS" != x ] && [ x"$PEER_DNS" != xyes ]; then
+ return 0
+ fi
+ local conf=
if [ x"$new_domain_name_servers" != x ]; then
- ( cat /dev/null > /etc/resolv.conf.dhclient )
- exit_status=$?
- if [ $exit_status -ne 0 ]; then
- $LOGGER "Unable to create /etc/resolv.conf.dhclient: Error $exit_status"
- else
- if [ "x$new_domain_search" != x ]; then
- ( echo search $new_domain_search >> /etc/resolv.conf.dhclient )
- exit_status=$?
- elif [ "x$new_domain_name" != x ]; then
- # Note that the DHCP 'Domain Name Option' is really just a domain
- # name, and that this practice of using the domain name option as
- # a search path is both nonstandard and deprecated.
- ( echo search $new_domain_name >> /etc/resolv.conf.dhclient )
- exit_status=$?
- fi
- for nameserver in $new_domain_name_servers; do
- if [ $exit_status -ne 0 ]; then
- break
- fi
- ( echo nameserver $nameserver >>/etc/resolv.conf.dhclient )
- exit_status=$?
- done
-
- # If there were no errors, attempt to mv the new file into place.
- if [ $exit_status -eq 0 ]; then
- ( mv /etc/resolv.conf.dhclient /etc/resolv.conf )
- exit_status=$?
- fi
-
- if [ $exit_status -ne 0 ]; then
- $LOGGER "Error while writing new /etc/resolv.conf."
- fi
+ if [ "x$new_domain_search" != x ]; then
+ conf="${conf}search ${new_domain_search}\n"
+ elif [ "x$new_domain_name" != x ]; then
+ # Note that the DHCP 'Domain Name Option' is really just a domain
+ # name, and that this practice of using the domain name option as
+ # a search path is both nonstandard and deprecated.
+ conf="${conf}search ${new_domain_name}\n"
fi
+ for nameserver in $new_domain_name_servers; do
+ conf="${conf}nameserver ${nameserver}\n"
+ done
elif [ "x${new_dhcp6_name_servers}" != x ] ; then
- ( cat /dev/null > /etc/resolv.conf.dhclient6 )
- exit_status=$?
- if [ $exit_status -ne 0 ] ; then
- $LOGGER "Unable to create /etc/resolv.conf.dhclient6: Error $exit_status"
- else
- if [ "x${new_dhcp6_domain_search}" != x ] ; then
- ( echo search ${new_dhcp6_domain_search} >> /etc/resolv.conf.dhclient6 )
- exit_status=$?
- fi
- for nameserver in ${new_dhcp6_name_servers} ; do
- if [ $exit_status -ne 0 ] ; then
- break
- fi
# If the nameserver has a link-local address
# add a <zone_id> (interface name) to it.
case $nameserver in
@@ -66,18 +35,21 @@
FE80:*) zone_id="%$interface";;
*) zone_id="";;
esac
- ( echo nameserver ${nameserver}$zone_id >> /etc/resolv.conf.dhclient6 )
- exit_status=$?
- done
-
- if [ $exit_status -eq 0 ] ; then
- ( mv /etc/resolv.conf.dhclient6 /etc/resolv.conf )
- exit_status=$?
- fi
+ if [ "x${new_dhcp6_domain_search}" != x ] ; then
+ conf="${conf}search ${new_dhcp6_domain_search}\n"
+ fi
+ for nameserver in ${new_dhcp6_name_servers} ; do
+ conf="${conf}nameserver ${nameserver}$zone_id\n"
+ done
+ fi
- if [ $exit_status -ne 0 ] ; then
- $LOGGER "Error while writing new /etc/resolv.conf."
- fi
+ if [ x"$conf" != x ]; then
+ conf="# Generated by dhclient or interface $interface\n${conf}"
+ if type resolvconf >/dev/null 2>&1; then
+ printf "${conf}" | resolvconf -a $interface
+ else
+ printf "${conf}" > /etc/resolv.conf
+ chmod 644 /etc/resolv.conf
fi
fi
}
--- dhcp-4.3.6/client/scripts/linux
+++ dhcp-4.3.6/client/scripts/linux
@@ -35,16 +35,16 @@
# update /etc/resolv.conf based on received values
# This updated version mostly follows Debian script by Andrew Pollock et al.
make_resolv_conf() {
- local new_resolv_conf
+ if [ x"$PEER_DNS" != x ] && [ x"$PEER_DNS" != xyes ]; then
+ return 0
+ fi
+ local conf
# DHCPv4
if [ -n "$new_domain_search" ] || [ -n "$new_domain_name" ] ||
[ -n "$new_domain_name_servers" ]; then
- new_resolv_conf=/etc/resolv.conf.dhclient-new
- rm -f $new_resolv_conf
-
if [ -n "$new_domain_name" ]; then
- echo domain ${new_domain_name%% *} >>$new_resolv_conf
+ conf="${conf}domain ${new_domain_name%% *}\n"
fi
if [ -n "$new_domain_search" ]; then
@@ -60,31 +60,23 @@
new_domain_search="$new_domain_name $new_domain_search"
fi
fi
- echo "search ${new_domain_search}" >> $new_resolv_conf
+ conf="${conf}search ${new_domain_search}\n"
elif [ -n "$new_domain_name" ]; then
- echo "search ${new_domain_name}" >> $new_resolv_conf
+ conf="${conf}search ${new_domain_name}\n"
fi
if [ -n "$new_domain_name_servers" ]; then
for nameserver in $new_domain_name_servers; do
- echo nameserver $nameserver >>$new_resolv_conf
+ conf="${conf}nameserver $nameserver\n"
done
else # keep 'old' nameservers
- sed -n /^\w*[Nn][Aa][Mm][Ee][Ss][Ee][Rr][Vv][Ee][Rr]/p /etc/resolv.conf >>$new_resolv_conf
+ conf="${conf}$(sed -n /^\w*[Nn][Aa][Mm][Ee][Ss][Ee][Rr][Vv][Ee][Rr]/p /etc/resolv.conf)\n"
fi
- if [ -f /etc/resolv.conf ]; then
- chown --reference=/etc/resolv.conf $new_resolv_conf
- chmod --reference=/etc/resolv.conf $new_resolv_conf
- fi
- mv -f $new_resolv_conf /etc/resolv.conf
# DHCPv6
elif [ -n "$new_dhcp6_domain_search" ] || [ -n "$new_dhcp6_name_servers" ]; then
- new_resolv_conf=/etc/resolv.conf.dhclient-new
- rm -f $new_resolv_conf
-
if [ -n "$new_dhcp6_domain_search" ]; then
- echo "search ${new_dhcp6_domain_search}" >> $new_resolv_conf
+ conf="${conf}search ${new_dhcp6_domain_search}\n"
fi
if [ -n "$new_dhcp6_name_servers" ]; then
@@ -94,17 +86,21 @@
[ "${nameserver##FE80::}" != "$nameserver" ]; then
nameserver="${nameserver}%${interface}"
fi
- echo nameserver $nameserver >>$new_resolv_conf
+ conf="${conf}nameserver $nameserver\n"
done
else # keep 'old' nameservers
- sed -n /^\w*[Nn][Aa][Mm][Ee][Ss][Ee][Rr][Vv][Ee][Rr]/p /etc/resolv.conf >>$new_resolv_conf
+ conf="${conf}$(sed -n /^\w*[Nn][Aa][Mm][Ee][Ss][Ee][Rr][Vv][Ee][Rr]/p /etc/resolv.conf)\n"
fi
+ fi
- if [ -f /etc/resolv.conf ]; then
- chown --reference=/etc/resolv.conf $new_resolv_conf
- chmod --reference=/etc/resolv.conf $new_resolv_conf
+ if [ x"$conf" != x ]; then
+ conf="# Generated by dhclient or interface $interface\n${conf}"
+ if type resolvconf >/dev/null 2>&1; then
+ printf "${conf}" | resolvconf -a $interface
+ else
+ printf "${conf}" > /etc/resolv.conf
+ chmod 644 /etc/resolv.conf
fi
- mv -f $new_resolv_conf /etc/resolv.conf
fi
}
--- dhcp-4.3.6/client/scripts/netbsd
+++ dhcp-4.3.6/client/scripts/netbsd
@@ -1,27 +1,25 @@
#!/bin/sh
make_resolv_conf() {
- if [ "x$new_domain_name" != x ] && [ x"$new_domain_name_servers" != x ]; then
- cat /dev/null > /etc/resolv.conf.dhclient
+ if [ x"$PEER_DNS" != x ] && [ x"$PEER_DNS" != xyes ]; then
+ return 0
+ fi
+ local conf=
+ if [ x"$new_domain_name_servers" != x ]; then
if [ "x$new_domain_search" != x ]; then
- echo search $new_domain_search >> /etc/resolv.conf.dhclient
+ conf="${conf}search ${new_domain_search}\n"
elif [ "x$new_domain_name" != x ]; then
# Note that the DHCP 'Domain Name Option' is really just a domain
# name, and that this practice of using the domain name option as
# a search path is both nonstandard and deprecated.
- echo search $new_domain_name >> /etc/resolv.conf.dhclient
+ conf="${conf}search ${new_domain_name}\n"
fi
for nameserver in $new_domain_name_servers; do
- echo nameserver $nameserver >>/etc/resolv.conf.dhclient
+ conf="${conf}nameserver ${nameserver}\n"
done
-
- mv /etc/resolv.conf.dhclient /etc/resolv.conf
elif [ "x${new_dhcp6_name_servers}" != x ] ; then
- cat /dev/null > /etc/resolv.conf.dhclient6
- chmod 644 /etc/resolv.conf.dhclient6
-
if [ "x${new_dhcp6_domain_search}" != x ] ; then
- echo search ${new_dhcp6_domain_search} >> /etc/resolv.conf.dhclient6
+ conf="${conf}search ${new_dhcp6_domain_search}\n"
fi
for nameserver in ${new_dhcp6_name_servers} ; do
# If the nameserver has a link-local address
@@ -31,10 +29,18 @@
FE80:*) zone_id="%$interface";;
*) zone_id="";;
esac
- echo nameserver ${nameserver}$zone_id >> /etc/resolv.conf.dhclient6
+ conf="${conf}nameserver ${nameserver}$zone_id\n"
done
+ fi
- mv /etc/resolv.conf.dhclient6 /etc/resolv.conf
+ if [ x"$conf" != x ]; then
+ conf="# Generated by dhclient or interface $interface\n${conf}"
+ if type resolvconf >/dev/null 2>&1; then
+ printf "${conf}" | resolvconf -a $interface
+ else
+ printf "${conf}" > /etc/resolv.conf
+ chmod 644 /etc/resolv.conf
+ fi
fi
}
--- dhcp-4.3.6/client/scripts/openbsd
+++ dhcp-4.3.6/client/scripts/openbsd
@@ -1,27 +1,25 @@
#!/bin/sh
make_resolv_conf() {
+ if [ x"$PEER_DNS" != x ] && [ x"$PEER_DNS" != xyes ]; then
+ return 0
+ fi
+ local conf=
if [ x"$new_domain_name_servers" != x ]; then
- cat /dev/null > /etc/resolv.conf.dhclient
- if [ x"$new_domain_search" != x ]; then
- echo search $new_domain_search >> /etc/resolv.conf.dhclient
- elif [ x"$new_domain_name" != x ]; then
+ if [ "x$new_domain_search" != x ]; then
+ conf="${conf}search ${new_domain_search}\n"
+ elif [ "x$new_domain_name" != x ]; then
# Note that the DHCP 'Domain Name Option' is really just a domain
# name, and that this practice of using the domain name option as
# a search path is both nonstandard and deprecated.
- echo search $new_domain_name >> /etc/resolv.conf.dhclient
+ conf="${conf}search ${new_domain_name}\n"
fi
for nameserver in $new_domain_name_servers; do
- echo nameserver $nameserver >>/etc/resolv.conf.dhclient
+ conf="${conf}nameserver ${nameserver}\n"
done
-
- mv /etc/resolv.conf.dhclient /etc/resolv.conf
elif [ "x${new_dhcp6_name_servers}" != x ] ; then
- cat /dev/null > /etc/resolv.conf.dhclient6
- chmod 644 /etc/resolv.conf.dhclient6
-
if [ "x${new_dhcp6_domain_search}" != x ] ; then
- echo search ${new_dhcp6_domain_search} >> /etc/resolv.conf.dhclient6
+ conf="${conf}search ${new_dhcp6_domain_search}\n"
fi
for nameserver in ${new_dhcp6_name_servers} ; do
# If the nameserver has a link-local address
@@ -31,10 +29,18 @@
FE80:*) zone_id="%$interface";;
*) zone_id="";;
esac
- echo nameserver ${nameserver}$zone_id >> /etc/resolv.conf.dhclient6
+ conf="${conf}nameserver ${nameserver}$zone_id\n"
done
+ fi
- mv /etc/resolv.conf.dhclient6 /etc/resolv.conf
+ if [ x"$conf" != x ]; then
+ conf="# Generated by dhclient or interface $interface\n${conf}"
+ if type resolvconf >/dev/null 2>&1; then
+ printf "${conf}" | resolvconf -a $interface
+ else
+ printf "${conf}" > /etc/resolv.conf
+ chmod 644 /etc/resolv.conf
+ fi
fi
}
--- dhcp-4.3.6/client/scripts/solaris
+++ dhcp-4.3.6/client/scripts/solaris
@@ -1,21 +1,39 @@
#!/bin/sh
make_resolv_conf() {
+ if [ x"$PEER_DNS" != x ] && [ x"$PEER_DNS" != xyes ]; then
+ return 0
+ fi
+ local conf=
if [ x"$new_domain_name_servers" != x ]; then
- cat /dev/null > /etc/resolv.conf.dhclient
- if [ x"$new_domain_search" != x ]; then
- echo search $new_domain_search >> /etc/resolv.conf.dhclient
- elif [ x"$new_domain_name" != x ]; then
+ if [ "x$new_domain_search" != x ]; then
+ conf="${conf}search ${new_domain_search}\n"
+ elif [ "x$new_domain_name" != x ]; then
# Note that the DHCP 'Domain Name Option' is really just a domain
# name, and that this practice of using the domain name option as
# a search path is both nonstandard and deprecated.
- echo search $new_domain_name >> /etc/resolv.conf.dhclient
+ conf="${conf}search ${new_domain_name}\n"
fi
for nameserver in $new_domain_name_servers; do
- echo nameserver $nameserver >>/etc/resolv.conf.dhclient
+ conf="${conf}nameserver ${nameserver}\n"
+ done
+ elif [ "x${new_dhcp6_name_servers}" != x ] ; then
+ if [ "x${new_dhcp6_domain_search}" != x ] ; then
+ conf="${conf}search ${new_dhcp6_domain_search}\n"
+ fi
+ for nameserver in ${new_dhcp6_name_servers} ; do
+ conf="${conf}nameserver ${nameserver}\n"
done
+ fi
- mv /etc/resolv.conf.dhclient /etc/resolv.conf
+ if [ x"$conf" != x ]; then
+ conf="# Generated by dhclient or interface $interface\n${conf}"
+ if type resolvconf >/dev/null 2>&1; then
+ printf "${conf}" | resolvconf -a $interface
+ else
+ printf "${conf}" > /etc/resolv.conf
+ chmod 644 /etc/resolv.conf
+ fi
fi
}