Fix race condition in dnsmasq config dir handling

This commit is contained in:
Matthias Schiffer 2014-01-22 19:44:27 +01:00
parent 6d5e47eeec
commit bb4a9fd5af
4 changed files with 11 additions and 4 deletions

View File

@ -0,0 +1,8 @@
#!/bin/sh /etc/rc.common
START=11
start() {
mkdir -p /var/gluon/dnsmasq.d
}

View File

@ -1,3 +1,3 @@
#!/bin/sh #!/bin/sh
echo 'conf-dir=/lib/gluon/dnsmasq.d' > /etc/dnsmasq.conf echo -e 'conf-dir=/lib/gluon/dnsmasq.d\nconf-dir=/var/gluon/dnsmasq.d' > /etc/dnsmasq.conf

View File

@ -1 +0,0 @@
/var/gluon/mesh-batman-adv/dnsmasq.conf

View File

@ -10,12 +10,12 @@ for ns in $RDNSS $RA_DNS; do
done done
done > /var/gluon/mesh-batman-adv/dnsmasq.conf.$$ done > /var/gluon/mesh-batman-adv/dnsmasq.conf.$$
if cmp -s /var/gluon/mesh-batman-adv/dnsmasq.conf.$$ /var/gluon/mesh-batman-adv/dnsmasq.conf; then if cmp -s /var/gluon/mesh-batman-adv/dnsmasq.conf.$$ /var/gluon/dnsmasq.d/mesh-batman-adv.conf; then
rm /var/gluon/mesh-batman-adv/dnsmasq.conf.$$ rm /var/gluon/mesh-batman-adv/dnsmasq.conf.$$
exit 0 exit 0
fi fi
lock /var/gluon/mesh-batman-adv/dnsmasq.conf.lock lock /var/gluon/mesh-batman-adv/dnsmasq.conf.lock
mv -f /var/gluon/mesh-batman-adv/dnsmasq.conf.$$ /var/gluon/mesh-batman-adv/dnsmasq.conf mv -f /var/gluon/mesh-batman-adv/dnsmasq.conf.$$ /var/gluon/dnsmasq.d/mesh-batman-adv.conf
/etc/init.d/dnsmasq restart /etc/init.d/dnsmasq restart
lock -u /var/gluon/mesh-batman-adv/dnsmasq.conf.lock lock -u /var/gluon/mesh-batman-adv/dnsmasq.conf.lock