wrong var declaration in if-up.d/resolved (nm-dispatcher[54417]: /etc/network/if-up.d/resolved: 12: mystatedir: not found)

Bug #1907878 reported by Jacopo Corbetta
234
This bug affects 47 people
Affects Status Importance Assigned to Milestone
ifupdown (Ubuntu)
Fix Released
Undecided
Heinrich Schuchardt
Jammy
Fix Released
Medium
Joao Andre Simioni

Bug Description

Syslog error:

   nm-dispatcher[...]: /etc/network/if-up.d/resolved: 12: mystatedir: not found

I think it's because of this line:

  if systemctl is-enabled systemd-resolved > /dev/null 2>&1; then
      mystatedir statedir ifindex interface <------------- this is interpreted as a 'mystatedir' command and fails

      interface=$IFACE
      if [ ! "$interface" ]; then

Perhaps the intention was to 'export mystatedir statedir ...'

SRU for Jammy:

[ Impact ]

   * /etc/network/if-{up,down}.d/resolved have a mistype:

   mystatedir statedir ifindex interface

   And when this line is executed, mystatedir is not found (not a valid command)
   and it generates an error log in /var/log/syslog and the terminal output.
   It's not fatal, and the rest of the code gets executed, but it generates the
   message.

   # ifup ens3
   /etc/network/if-up.d/resolved: 12: mystatedir: not found

   # ifdown ens3
   /etc/network/if-down.d/resolved: 12: mystatedir: not found

   The fix accepted in kinetic is only to remove this line. The same fix can be
   applied to Jammy.

[ Test Plan ]

   With the new package installed, remove netplan configuration and add a valid
   /etc/network/interfaces file and then use the commands:

   # ifdown <interface>
   # ifup <interface>

   And confirm the messages are not displayed and the network configuration
   succeeds.

[ Where problems could occur ]

   If mystatedir would be a valid command or function, which is not the case,
   that could break the script.

Revision history for this message
Jacopo Corbetta (jacopo-arc) wrote :

The same applies for if-down.d/resolved

Revision history for this message
Jacopo Corbetta (jacopo-arc) wrote :

I gotta say, removing the line causes DNS resolution to fail on my machine... perhaps this integration is not really working.

In case it matters, I have openresolv installed and set 'rc-manager=resolvconf' in NetworkManager's config. (My use case is picking up DNS settings from WireGuard.)

Revision history for this message
Launchpad Janitor (janitor) wrote :

Status changed to 'Confirmed' because the bug affects multiple users.

Changed in ifupdown (Ubuntu):
status: New → Confirmed
Revision history for this message
larson.eric.d@gmail.com (larsoner) wrote :

For what it's worth, I commented out the `mystatedir statedir ifindex interface` line, and changed the three `return` lines to be `exit 0` and now I no longer get the angry red FAILED line during boot, `systemctl status networking.service` looks okay, and my internet continues to function just fine.

Revision history for this message
Thomas (t.c) wrote (last edit ):

I just commended out the line "mystatedir statedir ifindex interface" on both files /etc/network/if-up.d/resolved and /etc/network/if-down.d/resolved

works without issues.

EDIT: ok, I also need to change the return to exit codes...

thomas@ub-tc:~$ sudo systemctl status networking.service
● networking.service - Raise network interfaces
     Loaded: loaded (/lib/systemd/system/networking.service; enabled; vendor preset: enabled)
     Active: failed (Result: exit-code) since Wed 2021-06-09 20:59:35 CEST; 6s ago
       Docs: man:interfaces(5)
    Process: 329244 ExecStart=/sbin/ifup -a --read-environment (code=exited, status=1/FAILURE)
   Main PID: 329244 (code=exited, status=1/FAILURE)

Jun 09 20:59:35 ub-tc systemd[1]: Starting Raise network interfaces...
Jun 09 20:59:35 ub-tc ifup[329283]: /etc/network/if-up.d/resolved: line 20: return: can only `return' from a function or sourced script
Jun 09 20:59:35 ub-tc ifup[329270]: run-parts: /etc/network/if-up.d/resolved exited with return code 2
Jun 09 20:59:35 ub-tc ifup[329244]: ifup: failed to bring up lo
Jun 09 20:59:35 ub-tc systemd[1]: networking.service: Main process exited, code=exited, status=1/FAILURE
Jun 09 20:59:35 ub-tc systemd[1]: networking.service: Failed with result 'exit-code'.
Jun 09 20:59:35 ub-tc systemd[1]: Failed to start Raise network interfaces.

Revision history for this message
W. J. van der Laan (laanwj) wrote :

FWIW this is still a problem as of Ubuntu 22.04. I'm aware that using /etc/network is deprecated in favor of netplan, I guess that's why the script can stay in a broken state for so long. I'll be looking at porting my configuration to that.

Revision history for this message
Heinrich Schuchardt (xypron) wrote :
Changed in ifupdown (Ubuntu):
status: Confirmed → Fix Committed
assignee: nobody → Heinrich Schuchardt (xypron)
Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package ifupdown - 0.8.36+nmu1ubuntu4

---------------
ifupdown (0.8.36+nmu1ubuntu4) kinetic; urgency=medium

  * Remove invalid lines from resolved integration scripts (LP: #1907878)

 -- Heinrich Schuchardt <email address hidden> Sun, 15 May 2022 15:35:51 +0200

Changed in ifupdown (Ubuntu):
status: Fix Committed → Fix Released
Revision history for this message
Andrea C G Mennucci (am70xk) wrote :

as ~larsoner mentioned, those scripts contain some `return` but not in functions, so they may fail in some cases; you should change all `return` to `exit 0`

Revision history for this message
Quentin Wertz (quwertz) wrote :

Hi, as of today the fix is not available via apt at Ubuntu jammy x64.
Am I doing something wrong?

Revision history for this message
Heinrich Schuchardt (xypron) wrote :

The fix was make for Kinetic Kudu (0.8.36+nmu1ubuntu4). It would take an SRU to port the fix to Jammy.

The stable release upgrade process is described here: https://wiki.ubuntu.com/StableReleaseUpdates

Do you want to give it a try?

Best regards

Heinrich

Revision history for this message
Quentin Wertz (quwertz) wrote :

Hello Heinrich,

yes, very gladly.

Revision history for this message
Federico Alves (h-sales) wrote :

I am also affected by this bug, un Ubuntu 22.04. Can somebody at least release a script that fixes it?
Porting it to Jammy would be great!

Changed in ifupdown (Ubuntu Jammy):
status: New → Triaged
importance: Undecided → Medium
Revision history for this message
Paul Wright (paulwright76) wrote :

If someone's fixing the syntax errors, note there's also https://bugs.launchpad.net/ubuntu/+source/ifupdown/+bug/1981103 which (in the initial comment) mentions another problem and its fix.

Revision history for this message
Paul Wright (paulwright76) wrote :

While we're about it, the use of a bash variable named "DNS" for both the actual server names and the name of the variable in which we're going to store the server names is confusing.

Lukas Märdian (slyon)
tags: added: foundations-triage-discuss
Revision history for this message
Lukas Märdian (slyon) wrote :

ifupdown is in universe these days, so I'll unsubscribe foundations.

tags: removed: foundations-triage-discuss
Revision history for this message
David Kowis (dkowis) wrote :

https://bugs.launchpad.net/ubuntu/+source/ifupdown/+bug/1910273

This one seems to have the full patch repair in the bug description. None of the other bugs I've found relating to this have the full solution.

Revision history for this message
ALinuxUser (buntulongername-new) wrote :

That other bug report says:

> I fixed it by removing the quotes around $DNS and $DOMAINS on line 47 and 51.

I found that in my version of the relevant file (which is - yes? - /etc/network/if-up.d/resolved) the lines at issue were lines 48 and 52. (I use Linux Mint 21.1, which is based upon Ubuntu 22.04.)

Revision history for this message
Joao Andre Simioni (jasimioni) wrote :

debdiff for Jammy SRU

description: updated
Changed in ifupdown (Ubuntu Jammy):
assignee: nobody → Joao Andre Simioni (jasimioni)
status: Triaged → In Progress
tags: added: se-sponsor-halves
Revision history for this message
Joao Andre Simioni (jasimioni) wrote (last edit ):
Download full text (3.5 KiB)

Built a PPA to test the fix:

sudo add-apt-repository ppa:jasimioni/lp1907878
sudo apt update

Below the testing with the PPA package:

ubuntu@jammy-test:~$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 22.04 LTS
Release: 22.04
Codename: jammy

ubuntu@jammy-test:~$ dpkg -l | grep -i ifupdown
ii ifupdown 0.8.36+nmu1ubuntu3 amd64 high level tools to configure network interfaces

ubuntu@jammy-test:~$ sudo ifdown ens3
/etc/network/if-down.d/resolved: 12: mystatedir: not found
Killed old client process
Internet Systems Consortium DHCP Client 4.4.1
Copyright 2004-2018 Internet Systems Consortium.
All rights reserved.
For info, please visit https://www.isc.org/software/dhcp/

Listening on LPF/ens3/52:54:00:92:e4:09
Sending on LPF/ens3/52:54:00:92:e4:09
Sending on Socket/fallback
DHCPRELEASE of 192.168.122.213 on ens3 to 192.168.122.1 port 67 (xid=0x3fe7fca)

ubuntu@jammy-test:~$ sudo ifup ens3
Internet Systems Consortium DHCP Client 4.4.1
Copyright 2004-2018 Internet Systems Consortium.
All rights reserved.
For info, please visit https://www.isc.org/software/dhcp/

Listening on LPF/ens3/52:54:00:92:e4:09
Sending on LPF/ens3/52:54:00:92:e4:09
Sending on Socket/fallback
DHCPDISCOVER on ens3 to 255.255.255.255 port 67 interval 3 (xid=0x96648e41)
DHCPDISCOVER on ens3 to 255.255.255.255 port 67 interval 3 (xid=0x96648e41)
DHCPOFFER of 192.168.122.213 from 192.168.122.1
DHCPREQUEST for 192.168.122.213 on ens3 to 255.255.255.255 port 67 (xid=0x418e6496)
DHCPACK of 192.168.122.213 from 192.168.122.1 (xid=0x96648e41)
bound to 192.168.122.213 -- renewal in 1488 seconds.
/etc/network/if-up.d/resolved: 12: mystatedir: not found

### AFTER UPGRADE ###

ubuntu@jammy-test:~$ apt-cache policy ifupdown
ifupdown:
  Installed: 0.8.36+nmu1ubuntu4
  Candidate: 0.8.36+nmu1ubuntu4
  Version table:
 *** 0.8.36+nmu1ubuntu4 500
        500 https://ppa.launchpadcontent.net/jasimioni/lp1907878/ubuntu jammy/main amd64 Packages
        100 /var/lib/dpkg/status
     0.8.36+nmu1ubuntu3 500
        500 http://archive.ubuntu.com/ubuntu jammy/universe amd64 Packages

ubuntu@jammy-test:~$ dpkg -l | grep -i ifupdown
ii ifupdown 0.8.36+nmu1ubuntu4 amd64 high level tools to configure network interfaces

ubuntu@jammy-test:~$ sudo ifdown ens3
Killed old client process
Internet Systems Consortium DHCP Client 4.4.1
Copyright 2004-2018 Internet Systems Consortium.
All rights reserved.
For info, please visit https://www.isc.org/software/dhcp/

Listening on LPF/ens3/52:54:00:92:e4:09
Sending on LPF/ens3/52:54:00:92:e4:09
Sending on Socket/fallback
DHCPRELEASE of 192.168.122.213 on ens3 to 192.168.122.1 port 67 (xid=0x5294bd40)

ubuntu@jammy-test:~$ sudo ifup ens3
Internet Systems Consortium DHCP Client 4.4.1
Copyright 2004-2018 Internet Systems Consortium.
All rights reserved.
For info, please visit https://www.isc.org/software/dhcp/

Listening on LPF/ens3/52:54:00:92:e4:09
Sending on LPF/ens3/52:54:00:92:e4:09
Sending on Socket/fallback
DHCPDISCOVER on ens3 to 255.255.255.255 port 67 interval 3 (xid=0x1c872a07)
DHCPDISCOV...

Read more...

Revision history for this message
ALinuxUser (buntulongername-new) wrote :

jasimioni: thank you. I am trying out the fix.

I notice the following already.

- There remain multiple instances of 'return' that should be 'exit'. (Dear me! Someone in this threat pointed out that problem already.)
- Line 3 (which is a comment) still, er, misspells the word 'information'.
- The script could be optimised (in that some conditionals could be replaced with operators).
- The linter shellCheck is not very happy with the script (and with reason).

Revision history for this message
Joao Andre Simioni (jasimioni) wrote :

I fixed the 'information' misspelling.

 - regarding the other points, it would add code changes not taken into the Mantic fix. I'm not sure what is the best path in this case.

Updated diff:

https://launchpadlibrarian.net/683020167/ifupdown_0.8.36+nmu1ubuntu3_0.8.36+nmu1ubuntu4.diff.gz

PPA is the same.

Revision history for this message
Heitor Alves de Siqueira (halves) wrote :

Thank you for the patches, João. Given this bug is fairly low-priority (as it seems to be about the warning message only), I'll stage it together with the fixes for bug 1981103.

Revision history for this message
Heitor Alves de Siqueira (halves) wrote :

@jasimioni I've dropped some bits of your diff that aren't necessary for SRU (the typo fix), and sponsored your changes with mine from bug 1981103. Thank you for the help on fixing this!

Revision history for this message
Timo Aaltonen (tjaalton) wrote : Please test proposed package

Hello Jacopo, or anyone else affected,

Accepted ifupdown into jammy-proposed. The package will build now and be available at https://launchpad.net/ubuntu/+source/ifupdown/0.8.36+nmu1ubuntu3.1 in a few hours, and then in the -proposed repository.

Please help us by testing this new package. See https://wiki.ubuntu.com/Testing/EnableProposed for documentation on how to enable and use -proposed. Your feedback will aid us getting this update out to other Ubuntu users.

If this package fixes the bug for you, please add a comment to this bug, mentioning the version of the package you tested, what testing has been performed on the package and change the tag from verification-needed-jammy to verification-done-jammy. If it does not fix the bug for you, please add a comment stating that, and change the tag to verification-failed-jammy. In either case, without details of your testing we will not be able to proceed.

Further information regarding the verification process can be found at https://wiki.ubuntu.com/QATeam/PerformingSRUVerification . Thank you in advance for helping!

N.B. The updated package will be released to -updates after the bug(s) fixed by this package have been verified and the package has been in -proposed for a minimum of 7 days.

Changed in ifupdown (Ubuntu Jammy):
status: In Progress → Fix Committed
tags: added: verification-needed verification-needed-jammy
Revision history for this message
Heitor Alves de Siqueira (halves) wrote :

Validated according to test case from description. No error messages shown, and networking has been correctly configured.

root@halves-lp1907878-j:~# dpkg -l | grep ifupdown
ii ifupdown 0.8.36+nmu1ubuntu3.1 amd64 high level tools to configure network interfaces

root@halves-lp1907878-j:~# ifdown enp5s0; ifup enp5s0
Killed old client process
Internet Systems Consortium DHCP Client 4.4.1
Copyright 2004-2018 Internet Systems Consortium.
All rights reserved.
For info, please visit https://www.isc.org/software/dhcp/

Listening on LPF/enp5s0/00:16:3e:a6:40:b0
Sending on LPF/enp5s0/00:16:3e:a6:40:b0
Sending on Socket/fallback
DHCPRELEASE of 10.125.177.48 on enp5s0 to 10.125.177.1 port 67 (xid=0x66ead755)
Internet Systems Consortium DHCP Client 4.4.1
Copyright 2004-2018 Internet Systems Consortium.
All rights reserved.
For info, please visit https://www.isc.org/software/dhcp/

Listening on LPF/enp5s0/00:16:3e:a6:40:b0
Sending on LPF/enp5s0/00:16:3e:a6:40:b0
Sending on Socket/fallback
DHCPDISCOVER on enp5s0 to 255.255.255.255 port 67 interval 3 (xid=0x58e21111)
DHCPOFFER of 10.125.177.48 from 10.125.177.1
DHCPREQUEST for 10.125.177.48 on enp5s0 to 255.255.255.255 port 67 (xid=0x1111e258)
DHCPACK of 10.125.177.48 from 10.125.177.1 (xid=0x58e21111)
bound to 10.125.177.48 -- renewal in 1555 seconds.

tags: added: verification-done verification-done-jammy
removed: verification-needed verification-needed-jammy
Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package ifupdown - 0.8.36+nmu1ubuntu3.1

---------------
ifupdown (0.8.36+nmu1ubuntu3.1) jammy; urgency=medium

  [ Uwe Kleine-König ]
  * Fix if-up.d/resolved hook to properly work with nameservers and search
    domains (LP: #1981103)

  [ Heinrich Schuchardt ]
  * Remove invalid lines from resolved integration scripts (LP: #1907878)

 -- Joao Andre Simioni <email address hidden> Mon, 16 Oct 2023 14:41:24 +0000

Changed in ifupdown (Ubuntu Jammy):
status: Fix Committed → Fix Released
Revision history for this message
Brian Murray (brian-murray) wrote : Update Released

The verification of the Stable Release Update for ifupdown has completed successfully and the package is now being released to -updates. Subsequently, the Ubuntu Stable Release Updates Team is being unsubscribed and will not receive messages about this bug report. In the event that you encounter a regression using the package from -updates please report a new bug using ubuntu-bug and tag the bug report regression-update so we can easily find any regressions.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Duplicates of this bug

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.