Package: ifupdown Version: 0.6.8+nmu1 Severity: wishlist Tags: patch *** Please type your report below this line ***
Every package sticks its own files in /etc/network/if-*.d, unaware of what other files are there. The order of running the scripts is determined, arbitrarily, by their filename. This is made worse by various scripts which believe they should be "first", and prepend 00 to the filename. My suggestion is to use the same solution for /etc/rcN.d, which has ordered symlinks for /etc/init.d (apache uses a similar configuration in debian, with sites.available and sites.enabled). The attached patch will use /etc/network/if-%s.ordered.d instead of /etc/network/if-%s.d if it is available. If not, the previous functionality is preserved. -- System Information: Debian Release: 5.0.4 APT prefers stable APT policy: (500, 'stable') Architecture: i386 (i686) Kernel: Linux 2.6.26-2-686 (SMP w/1 CPU core) Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8) Shell: /bin/sh linked to /bin/bash Versions of packages ifupdown depends on: ii libc6 2.7-18lenny2 GNU C Library: Shared libraries ii lsb-base 3.2-20 Linux Standard Base 3.2 init scrip ii net-tools 1.60-22 The NET-3 networking toolkit ifupdown recommends no packages. Versions of packages ifupdown suggests: ii dhcp3-client 3.1.1-6+lenny4 DHCP client ii iproute 20080725-2 networking and traffic control too pn ppp <none> (no description available) -- no debconf information -- Man is the only animal that laughs and weeps, for he is the only animal that is struck with the difference between what things are and what they ought to be. - William Hazlitt Ohad Lutzky
Support /etc/network/if-%s.ordered.d Creating these directories, which should contain symlinks (ordered by filename) to scripts in /etc/network/if-%s.d, will cause them to be run by ifupdown instead of the originals. This way you can control the order without touching individual package files. diff -Naur ifupdown-0.6.8+nmu1.orig/ifupdown.nw ifupdown-0.6.8+nmu1/ifupdown.nw --- ifupdown-0.6.8+nmu1.orig/ifupdown.nw 2010-03-18 13:38:16.000000000 +0200 +++ ifupdown-0.6.8+nmu1/ifupdown.nw 2010-03-18 13:52:24.000000000 +0200 @@ -2077,6 +2077,8 @@ #include <ctype.h> #include <stdlib.h> #include <string.h> +#include <sys/types.h> +#include <sys/stat.h> #include <assert.h> #include "header.h" @@ -2401,6 +2403,11 @@ and call the [[run-parts]] command on the appropriate directory of scripts. That doesn't make for thrilling code. +If the { \tt /etc/network/if-%s.ordered.d } directory exists, we will +use it instead. The idea is to make it possible for the administrator +to have a collection of symlinks which, by filename, define order --- +a la { \tt /etc/rc$n$.d/ }. + This function will generally have [[doit]] passed in as the [[exec]] parameter. @@ -2408,6 +2415,11 @@ int execute_all(interface_defn *ifd, execfn *exec, char *opt) { int i; char buf[100]; + char parts_dir[50]; + char ordered_parts_dir[50]; + struct stat st_buf; + char * parts_dir_to_use = parts_dir; + for (i = 0; i < ifd->n_options; i++) { if (strcmp(ifd->option[i].name, opt) == 0) { if (!(*exec)(ifd->option[i].value)) { @@ -2416,8 +2428,18 @@ } } - snprintf(buf, sizeof(buf), "run-parts %s /etc/network/if-%s.d", - verbose ? "--verbose" : "", opt); + snprintf(parts_dir, sizeof(parts_dir), + "/etc/network/if-%s.d", opt); + snprintf(ordered_parts_dir, sizeof(ordered_parts_dir), + "/etc/network/if-%s.ordered.d", opt); + + if (stat(ordered_parts_dir, &st_buf) != -1 && + S_ISDIR(st_buf.st_mode)) { + parts_dir_to_use = ordered_parts_dir; + } + + snprintf(buf, sizeof(buf), "run-parts %s %s", + verbose ? "--verbose" : "", parts_dir_to_use); (*exec)(buf);