diff options
author | Roy Marples <uberlord@gentoo.org> | 2007-04-10 15:11:03 +0000 |
---|---|---|
committer | Roy Marples <uberlord@gentoo.org> | 2007-04-10 15:11:03 +0000 |
commit | d943ca0c320a6193b5568383368f66209a77d951 (patch) | |
tree | ed5c2ee1a1c62b5425ec54ad81236bedad2ee321 /net-dns/dnsmasq | |
parent | Fixed logic issue in cache regen check. Submitted upstream. (diff) | |
download | gentoo-2-d943ca0c320a6193b5568383368f66209a77d951.tar.gz gentoo-2-d943ca0c320a6193b5568383368f66209a77d951.tar.bz2 gentoo-2-d943ca0c320a6193b5568383368f66209a77d951.zip |
The resolvconf script now works with the busybox, BSD and dash shells.
It also configures the domain specific servers using DBus provided both
dnsmasq and dbus are running.
(Portage version: 2.1.2.3)
Diffstat (limited to 'net-dns/dnsmasq')
-rw-r--r-- | net-dns/dnsmasq/ChangeLog | 7 | ||||
-rw-r--r-- | net-dns/dnsmasq/files/resolvconf.dnsmasq | 111 |
2 files changed, 88 insertions, 30 deletions
diff --git a/net-dns/dnsmasq/ChangeLog b/net-dns/dnsmasq/ChangeLog index 6442c49a9e54..6882fc995733 100644 --- a/net-dns/dnsmasq/ChangeLog +++ b/net-dns/dnsmasq/ChangeLog @@ -1,6 +1,11 @@ # ChangeLog for net-dns/dnsmasq # Copyright 2002-2007 Gentoo Foundation; Distributed under the GPL v2 -# $Header: /var/cvsroot/gentoo-x86/net-dns/dnsmasq/ChangeLog,v 1.120 2007/04/06 10:26:22 dertobi123 Exp $ +# $Header: /var/cvsroot/gentoo-x86/net-dns/dnsmasq/ChangeLog,v 1.121 2007/04/10 15:11:03 uberlord Exp $ + + 10 Apr 2007; Roy Marples <uberlord@gentoo.org> files/resolvconf.dnsmasq: + The resolvconf script now works with the busybox, BSD and dash shells. + It also configures the domain specific servers using DBus provided both + dnsmasq and dbus are running. 06 Apr 2007; Tobias Scherbaum <dertobi123@gentoo.org> dnsmasq-2.38-r1.ebuild: diff --git a/net-dns/dnsmasq/files/resolvconf.dnsmasq b/net-dns/dnsmasq/files/resolvconf.dnsmasq index 423769a0dd5c..62fc73f4118f 100644 --- a/net-dns/dnsmasq/files/resolvconf.dnsmasq +++ b/net-dns/dnsmasq/files/resolvconf.dnsmasq @@ -1,4 +1,4 @@ -#!/bin/bash +#!/bin/sh # Copyright 2006 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 @@ -18,15 +18,12 @@ # A sample dnsmasq config that works as above is like so #domain-needed #interface=lo -#conf-file=/etc/dnsmasq-resolvconf.conf #resolv-file=/etc/dnsmasq-resolv.conf +#conf-file=/etc/dnsmasq-resolvconf.conf # The last step is to configure dns configuration for /etc/resolv.conf # for the lo interface. In Gentoo we set it up like so in /etc/conf.d/net -#dns_servers_lo=( "127.0.0.1" ) - -# Load generic Gentoo functions -source /etc/init.d/functions.sh +#dns_servers_lo="127.0.0.1" # Load our variables from resolvconf VARS="$(resolvconf -v)" @@ -38,52 +35,108 @@ DNSMASQCONF="/etc/dnsmasq-resolvconf.conf" NEWCONF="# Generated by resolvconf" NEWRESOLV="${NEWCONF}\nsearch" +# Using DBUS means that we never have to restart the daemon +# This is important as it means we should not drop DNS queries +# whilst changing DNS options around. However, DBUS support is optional +# so we need to validate a few things first. +# Check for DBus support in the binary +DBUS=no +if dnsmasq --version 2>/dev/null | \ +grep -q "^Compile time options.*[[:space:]]DBus[[:space:]]" \ +; then + # Sanity - check that dnsmasq and dbus are running + if [ -x /etc/init.d/dbus -a -x /etc/init.d/dnsmasq ] ; then + if /etc/init.d/dbus --quiet status && /etc/init.d/dnsmasq --quiet status ; then + DBUS=yes + NEWCONF="${NEWCONF}\n# Domain specific servers will be sent over dbus\n\nenable-dbus" + fi + fi +fi + +uniqify() { + local result= + while [ -n "$1" ] ; do + case " ${result} " in + *" $1 "*) ;; + *) result="${result} $1" ;; + esac + shift + done + echo "${result# *}" +} + # If we only have domain information then put it in search too -[[ -z ${NEWSEARCH} && -z ${NEWNS} ]] && NEWSEARCH="${NEWDOMAIN}" +[ -z "${NEWSEARCH}" -a -z "${NEWNS}" ] && NEWSEARCH="${NEWDOMAIN}" for N in ${NEWSEARCH} ; do - if [[ " ${NEWSL} " != *" ${N%,*} "* ]] ; then - NEWSL="${NEWSL} ${N%,*}" - fi - if [[ "\n${NEWRESOLV}\n" != *"\nnameserver ${N#*,}\n"* ]] ; then - NEWRESOLV="${NEWRESOLV}\nnameserver ${N#*,}" - fi + case " ${NEWSL} " in + *" ${N%,*} "*) ;; + *) NEWSL="${NEWSL} ${N%,*}" ;; + esac + case "\n${NEWRESOLV}\n" in + *"\nnameserver ${N#*,}\n"*) ;; + *) NEWRESOLV="${NEWRESOLV}\nnameserver ${N#*,}" ;; + esac done for N in ${NEWNS} ; do - if [[ "\n${NEWRESOLV}\n" != *"\nnameserver ${N}\n" ]] ; then - NEWRESOLV="${NEWRESOLV}\nnameserver ${N}" - fi + case "\n${NEWRESOLV}\n" in + *"\nnameserver ${N}\n") ;; + *) NEWRESOLV="${NEWRESOLV}\nnameserver ${N}" ;; + esac done -NEWRESOLV="${NEWRESOLV//\\nsearch/${NEWSL:+\nsearch${NEWSL}}}" +NEWRESOLV="$(echo "${NEWRESOLV}" | sed -e "s/^search/${NEWSL:+search${NEWSL}}/g")" +DBUSDEST= for DN in $(uniqify ${NEWDOMAIN}) ; do - NEWCONF="${NEWCONF}\nserver=/${DN%,*}/${DN#*,}" + if [ "${DBUS}" = "yes" ] ; then + IP=${DN#*,} + SIFS=${IFS-y} OIFS=$IFS + IFS=. + set -- ${IP} + NUM="0x$(printf "%02x" $1 $2 $3 $4)" + if [ "${SIFS}" = "y" ] ; then + IFS=$OIFS + else + unset IFS + fi + DBUSDEST="${DBUSDEST} uint32:$(printf "%d" ${NUM}) string:${DN%,*}" + else + NEWCONF="${NEWCONF}\nserver=/${DN%,*}/${DN#*,}" + fi done RELOAD="no" -if [[ -e ${DNSMASQCONF} ]] ; then - if [[ $(< "${DNSMASQCONF}") != "$(echo -e "${NEWCONF}")" ]] ; then +if [ -e "${DNSMASQCONF}" ] ; then + if [ "$(cat "${DNSMASQCONF}")" != "$(printf "${NEWCONF}")" ] ; then RELOAD="yes" - echo -e "${NEWCONF}" > "${DNSMASQCONF}" + printf "${NEWCONF}" > "${DNSMASQCONF}" fi else RELOAD="yes" - echo -e "${NEWCONF}" > "${DNSMASQCONF}" + printf "${NEWCONF}" > "${DNSMASQCONF}" fi -if [[ -e ${DNSMASQRESOLV}} ]] ; then - if [[ $(< "${DNSMASQRESOLV}") != "$(echo -e "${NEWRESOLV}")" ]] ; then +if [ -e "${DNSMASQRESOLV}" ] ; then + if [ "$(cat "${DNSMASQRESOLV}")" != "$(printf "${NEWRESOLV}")" ] ; then RELOAD="yes" - echo -e "${NEWRESOLV}" > "${DNSMASQRESOLV}" + printf "${NEWRESOLV}" > "${DNSMASQRESOLV}" fi else # dnsmasq polls this file so no need to set RELOAD="yes" - echo -e "${NEWRESOLV}" > "${DNSMASQRESOLV}" + printf "${NEWRESOLV}" > "${DNSMASQRESOLV}" +fi + +if [ "${RELOAD}" = "yes" -a -x /etc/init.d/dnsmasq ] ; then + /etc/init.d/dnsmasq --quiet --nodeps conditionalrestart fi -if [[ ${RELOAD} == "yes" && -x /etc/init.d/dnsmasq ]] ; then - if /etc/init.d/dnsmasq --quiet status ; then - /etc/init.d/dnsmasq --quiet --nodeps restart +if [ "${DBUS}" = "yes" ] ; then + if [ "${RELOAD}" != "yes" -a -x /etc/init.d/dnsmasq ] ; then + /etc/init.d/dnsmasq --quiet reload fi + # Send even if emtpy so old servers are cleared + dbus-send --system --dest=uk.org.thekelleys.dnsmasq \ + /uk/org/thekelleys/dnsmasq uk.org.thekelleys.SetServers \ + ${DBUSDEST} fi # vim: ts=4 : |