All of lore.kernel.org
 help / color / mirror / Atom feed
* [meta-networking][PATCH] dnsmasq: get systemd only working again
@ 2016-04-19  3:30 Joe MacDonald
  2016-04-19  7:41 ` Anders Darander
  2016-04-19 13:54 ` [meta-networking][PATCH] " Mark Asselstine
  0 siblings, 2 replies; 12+ messages in thread
From: Joe MacDonald @ 2016-04-19  3:30 UTC (permalink / raw)
  To: mark.asselstine; +Cc: anders, openembedded-devel

From: Mark Asselstine <mark.asselstine@windriver.com>

The changes made in commit 2497cf2960537152427c99629b2af412787eb6c2
[dnsmasq: steal resolvconf support from Ubuntu] broke systemd only
dnsmasq runtime. No sysvinit scripts are included in systemd only
builds (and should not be) and the dnsmasq executable has not moved to
/usr/sbin.

Reverting to the previous version of the systemd service file. If
folks want the local dnsmasq instance to be queried before going to
an external DNS they should add 'nameserver 127.0.0.1' to
/etc/resolv.conf. Or submit a change which will work with systemd.

Signed-off-by: Mark Asselstine <mark.asselstine@windriver.com>
Signed-off-by: Joe MacDonald <joe_macdonald@mentor.com>
---

Mark,

Thanks for the patch.  In the interests of not causing any more hassle
than I already have, I'm proposing this as an alternative to what you sent
earlier today.  This hopefully preserves the resolvconf/start-stop
functionality while not relying on any sysvinit-ness.  What do you think
about this as a middle-ground?

Anders,

I trust that nothing Mark and I are discussing here changes the issue you
noted about dnsmasq just falling over after a few minutes.  I propose we
dig into that separately, since it looks like a different problem probably
related to the uprev.  If it turns out that once we merge something to
support systemd-only builds that resolves the 'dnsmasq vandalizes itself'
issue, even better.

-J.

 .../recipes-support/dnsmasq/dnsmasq.inc            |  9 ++--
 .../dnsmasq/files/dnsmasq-resolvconf-helper        | 62 ++++++++++++++++++++++
 .../recipes-support/dnsmasq/files/dnsmasq.service  |  9 ++--
 3 files changed, 72 insertions(+), 8 deletions(-)
 create mode 100644 meta-networking/recipes-support/dnsmasq/files/dnsmasq-resolvconf-helper

diff --git a/meta-networking/recipes-support/dnsmasq/dnsmasq.inc b/meta-networking/recipes-support/dnsmasq/dnsmasq.inc
index 622e630..df58e5c 100644
--- a/meta-networking/recipes-support/dnsmasq/dnsmasq.inc
+++ b/meta-networking/recipes-support/dnsmasq/dnsmasq.inc
@@ -60,11 +60,12 @@ do_install () {
         install -m 644 dbus/dnsmasq.conf ${D}${sysconfdir}/dbus-1/system.d/
     fi
     if [ "${@base_contains('PACKAGECONFIG', 'resolvconf', 'resolvconf', '', d)}" != "" ]; then
-	install -d ${D}${sysconfdir}/resolvconf/update.d/
-	install -m 0755 ${WORKDIR}/dnsmasq.resolvconf ${D}${sysconfdir}/resolvconf/update.d/dnsmasq
+        install -d ${D}${sysconfdir}/resolvconf/update.d/
+        install -m 0755 ${WORKDIR}/dnsmasq.resolvconf ${D}${sysconfdir}/resolvconf/update.d/dnsmasq
 
-	install -d ${D}${sysconfdir}/default/volatiles
-	install -m 0644 ${WORKDIR}/99_dnsmasq ${D}${sysconfdir}/default/volatiles
+        install -d ${D}${sysconfdir}/default/volatiles
+        install -m 0644 ${WORKDIR}/99_dnsmasq ${D}${sysconfdir}/default/volatiles
+        install -m 0755 ${WORKDIR}/dnsmasq-resolvconf-helper ${D}${bindir}
     fi
 }
 
diff --git a/meta-networking/recipes-support/dnsmasq/files/dnsmasq-resolvconf-helper b/meta-networking/recipes-support/dnsmasq/files/dnsmasq-resolvconf-helper
new file mode 100644
index 0000000..db54d46
--- /dev/null
+++ b/meta-networking/recipes-support/dnsmasq/files/dnsmasq-resolvconf-helper
@@ -0,0 +1,62 @@
+#!/bin/bash
+#
+# Borrowing heavily from the dnsmasq initscript's version of support for
+# resolvconf, intended for use in systemd-only configurations.
+#
+PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
+DAEMON=/usr/sbin/dnsmasq
+NAME=dnsmasq
+
+# Most configuration options in /etc/default/dnsmasq are deprecated
+# but still honoured.
+if [ -r /etc/default/$NAME ]; then
+   . /etc/default/$NAME
+fi
+
+start_resolvconf()
+{
+   # If interface "lo" is explicitly disabled in /etc/default/dnsmasq
+   # Then dnsmasq won't be providing local DNS, so don't add it to
+   # the resolvconf server set.
+   for interface in $DNSMASQ_EXCEPT
+   do
+      [ $interface = lo ] && return
+   done
+
+   if [ -x /sbin/resolvconf ] ; then
+      echo "nameserver 127.0.0.1" |
+      /sbin/resolvconf -a lo.$NAME
+   fi
+   return 0
+}
+
+stop_resolvconf()
+{
+   if [ -x /sbin/resolvconf ] ; then
+      /sbin/resolvconf -d lo.$NAME
+   fi
+   return 0
+}
+
+case "$1" in
+   start)
+      start_resolvconf
+      exit 0
+      ;;
+   stop)
+      stop_resolvconf
+      exit 0
+      ;;
+   restart)
+      stop_resolvconf
+      start_resolvconf
+      exit 0
+      ;;
+   *)
+      echo "Usage: /etc/init.d/$NAME {start|stop|restart}" >&2
+      exit 3
+      ;;
+esac
+
+exit 0
+
diff --git a/meta-networking/recipes-support/dnsmasq/files/dnsmasq.service b/meta-networking/recipes-support/dnsmasq/files/dnsmasq.service
index c3637e1..5824b62 100644
--- a/meta-networking/recipes-support/dnsmasq/files/dnsmasq.service
+++ b/meta-networking/recipes-support/dnsmasq/files/dnsmasq.service
@@ -5,10 +5,10 @@ After=network.target
 [Service]
 Type=forking
 PIDFile=/run/dnsmasq.pid
-ExecStartPre=/usr/sbin/dnsmasq --test
-ExecStart=/etc/init.d/dnsmasq systemd-exec
-ExecStartPost=/etc/init.d/dnsmasq systemd-start-resolvconf
-ExecStopPre=/etc/init.d/dnsmasq systemd-stop-resolvconf
+ExecStartPre=/usr/bin/dnsmasq --test
+ExecStart=/usr/bin/dnsmasq -x $MAINPID
+ExecStartPost=/usr/bin/dnsmasq-resolvconf-helper start
+ExecStop=/usr/bin/dnsmasq-resolvconf-helper stop
 ExecReload=/bin/kill -HUP $MAINPID
 
 [Install]
-- 
1.9.1



^ permalink raw reply related	[flat|nested] 12+ messages in thread

* Re: [meta-networking][PATCH] dnsmasq: get systemd only working again
  2016-04-19  3:30 [meta-networking][PATCH] dnsmasq: get systemd only working again Joe MacDonald
@ 2016-04-19  7:41 ` Anders Darander
  2016-04-19 14:21   ` Joe MacDonald
  2016-04-19 13:54 ` [meta-networking][PATCH] " Mark Asselstine
  1 sibling, 1 reply; 12+ messages in thread
From: Anders Darander @ 2016-04-19  7:41 UTC (permalink / raw)
  To: Joe MacDonald; +Cc: mark.asselstine, openembedded-devel

* Joe MacDonald <joe_macdonald@mentor.com> [160419 05:29]:

> From: Mark Asselstine <mark.asselstine@windriver.com>

> The changes made in commit 2497cf2960537152427c99629b2af412787eb6c2
> [dnsmasq: steal resolvconf support from Ubuntu] broke systemd only
> dnsmasq runtime. No sysvinit scripts are included in systemd only
> builds (and should not be) and the dnsmasq executable has not moved to
> /usr/sbin.

> Reverting to the previous version of the systemd service file. If
> folks want the local dnsmasq instance to be queried before going to
> an external DNS they should add 'nameserver 127.0.0.1' to
> /etc/resolv.conf. Or submit a change which will work with systemd.

> Signed-off-by: Mark Asselstine <mark.asselstine@windriver.com>
> Signed-off-by: Joe MacDonald <joe_macdonald@mentor.com>
> ---

> Mark,

> Thanks for the patch.  In the interests of not causing any more hassle
> than I already have, I'm proposing this as an alternative to what you sent
> earlier today.  This hopefully preserves the resolvconf/start-stop
> functionality while not relying on any sysvinit-ness.  What do you think
> about this as a middle-ground?

> Anders,

> I trust that nothing Mark and I are discussing here changes the issue you
> noted about dnsmasq just falling over after a few minutes.  I propose we
> dig into that separately, since it looks like a different problem probably
> related to the uprev.  If it turns out that once we merge something to
> support systemd-only builds that resolves the 'dnsmasq vandalizes itself'
> issue, even better.

Well, I've tried this patch, but dnsmasq isn't running. Was it run-time
tested?

Isn't MAINPID the PID of the main process started by systemd? And -x
should specify a path to the pid-file?

Logs below.

Cheers,
Anders

[FAILED] Failed to start DNS forwarder and DHCP server.
See 'systemctl status dnsmasq.service' for details.

Running `systemctl status dnsmasq.service` gives:

[[0;1;31m●[[0m dnsmasq.service - DNS forwarder and DHCP server    Loaded: loaded (/lib/systemd/system/dnsmasq.service; enabled; vendor preset: enabled)
   Active: [[0;1;31mfailed[[0m (Result: exit-code) since Fri 2016-04-08 11:07:27 CEST; 8min ago
  Process: 384 ExecStart=/usr/bin/dnsmasq -x $MAINPID [[0;1;31m(code=exited, status=1/FAILURE)[[0m
  Process: 381 ExecStartPre=/usr/bin/dnsmasq --test (code=exited, status=0/SUCCESS)

Apr 08 11:07:27 ccu systemd[1]: Starting DNS forwarder and DHCP server...
Apr 08 11:07:27 ccu dnsmasq[381]: dnsmasq: syntax check OK.
Apr 08 11:07:27 ccu dnsmasq[384]: dnsmasq: bad command line options: try --help
Apr 08 11:07:27 ccu dnsmasq[384]: [[0;1;31mbad command line options: try --help[[0m
Apr 08 11:07:27 ccu dnsmasq[384]: [[0;1;31mFAILED to start up[[0m 
Apr 08 11:07:27 ccu systemd[1]: [[0;1;39mdnsmasq.service: Control process exited, code=exited status=1[[0m
Apr 08 11:07:27 ccu systemd[1]: [[0;1;31mFailed to start DNS forwarder and DHCP server.[[0m
Apr 08 11:07:27 ccu systemd[1]: [[0;1;39mdnsmasq.service: Unit entered failed state.[[0m
Apr 08 11:07:27 ccu systemd[1]: [[0;1;39mdnsmasq.service: Failed with result 'exit-code'.[[0m

-- 
Anders Darander, Senior System Architect
ChargeStorm AB / eStorm AB


^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [meta-networking][PATCH] dnsmasq: get systemd only working again
  2016-04-19  3:30 [meta-networking][PATCH] dnsmasq: get systemd only working again Joe MacDonald
  2016-04-19  7:41 ` Anders Darander
@ 2016-04-19 13:54 ` Mark Asselstine
  1 sibling, 0 replies; 12+ messages in thread
From: Mark Asselstine @ 2016-04-19 13:54 UTC (permalink / raw)
  To: Joe MacDonald; +Cc: anders, openembedded-devel

On April 18, 2016 23:30:07 Joe MacDonald wrote:
> From: Mark Asselstine <mark.asselstine@windriver.com>
> 
> The changes made in commit 2497cf2960537152427c99629b2af412787eb6c2
> [dnsmasq: steal resolvconf support from Ubuntu] broke systemd only
> dnsmasq runtime. No sysvinit scripts are included in systemd only
> builds (and should not be) and the dnsmasq executable has not moved to
> /usr/sbin.
> 
> Reverting to the previous version of the systemd service file. If
> folks want the local dnsmasq instance to be queried before going to
> an external DNS they should add 'nameserver 127.0.0.1' to
> /etc/resolv.conf. Or submit a change which will work with systemd.
> 
> Signed-off-by: Mark Asselstine <mark.asselstine@windriver.com>
> Signed-off-by: Joe MacDonald <joe_macdonald@mentor.com>
> ---
> 
> Mark,
> 
> Thanks for the patch.  In the interests of not causing any more hassle
> than I already have, I'm proposing this as an alternative to what you sent
> earlier today.  This hopefully preserves the resolvconf/start-stop
> functionality while not relying on any sysvinit-ness.  What do you think
> about this as a middle-ground?

No worries about causing hassle. Things brake, things get fixed, we move on and 
learn.

The approach is fine with me. When looking at this yesterday I question the 
need for this 'wrapper' and side with Arch Linux approach. But I definitely 
trust your call on this, knowing you have spent many more hours dealing with 
dnsmasq and resolv.conf than I ever will in my lifetime.

Anyways, definitely no complaints from me with this change, if you can sort out 
the runtime issues that Anders seems to have run in to.

Thanks for getting to this so quickly,
Mark

> 
> Anders,
> 
> I trust that nothing Mark and I are discussing here changes the issue you
> noted about dnsmasq just falling over after a few minutes.  I propose we
> dig into that separately, since it looks like a different problem probably
> related to the uprev.  If it turns out that once we merge something to
> support systemd-only builds that resolves the 'dnsmasq vandalizes itself'
> issue, even better.
> 
> -J.
> 
>  .../recipes-support/dnsmasq/dnsmasq.inc            |  9 ++--
>  .../dnsmasq/files/dnsmasq-resolvconf-helper        | 62
> ++++++++++++++++++++++ .../recipes-support/dnsmasq/files/dnsmasq.service  |
>  9 ++--
>  3 files changed, 72 insertions(+), 8 deletions(-)
>  create mode 100644
> meta-networking/recipes-support/dnsmasq/files/dnsmasq-resolvconf-helper
> 
> diff --git a/meta-networking/recipes-support/dnsmasq/dnsmasq.inc
> b/meta-networking/recipes-support/dnsmasq/dnsmasq.inc index
> 622e630..df58e5c 100644
> --- a/meta-networking/recipes-support/dnsmasq/dnsmasq.inc
> +++ b/meta-networking/recipes-support/dnsmasq/dnsmasq.inc
> @@ -60,11 +60,12 @@ do_install () {
>          install -m 644 dbus/dnsmasq.conf ${D}${sysconfdir}/dbus-1/system.d/
> fi
>      if [ "${@base_contains('PACKAGECONFIG', 'resolvconf', 'resolvconf', '',
> d)}" != "" ]; then -	install -d ${D}${sysconfdir}/resolvconf/update.d/
> -	install -m 0755 ${WORKDIR}/dnsmasq.resolvconf
> ${D}${sysconfdir}/resolvconf/update.d/dnsmasq +        install -d
> ${D}${sysconfdir}/resolvconf/update.d/
> +        install -m 0755 ${WORKDIR}/dnsmasq.resolvconf
> ${D}${sysconfdir}/resolvconf/update.d/dnsmasq
> 
> -	install -d ${D}${sysconfdir}/default/volatiles
> -	install -m 0644 ${WORKDIR}/99_dnsmasq ${D}${sysconfdir}/default/volatiles
> +        install -d ${D}${sysconfdir}/default/volatiles
> +        install -m 0644 ${WORKDIR}/99_dnsmasq
> ${D}${sysconfdir}/default/volatiles +        install -m 0755
> ${WORKDIR}/dnsmasq-resolvconf-helper ${D}${bindir} fi
>  }
> 
> diff --git
> a/meta-networking/recipes-support/dnsmasq/files/dnsmasq-resolvconf-helper
> b/meta-networking/recipes-support/dnsmasq/files/dnsmasq-resolvconf-helper
> new file mode 100644
> index 0000000..db54d46
> --- /dev/null
> +++
> b/meta-networking/recipes-support/dnsmasq/files/dnsmasq-resolvconf-helper
> @@ -0,0 +1,62 @@
> +#!/bin/bash
> +#
> +# Borrowing heavily from the dnsmasq initscript's version of support for
> +# resolvconf, intended for use in systemd-only configurations.
> +#
> +PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
> +DAEMON=/usr/sbin/dnsmasq
> +NAME=dnsmasq
> +
> +# Most configuration options in /etc/default/dnsmasq are deprecated
> +# but still honoured.
> +if [ -r /etc/default/$NAME ]; then
> +   . /etc/default/$NAME
> +fi
> +
> +start_resolvconf()
> +{
> +   # If interface "lo" is explicitly disabled in /etc/default/dnsmasq
> +   # Then dnsmasq won't be providing local DNS, so don't add it to
> +   # the resolvconf server set.
> +   for interface in $DNSMASQ_EXCEPT
> +   do
> +      [ $interface = lo ] && return
> +   done
> +
> +   if [ -x /sbin/resolvconf ] ; then
> +      echo "nameserver 127.0.0.1" |
> +      /sbin/resolvconf -a lo.$NAME
> +   fi
> +   return 0
> +}
> +
> +stop_resolvconf()
> +{
> +   if [ -x /sbin/resolvconf ] ; then
> +      /sbin/resolvconf -d lo.$NAME
> +   fi
> +   return 0
> +}
> +
> +case "$1" in
> +   start)
> +      start_resolvconf
> +      exit 0
> +      ;;
> +   stop)
> +      stop_resolvconf
> +      exit 0
> +      ;;
> +   restart)
> +      stop_resolvconf
> +      start_resolvconf
> +      exit 0
> +      ;;
> +   *)
> +      echo "Usage: /etc/init.d/$NAME {start|stop|restart}" >&2
> +      exit 3
> +      ;;
> +esac
> +
> +exit 0
> +
> diff --git a/meta-networking/recipes-support/dnsmasq/files/dnsmasq.service
> b/meta-networking/recipes-support/dnsmasq/files/dnsmasq.service index
> c3637e1..5824b62 100644
> --- a/meta-networking/recipes-support/dnsmasq/files/dnsmasq.service
> +++ b/meta-networking/recipes-support/dnsmasq/files/dnsmasq.service
> @@ -5,10 +5,10 @@ After=network.target
>  [Service]
>  Type=forking
>  PIDFile=/run/dnsmasq.pid
> -ExecStartPre=/usr/sbin/dnsmasq --test
> -ExecStart=/etc/init.d/dnsmasq systemd-exec
> -ExecStartPost=/etc/init.d/dnsmasq systemd-start-resolvconf
> -ExecStopPre=/etc/init.d/dnsmasq systemd-stop-resolvconf
> +ExecStartPre=/usr/bin/dnsmasq --test
> +ExecStart=/usr/bin/dnsmasq -x $MAINPID
> +ExecStartPost=/usr/bin/dnsmasq-resolvconf-helper start
> +ExecStop=/usr/bin/dnsmasq-resolvconf-helper stop
>  ExecReload=/bin/kill -HUP $MAINPID
> 
>  [Install]



^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [meta-networking][PATCH] dnsmasq: get systemd only working again
  2016-04-19  7:41 ` Anders Darander
@ 2016-04-19 14:21   ` Joe MacDonald
  2016-04-19 15:37     ` [meta-networking][PATCH v3] " Joe MacDonald
  0 siblings, 1 reply; 12+ messages in thread
From: Joe MacDonald @ 2016-04-19 14:21 UTC (permalink / raw)
  To: mark.asselstine, rehsack, openembedded-devel

[-- Attachment #1: Type: text/plain, Size: 4256 bytes --]

[Re: [meta-networking][PATCH] dnsmasq: get systemd only working again] On 16.04.19 (Tue 09:41) Anders Darander wrote:

> * Joe MacDonald <joe_macdonald@mentor.com> [160419 05:29]:
> 
> > From: Mark Asselstine <mark.asselstine@windriver.com>
> 
> > The changes made in commit 2497cf2960537152427c99629b2af412787eb6c2
> > [dnsmasq: steal resolvconf support from Ubuntu] broke systemd only
> > dnsmasq runtime. No sysvinit scripts are included in systemd only
> > builds (and should not be) and the dnsmasq executable has not moved to
> > /usr/sbin.
> 
> > Reverting to the previous version of the systemd service file. If
> > folks want the local dnsmasq instance to be queried before going to
> > an external DNS they should add 'nameserver 127.0.0.1' to
> > /etc/resolv.conf. Or submit a change which will work with systemd.
> 
> > Signed-off-by: Mark Asselstine <mark.asselstine@windriver.com>
> > Signed-off-by: Joe MacDonald <joe_macdonald@mentor.com>
> > ---
> 
> > Mark,
> 
> > Thanks for the patch.  In the interests of not causing any more hassle
> > than I already have, I'm proposing this as an alternative to what you sent
> > earlier today.  This hopefully preserves the resolvconf/start-stop
> > functionality while not relying on any sysvinit-ness.  What do you think
> > about this as a middle-ground?
> 
> > Anders,
> 
> > I trust that nothing Mark and I are discussing here changes the issue you
> > noted about dnsmasq just falling over after a few minutes.  I propose we
> > dig into that separately, since it looks like a different problem probably
> > related to the uprev.  If it turns out that once we merge something to
> > support systemd-only builds that resolves the 'dnsmasq vandalizes itself'
> > issue, even better.
> 
> Well, I've tried this patch, but dnsmasq isn't running. Was it run-time
> tested?

Yes, it worked on my setup last night, but the testing I did was a bit
of a fake due to trying it out on a live system rather than waiting for
the filesystem generation to happen and copying it over to the target.
Thus the error you noted below.

> Isn't MAINPID the PID of the main process started by systemd?

In the case of Type=forking, $MAINPID is the value out of PIDFile unless
PIDFile is unset, then systemd needs to guess at the value (unless
you've also set GuessMainPID='no', in which case I have no idea what
happens, but the default is 'yes', so it shouldn't matter in this case).
At least that's my reading of the docs at
https://www.freedesktop.org/software/systemd/man/systemd.service.html,
I'm no expert when it comes to systemd service files, though, so please
correct me if I'm wrong.

> And -x should specify a path to the pid-file?

Yes, it absolutely should.

-J.

> Logs below.
> 
> Cheers,
> Anders
> 
> [FAILED] Failed to start DNS forwarder and DHCP server.
> See 'systemctl status dnsmasq.service' for details.
> 
> Running `systemctl status dnsmasq.service` gives:
> 
> [[0;1;31m●[[0m dnsmasq.service - DNS forwarder and DHCP server    Loaded: loaded (/lib/systemd/system/dnsmasq.service; enabled; vendor preset: enabled)
>    Active: [[0;1;31mfailed[[0m (Result: exit-code) since Fri 2016-04-08 11:07:27 CEST; 8min ago
>   Process: 384 ExecStart=/usr/bin/dnsmasq -x $MAINPID [[0;1;31m(code=exited, status=1/FAILURE)[[0m
>   Process: 381 ExecStartPre=/usr/bin/dnsmasq --test (code=exited, status=0/SUCCESS)
> 
> Apr 08 11:07:27 ccu systemd[1]: Starting DNS forwarder and DHCP server...
> Apr 08 11:07:27 ccu dnsmasq[381]: dnsmasq: syntax check OK.
> Apr 08 11:07:27 ccu dnsmasq[384]: dnsmasq: bad command line options: try --help
> Apr 08 11:07:27 ccu dnsmasq[384]: [[0;1;31mbad command line options: try --help[[0m
> Apr 08 11:07:27 ccu dnsmasq[384]: [[0;1;31mFAILED to start up[[0m 
> Apr 08 11:07:27 ccu systemd[1]: [[0;1;39mdnsmasq.service: Control process exited, code=exited status=1[[0m
> Apr 08 11:07:27 ccu systemd[1]: [[0;1;31mFailed to start DNS forwarder and DHCP server.[[0m
> Apr 08 11:07:27 ccu systemd[1]: [[0;1;39mdnsmasq.service: Unit entered failed state.[[0m
> Apr 08 11:07:27 ccu systemd[1]: [[0;1;39mdnsmasq.service: Failed with result 'exit-code'.[[0m
> 
-- 
-Joe MacDonald.
:wq

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 484 bytes --]

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [meta-networking][PATCH v3] dnsmasq: get systemd only working again
  2016-04-19 14:21   ` Joe MacDonald
@ 2016-04-19 15:37     ` Joe MacDonald
  2016-04-20  8:24       ` Anders Darander
  0 siblings, 1 reply; 12+ messages in thread
From: Joe MacDonald @ 2016-04-19 15:37 UTC (permalink / raw)
  To: mark.asselstine; +Cc: anders, openembedded-devel

From: Mark Asselstine <mark.asselstine@windriver.com>

The changes made in commit 2497cf2960537152427c99629b2af412787eb6c2
[dnsmasq: steal resolvconf support from Ubuntu] broke systemd only
dnsmasq runtime. No sysvinit scripts are included in systemd only
builds (and should not be) and the dnsmasq executable has not moved to
/usr/sbin.

Reverting to the previous version of the systemd service file. If
folks want the local dnsmasq instance to be queried before going to
an external DNS they should add 'nameserver 127.0.0.1' to
/etc/resolv.conf. Or submit a change which will work with systemd.

Signed-off-by: Mark Asselstine <mark.asselstine@windriver.com>
Signed-off-by: Joe MacDonald <joe_macdonald@mentor.com>
---

The previous one should've been v2, so I've named this one v3 explicitly.
After reading more of the systemd documentation I think this approach in
the service file is the current best option available.  It would certainly
be cleaner to store the pidfile name in an environment variable but it
turns out on further inspection that if you pass a varaible to PIDFile,
you get errors (that you only see when the service is stopped, not while
it is running) indicating essentially that it is falling back to the
"guess the MAINPID value" behaviour.  So this seems to be the way we're
supposed to do this type of thing now.

-J.

 .../recipes-support/dnsmasq/dnsmasq.inc            |  9 ++--
 .../dnsmasq/files/dnsmasq-resolvconf-helper        | 62 ++++++++++++++++++++++
 .../recipes-support/dnsmasq/files/dnsmasq.service  |  9 ++--
 3 files changed, 72 insertions(+), 8 deletions(-)
 create mode 100644 meta-networking/recipes-support/dnsmasq/files/dnsmasq-resolvconf-helper

diff --git a/meta-networking/recipes-support/dnsmasq/dnsmasq.inc b/meta-networking/recipes-support/dnsmasq/dnsmasq.inc
index 622e630..df58e5c 100644
--- a/meta-networking/recipes-support/dnsmasq/dnsmasq.inc
+++ b/meta-networking/recipes-support/dnsmasq/dnsmasq.inc
@@ -60,11 +60,12 @@ do_install () {
         install -m 644 dbus/dnsmasq.conf ${D}${sysconfdir}/dbus-1/system.d/
     fi
     if [ "${@base_contains('PACKAGECONFIG', 'resolvconf', 'resolvconf', '', d)}" != "" ]; then
-	install -d ${D}${sysconfdir}/resolvconf/update.d/
-	install -m 0755 ${WORKDIR}/dnsmasq.resolvconf ${D}${sysconfdir}/resolvconf/update.d/dnsmasq
+        install -d ${D}${sysconfdir}/resolvconf/update.d/
+        install -m 0755 ${WORKDIR}/dnsmasq.resolvconf ${D}${sysconfdir}/resolvconf/update.d/dnsmasq
 
-	install -d ${D}${sysconfdir}/default/volatiles
-	install -m 0644 ${WORKDIR}/99_dnsmasq ${D}${sysconfdir}/default/volatiles
+        install -d ${D}${sysconfdir}/default/volatiles
+        install -m 0644 ${WORKDIR}/99_dnsmasq ${D}${sysconfdir}/default/volatiles
+        install -m 0755 ${WORKDIR}/dnsmasq-resolvconf-helper ${D}${bindir}
     fi
 }
 
diff --git a/meta-networking/recipes-support/dnsmasq/files/dnsmasq-resolvconf-helper b/meta-networking/recipes-support/dnsmasq/files/dnsmasq-resolvconf-helper
new file mode 100644
index 0000000..db54d46
--- /dev/null
+++ b/meta-networking/recipes-support/dnsmasq/files/dnsmasq-resolvconf-helper
@@ -0,0 +1,62 @@
+#!/bin/bash
+#
+# Borrowing heavily from the dnsmasq initscript's version of support for
+# resolvconf, intended for use in systemd-only configurations.
+#
+PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
+DAEMON=/usr/sbin/dnsmasq
+NAME=dnsmasq
+
+# Most configuration options in /etc/default/dnsmasq are deprecated
+# but still honoured.
+if [ -r /etc/default/$NAME ]; then
+   . /etc/default/$NAME
+fi
+
+start_resolvconf()
+{
+   # If interface "lo" is explicitly disabled in /etc/default/dnsmasq
+   # Then dnsmasq won't be providing local DNS, so don't add it to
+   # the resolvconf server set.
+   for interface in $DNSMASQ_EXCEPT
+   do
+      [ $interface = lo ] && return
+   done
+
+   if [ -x /sbin/resolvconf ] ; then
+      echo "nameserver 127.0.0.1" |
+      /sbin/resolvconf -a lo.$NAME
+   fi
+   return 0
+}
+
+stop_resolvconf()
+{
+   if [ -x /sbin/resolvconf ] ; then
+      /sbin/resolvconf -d lo.$NAME
+   fi
+   return 0
+}
+
+case "$1" in
+   start)
+      start_resolvconf
+      exit 0
+      ;;
+   stop)
+      stop_resolvconf
+      exit 0
+      ;;
+   restart)
+      stop_resolvconf
+      start_resolvconf
+      exit 0
+      ;;
+   *)
+      echo "Usage: /etc/init.d/$NAME {start|stop|restart}" >&2
+      exit 3
+      ;;
+esac
+
+exit 0
+
diff --git a/meta-networking/recipes-support/dnsmasq/files/dnsmasq.service b/meta-networking/recipes-support/dnsmasq/files/dnsmasq.service
index c3637e1..68b175c 100644
--- a/meta-networking/recipes-support/dnsmasq/files/dnsmasq.service
+++ b/meta-networking/recipes-support/dnsmasq/files/dnsmasq.service
@@ -5,10 +5,11 @@ After=network.target
 [Service]
 Type=forking
 PIDFile=/run/dnsmasq.pid
-ExecStartPre=/usr/sbin/dnsmasq --test
-ExecStart=/etc/init.d/dnsmasq systemd-exec
-ExecStartPost=/etc/init.d/dnsmasq systemd-start-resolvconf
-ExecStopPre=/etc/init.d/dnsmasq systemd-stop-resolvconf
+ExecStartPre=/usr/bin/dnsmasq --test
+ExecStart=/usr/bin/dnsmasq -x /run/dnsmasq.pid
+ExecStartPost=/usr/bin/dnsmasq-resolvconf-helper start
+ExecStopPre=/usr/bin/dnsmasq-resolvconf-helper stop
+ExecStop=/bin/kill $MAINPID
 ExecReload=/bin/kill -HUP $MAINPID
 
 [Install]
-- 
1.9.1



^ permalink raw reply related	[flat|nested] 12+ messages in thread

* Re: [meta-networking][PATCH v3] dnsmasq: get systemd only working again
  2016-04-19 15:37     ` [meta-networking][PATCH v3] " Joe MacDonald
@ 2016-04-20  8:24       ` Anders Darander
  2016-04-20  8:29         ` Anders Darander
  0 siblings, 1 reply; 12+ messages in thread
From: Anders Darander @ 2016-04-20  8:24 UTC (permalink / raw)
  To: Joe MacDonald; +Cc: mark.asselstine, openembedded-devel

* Joe MacDonald <joe_macdonald@mentor.com> [160419 17:36]:

> From: Mark Asselstine <mark.asselstine@windriver.com>

> The changes made in commit 2497cf2960537152427c99629b2af412787eb6c2
> [dnsmasq: steal resolvconf support from Ubuntu] broke systemd only
> dnsmasq runtime. No sysvinit scripts are included in systemd only
> builds (and should not be) and the dnsmasq executable has not moved to
> /usr/sbin.

> Reverting to the previous version of the systemd service file. If
> folks want the local dnsmasq instance to be queried before going to
> an external DNS they should add 'nameserver 127.0.0.1' to
> /etc/resolv.conf. Or submit a change which will work with systemd.

> Signed-off-by: Mark Asselstine <mark.asselstine@windriver.com>
> Signed-off-by: Joe MacDonald <joe_macdonald@mentor.com>
> ---

> The previous one should've been v2, so I've named this one v3 explicitly.
> After reading more of the systemd documentation I think this approach in
> the service file is the current best option available.  It would certainly
> be cleaner to store the pidfile name in an environment variable but it
> turns out on further inspection that if you pass a varaible to PIDFile,
> you get errors (that you only see when the service is stopped, not while
> it is running) indicating essentially that it is falling back to the
> "guess the MAINPID value" behaviour.  So this seems to be the way we're
> supposed to do this type of thing now.

> -J.

>  .../recipes-support/dnsmasq/dnsmasq.inc            |  9 ++--
>  .../dnsmasq/files/dnsmasq-resolvconf-helper        | 62 ++++++++++++++++++++++

This file, dnsmasq-resolvconf-helper, isn't include in SRC_URI, neither
in do_install(). However it is referenced in the dnsmasq.service, which
leads to:

Apr 08 11:07:27 ccu dnsmasq[384]: started, version 2.75 cachesize 150
Apr 08 11:07:27 ccu dnsmasq[384]: compile time options: IPv6 GNU-getopt no-DBus no-i18n no-IDN DHCP DHCPv6 no-Lua TFTP no-conntrack ipset auth no-DNSSEC loop- detect inotify
Apr 08 11:07:27 ccu dnsmasq-dhcp[384]: DHCP, IP range 192.168.7.1 -- 192.168.7.1, lease time 2m
Apr 08 11:07:27 ccu dnsmasq[384]: [[0;1;39mno servers found in /etc/resolv.conf, will retry[[0m
Apr 08 11:07:27 ccu dnsmasq[384]: read /etc/hosts - 2 addresses Apr 08 11:07:27 ccu systemd[386]: [[0;1;31mdnsmasq.service: Failed at
step EXEC spawning /usr/bin/dnsmasq-resolvconf-helper: No such file or directory[[0m
Apr 08 11:07:27 ccu systemd[1]: [[0;1;39mdnsmasq.service: Control process exited, code=exited status=203[[0m
Apr 08 11:07:27 ccu systemd[1]: [[0;1;31mFailed to start DNS forwarder and DHCP server.[[0m
Apr 08 11:07:27 ccu systemd[1]: [[0;1;39mdnsmasq.service: Unit entered failed state.[[0m
Apr 08 11:07:27 ccu systemd[1]: [[0;1;39mdnsmasq.service: Failed with result 'exit-code'.[[0m


Thus, with the following patch amended, I'm happy with this patch!

Cheers,
Anders

diff --git a/meta-networking/recipes-support/dnsmasq/dnsmasq.inc b/meta-networking/recipes-support/dnsmasq/dnsmasq.inc
index df58e5c..db54658 100644
--- a/meta-networking/recipes-support/dnsmasq/dnsmasq.inc
+++ b/meta-networking/recipes-support/dnsmasq/dnsmasq.inc
@@ -11,6 +11,7 @@ SRC_URI = "http://www.thekelleys.org.uk/dnsmasq/${@['archive/', ''][float(d.getV
            file://init \
            file://dnsmasq.conf \
            file://dnsmasq.service \
+           file://dnsmasq-resolvconf-helper \
 "

 inherit pkgconfig update-rc.d systemd
@@ -54,7 +55,7 @@ do_install () {
     install -m 0644 ${WORKDIR}/dnsmasq.service ${D}${systemd_unitdir}/system

     install -m 0755 ${S}/contrib/wrt/dhcp_release ${D}${bindir}
-
+    install -m 0755 ${WORKDIR}/dnsmasq-resolvconf-helper ${D}${bindir}/dnsmasq-resolvconf-helper
     if [ "${@base_contains('PACKAGECONFIG', 'dbus', 'dbus', '', d)}" != "" ]; then
         install -d ${D}${sysconfdir}/dbus-1/system.d
         install -m 644 dbus/dnsmasq.conf ${D}${sysconfdir}/dbus-1/system.d/



-- 
Anders Darander, Senior System Architect
ChargeStorm AB / eStorm AB


^ permalink raw reply related	[flat|nested] 12+ messages in thread

* Re: [meta-networking][PATCH v3] dnsmasq: get systemd only working again
  2016-04-20  8:24       ` Anders Darander
@ 2016-04-20  8:29         ` Anders Darander
  2016-04-20 18:56           ` Joe MacDonald
  0 siblings, 1 reply; 12+ messages in thread
From: Anders Darander @ 2016-04-20  8:29 UTC (permalink / raw)
  To: Joe MacDonald, mark.asselstine, rehsack, openembedded-devel

* Anders Darander <anders@chargestorm.se> [160420 10:24]:

> * Joe MacDonald <joe_macdonald@mentor.com> [160419 17:36]:

> > From: Mark Asselstine <mark.asselstine@windriver.com>

> > The changes made in commit 2497cf2960537152427c99629b2af412787eb6c2
> > [dnsmasq: steal resolvconf support from Ubuntu] broke systemd only
> > dnsmasq runtime. No sysvinit scripts are included in systemd only
> > builds (and should not be) and the dnsmasq executable has not moved to
> > /usr/sbin.

> > Reverting to the previous version of the systemd service file. If
> > folks want the local dnsmasq instance to be queried before going to
> > an external DNS they should add 'nameserver 127.0.0.1' to
> > /etc/resolv.conf. Or submit a change which will work with systemd.

> > Signed-off-by: Mark Asselstine <mark.asselstine@windriver.com>
> > Signed-off-by: Joe MacDonald <joe_macdonald@mentor.com>
> > ---

> > The previous one should've been v2, so I've named this one v3 explicitly.
> > After reading more of the systemd documentation I think this approach in
> > the service file is the current best option available.  It would certainly
> > be cleaner to store the pidfile name in an environment variable but it
> > turns out on further inspection that if you pass a varaible to PIDFile,
> > you get errors (that you only see when the service is stopped, not while
> > it is running) indicating essentially that it is falling back to the
> > "guess the MAINPID value" behaviour.  So this seems to be the way we're
> > supposed to do this type of thing now.

> > -J.

> >  .../recipes-support/dnsmasq/dnsmasq.inc            |  9 ++--
> >  .../dnsmasq/files/dnsmasq-resolvconf-helper        | 62 ++++++++++++++++++++++

> This file, dnsmasq-resolvconf-helper, isn't include in SRC_URI, neither
> in do_install(). However it is referenced in the dnsmasq.service, which
> leads to:

> Apr 08 11:07:27 ccu dnsmasq[384]: started, version 2.75 cachesize 150
> Apr 08 11:07:27 ccu dnsmasq[384]: compile time options: IPv6 GNU-getopt no-DBus no-i18n no-IDN DHCP DHCPv6 no-Lua TFTP no-conntrack ipset auth no-DNSSEC loop- detect inotify
> Apr 08 11:07:27 ccu dnsmasq-dhcp[384]: DHCP, IP range 192.168.7.1 -- 192.168.7.1, lease time 2m
> Apr 08 11:07:27 ccu dnsmasq[384]: [[0;1;39mno servers found in /etc/resolv.conf, will retry[[0m
> Apr 08 11:07:27 ccu dnsmasq[384]: read /etc/hosts - 2 addresses Apr 08 11:07:27 ccu systemd[386]: [[0;1;31mdnsmasq.service: Failed at
> step EXEC spawning /usr/bin/dnsmasq-resolvconf-helper: No such file or directory[[0m

This is the actual issue, the dnsmasq.service file will unconditionally
execute dnsmasq-resolvconf-helper, while it's only installed if the
PACKAGECONFIG resolved is set.

Could you add the line 

ExecStartPost=/usr/bin/dnsmasq-resolvconf-helper start

to dnsmasq.service conditionally on the PACKAGECONFIG resolved? (Using sed
 is an option).

> Apr 08 11:07:27 ccu systemd[1]: [[0;1;39mdnsmasq.service: Control process exited, code=exited status=203[[0m
> Apr 08 11:07:27 ccu systemd[1]: [[0;1;31mFailed to start DNS forwarder and DHCP server.[[0m
> Apr 08 11:07:27 ccu systemd[1]: [[0;1;39mdnsmasq.service: Unit entered failed state.[[0m
> Apr 08 11:07:27 ccu systemd[1]: [[0;1;39mdnsmasq.service: Failed with result 'exit-code'.[[0m


> Thus, with the following patch amended, I'm happy with this patch!

No, I was slightly wrong...

> Cheers,
> Anders

> diff --git a/meta-networking/recipes-support/dnsmasq/dnsmasq.inc b/meta-networking/recipes-support/dnsmasq/dnsmasq.inc
> index df58e5c..db54658 100644
> --- a/meta-networking/recipes-support/dnsmasq/dnsmasq.inc
> +++ b/meta-networking/recipes-support/dnsmasq/dnsmasq.inc
> @@ -11,6 +11,7 @@ SRC_URI = "http://www.thekelleys.org.uk/dnsmasq/${@['archive/', ''][float(d.getV
>             file://init \
>             file://dnsmasq.conf \
>             file://dnsmasq.service \
> +           file://dnsmasq-resolvconf-helper \
>  "

>  inherit pkgconfig update-rc.d systemd
> @@ -54,7 +55,7 @@ do_install () {
>      install -m 0644 ${WORKDIR}/dnsmasq.service ${D}${systemd_unitdir}/system

>      install -m 0755 ${S}/contrib/wrt/dhcp_release ${D}${bindir}
> -
> +    install -m 0755 ${WORKDIR}/dnsmasq-resolvconf-helper ${D}${bindir}/dnsmasq-resolvconf-helper

This line should obviously not be here, as you're actually installing
dnsmasq-resolvconf-helper, if the PACKAGECONFIG resolved is set.

>      if [ "${@base_contains('PACKAGECONFIG', 'dbus', 'dbus', '', d)}" != "" ]; then
>          install -d ${D}${sysconfdir}/dbus-1/system.d
>          install -m 644 dbus/dnsmasq.conf ${D}${sysconfdir}/dbus-1/system.d/
-- 
Anders Darander, Senior System Architect
ChargeStorm AB / eStorm AB


^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [meta-networking][PATCH v3] dnsmasq: get systemd only working again
  2016-04-20  8:29         ` Anders Darander
@ 2016-04-20 18:56           ` Joe MacDonald
  2016-04-20 19:09             ` Joe MacDonald
  0 siblings, 1 reply; 12+ messages in thread
From: Joe MacDonald @ 2016-04-20 18:56 UTC (permalink / raw)
  To: mark.asselstine, rehsack, openembedded-devel


[-- Attachment #1.1: Type: text/plain, Size: 5264 bytes --]

Wow this one is kind of thorny, huh?

How about the attached patch?  I hope it strikes the right balance
between not duplicating too much and not making things too complex to
maintain later on.

-J.

[Re: [meta-networking][PATCH v3] dnsmasq: get systemd only working again] On 16.04.20 (Wed 10:29) Anders Darander wrote:

> * Anders Darander <anders@chargestorm.se> [160420 10:24]:
> 
> > * Joe MacDonald <joe_macdonald@mentor.com> [160419 17:36]:
> 
> > > From: Mark Asselstine <mark.asselstine@windriver.com>
> 
> > > The changes made in commit 2497cf2960537152427c99629b2af412787eb6c2
> > > [dnsmasq: steal resolvconf support from Ubuntu] broke systemd only
> > > dnsmasq runtime. No sysvinit scripts are included in systemd only
> > > builds (and should not be) and the dnsmasq executable has not moved to
> > > /usr/sbin.
> 
> > > Reverting to the previous version of the systemd service file. If
> > > folks want the local dnsmasq instance to be queried before going to
> > > an external DNS they should add 'nameserver 127.0.0.1' to
> > > /etc/resolv.conf. Or submit a change which will work with systemd.
> 
> > > Signed-off-by: Mark Asselstine <mark.asselstine@windriver.com>
> > > Signed-off-by: Joe MacDonald <joe_macdonald@mentor.com>
> > > ---
> 
> > > The previous one should've been v2, so I've named this one v3 explicitly.
> > > After reading more of the systemd documentation I think this approach in
> > > the service file is the current best option available.  It would certainly
> > > be cleaner to store the pidfile name in an environment variable but it
> > > turns out on further inspection that if you pass a varaible to PIDFile,
> > > you get errors (that you only see when the service is stopped, not while
> > > it is running) indicating essentially that it is falling back to the
> > > "guess the MAINPID value" behaviour.  So this seems to be the way we're
> > > supposed to do this type of thing now.
> 
> > > -J.
> 
> > >  .../recipes-support/dnsmasq/dnsmasq.inc            |  9 ++--
> > >  .../dnsmasq/files/dnsmasq-resolvconf-helper        | 62 ++++++++++++++++++++++
> 
> > This file, dnsmasq-resolvconf-helper, isn't include in SRC_URI, neither
> > in do_install(). However it is referenced in the dnsmasq.service, which
> > leads to:
> 
> > Apr 08 11:07:27 ccu dnsmasq[384]: started, version 2.75 cachesize 150
> > Apr 08 11:07:27 ccu dnsmasq[384]: compile time options: IPv6 GNU-getopt no-DBus no-i18n no-IDN DHCP DHCPv6 no-Lua TFTP no-conntrack ipset auth no-DNSSEC loop- detect inotify
> > Apr 08 11:07:27 ccu dnsmasq-dhcp[384]: DHCP, IP range 192.168.7.1 -- 192.168.7.1, lease time 2m
> > Apr 08 11:07:27 ccu dnsmasq[384]: [[0;1;39mno servers found in /etc/resolv.conf, will retry[[0m
> > Apr 08 11:07:27 ccu dnsmasq[384]: read /etc/hosts - 2 addresses Apr 08 11:07:27 ccu systemd[386]: [[0;1;31mdnsmasq.service: Failed at
> > step EXEC spawning /usr/bin/dnsmasq-resolvconf-helper: No such file or directory[[0m
> 
> This is the actual issue, the dnsmasq.service file will unconditionally
> execute dnsmasq-resolvconf-helper, while it's only installed if the
> PACKAGECONFIG resolved is set.
> 
> Could you add the line 
> 
> ExecStartPost=/usr/bin/dnsmasq-resolvconf-helper start
> 
> to dnsmasq.service conditionally on the PACKAGECONFIG resolved? (Using sed
>  is an option).
> 
> > Apr 08 11:07:27 ccu systemd[1]: [[0;1;39mdnsmasq.service: Control process exited, code=exited status=203[[0m
> > Apr 08 11:07:27 ccu systemd[1]: [[0;1;31mFailed to start DNS forwarder and DHCP server.[[0m
> > Apr 08 11:07:27 ccu systemd[1]: [[0;1;39mdnsmasq.service: Unit entered failed state.[[0m
> > Apr 08 11:07:27 ccu systemd[1]: [[0;1;39mdnsmasq.service: Failed with result 'exit-code'.[[0m
> 
> 
> > Thus, with the following patch amended, I'm happy with this patch!
> 
> No, I was slightly wrong...
> 
> > Cheers,
> > Anders
> 
> > diff --git a/meta-networking/recipes-support/dnsmasq/dnsmasq.inc b/meta-networking/recipes-support/dnsmasq/dnsmasq.inc
> > index df58e5c..db54658 100644
> > --- a/meta-networking/recipes-support/dnsmasq/dnsmasq.inc
> > +++ b/meta-networking/recipes-support/dnsmasq/dnsmasq.inc
> > @@ -11,6 +11,7 @@ SRC_URI = "http://www.thekelleys.org.uk/dnsmasq/${@['archive/', ''][float(d.getV
> >             file://init \
> >             file://dnsmasq.conf \
> >             file://dnsmasq.service \
> > +           file://dnsmasq-resolvconf-helper \
> >  "
> 
> >  inherit pkgconfig update-rc.d systemd
> > @@ -54,7 +55,7 @@ do_install () {
> >      install -m 0644 ${WORKDIR}/dnsmasq.service ${D}${systemd_unitdir}/system
> 
> >      install -m 0755 ${S}/contrib/wrt/dhcp_release ${D}${bindir}
> > -
> > +    install -m 0755 ${WORKDIR}/dnsmasq-resolvconf-helper ${D}${bindir}/dnsmasq-resolvconf-helper
> 
> This line should obviously not be here, as you're actually installing
> dnsmasq-resolvconf-helper, if the PACKAGECONFIG resolved is set.
> 
> >      if [ "${@base_contains('PACKAGECONFIG', 'dbus', 'dbus', '', d)}" != "" ]; then
> >          install -d ${D}${sysconfdir}/dbus-1/system.d
> >          install -m 644 dbus/dnsmasq.conf ${D}${sysconfdir}/dbus-1/system.d/
-- 
-Joe MacDonald.
:wq

[-- Attachment #1.2: 0001-dnsmasq-get-systemd-only-working-again.patch --]
[-- Type: text/x-diff, Size: 7304 bytes --]

From 8247d6d515be338aeef58978f5d52ce08f637adf Mon Sep 17 00:00:00 2001
From: Mark Asselstine <mark.asselstine@windriver.com>
Date: Mon, 18 Apr 2016 16:34:36 -0400
Subject: [PATCH 01/10] dnsmasq: get systemd only working again

The changes made in commit 2497cf2960537152427c99629b2af412787eb6c2
[dnsmasq: steal resolvconf support from Ubuntu] broke systemd only
dnsmasq runtime. No sysvinit scripts are included in systemd only
builds (and should not be) and the dnsmasq executable has not moved to
/usr/sbin.

Reverting to the previous version of the systemd service file. If
folks want the local dnsmasq instance to be queried before going to
an external DNS they should add 'nameserver 127.0.0.1' to
/etc/resolv.conf. Or submit a change which will work with systemd.

Signed-off-by: Mark Asselstine <mark.asselstine@windriver.com>
Acked-by: Anders Darander <anders@chargestorm.se>
Signed-off-by: Martin Jansa <Martin.Jansa@gmail.com>
Signed-off-by: Joe MacDonald <joe_macdonald@mentor.com>
---
 .../recipes-support/dnsmasq/dnsmasq.inc            | 18 ++++---
 ...nsmasq.service => dnsmasq-noresolvconf.service} |  7 ++-
 .../dnsmasq/files/dnsmasq-resolvconf-helper        | 62 ++++++++++++++++++++++
 .../dnsmasq/files/dnsmasq-resolvconf.service       | 17 ++++++
 4 files changed, 94 insertions(+), 10 deletions(-)
 rename meta-networking/recipes-support/dnsmasq/files/{dnsmasq.service => dnsmasq-noresolvconf.service} (49%)
 create mode 100644 meta-networking/recipes-support/dnsmasq/files/dnsmasq-resolvconf-helper
 create mode 100644 meta-networking/recipes-support/dnsmasq/files/dnsmasq-resolvconf.service

diff --git a/meta-networking/recipes-support/dnsmasq/dnsmasq.inc b/meta-networking/recipes-support/dnsmasq/dnsmasq.inc
index 622e630..1f74156 100644
--- a/meta-networking/recipes-support/dnsmasq/dnsmasq.inc
+++ b/meta-networking/recipes-support/dnsmasq/dnsmasq.inc
@@ -33,7 +33,7 @@ EXTRA_OEMAKE = "\
     'LDFLAGS=${LDFLAGS}' \
 "
 
-SRC_URI += "${@bb.utils.contains('PACKAGECONFIG', 'resolvconf', 'file://dnsmasq.resolvconf file://99_dnsmasq', '', d)}"
+SRC_URI += "${@bb.utils.contains('PACKAGECONFIG', 'resolvconf', 'file://dnsmasq.resolvconf file://99_dnsmasq file://dnsmasq-resolvconf-helper', '', d)}"
 
 do_compile_append() {
     # build dhcp_release
@@ -51,7 +51,12 @@ do_install () {
     install -m 755 ${WORKDIR}/init ${D}${sysconfdir}/init.d/dnsmasq
 
     install -d ${D}${systemd_unitdir}/system
-    install -m 0644 ${WORKDIR}/dnsmasq.service ${D}${systemd_unitdir}/system
+
+    if [ "${@base_contains('PACKAGECONFIG', 'resolvconf', 'resolvconf', '', d)}" != "" ]; then
+        install -m 0644 ${WORKDIR}/dnsmasq-resolvconf.service ${D}${systemd_unitdir}/system/dnsmasq.service
+    else
+        install -m 0644 ${WORKDIR}/dnsmasq-noresolvconf.service ${D}${systemd_unitdir}/system/dnsmasq.service
+    fi
 
     install -m 0755 ${S}/contrib/wrt/dhcp_release ${D}${bindir}
 
@@ -60,11 +65,12 @@ do_install () {
         install -m 644 dbus/dnsmasq.conf ${D}${sysconfdir}/dbus-1/system.d/
     fi
     if [ "${@base_contains('PACKAGECONFIG', 'resolvconf', 'resolvconf', '', d)}" != "" ]; then
-	install -d ${D}${sysconfdir}/resolvconf/update.d/
-	install -m 0755 ${WORKDIR}/dnsmasq.resolvconf ${D}${sysconfdir}/resolvconf/update.d/dnsmasq
+        install -d ${D}${sysconfdir}/resolvconf/update.d/
+        install -m 0755 ${WORKDIR}/dnsmasq.resolvconf ${D}${sysconfdir}/resolvconf/update.d/dnsmasq
 
-	install -d ${D}${sysconfdir}/default/volatiles
-	install -m 0644 ${WORKDIR}/99_dnsmasq ${D}${sysconfdir}/default/volatiles
+        install -d ${D}${sysconfdir}/default/volatiles
+        install -m 0644 ${WORKDIR}/99_dnsmasq ${D}${sysconfdir}/default/volatiles
+        install -m 0755 ${WORKDIR}/dnsmasq-resolvconf-helper ${D}${bindir}
     fi
 }
 
diff --git a/meta-networking/recipes-support/dnsmasq/files/dnsmasq.service b/meta-networking/recipes-support/dnsmasq/files/dnsmasq-noresolvconf.service
similarity index 49%
rename from meta-networking/recipes-support/dnsmasq/files/dnsmasq.service
rename to meta-networking/recipes-support/dnsmasq/files/dnsmasq-noresolvconf.service
index c3637e1..cde2244 100644
--- a/meta-networking/recipes-support/dnsmasq/files/dnsmasq.service
+++ b/meta-networking/recipes-support/dnsmasq/files/dnsmasq-noresolvconf.service
@@ -5,10 +5,9 @@ After=network.target
 [Service]
 Type=forking
 PIDFile=/run/dnsmasq.pid
-ExecStartPre=/usr/sbin/dnsmasq --test
-ExecStart=/etc/init.d/dnsmasq systemd-exec
-ExecStartPost=/etc/init.d/dnsmasq systemd-start-resolvconf
-ExecStopPre=/etc/init.d/dnsmasq systemd-stop-resolvconf
+ExecStartPre=/usr/bin/dnsmasq --test
+ExecStart=/usr/bin/dnsmasq -x /run/dnsmasq.pid
+ExecStop=/bin/kill $MAINPID
 ExecReload=/bin/kill -HUP $MAINPID
 
 [Install]
diff --git a/meta-networking/recipes-support/dnsmasq/files/dnsmasq-resolvconf-helper b/meta-networking/recipes-support/dnsmasq/files/dnsmasq-resolvconf-helper
new file mode 100644
index 0000000..db54d46
--- /dev/null
+++ b/meta-networking/recipes-support/dnsmasq/files/dnsmasq-resolvconf-helper
@@ -0,0 +1,62 @@
+#!/bin/bash
+#
+# Borrowing heavily from the dnsmasq initscript's version of support for
+# resolvconf, intended for use in systemd-only configurations.
+#
+PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
+DAEMON=/usr/sbin/dnsmasq
+NAME=dnsmasq
+
+# Most configuration options in /etc/default/dnsmasq are deprecated
+# but still honoured.
+if [ -r /etc/default/$NAME ]; then
+   . /etc/default/$NAME
+fi
+
+start_resolvconf()
+{
+   # If interface "lo" is explicitly disabled in /etc/default/dnsmasq
+   # Then dnsmasq won't be providing local DNS, so don't add it to
+   # the resolvconf server set.
+   for interface in $DNSMASQ_EXCEPT
+   do
+      [ $interface = lo ] && return
+   done
+
+   if [ -x /sbin/resolvconf ] ; then
+      echo "nameserver 127.0.0.1" |
+      /sbin/resolvconf -a lo.$NAME
+   fi
+   return 0
+}
+
+stop_resolvconf()
+{
+   if [ -x /sbin/resolvconf ] ; then
+      /sbin/resolvconf -d lo.$NAME
+   fi
+   return 0
+}
+
+case "$1" in
+   start)
+      start_resolvconf
+      exit 0
+      ;;
+   stop)
+      stop_resolvconf
+      exit 0
+      ;;
+   restart)
+      stop_resolvconf
+      start_resolvconf
+      exit 0
+      ;;
+   *)
+      echo "Usage: /etc/init.d/$NAME {start|stop|restart}" >&2
+      exit 3
+      ;;
+esac
+
+exit 0
+
diff --git a/meta-networking/recipes-support/dnsmasq/files/dnsmasq-resolvconf.service b/meta-networking/recipes-support/dnsmasq/files/dnsmasq-resolvconf.service
new file mode 100644
index 0000000..68b175c
--- /dev/null
+++ b/meta-networking/recipes-support/dnsmasq/files/dnsmasq-resolvconf.service
@@ -0,0 +1,17 @@
+[Unit]
+Description=DNS forwarder and DHCP server
+After=network.target
+
+[Service]
+Type=forking
+PIDFile=/run/dnsmasq.pid
+ExecStartPre=/usr/bin/dnsmasq --test
+ExecStart=/usr/bin/dnsmasq -x /run/dnsmasq.pid
+ExecStartPost=/usr/bin/dnsmasq-resolvconf-helper start
+ExecStopPre=/usr/bin/dnsmasq-resolvconf-helper stop
+ExecStop=/bin/kill $MAINPID
+ExecReload=/bin/kill -HUP $MAINPID
+
+[Install]
+WantedBy=multi-user.target
+
-- 
1.9.1


[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 484 bytes --]

^ permalink raw reply related	[flat|nested] 12+ messages in thread

* Re: [meta-networking][PATCH v3] dnsmasq: get systemd only working again
  2016-04-20 18:56           ` Joe MacDonald
@ 2016-04-20 19:09             ` Joe MacDonald
  2016-04-21 13:39               ` Anders Darander
  0 siblings, 1 reply; 12+ messages in thread
From: Joe MacDonald @ 2016-04-20 19:09 UTC (permalink / raw)
  To: mark.asselstine, rehsack, openembedded-devel


[-- Attachment #1.1: Type: text/plain, Size: 13367 bytes --]

[Re: [oe] [meta-networking][PATCH v3] dnsmasq: get systemd only working again] On 16.04.20 (Wed 14:56) Joe MacDonald wrote:

> Wow this one is kind of thorny, huh?
> 
> How about the attached patch?  I hope it strikes the right balance
> between not duplicating too much and not making things too complex to
> maintain later on.

Or, rather, this one.  :-)

-J.

> 
> -J.
> 
> [Re: [meta-networking][PATCH v3] dnsmasq: get systemd only working again] On 16.04.20 (Wed 10:29) Anders Darander wrote:
> 
> > * Anders Darander <anders@chargestorm.se> [160420 10:24]:
> > 
> > > * Joe MacDonald <joe_macdonald@mentor.com> [160419 17:36]:
> > 
> > > > From: Mark Asselstine <mark.asselstine@windriver.com>
> > 
> > > > The changes made in commit 2497cf2960537152427c99629b2af412787eb6c2
> > > > [dnsmasq: steal resolvconf support from Ubuntu] broke systemd only
> > > > dnsmasq runtime. No sysvinit scripts are included in systemd only
> > > > builds (and should not be) and the dnsmasq executable has not moved to
> > > > /usr/sbin.
> > 
> > > > Reverting to the previous version of the systemd service file. If
> > > > folks want the local dnsmasq instance to be queried before going to
> > > > an external DNS they should add 'nameserver 127.0.0.1' to
> > > > /etc/resolv.conf. Or submit a change which will work with systemd.
> > 
> > > > Signed-off-by: Mark Asselstine <mark.asselstine@windriver.com>
> > > > Signed-off-by: Joe MacDonald <joe_macdonald@mentor.com>
> > > > ---
> > 
> > > > The previous one should've been v2, so I've named this one v3 explicitly.
> > > > After reading more of the systemd documentation I think this approach in
> > > > the service file is the current best option available.  It would certainly
> > > > be cleaner to store the pidfile name in an environment variable but it
> > > > turns out on further inspection that if you pass a varaible to PIDFile,
> > > > you get errors (that you only see when the service is stopped, not while
> > > > it is running) indicating essentially that it is falling back to the
> > > > "guess the MAINPID value" behaviour.  So this seems to be the way we're
> > > > supposed to do this type of thing now.
> > 
> > > > -J.
> > 
> > > >  .../recipes-support/dnsmasq/dnsmasq.inc            |  9 ++--
> > > >  .../dnsmasq/files/dnsmasq-resolvconf-helper        | 62 ++++++++++++++++++++++
> > 
> > > This file, dnsmasq-resolvconf-helper, isn't include in SRC_URI, neither
> > > in do_install(). However it is referenced in the dnsmasq.service, which
> > > leads to:
> > 
> > > Apr 08 11:07:27 ccu dnsmasq[384]: started, version 2.75 cachesize 150
> > > Apr 08 11:07:27 ccu dnsmasq[384]: compile time options: IPv6 GNU-getopt no-DBus no-i18n no-IDN DHCP DHCPv6 no-Lua TFTP no-conntrack ipset auth no-DNSSEC loop- detect inotify
> > > Apr 08 11:07:27 ccu dnsmasq-dhcp[384]: DHCP, IP range 192.168.7.1 -- 192.168.7.1, lease time 2m
> > > Apr 08 11:07:27 ccu dnsmasq[384]: [[0;1;39mno servers found in /etc/resolv.conf, will retry[[0m
> > > Apr 08 11:07:27 ccu dnsmasq[384]: read /etc/hosts - 2 addresses Apr 08 11:07:27 ccu systemd[386]: [[0;1;31mdnsmasq.service: Failed at
> > > step EXEC spawning /usr/bin/dnsmasq-resolvconf-helper: No such file or directory[[0m
> > 
> > This is the actual issue, the dnsmasq.service file will unconditionally
> > execute dnsmasq-resolvconf-helper, while it's only installed if the
> > PACKAGECONFIG resolved is set.
> > 
> > Could you add the line 
> > 
> > ExecStartPost=/usr/bin/dnsmasq-resolvconf-helper start
> > 
> > to dnsmasq.service conditionally on the PACKAGECONFIG resolved? (Using sed
> >  is an option).
> > 
> > > Apr 08 11:07:27 ccu systemd[1]: [[0;1;39mdnsmasq.service: Control process exited, code=exited status=203[[0m
> > > Apr 08 11:07:27 ccu systemd[1]: [[0;1;31mFailed to start DNS forwarder and DHCP server.[[0m
> > > Apr 08 11:07:27 ccu systemd[1]: [[0;1;39mdnsmasq.service: Unit entered failed state.[[0m
> > > Apr 08 11:07:27 ccu systemd[1]: [[0;1;39mdnsmasq.service: Failed with result 'exit-code'.[[0m
> > 
> > 
> > > Thus, with the following patch amended, I'm happy with this patch!
> > 
> > No, I was slightly wrong...
> > 
> > > Cheers,
> > > Anders
> > 
> > > diff --git a/meta-networking/recipes-support/dnsmasq/dnsmasq.inc b/meta-networking/recipes-support/dnsmasq/dnsmasq.inc
> > > index df58e5c..db54658 100644
> > > --- a/meta-networking/recipes-support/dnsmasq/dnsmasq.inc
> > > +++ b/meta-networking/recipes-support/dnsmasq/dnsmasq.inc
> > > @@ -11,6 +11,7 @@ SRC_URI = "http://www.thekelleys.org.uk/dnsmasq/${@['archive/', ''][float(d.getV
> > >             file://init \
> > >             file://dnsmasq.conf \
> > >             file://dnsmasq.service \
> > > +           file://dnsmasq-resolvconf-helper \
> > >  "
> > 
> > >  inherit pkgconfig update-rc.d systemd
> > > @@ -54,7 +55,7 @@ do_install () {
> > >      install -m 0644 ${WORKDIR}/dnsmasq.service ${D}${systemd_unitdir}/system
> > 
> > >      install -m 0755 ${S}/contrib/wrt/dhcp_release ${D}${bindir}
> > > -
> > > +    install -m 0755 ${WORKDIR}/dnsmasq-resolvconf-helper ${D}${bindir}/dnsmasq-resolvconf-helper
> > 
> > This line should obviously not be here, as you're actually installing
> > dnsmasq-resolvconf-helper, if the PACKAGECONFIG resolved is set.
> > 
> > >      if [ "${@base_contains('PACKAGECONFIG', 'dbus', 'dbus', '', d)}" != "" ]; then
> > >          install -d ${D}${sysconfdir}/dbus-1/system.d
> > >          install -m 644 dbus/dnsmasq.conf ${D}${sysconfdir}/dbus-1/system.d/
> -- 
> -Joe MacDonald.
> :wq

> From 8247d6d515be338aeef58978f5d52ce08f637adf Mon Sep 17 00:00:00 2001
> From: Mark Asselstine <mark.asselstine@windriver.com>
> Date: Mon, 18 Apr 2016 16:34:36 -0400
> Subject: [PATCH 01/10] dnsmasq: get systemd only working again
> 
> The changes made in commit 2497cf2960537152427c99629b2af412787eb6c2
> [dnsmasq: steal resolvconf support from Ubuntu] broke systemd only
> dnsmasq runtime. No sysvinit scripts are included in systemd only
> builds (and should not be) and the dnsmasq executable has not moved to
> /usr/sbin.
> 
> Reverting to the previous version of the systemd service file. If
> folks want the local dnsmasq instance to be queried before going to
> an external DNS they should add 'nameserver 127.0.0.1' to
> /etc/resolv.conf. Or submit a change which will work with systemd.
> 
> Signed-off-by: Mark Asselstine <mark.asselstine@windriver.com>
> Acked-by: Anders Darander <anders@chargestorm.se>
> Signed-off-by: Martin Jansa <Martin.Jansa@gmail.com>
> Signed-off-by: Joe MacDonald <joe_macdonald@mentor.com>
> ---
>  .../recipes-support/dnsmasq/dnsmasq.inc            | 18 ++++---
>  ...nsmasq.service => dnsmasq-noresolvconf.service} |  7 ++-
>  .../dnsmasq/files/dnsmasq-resolvconf-helper        | 62 ++++++++++++++++++++++
>  .../dnsmasq/files/dnsmasq-resolvconf.service       | 17 ++++++
>  4 files changed, 94 insertions(+), 10 deletions(-)
>  rename meta-networking/recipes-support/dnsmasq/files/{dnsmasq.service => dnsmasq-noresolvconf.service} (49%)
>  create mode 100644 meta-networking/recipes-support/dnsmasq/files/dnsmasq-resolvconf-helper
>  create mode 100644 meta-networking/recipes-support/dnsmasq/files/dnsmasq-resolvconf.service
> 
> diff --git a/meta-networking/recipes-support/dnsmasq/dnsmasq.inc b/meta-networking/recipes-support/dnsmasq/dnsmasq.inc
> index 622e630..1f74156 100644
> --- a/meta-networking/recipes-support/dnsmasq/dnsmasq.inc
> +++ b/meta-networking/recipes-support/dnsmasq/dnsmasq.inc
> @@ -33,7 +33,7 @@ EXTRA_OEMAKE = "\
>      'LDFLAGS=${LDFLAGS}' \
>  "
>  
> -SRC_URI += "${@bb.utils.contains('PACKAGECONFIG', 'resolvconf', 'file://dnsmasq.resolvconf file://99_dnsmasq', '', d)}"
> +SRC_URI += "${@bb.utils.contains('PACKAGECONFIG', 'resolvconf', 'file://dnsmasq.resolvconf file://99_dnsmasq file://dnsmasq-resolvconf-helper', '', d)}"
>  
>  do_compile_append() {
>      # build dhcp_release
> @@ -51,7 +51,12 @@ do_install () {
>      install -m 755 ${WORKDIR}/init ${D}${sysconfdir}/init.d/dnsmasq
>  
>      install -d ${D}${systemd_unitdir}/system
> -    install -m 0644 ${WORKDIR}/dnsmasq.service ${D}${systemd_unitdir}/system
> +
> +    if [ "${@base_contains('PACKAGECONFIG', 'resolvconf', 'resolvconf', '', d)}" != "" ]; then
> +        install -m 0644 ${WORKDIR}/dnsmasq-resolvconf.service ${D}${systemd_unitdir}/system/dnsmasq.service
> +    else
> +        install -m 0644 ${WORKDIR}/dnsmasq-noresolvconf.service ${D}${systemd_unitdir}/system/dnsmasq.service
> +    fi
>  
>      install -m 0755 ${S}/contrib/wrt/dhcp_release ${D}${bindir}
>  
> @@ -60,11 +65,12 @@ do_install () {
>          install -m 644 dbus/dnsmasq.conf ${D}${sysconfdir}/dbus-1/system.d/
>      fi
>      if [ "${@base_contains('PACKAGECONFIG', 'resolvconf', 'resolvconf', '', d)}" != "" ]; then
> -	install -d ${D}${sysconfdir}/resolvconf/update.d/
> -	install -m 0755 ${WORKDIR}/dnsmasq.resolvconf ${D}${sysconfdir}/resolvconf/update.d/dnsmasq
> +        install -d ${D}${sysconfdir}/resolvconf/update.d/
> +        install -m 0755 ${WORKDIR}/dnsmasq.resolvconf ${D}${sysconfdir}/resolvconf/update.d/dnsmasq
>  
> -	install -d ${D}${sysconfdir}/default/volatiles
> -	install -m 0644 ${WORKDIR}/99_dnsmasq ${D}${sysconfdir}/default/volatiles
> +        install -d ${D}${sysconfdir}/default/volatiles
> +        install -m 0644 ${WORKDIR}/99_dnsmasq ${D}${sysconfdir}/default/volatiles
> +        install -m 0755 ${WORKDIR}/dnsmasq-resolvconf-helper ${D}${bindir}
>      fi
>  }
>  
> diff --git a/meta-networking/recipes-support/dnsmasq/files/dnsmasq.service b/meta-networking/recipes-support/dnsmasq/files/dnsmasq-noresolvconf.service
> similarity index 49%
> rename from meta-networking/recipes-support/dnsmasq/files/dnsmasq.service
> rename to meta-networking/recipes-support/dnsmasq/files/dnsmasq-noresolvconf.service
> index c3637e1..cde2244 100644
> --- a/meta-networking/recipes-support/dnsmasq/files/dnsmasq.service
> +++ b/meta-networking/recipes-support/dnsmasq/files/dnsmasq-noresolvconf.service
> @@ -5,10 +5,9 @@ After=network.target
>  [Service]
>  Type=forking
>  PIDFile=/run/dnsmasq.pid
> -ExecStartPre=/usr/sbin/dnsmasq --test
> -ExecStart=/etc/init.d/dnsmasq systemd-exec
> -ExecStartPost=/etc/init.d/dnsmasq systemd-start-resolvconf
> -ExecStopPre=/etc/init.d/dnsmasq systemd-stop-resolvconf
> +ExecStartPre=/usr/bin/dnsmasq --test
> +ExecStart=/usr/bin/dnsmasq -x /run/dnsmasq.pid
> +ExecStop=/bin/kill $MAINPID
>  ExecReload=/bin/kill -HUP $MAINPID
>  
>  [Install]
> diff --git a/meta-networking/recipes-support/dnsmasq/files/dnsmasq-resolvconf-helper b/meta-networking/recipes-support/dnsmasq/files/dnsmasq-resolvconf-helper
> new file mode 100644
> index 0000000..db54d46
> --- /dev/null
> +++ b/meta-networking/recipes-support/dnsmasq/files/dnsmasq-resolvconf-helper
> @@ -0,0 +1,62 @@
> +#!/bin/bash
> +#
> +# Borrowing heavily from the dnsmasq initscript's version of support for
> +# resolvconf, intended for use in systemd-only configurations.
> +#
> +PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
> +DAEMON=/usr/sbin/dnsmasq
> +NAME=dnsmasq
> +
> +# Most configuration options in /etc/default/dnsmasq are deprecated
> +# but still honoured.
> +if [ -r /etc/default/$NAME ]; then
> +   . /etc/default/$NAME
> +fi
> +
> +start_resolvconf()
> +{
> +   # If interface "lo" is explicitly disabled in /etc/default/dnsmasq
> +   # Then dnsmasq won't be providing local DNS, so don't add it to
> +   # the resolvconf server set.
> +   for interface in $DNSMASQ_EXCEPT
> +   do
> +      [ $interface = lo ] && return
> +   done
> +
> +   if [ -x /sbin/resolvconf ] ; then
> +      echo "nameserver 127.0.0.1" |
> +      /sbin/resolvconf -a lo.$NAME
> +   fi
> +   return 0
> +}
> +
> +stop_resolvconf()
> +{
> +   if [ -x /sbin/resolvconf ] ; then
> +      /sbin/resolvconf -d lo.$NAME
> +   fi
> +   return 0
> +}
> +
> +case "$1" in
> +   start)
> +      start_resolvconf
> +      exit 0
> +      ;;
> +   stop)
> +      stop_resolvconf
> +      exit 0
> +      ;;
> +   restart)
> +      stop_resolvconf
> +      start_resolvconf
> +      exit 0
> +      ;;
> +   *)
> +      echo "Usage: /etc/init.d/$NAME {start|stop|restart}" >&2
> +      exit 3
> +      ;;
> +esac
> +
> +exit 0
> +
> diff --git a/meta-networking/recipes-support/dnsmasq/files/dnsmasq-resolvconf.service b/meta-networking/recipes-support/dnsmasq/files/dnsmasq-resolvconf.service
> new file mode 100644
> index 0000000..68b175c
> --- /dev/null
> +++ b/meta-networking/recipes-support/dnsmasq/files/dnsmasq-resolvconf.service
> @@ -0,0 +1,17 @@
> +[Unit]
> +Description=DNS forwarder and DHCP server
> +After=network.target
> +
> +[Service]
> +Type=forking
> +PIDFile=/run/dnsmasq.pid
> +ExecStartPre=/usr/bin/dnsmasq --test
> +ExecStart=/usr/bin/dnsmasq -x /run/dnsmasq.pid
> +ExecStartPost=/usr/bin/dnsmasq-resolvconf-helper start
> +ExecStopPre=/usr/bin/dnsmasq-resolvconf-helper stop
> +ExecStop=/bin/kill $MAINPID
> +ExecReload=/bin/kill -HUP $MAINPID
> +
> +[Install]
> +WantedBy=multi-user.target
> +
> -- 
> 1.9.1
> 




-- 
-Joe MacDonald.
:wq

[-- Attachment #1.2: 0001-dnsmasq-get-systemd-only-working-again.patch --]
[-- Type: text/x-diff, Size: 7795 bytes --]

From 237ade5065aee5290288febfbbae90145c2c7764 Mon Sep 17 00:00:00 2001
From: Mark Asselstine <mark.asselstine@windriver.com>
Date: Mon, 18 Apr 2016 16:34:36 -0400
Subject: [PATCH] dnsmasq: get systemd only working again

The changes made in commit 2497cf2960537152427c99629b2af412787eb6c2
[dnsmasq: steal resolvconf support from Ubuntu] broke systemd only
dnsmasq runtime. No sysvinit scripts are included in systemd only
builds (and should not be) and the dnsmasq executable has not moved to
/usr/sbin.

Reverting to the previous version of the systemd service file. If
folks want the local dnsmasq instance to be queried before going to
an external DNS they should add 'nameserver 127.0.0.1' to
/etc/resolv.conf. Or submit a change which will work with systemd.

Signed-off-by: Mark Asselstine <mark.asselstine@windriver.com>
Acked-by: Anders Darander <anders@chargestorm.se>
Signed-off-by: Martin Jansa <Martin.Jansa@gmail.com>
Signed-off-by: Joe MacDonald <joe_macdonald@mentor.com>
---
 .../recipes-support/dnsmasq/dnsmasq.inc            | 21 +++++---
 ...nsmasq.service => dnsmasq-noresolvconf.service} |  7 ++-
 .../dnsmasq/files/dnsmasq-resolvconf-helper        | 62 ++++++++++++++++++++++
 .../dnsmasq/files/dnsmasq-resolvconf.service       | 17 ++++++
 4 files changed, 96 insertions(+), 11 deletions(-)
 rename meta-networking/recipes-support/dnsmasq/files/{dnsmasq.service => dnsmasq-noresolvconf.service} (49%)
 create mode 100644 meta-networking/recipes-support/dnsmasq/files/dnsmasq-resolvconf-helper
 create mode 100644 meta-networking/recipes-support/dnsmasq/files/dnsmasq-resolvconf.service

diff --git a/meta-networking/recipes-support/dnsmasq/dnsmasq.inc b/meta-networking/recipes-support/dnsmasq/dnsmasq.inc
index 622e630..cc7f9e3 100644
--- a/meta-networking/recipes-support/dnsmasq/dnsmasq.inc
+++ b/meta-networking/recipes-support/dnsmasq/dnsmasq.inc
@@ -10,7 +10,8 @@ LIC_FILES_CHKSUM = "file://COPYING;md5=0636e73ff0215e8d672dc4c32c317bb3 \
 SRC_URI = "http://www.thekelleys.org.uk/dnsmasq/${@['archive/', ''][float(d.getVar('PV',1).split('.')[1]) > 15]}dnsmasq-${PV}.tar.gz;name=dnsmasq-${PV} \
            file://init \
            file://dnsmasq.conf \
-           file://dnsmasq.service \
+           file://dnsmasq-resolvconf.service \
+           file://dnsmasq-noresolvconf.service \
 "
 
 inherit pkgconfig update-rc.d systemd
@@ -33,7 +34,7 @@ EXTRA_OEMAKE = "\
     'LDFLAGS=${LDFLAGS}' \
 "
 
-SRC_URI += "${@bb.utils.contains('PACKAGECONFIG', 'resolvconf', 'file://dnsmasq.resolvconf file://99_dnsmasq', '', d)}"
+SRC_URI += "${@bb.utils.contains('PACKAGECONFIG', 'resolvconf', 'file://dnsmasq.resolvconf file://99_dnsmasq file://dnsmasq-resolvconf-helper', '', d)}"
 
 do_compile_append() {
     # build dhcp_release
@@ -51,7 +52,12 @@ do_install () {
     install -m 755 ${WORKDIR}/init ${D}${sysconfdir}/init.d/dnsmasq
 
     install -d ${D}${systemd_unitdir}/system
-    install -m 0644 ${WORKDIR}/dnsmasq.service ${D}${systemd_unitdir}/system
+
+    if [ "${@base_contains('PACKAGECONFIG', 'resolvconf', 'resolvconf', '', d)}" != "" ]; then
+        install -m 0644 ${WORKDIR}/dnsmasq-resolvconf.service ${D}${systemd_unitdir}/system/dnsmasq.service
+    else
+        install -m 0644 ${WORKDIR}/dnsmasq-noresolvconf.service ${D}${systemd_unitdir}/system/dnsmasq.service
+    fi
 
     install -m 0755 ${S}/contrib/wrt/dhcp_release ${D}${bindir}
 
@@ -60,11 +66,12 @@ do_install () {
         install -m 644 dbus/dnsmasq.conf ${D}${sysconfdir}/dbus-1/system.d/
     fi
     if [ "${@base_contains('PACKAGECONFIG', 'resolvconf', 'resolvconf', '', d)}" != "" ]; then
-	install -d ${D}${sysconfdir}/resolvconf/update.d/
-	install -m 0755 ${WORKDIR}/dnsmasq.resolvconf ${D}${sysconfdir}/resolvconf/update.d/dnsmasq
+        install -d ${D}${sysconfdir}/resolvconf/update.d/
+        install -m 0755 ${WORKDIR}/dnsmasq.resolvconf ${D}${sysconfdir}/resolvconf/update.d/dnsmasq
 
-	install -d ${D}${sysconfdir}/default/volatiles
-	install -m 0644 ${WORKDIR}/99_dnsmasq ${D}${sysconfdir}/default/volatiles
+        install -d ${D}${sysconfdir}/default/volatiles
+        install -m 0644 ${WORKDIR}/99_dnsmasq ${D}${sysconfdir}/default/volatiles
+        install -m 0755 ${WORKDIR}/dnsmasq-resolvconf-helper ${D}${bindir}
     fi
 }
 
diff --git a/meta-networking/recipes-support/dnsmasq/files/dnsmasq.service b/meta-networking/recipes-support/dnsmasq/files/dnsmasq-noresolvconf.service
similarity index 49%
rename from meta-networking/recipes-support/dnsmasq/files/dnsmasq.service
rename to meta-networking/recipes-support/dnsmasq/files/dnsmasq-noresolvconf.service
index c3637e1..cde2244 100644
--- a/meta-networking/recipes-support/dnsmasq/files/dnsmasq.service
+++ b/meta-networking/recipes-support/dnsmasq/files/dnsmasq-noresolvconf.service
@@ -5,10 +5,9 @@ After=network.target
 [Service]
 Type=forking
 PIDFile=/run/dnsmasq.pid
-ExecStartPre=/usr/sbin/dnsmasq --test
-ExecStart=/etc/init.d/dnsmasq systemd-exec
-ExecStartPost=/etc/init.d/dnsmasq systemd-start-resolvconf
-ExecStopPre=/etc/init.d/dnsmasq systemd-stop-resolvconf
+ExecStartPre=/usr/bin/dnsmasq --test
+ExecStart=/usr/bin/dnsmasq -x /run/dnsmasq.pid
+ExecStop=/bin/kill $MAINPID
 ExecReload=/bin/kill -HUP $MAINPID
 
 [Install]
diff --git a/meta-networking/recipes-support/dnsmasq/files/dnsmasq-resolvconf-helper b/meta-networking/recipes-support/dnsmasq/files/dnsmasq-resolvconf-helper
new file mode 100644
index 0000000..db54d46
--- /dev/null
+++ b/meta-networking/recipes-support/dnsmasq/files/dnsmasq-resolvconf-helper
@@ -0,0 +1,62 @@
+#!/bin/bash
+#
+# Borrowing heavily from the dnsmasq initscript's version of support for
+# resolvconf, intended for use in systemd-only configurations.
+#
+PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
+DAEMON=/usr/sbin/dnsmasq
+NAME=dnsmasq
+
+# Most configuration options in /etc/default/dnsmasq are deprecated
+# but still honoured.
+if [ -r /etc/default/$NAME ]; then
+   . /etc/default/$NAME
+fi
+
+start_resolvconf()
+{
+   # If interface "lo" is explicitly disabled in /etc/default/dnsmasq
+   # Then dnsmasq won't be providing local DNS, so don't add it to
+   # the resolvconf server set.
+   for interface in $DNSMASQ_EXCEPT
+   do
+      [ $interface = lo ] && return
+   done
+
+   if [ -x /sbin/resolvconf ] ; then
+      echo "nameserver 127.0.0.1" |
+      /sbin/resolvconf -a lo.$NAME
+   fi
+   return 0
+}
+
+stop_resolvconf()
+{
+   if [ -x /sbin/resolvconf ] ; then
+      /sbin/resolvconf -d lo.$NAME
+   fi
+   return 0
+}
+
+case "$1" in
+   start)
+      start_resolvconf
+      exit 0
+      ;;
+   stop)
+      stop_resolvconf
+      exit 0
+      ;;
+   restart)
+      stop_resolvconf
+      start_resolvconf
+      exit 0
+      ;;
+   *)
+      echo "Usage: /etc/init.d/$NAME {start|stop|restart}" >&2
+      exit 3
+      ;;
+esac
+
+exit 0
+
diff --git a/meta-networking/recipes-support/dnsmasq/files/dnsmasq-resolvconf.service b/meta-networking/recipes-support/dnsmasq/files/dnsmasq-resolvconf.service
new file mode 100644
index 0000000..68b175c
--- /dev/null
+++ b/meta-networking/recipes-support/dnsmasq/files/dnsmasq-resolvconf.service
@@ -0,0 +1,17 @@
+[Unit]
+Description=DNS forwarder and DHCP server
+After=network.target
+
+[Service]
+Type=forking
+PIDFile=/run/dnsmasq.pid
+ExecStartPre=/usr/bin/dnsmasq --test
+ExecStart=/usr/bin/dnsmasq -x /run/dnsmasq.pid
+ExecStartPost=/usr/bin/dnsmasq-resolvconf-helper start
+ExecStopPre=/usr/bin/dnsmasq-resolvconf-helper stop
+ExecStop=/bin/kill $MAINPID
+ExecReload=/bin/kill -HUP $MAINPID
+
+[Install]
+WantedBy=multi-user.target
+
-- 
1.9.1


[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 484 bytes --]

^ permalink raw reply related	[flat|nested] 12+ messages in thread

* Re: [meta-networking][PATCH v3] dnsmasq: get systemd only working again
  2016-04-20 19:09             ` Joe MacDonald
@ 2016-04-21 13:39               ` Anders Darander
  0 siblings, 0 replies; 12+ messages in thread
From: Anders Darander @ 2016-04-21 13:39 UTC (permalink / raw)
  To: openembedded-devel; +Cc: mark.asselstine

* Joe MacDonald <Joe_MacDonald@mentor.com> [160420 21:09]:

> [Re: [oe] [meta-networking][PATCH v3] dnsmasq: get systemd only working again] On 16.04.20 (Wed 14:56) Joe MacDonald wrote:

> > Wow this one is kind of thorny, huh?

> > How about the attached patch?  I hope it strikes the right balance
> > between not duplicating too much and not making things too complex to
> > maintain later on.

> Or, rather, this one.  :-)

This one works fine for my use-case! ;-)

Thus,

Acked-by: Anders Darander <anders@chargestorm.se>

Cheers,
Anders

-- 
Anders Darander, Senior System Architect
ChargeStorm AB / eStorm AB


^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [meta-networking][PATCH] dnsmasq: get systemd only working again
  2016-04-18 20:34 Mark Asselstine
@ 2016-04-19  4:39 ` Anders Darander
  0 siblings, 0 replies; 12+ messages in thread
From: Anders Darander @ 2016-04-19  4:39 UTC (permalink / raw)
  To: openembedded-devel

* Mark Asselstine <mark.asselstine@windriver.com> [160418 22:34]:

> The changes made in commit 2497cf2960537152427c99629b2af412787eb6c2
> [dnsmasq: steal resolvconf support from Ubuntu] broke systemd only
> dnsmasq runtime. No sysvinit scripts are included in systemd only
> builds (and should not be) and the dnsmasq executable has not moved to
> /usr/sbin.

> Reverting to the previous version of the systemd service file. If
> folks want the local dnsmasq instance to be queried before going to
> an external DNS they should add 'nameserver 127.0.0.1' to
> /etc/resolv.conf. Or submit a change which will work with systemd.

> Signed-off-by: Mark Asselstine <mark.asselstine@windriver.com>
> ---

Acked-by: Anders Darander <anders@chargestorm.se>

-- 
Anders Darander, Senior System Architect
ChargeStorm AB / eStorm AB


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [meta-networking][PATCH] dnsmasq: get systemd only working again
@ 2016-04-18 20:34 Mark Asselstine
  2016-04-19  4:39 ` Anders Darander
  0 siblings, 1 reply; 12+ messages in thread
From: Mark Asselstine @ 2016-04-18 20:34 UTC (permalink / raw)
  To: joe_macdonald, openembedded-devel; +Cc: anders

The changes made in commit 2497cf2960537152427c99629b2af412787eb6c2
[dnsmasq: steal resolvconf support from Ubuntu] broke systemd only
dnsmasq runtime. No sysvinit scripts are included in systemd only
builds (and should not be) and the dnsmasq executable has not moved to
/usr/sbin.

Reverting to the previous version of the systemd service file. If
folks want the local dnsmasq instance to be queried before going to
an external DNS they should add 'nameserver 127.0.0.1' to
/etc/resolv.conf. Or submit a change which will work with systemd.

Signed-off-by: Mark Asselstine <mark.asselstine@windriver.com>
---
 meta-networking/recipes-support/dnsmasq/files/dnsmasq.service | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/meta-networking/recipes-support/dnsmasq/files/dnsmasq.service b/meta-networking/recipes-support/dnsmasq/files/dnsmasq.service
index c3637e1..549e15e 100644
--- a/meta-networking/recipes-support/dnsmasq/files/dnsmasq.service
+++ b/meta-networking/recipes-support/dnsmasq/files/dnsmasq.service
@@ -5,11 +5,8 @@ After=network.target
 [Service]
 Type=forking
 PIDFile=/run/dnsmasq.pid
-ExecStartPre=/usr/sbin/dnsmasq --test
-ExecStart=/etc/init.d/dnsmasq systemd-exec
-ExecStartPost=/etc/init.d/dnsmasq systemd-start-resolvconf
-ExecStopPre=/etc/init.d/dnsmasq systemd-stop-resolvconf
-ExecReload=/bin/kill -HUP $MAINPID
+ExecStart=/usr/bin/dnsmasq -x /run/dnsmasq.pid
+ExecReload=/bin/kill -HUP $(/bin/cat /run/dnsmasq.pid)
 
 [Install]
 WantedBy=multi-user.target
-- 
2.1.4



^ permalink raw reply related	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2016-04-21 13:39 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-04-19  3:30 [meta-networking][PATCH] dnsmasq: get systemd only working again Joe MacDonald
2016-04-19  7:41 ` Anders Darander
2016-04-19 14:21   ` Joe MacDonald
2016-04-19 15:37     ` [meta-networking][PATCH v3] " Joe MacDonald
2016-04-20  8:24       ` Anders Darander
2016-04-20  8:29         ` Anders Darander
2016-04-20 18:56           ` Joe MacDonald
2016-04-20 19:09             ` Joe MacDonald
2016-04-21 13:39               ` Anders Darander
2016-04-19 13:54 ` [meta-networking][PATCH] " Mark Asselstine
  -- strict thread matches above, loose matches on Subject: below --
2016-04-18 20:34 Mark Asselstine
2016-04-19  4:39 ` Anders Darander

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.