Comment 7 for bug 1639452

Revision history for this message
Miriam España Acebal (mirespace) wrote (last edit ):

Hi ingopingo and anyone else,

I have looked closely at your perfectly valid bug report, and I have to say thank you for reporting it and helping to improve Ubuntu.

It's true that the ExecStartPre directive is incomplete, as it is not using the --conf-dir/-7 option and there isn't a hardcoded folder anywhere that the daemon uses with the --test option without argument, as we can see experimenting a bit directly with the command in that directive (root@focal:~# grep ExecStartPre /lib/systemd/system/dnsmasq.service
ExecStartPre=/usr/sbin/dnsmasq --test ):

 1- Let's put a bad configuration file under /etc/dnsmasq.d :
     root@focal:~# cat /etc/dnsmasq.d/kk.conf
     HELLO="I need coffee to say hello in the morning"

 2- Running the command from the directive, we get:
     root@focal:~# /usr/sbin/dnsmasq --test
     dnsmasq: syntax check OK.

 3- Running the command with the --conf-dir/-7 option:
     root@focal:~# /usr/sbin/dnsmasq --test --conf-dir=/etc/dnsmasq.d

     dnsmasq: bad option at line 1 of /etc/dnsmasq.d/kk.conf

So, as you pointed out, the ExecStartPre is doing nothing in the service unit file. But, if we look at the failed status after trying a "systemctl start dnsmasq" with the bad config, we get:

    - Not testing well, with SUCCESS status for the directive (so the starting process continues):
       Process: 34824 ExecStartPre=/usr/sbin/dnsmasq --test (code=exited, status=0/SUCCESS)
       Nov 25 10:16:43 focal dnsmasq[34824]: dnsmasq: syntax check OK.

    - and not starting the service, because fortunately the dnsmasq's init.d file check the configuration on start:
       Process: 34825 ExecStart=/etc/init.d/dnsmasq systemd-exec (code=exited, status=1/FAILURE)
       Nov 25 10:16:43 focal dnsmasq[34825]: dnsmasq: bad option at line 1 of /etc/dnsmasq.d/kk.conf
       Nov 25 10:16:43 focal dnsmasq[34825]: bad option at line 1 of /etc/dnsmasq.d/kk.conf

     root@focal:~# systemctl start dnsmasq
    Job for dnsmasq.service failed because the control process exited with error code.
    See "systemctl status dnsmasq.service" and "journalctl -xe" for details.
    root@focal:~# systemctl status dnsmasq
    ● dnsmasq.service - dnsmasq - A lightweight DHCP and caching DNS server
     Loaded: loaded (/lib/systemd/system/dnsmasq.service; enabled; vendor preset: enabled)
     Active: failed (Result: exit-code) since Thu 2021-11-25 10:16:43 UTC; 4s ago
    Process: 34824 ExecStartPre=/usr/sbin/dnsmasq --test (code=exited, status=0/SUCCESS)
    Process: 34825 ExecStart=/etc/init.d/dnsmasq systemd-exec (code=exited, status=1/FAILURE)

    Nov 25 10:16:43 focal systemd[1]: Starting dnsmasq - A lightweight DHCP and caching DNS server...
    Nov 25 10:16:43 focal dnsmasq[34824]: dnsmasq: syntax check OK.
    Nov 25 10:16:43 focal dnsmasq[34825]: dnsmasq: bad option at line 1 of /etc/dnsmasq.d/kk.conf
    Nov 25 10:16:43 focal dnsmasq[34825]: bad option at line 1 of /etc/dnsmasq.d/kk.conf
    Nov 25 10:16:43 focal dnsmasq[34825]: FAILED to start up
    Nov 25 10:16:43 focal systemd[1]: dnsmasq.service: Control process exited, code=exited, status=1/FAILURE
    Nov 25 10:16:43 focal systemd[1]: dnsmasq.service: Failed with result 'exit-code'.
    Nov 25 10:16:43 focal systemd[1]: Failed to start dnsmasq - A lightweight DHCP and caching DNS server.

Therefore, it seems it has no final impact if the config file syntax check is made in advance to the daemon's start (well, maybe microseconds). To be as sure as possible, let's see if something more happens when the command on ExecStart is executed and if it happens before the syntax check is done there. We might be suspicious about /etc/resolv.conf, but we can see the file is not affected by any directive in the service unit if the start fails (ExecStartPost or ExecStop, that could touch /etc/resolv.conf) neither for the code in init.d relative to systemd-exec:

root@focal:~# cat /etc/resolv.conf | grep -v ^#

nameserver 127.0.0.53
options edns0 trust-ad
search lxd
root@dnsmasq-focal:~# systemctl restart dnsmasq
Job for dnsmasq.service failed because the control process exited with error code.
See "systemctl status dnsmasq.service" and "journalctl -xe" for details.
root@dnsmasq-focal:~# systemctl status dnsmasq
● dnsmasq.service - dnsmasq - A lightweight DHCP and caching DNS server
     Loaded: loaded (/lib/systemd/system/dnsmasq.service; enabled; vendor preset: enabled)
    Drop-In: /run/systemd/system/service.d
             └─zzz-lxc-service.conf
     Active: failed (Result: exit-code) since Thu 2021-11-25 10:51:42 UTC; 7s ago
    Process: 572 ExecStartPre=/usr/sbin/dnsmasq --test (code=exited, status=0/SUCCESS)
    Process: 573 ExecStart=/etc/init.d/dnsmasq systemd-exec (code=exited, status=2)

Nov 25 10:51:42 dnsmasq-focal systemd[1]: Starting dnsmasq - A lightweight DHCP and caching [...]
root@focal:~# cat /etc/resolv.conf | grep -v ^#

nameserver 127.0.0.53
options edns0 trust-ad
search lxd

I might have the chance to fix it but, as I couldn't demonstrate a major impact and this is not affecting the actual Ubuntu series, I will need to ask for an SRU process [1] where it likely won't be accepted ( this bug wouldn't qualify under that policy) due to the change itself doesn't create a profit, i.e., to the stability or user experience.

However, if you feel that there may be another side effect that I have not considered here that has a major impact on the system or may cause the system to reach an incoherent state, feel free to bring it up and I or someone else can look into it again. Until that, I'll mark this bug as "Opinion/Wishlist".

[1] https://wiki.ubuntu.com/StableReleaseUpdates