~ubuntu-branches/ubuntu/saucy/openresolv/saucy

« back to all changes in this revision

Viewing changes to dnsmasq.in

  • Committer: Package Import Robot
  • Author(s): Roy Marples
  • Date: 2012-04-06 16:03:03 UTC
  • mfrom: (1.1.3)
  • Revision ID: package-import@ubuntu.com-20120406160303-4h05bhnwpbncb1zk
Tags: 3.5.2-1
* New upstream release
* Return 0 for subscribers whose init script do not exist (closes: 659760)
* Support sortlist in our resolvconf hook (closes: 637285)
* Updated Standards-Version to 3.9.3 (no changes needed)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
#!/bin/sh
2
 
# Copyright (c) 2007-2011 Roy Marples
 
2
# Copyright (c) 2007-2012 Roy Marples
3
3
# All rights reserved
4
4
 
5
5
# dnsmasq subscriber for resolvconf
58
58
                        kill -0 $(cat "$dnsmasq_pid") 2>/dev/null
59
59
                then
60
60
                        dbus=true
61
 
                        newconf="$newconf$NL# Domain specific servers will"
62
 
                        newconf="$newconf be sent over dbus${NL}enable-dbus$NL"
63
61
                fi
64
62
        fi
65
63
fi
69
67
done
70
68
 
71
69
dbusdest=
 
70
conf=
72
71
for d in $DOMAINS; do
73
72
        dn="${d%%:*}"
74
73
        ns="${d#*:}"
 
74
        n="${ns%%,*}"
75
75
        while [ -n "$ns" ]; do
76
 
                if $dbus; then
 
76
                case "$n" in
 
77
                *.*.*.*)
77
78
                        SIFS=${IFS-y} OIFS=$IFS
78
79
                        IFS=.
79
 
                        set -- ${ns%%,*}
 
80
                        set -- $n
80
81
                        num="0x$(printf %02x $1 $2 $3 $4)"
81
 
                        if [ "$SIFS" = yi ]; then
 
82
                        if [ "$SIFS" = y ]; then
82
83
                                unset IFS
83
84
                        else
84
85
                                IFS=$OIFS
85
86
                        fi
86
87
                        dbusdest="$dbusdest uint32:$(printf %u $num)"
87
88
                        dbusdest="$dbusdest string:$dn"
88
 
                else
89
 
                        newconf="${newconf}server=/$dn/${ns%%,*}$NL"
90
 
                fi
 
89
                        ;;
 
90
                *:*:*:*:*:*:*:*)
 
91
                        SIFS=${IFS-y} OIFS=$IFS bytes=
 
92
                        IFS=:
 
93
                        set -- $n
 
94
                        while [ -n "$1" ]; do
 
95
                                addr="$1"
 
96
                                shift
 
97
                                while [ ${#addr} -lt 4 ]; do
 
98
                                        addr="0${addr}"
 
99
                                done
 
100
                                byte1="$(printf %d 0x${addr%??})"
 
101
                                byte2="$(printf %d 0x${addr#??})"
 
102
                                dbusdest="$dbusdest byte:$byte1 byte:$byte2"
 
103
                        done
 
104
                        if [ "$SIFS" = y ]; then
 
105
                                unset IFS
 
106
                        else
 
107
                                IFS=$OIFS
 
108
                        fi
 
109
                        dbusdest="$dbusdest string:$dn"
 
110
                        ;;
 
111
                *)
 
112
                        dbus=false
 
113
                        ;;
 
114
                esac
 
115
                conf="${conf}server=/$dn/$n$NL"
91
116
                [ "$ns" = "${ns#*,}" ] && break
92
117
                ns="${ns#*,}"
93
118
        done
94
119
done
95
120
 
 
121
if $dbus; then
 
122
        newconf="$newconf$NL# Domain specific servers will"
 
123
        newconf="$newconf be sent over dbus${NL}enable-dbus$NL"
 
124
else
 
125
        newconf="$newconf$conf"
 
126
fi
 
127
 
96
128
# Try to ensure that config dirs exist
97
129
if type config_mkdirs >/dev/null 2>&1; then
98
130
        config_mkdirs "$dnsmasq_conf" "$dnsmasq_resolv"
110
142
        fi
111
143
fi
112
144
if [ -n "$dnsmasq_resolv" ]; then
 
145
        # dnsmasq polls this file so no need to set changed=true
113
146
        if [ -f "$dnsmasq_resolv" ]; then
114
147
                if [ "$(cat "$dnsmasq_resolv")" != "$(printf %s "$newresolv")" ]
115
148
                then
116
 
                        changed=true
117
149
                        printf %s "$newresolv" >"$dnsmasq_resolv"
118
150
                fi
119
151
        else
120
 
                # dnsmasq polls this file so no need to set changed=true
121
152
                printf %s "$newresolv" >"$dnsmasq_resolv"
122
153
        fi
123
154
fi