Stop quering the dnsmasq pidfile, compile options and dbus pidfile.
authorRoy Marples <roy@marples.name>
Fri, 7 Dec 2012 15:18:30 +0000 (15:18 +0000)
committerRoy Marples <roy@marples.name>
Fri, 7 Dec 2012 15:18:30 +0000 (15:18 +0000)
Just interrogate DBus for the available dnsmasq interfaces.

dnsmasq.in
resolvconf.conf.5.in

index 1f7bb60b0ccab8802660eaa1b061194c4386c92a..96b5593ea978dfffd1000cc531875f26977eaa79 100644 (file)
@@ -47,25 +47,17 @@ newresolv="$newconf"
 # Check for DBus support in the binary
 dbus=false
 dbus_ex=false
-: ${dbus_pid:=/var/run/dbus/dbus.pid}
-[ -s "$dbus_pid" ] || dbus_pid=/var/run/dbus.pid
-[ -s "$dbus_pid" ] || dbus_pid=/var/run/dbus/pid
-if [ -s "$dbus_pid" -a -s "$dnsmasq_pid" ]; then
-       if dnsmasq --version 2>/dev/null | \
-               grep -q "^Compile time options.*[[:space:]]DBus[[:space:]]"
+dbus_introspect=$(dbus-send --print-reply --system \
+       --dest=uk.org.thekelleys.dnsmasq \
+       /uk/org/thekelleys/dnsmasq \
+       org.freedesktop.DBus.Introspectable.Introspect \
+       2>/dev/null)
+if [ $? = 0 ]; then
+       dbus=true
+       if printf %s "$dbus_introspect" | \
+           grep -q '<method name="SetDomainServers">'
        then
-               # Sanity - check that dnsmasq and dbus are running
-               if kill -0 $(cat "$dbus_pid") 2>/dev/null && \
-                       kill -0 $(cat "$dnsmasq_pid") 2>/dev/null
-               then
-                       dbus=true
-                       # Stupid test as it relies on dnsmasq running AND
-                       # being configured for DBus
-                       if dbus-send --print-reply --system --dest=uk.org.thekelleys.dnsmasq /uk/org/thekelleys/dnsmasq org.freedesktop.DBus.Introspectable.Introspect 2>/dev/null | grep -q '<method name="SetDomainServers">'
-                       then
-                               dbus_ex=true
-                       fi
-               fi
+               dbus_ex=true
        fi
 fi
 
@@ -153,7 +145,7 @@ done
 
 if $dbus; then
        newconf="$newconf$NL# Domain specific servers will"
-       newconf="$newconf be sent over dbus${NL}enable-dbus$NL"
+       newconf="$newconf be sent over dbus${NL}"
 else
        newconf="$newconf$conf"
 fi
index 6e2831abcab10f157526731babd08ef40e63776d..0b2c72e6022793cf1c63d15bbc8a9969d8ee051b 100644 (file)
@@ -211,8 +211,6 @@ To accomodate this, the subscribers have these files in configurable
 variables, documented below.
 .Pp
 .Bl -tag -width indent
-.It Sy dbus_pid
-Locaiton of the dbus pidfile.
 .It Sy dnsmasq_service
 Location of the dnsmasq service.
 .It Sy dnsmasq_restart
@@ -243,7 +241,7 @@ and
 .An Roy Marples Aq roy@marples.name
 .Sh BUGS
 Each distribution is a special snowflake and likes to name the same thing
-differently, namely the named service script and the dbus pidfile location.
+differently, namely the named service script.
 .Pp
 Please report them to
 .Lk http://roy.marples.name/projects/openresolv