Bug#765577: udev-udeb: Write dupliate entries into 70-persistent-net.rules

Petter Reinholdtsen pere at hungry.com
Fri Oct 24 11:25:33 BST 2014


[Petter Reinholdtsen]
> It would be nice if /lib/udev/write_net_rules could be changed to log
> a message to syslog when 70-persistent-net.rules is updated, to be
> able to figure out when it happen.  I in the places I suspect are
> related to this issue, add similar instrumentation in the hw-detect
> code.

Anyone around to help out with this issue?

While waiting for ideas how to find the source of the duplicate
entries, I added the following workaround to debian-edu-config,
rewriting the 70-persistent-net.rules file to remove duplicate if
anyone are present in the pre-pkgsel step.  It solve the problem for
us for now, but I suspect a generic fix should be added to the code
inserting the duplicate entries.

diff --git a/share/debian-edu-config/d-i/pre-pkgsel b/share/debian-edu-config/d-i/pre-pkgsel
index c298731..34d47a9 100644
--- a/share/debian-edu-config/d-i/pre-pkgsel
+++ b/share/debian-edu-config/d-i/pre-pkgsel
@@ -209,6 +209,13 @@ EOF
        echo "$MAILNAME" > /target/etc/mailname
     fi
 
+    # Workaround for bug in d-i/udev, causing duplicate entries in
+    # /etc/udev/rules.d/70-persistent-net.rules in both d-i and
+    # /target/.  See bug $765577 for the details.
+    if in-target /usr/share/debian-edu-config/tools/workaround-udev-bug-765577 ; then
+       error "disabled duplicate udev rule (bug #765577)"
+    fi
+
     # Make sure that the interfaces are there for the cfengine run if
     # network isn't already configured
     if route | grep -q default ; then
diff --git a/share/debian-edu-config/tools/workaround-udev-bug-765577 b/share/debian-edu-config/tools/workar
new file mode 100755
index 0000000..7054c58
--- /dev/null
+++ b/share/debian-edu-config/tools/workaround-udev-bug-765577
@@ -0,0 +1,71 @@
+#!/usr/bin/perl
+#
+# Implement workaround for bug #765577 by removing duplicate entries
+# from the persistent network interface name rule before rebooting for
+# the first time, to make sure eth0 is present on the machines with
+# fixed network setup in /etc/network/interfaces
+
+use strict;
+use warnings;
+use Getopt::Std;
+
+my $bugurl = "https://bugs.debian.org/765577";
+
+my $rulefile = "/etc/udev/rules.d/70-persistent-net.rules";
+my $newfile = "$rulefile.new";
+
+my $debug = 0;
+my %linecache;
+my $modified = 0;
+my %opts;
+
+sub usage {
+    my $retval = shift;
+    print <<EOF;
+Usage: $0: [-dn]
+Fix
+  -d   enable debugging
+  -n   do not modify $rulefile
+EOF
+  exit($retval) if $retval;
+}
+
+getopts("dn", \%opts) || usage(1);
+
+open(my $rh, '<', $rulefile) || die "error: unable to read from $rulefile";
+my $wh;
+if (!$opts{'n'}) {
+    open($wh, '>', "$newfile") || die "error: unable to write to $newfile";
+}
+my $shortline;
+while (my $line = <$rh>) {
+    $shortline = $line;
+    $shortline =~ s/, NAME="[^"]+"//;
+    print STDERR "shortline: '$shortline'\n" if $opts{'d'};
+    if ($shortline !~ m/^\s*$/
+        && $shortline =~ m/^SUBSYSTEM=/
+        && exists $linecache{$shortline}) {
+        # Seen the same line before, skip it.
+        print STDERR "skipping line\n" if $opts{'d'};
+        $modified = 1;
+        if (!$opts{'n'}) {
+            print $wh "# Duplicate entry disabled, workaround for $bugurl\n#$line";
+        }
+        next;
+    }
+    $linecache{$shortline} = 1;
+    if (!$opts{'n'}) {
+        print $wh $line;
+    }
+}
+close($rh);
+if (!$opts{'n'}) {
+    close($wh);
+    if ($modified) {
+        rename("$newfile", "$rulefile") || die "error: unable to rename $newfile to $rulefile";
+    } else {
+        unlink $newfile;
+    }
+} else {
+}
+exit ! $modified;

-- 
Happy hacking
Petter Reinholdtsen




More information about the Pkg-systemd-maintainers mailing list