Hello, Following the discussion to #695906, I propose the following solution to the problem. First of all, I'd like to remind that ifupdown supports source directive since very long ago (it was actually my very first patch to ifupdown to add that support), so anyone can split their network config into small chucks and place them under /etc/network/interfaces.d — it's not done by default, however, yet. The main problem mentioned by Tollef was, basically, that he couldn't disable lo interface configuration, which he needed for some reason, as ifupdown's postinst script was repairing the interfaces file. (Actually, creating an empty interfaces file would prevent it from doing so, as it only checks if the file exists, not if it's valid or not.) While there are various opinions on the question raised in that bug, I don't agree that this is a policy violation, but I propose to resolve this by enabling the usage of 'source' directive in the default configuration, and moving 'lo' interface description into /e/n/interfaces.d. Also, d-i would be now supposed to generate interfaces description in this directory as well, and the default interfaces file would consist of one line only from now: source /etc/network/interfaces.d/* (Please note that this 'source' doesn't recurse into subdirectories.) As /etc/network/interfaces.d/lo is now a conffile, it may be freely edited while being managed by dpkg. Of course, I could modify ifupdown to source these files automatically, but I'm not sure it's a very good idea to do that now. Same about making lo implicit and not requiring a declaration. Users upgrading the package from previous versions can have a warning reminding them that there's a new directory, so they may choose to change their configs; alternatively, we may try to migrate them automatically. I'd like to hear opinions on this idea. The current version of the patch is attached. -- WBR, Andrew
From: Andrew Shadura <bugzilla@tut.by> Subject: Move loopback definition under /etc/network/interfaces.d, Date: Sun, 06 Jan 2013 20:27:13 +0100 Commit-Id: 534:9673a0084e119856fb5a0e81f9badfd69733c5e7 Move loopback definition under /etc/network/interfaces.d, which is now sourced from the default /etc/network/interfaces. Closes #695906. diff --git a/debian/dirs b/debian/dirs --- a/debian/dirs +++ b/debian/dirs @@ -8,3 +8,4 @@ etc/network/if-pre-up.d etc/network/if-up.d etc/network/if-down.d etc/network/if-post-down.d +etc/network/interfaces.d diff --git a/debian/ifupdown.interfaces.d.lo b/debian/ifupdown.interfaces.d.lo new file mode 100644 --- /dev/null +++ b/debian/ifupdown.interfaces.d.lo @@ -0,0 +1,4 @@ +# We should always have a loopback interface, or bad things may happen. + +auto lo +iface lo inet loopback diff --git a/debian/postinst b/debian/postinst --- a/debian/postinst +++ b/debian/postinst @@ -99,17 +99,26 @@ if [ "$1" = "configure" ] ; then if [ -f /etc/network/interfaces ] ; then # TODO: This should be handled with debconf and the script # could introduce the line there directly - if ! grep -q "^[[:space:]]*iface[[:space:]]\+lo0\?[[:space:]]\+inet[[:space:]]\+loopback\>" /etc/network/interfaces ; then - report_warn "No 'iface lo' definition found in /etc/network/interfaces" - fi - if ! grep -q "^[[:space:]]*\(allow-\|\)auto[[:space:]]\+\(.*[[:space:]]\+\|\)lo0\?\([[:space:]]\+\|$\)" /etc/network/interfaces ; then - report_warn "No 'auto lo' statement found in /etc/network/interfaces" + if ! ifquery --list | grep -q "^lo[0-9]*$" ; then + report_warn "No loopback interface definition is found, you may want to check you configuration, as it may break software badly." + if ! grep -q "^[[:space:]]*iface[[:space:]]\+lo0\?[[:space:]]\+inet[[:space:]]\+loopback\>" /etc/network/interfaces ; then + report_warn "No 'iface lo' definition found in /etc/network/interfaces." + fi + if ! grep -q "^[[:space:]]*\(allow-\|\)auto[[:space:]]\+\(.*[[:space:]]\+\|\)lo0\?\([[:space:]]\+\|$\)" /etc/network/interfaces ; then + report_warn "No 'auto lo' statement found in /etc/network/interfaces." + fi + if [ -d /etc/network/interfaces.d ] ; then + if grep -q "^[[:space:]]*iface[[:space:]]\+lo0\?[[:space:]]\+inet[[:space:]]\+loopback\>" /etc/network/interfaces.d/* ; then + files=$(grep "^[[:space:]]*iface[[:space:]]\+lo0\?[[:space:]]\+inet[[:space:]]\+loopback\>" /etc/network/interfaces.d/* | cut -d : -f 1) + report_warn "Loopback interface definition is found in the following files: $files.\nYou may want to include one of them in your /etc/network/interfaces file using 'source' directive. Read more in interfaces(5)." + fi + fi fi else # ! -f /etc/network/interfaces echo "Creating /etc/network/interfaces." echo "# interfaces(5) file used by ifup(8) and ifdown(8)" > /etc/network/interfaces - echo "auto lo" >> /etc/network/interfaces - echo "iface lo inet loopback" >> /etc/network/interfaces + echo "# Include files from /etc/network/interfaces.d:" >> /etc/network/interfaces + echo "source /etc/network/interfaces.d/*" >> /etc/network/interfaces fi fi diff --git a/debian/rules b/debian/rules --- a/debian/rules +++ b/debian/rules @@ -52,6 +52,7 @@ override_dh_auto_configure: override_dh_installinit: dh_installinit --name=networking --no-start -- start 40 S . start 35 0 6 . install -p -m 0644 debian/networking.defaults $(DESTDIR)/etc/default/networking + install -p -m 0644 debian/ifupdown.interfaces.d.lo $(DESTDIR)/etc/network/interfaces.d/lo dh_installinit --name=network-interface-container --noscripts dh_installinit --name=network-interface-security --noscripts dh_installinit --name=network-interface --noscripts
Attachment:
signature.asc
Description: PGP signature